author | cniehaus <cniehaus> | 2002-09-17 14:06:12 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-17 14:06:12 (UTC) |
commit | 62b5cd2ee8eb65d11467ce7469505788ef2280d5 (patch) (unidiff) | |
tree | 2beb7d27c7a0f31b89d5f4ee80b4c5437888000f /noncore/apps | |
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 | 29 | ||||
-rw-r--r-- | noncore/apps/oxygen/datawidgetui.cpp | 4 |
2 files changed, 13 insertions, 20 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 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | #include "oxygen.h" | 9 | #include "oxygen.h" |
10 | 10 | ||
11 | #include "dataTable.h" | 11 | #include "dataTable.h" |
12 | #include <qtable.h> | 12 | #include <qtable.h> |
13 | 13 | ||
14 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, | 14 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
15 | const char *name) : QTable(numRows, numRows, parent, name) | 15 | const char *name) : QTable(numRows, numRows, parent, name) |
16 | { | 16 | { |
17 | } | 17 | } |
18 | 18 | ||
19 | |||
20 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | 19 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) |
21 | { | 20 | { |
22 | if ( cr.width() == 0 || cr.height() == 0 ) | 21 | if ( cr.width() == 0 || cr.height() == 0 ) |
23 | return; | 22 | return; |
24 | if ( selected && | 23 | selected = FALSE; |
25 | row == currentRow() && | ||
26 | col == currentColumn() ) | ||
27 | selected = FALSE; | ||
28 | 24 | ||
29 | int w = cr.width(); | 25 | int w = cr.width(); |
30 | int h = cr.height(); | 26 | int h = cr.height(); |
31 | 27 | ||
32 | QTableItem *itm = item( row, col ); | 28 | QTableItem *itm = item( row, col ); |
33 | if ( itm ) { | 29 | QColorGroup colgrp = colorGroup(); |
30 | if ( itm ) | ||
31 | { | ||
32 | if ( row%2 ) | ||
33 | colgrp.setColor( QColorGroup::Base, QColor( cyan ) ); | ||
34 | else | ||
35 | colgrp.setColor( QColorGroup::Base, QColor( white ) ); | ||
34 | p->save(); | 36 | p->save(); |
35 | itm->paint( p, colorGroup(), cr, selected ); | 37 | itm->paint( p, colgrp, cr, selected ); |
36 | p->restore(); | 38 | p->restore(); |
37 | } else { | ||
38 | if ( currentRow()%2 ) //every even row | ||
39 | p->fillRect( 0, 0, w, h, selected ? colorGroup().brush( QColorGroup::Highlight ) : colorGroup().brush( QColorGroup::Base ) ); | ||
40 | else //every odd row | ||
41 | p->fillRect( 0, 0, w, h, selected ? colorGroup().brush( QColorGroup::Highlight ) : colorGroup().brush( QColorGroup::Base ) ); | ||
42 | } | 39 | } |
43 | } | 40 | } |
44 | |||
45 | |||
46 | |||
47 | |||
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,49 +1,49 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 6 | * ( at your option ) any later version. * |
7 | * * | 7 | * * |
8 | **************************************************************************/ | 8 | **************************************************************************/ |
9 | #include "oxygen.h" | 9 | #include "oxygen.h" |
10 | 10 | ||
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | #include "datawidgetui.h" | 12 | #include "datawidgetui.h" |
13 | #include <qtable.h> | ||
14 | #include <qstring.h> | 13 | #include <qstring.h> |
15 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
16 | #include <qlayout.h> | 15 | #include <qlayout.h> |
17 | 16 | ||
18 | dataWidgetUI::dataWidgetUI() : QDialog() | 17 | dataWidgetUI::dataWidgetUI() : QDialog() |
19 | { | 18 | { |
20 | this->setCaption("foo"); | 19 | this->setCaption("Chemical Data"); |
21 | 20 | ||
22 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 21 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
23 | 22 | ||
24 | dataCombo = new QComboBox( this ); | 23 | dataCombo = new QComboBox( this ); |
25 | DataTable = new OxydataTable( 7,2, this ); | 24 | DataTable = new OxydataTable( 7,2, this ); |
25 | DataTable->setShowGrid( false ); | ||
26 | 26 | ||
27 | vbox->addWidget( dataCombo ); | 27 | vbox->addWidget( dataCombo ); |
28 | vbox->addWidget( DataTable ); | 28 | vbox->addWidget( DataTable ); |
29 | 29 | ||
30 | DataTable->show(); | 30 | DataTable->show(); |
31 | dataCombo->show(); | 31 | dataCombo->show(); |
32 | 32 | ||
33 | connect ( dataCombo, SIGNAL( activated(int) ), this, SLOT( slotShowData(int) ) ); | 33 | connect ( dataCombo, SIGNAL( activated(int) ), this, SLOT( slotShowData(int) ) ); |
34 | Config test( "/home/opie/Settings/oxygendata", Config::File ); | 34 | Config test( "/home/opie/Settings/oxygendata", Config::File ); |
35 | 35 | ||
36 | //read in all names of the 118 elements | 36 | //read in all names of the 118 elements |
37 | for ( int i = 1 ; i < 119 ; i++ ) | 37 | for ( int i = 1 ; i < 119 ; i++ ) |
38 | { | 38 | { |
39 | test.setGroup( QString::number( i ) ); | 39 | test.setGroup( QString::number( i ) ); |
40 | QString foo = test.readEntry( "Name" ); | 40 | QString foo = test.readEntry( "Name" ); |
41 | dataCombo->insertItem( foo ); | 41 | dataCombo->insertItem( foo ); |
42 | } | 42 | } |
43 | 43 | ||
44 | createTableLayout(); | 44 | createTableLayout(); |
45 | slotShowData( 1 ); //this way we do always get data here | 45 | slotShowData( 1 ); //this way we do always get data here |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | void dataWidgetUI::createTableLayout(){ | 49 | void dataWidgetUI::createTableLayout(){ |