-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 29 | ||||
-rw-r--r-- | noncore/apps/oxygen/dataTable.h | 16 | ||||
-rw-r--r-- | noncore/apps/oxygen/datawidgetui.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/oxygen/datawidgetui.h | 2 |
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 @@ -1,24 +1,47 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "oxygen.h" #include "dataTable.h" #include <qtable.h> -dataTable::dataTable() : QTable() +OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, + const char *name) : QTable(numRows, numRows, parent, name) { } -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 ) ); + } } + 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 @@ -1,22 +1,34 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ +#ifndef _DATATABLE_H +#define _DATATABLE_H + + #include <qtable.h> -class dataTable : public QTable +class OxydataTable : public QTable { Q_OBJECT 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 @@ -1,85 +1,85 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "oxygen.h" #include <qpe/config.h> #include "datawidgetui.h" #include <qtable.h> #include <qstring.h> #include <qcombobox.h> #include <qlayout.h> dataWidgetUI::dataWidgetUI() : QDialog() { this->setCaption("foo"); QVBoxLayout *vbox = new QVBoxLayout( this ); dataCombo = new QComboBox( this ); - DataTable = new QTable( 7,2, this ); + DataTable = new OxydataTable( 7,2, this ); vbox->addWidget( dataCombo ); vbox->addWidget( DataTable ); DataTable->show(); dataCombo->show(); connect ( dataCombo, SIGNAL( activated(int) ), this, SLOT( slotShowData(int) ) ); Config test( "/home/opie/Settings/oxygendata", Config::File ); //read in all names of the 118 elements for ( int i = 1 ; i < 119 ; i++ ) { test.setGroup( QString::number( i ) ); QString foo = test.readEntry( "Name" ); dataCombo->insertItem( foo ); } createTableLayout(); slotShowData( 1 ); //this way we do always get data here } void dataWidgetUI::createTableLayout(){ DataTable->horizontalHeader()->hide(); DataTable->verticalHeader()->hide(); DataTable->setTopMargin( 0 ); DataTable->setLeftMargin( 0 ); DataTable->setText( 0,0,"Weight:" ); DataTable->setText( 1,0,"Block" ); DataTable->setText( 2,0,"Group" ); DataTable->setText( 3,0,"Electronegativity" ); DataTable->setText( 4,0,"Atomic radius" ); DataTable->setText( 5,0,"Ionizationenergie" ); DataTable->setText( 6,0,"Density" ); DataTable->setText( 7,0,"Boilingpoint" ); } void dataWidgetUI::slotShowData(int number){ Config test( "/home/opie/Settings/oxygendata", Config::File ); test.setGroup( QString::number( number+1 )); QString weight = test.readEntry( "Weight" ); DataTable->setText( 0,1,weight ); QString block = test.readEntry( "Block" ); DataTable->setText( 1,1,block ); QString grp = test.readEntry( "Group" ); DataTable->setText( 2,1,grp ); QString en = test.readEntry( "EN" ); DataTable->setText( 3,1,en ); QString ar = test.readEntry( "AR" ); DataTable->setText( 4,1,ar ) ; QString ion = test.readEntry( "IE" ); DataTable->setText( 5,1,ion ); QString dens = test.readEntry( "Density" ); DataTable->setText( 6,1,dens ); QString bp = test.readEntry( "BP" ); DataTable->setText( 7,1,bp ); } 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 @@ -1,30 +1,30 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * **************************************************************************/ #include "dataTable.h" #include <qdialog.h> class QTable; class QComboBox; class dataWidgetUI : public QDialog { Q_OBJECT public: dataWidgetUI(); private: void createTableLayout(); - QTable *DataTable; + OxydataTable *DataTable; QComboBox *dataCombo; private slots: void slotShowData(int); }; |