summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/dataTable.cpp29
-rw-r--r--noncore/apps/oxygen/dataTable.h16
-rw-r--r--noncore/apps/oxygen/datawidgetui.cpp2
-rw-r--r--noncore/apps/oxygen/datawidgetui.h2
4 files changed, 42 insertions, 7 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp
index 80c0311..f03e973 100644
--- a/noncore/apps/oxygen/dataTable.cpp
+++ b/noncore/apps/oxygen/dataTable.cpp
@@ -13,3 +13,4 @@
-dataTable::dataTable() : QTable()
+OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent,
+ const char *name) : QTable(numRows, numRows, parent, name)
{
@@ -17,5 +18,26 @@ dataTable::dataTable() : QTable()
-void dataTable::paintCell( QPainter *p, int, int, const QRect &cr, bool )
+
+void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected)
{
- if ( currentRow()%2) qDebug("foo" );
+ if ( cr.width() == 0 || cr.height() == 0 )
+ return;
+ if ( selected &&
+ row == currentRow() &&
+ col == currentColumn() )
+ selected = FALSE;
+
+ int w = cr.width();
+ int h = cr.height();
+
+ QTableItem *itm = item( row, col );
+ if ( itm ) {
+ p->save();
+ itm->paint( p, colorGroup(), cr, selected );
+ p->restore();
+ } else {
+ if ( currentRow()%2 ) //every even row
+ p->fillRect( 0, 0, w, h, selected ? colorGroup().brush( QColorGroup::Highlight ) : colorGroup().brush( QColorGroup::Base ) );
+ else //every odd row
+ p->fillRect( 0, 0, w, h, selected ? colorGroup().brush( QColorGroup::Highlight ) : colorGroup().brush( QColorGroup::Base ) );
+ }
}
@@ -24 +46,2 @@ void dataTable::paintCell( QPainter *p, int, int, const QRect &cr, bool )
+
diff --git a/noncore/apps/oxygen/dataTable.h b/noncore/apps/oxygen/dataTable.h
index 7fd9517..5adbcc2 100644
--- a/noncore/apps/oxygen/dataTable.h
+++ b/noncore/apps/oxygen/dataTable.h
@@ -10,5 +10,9 @@
+#ifndef _DATATABLE_H
+#define _DATATABLE_H
+
+
#include <qtable.h>
-class dataTable : public QTable
+class OxydataTable : public QTable
{
@@ -17,6 +21,14 @@ class dataTable : public QTable
public:
- dataTable();
+ OxydataTable();
+ OxydataTable( int numRows, int numCols,
+ QWidget *parent = 0, const char *name = 0 );
protected:
+ /*
+ * This method is reimplemented form QTable. It implements the colourisation
+ * of every second row.
+ */
virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
};
+
+#endif
diff --git a/noncore/apps/oxygen/datawidgetui.cpp b/noncore/apps/oxygen/datawidgetui.cpp
index 79d35e5..0f8a146 100644
--- a/noncore/apps/oxygen/datawidgetui.cpp
+++ b/noncore/apps/oxygen/datawidgetui.cpp
@@ -24,3 +24,3 @@ dataWidgetUI::dataWidgetUI() : QDialog()
dataCombo = new QComboBox( this );
- DataTable = new QTable( 7,2, this );
+ DataTable = new OxydataTable( 7,2, this );
diff --git a/noncore/apps/oxygen/datawidgetui.h b/noncore/apps/oxygen/datawidgetui.h
index 0911f03..9427adf 100644
--- a/noncore/apps/oxygen/datawidgetui.h
+++ b/noncore/apps/oxygen/datawidgetui.h
@@ -24,3 +24,3 @@ class dataWidgetUI : public QDialog
void createTableLayout();
- QTable *DataTable;
+ OxydataTable *DataTable;
QComboBox *dataCombo;