author | cniehaus <cniehaus> | 2002-09-17 14:06:12 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-17 14:06:12 (UTC) |
commit | 62b5cd2ee8eb65d11467ce7469505788ef2280d5 (patch) (side-by-side diff) | |
tree | 2beb7d27c7a0f31b89d5f4ee80b4c5437888000f /noncore | |
parent | bb15715567b88dd01f074092c1c4c3b7e0702693 (diff) | |
download | opie-62b5cd2ee8eb65d11467ce7469505788ef2280d5.zip opie-62b5cd2ee8eb65d11467ce7469505788ef2280d5.tar.gz opie-62b5cd2ee8eb65d11467ce7469505788ef2280d5.tar.bz2 |
Heureka! It works. Took only 3 hours for 5 LOC. Super
-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 23 | ||||
-rw-r--r-- | noncore/apps/oxygen/datawidgetui.cpp | 4 |
2 files changed, 10 insertions, 17 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index f03e973..6c6b9dc 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp @@ -1,47 +1,40 @@ /*************************************************************************** * * * 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> OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, const char *name) : QTable(numRows, numRows, parent, name) { } - void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) { 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 ) { + QColorGroup colgrp = colorGroup(); + if ( itm ) + { + if ( row%2 ) + colgrp.setColor( QColorGroup::Base, QColor( cyan ) ); + else + colgrp.setColor( QColorGroup::Base, QColor( white ) ); p->save(); - itm->paint( p, colorGroup(), cr, selected ); + itm->paint( p, colgrp, 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/datawidgetui.cpp b/noncore/apps/oxygen/datawidgetui.cpp index 0f8a146..c8492e5 100644 --- a/noncore/apps/oxygen/datawidgetui.cpp +++ b/noncore/apps/oxygen/datawidgetui.cpp @@ -1,73 +1,73 @@ /*************************************************************************** * * * 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"); + this->setCaption("Chemical Data"); QVBoxLayout *vbox = new QVBoxLayout( this ); dataCombo = new QComboBox( this ); DataTable = new OxydataTable( 7,2, this ); + DataTable->setShowGrid( false ); 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" ); |