QColor QtxTable::cellForeground( const int row, const int col ) const
{
- QColor res;
+ QColor res = Qt::black;
QTableWidgetItem* anItem = item( row, col );
if ( anItem && anItem->foreground().style() != Qt::NoBrush )
res = anItem->foreground().color();
QColor QtxTable::cellBackground( const int row, const int col ) const
{
- QColor res;
+ QColor res = Qt::white;
QTableWidgetItem* anItem = item( row, col );
if ( anItem && anItem->background().style() != Qt::NoBrush )
res = anItem->background().color();
anItem->setBackground( c );
}
+/*!
+ Return item from cell
+ \param row - table row
+ \param col - table column
+ \param created - if item not exit and create=true, it will be created
+*/
+QTableWidgetItem* QtxTable::getItem( const int row, const int col, const bool created )
+{
+ QTableWidgetItem* anItem = item( row, col );
+ if ( !anItem && created && row < rowCount() && col < columnCount() ) {
+ anItem = new QTableWidgetItem();
+ setItem( row, col, anItem );
+ }
+ return anItem;
+}
+
+QModelIndexList QtxTable::getSelectedIndexes()
+{
+ return selectedIndexes();
+}
+
+bool QtxTable::indexPosition( const QModelIndex& theIndex, int& theRow,
+ int& theCol ) const
+{
+ theRow = -1;
+ theCol = -1;
+ QAbstractTableModel* aModel = ::qobject_cast<QAbstractTableModel*>
+ ( model() );
+ if ( aModel ) {
+ for ( int i = 0, aNbCols = columnCount(); i < aNbCols; i++ )
+ for ( int j = 0, aNbRows = rowCount(); j < aNbRows; j++ )
+ if ( aModel->index( j, i ) == theIndex ) {
+ theRow = i;
+ theCol = j;
+ break;
+ }
+ }
+ return theRow != -1 && theCol != -1;
+}
+
/*void QtxTable::paintCell( QPainter* p, int row, int col, const QRect& cr,
bool selected, const QColorGroup& cg )
{
//updateGeometries();
}
-/*!
- Return item from cell
- \param row - table row
- \param col - table column
- \param created - if item not exit and create=true, it will be created
-*/
-QTableWidgetItem* QtxTable::getItem( const int row, const int col, const bool created )
-{
- QTableWidgetItem* anItem = item( row, col );
- if ( !anItem && created && row < rowCount() && col < columnCount() ) {
- anItem = new QTableWidgetItem();
- setItem( row, col, anItem );
- }
- return anItem;
-}
-
-
/*!
Starts edition of header
\param o - header orientation
#include <QTableWidget>
#include <QHeaderView>
#include <QIcon>
+#include <QModelIndex>
//#include <qvariant.h>
//#include <qptrvector.h>
void setCellFont( const int, const int, const QFont& );
void setCellForeground( const int, const int, const QColor& );
void setCellBackground( const int, const int, const QColor& );
- void setCellIcont( const int, const int, QIcon& );
+ void setCellIcon( const int, const int, QIcon& );
+
+ virtual QTableWidgetItem* getItem( const int, const int, const bool = true );
+ QModelIndexList getSelectedIndexes();
+ bool indexPosition( const QModelIndex&, int&, int& ) const;
//virtual void paintCell( QPainter*, int, int, const QRect&, bool, const QColorGroup& );
QHeaderView* header( Qt::Orientation o ) const;
virtual QRect headerSectionRect( QHeaderView*, const int, int* = 0 ) const;
- QTableWidgetItem* getItem( const int, const int, const bool = true );
-
private:
typedef QMap<QHeaderView*, bool> HeaderState;
typedef QVector<QHeaderView*> HeaderVector;