author | cniehaus <cniehaus> | 2002-09-17 11:26:33 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-17 11:26:33 (UTC) |
commit | bb15715567b88dd01f074092c1c4c3b7e0702693 (patch) (unidiff) | |
tree | 01bbe60177230f5e9b5b482c4e436e454b5c933e | |
parent | 92b88813ad8d6352fbf74964fc56dfc1a2aada8c (diff) | |
download | opie-bb15715567b88dd01f074092c1c4c3b7e0702693.zip opie-bb15715567b88dd01f074092c1c4c3b7e0702693.tar.gz opie-bb15715567b88dd01f074092c1c4c3b7e0702693.tar.bz2 |
first attempt of a reimplementation of paintCell
-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 @@ | |||
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 | dataTable::dataTable() : QTable() | 14 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
15 | const char *name) : QTable(numRows, numRows, parent, name) | ||
15 | { | 16 | { |
16 | } | 17 | } |
17 | 18 | ||
18 | void dataTable::paintCell( QPainter *p, int, int, const QRect &cr, bool ) | 19 | |
20 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | ||
19 | { | 21 | { |
20 | if ( currentRow()%2) qDebug("foo" ); | 22 | if ( cr.width() == 0 || cr.height() == 0 ) |
23 | return; | ||
24 | if ( selected && | ||
25 | row == currentRow() && | ||
26 | col == currentColumn() ) | ||
27 | selected = FALSE; | ||
28 | |||
29 | int w = cr.width(); | ||
30 | int h = cr.height(); | ||
31 | |||
32 | QTableItem *itm = item( row, col ); | ||
33 | if ( itm ) { | ||
34 | p->save(); | ||
35 | itm->paint( p, colorGroup(), cr, selected ); | ||
36 | 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 | } | ||
21 | } | 43 | } |
22 | 44 | ||
23 | 45 | ||
24 | 46 | ||
47 | |||
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 @@ | |||
1 | 1 | ||
2 | /*************************************************************************** | 2 | /*************************************************************************** |
3 | * * | 3 | * * |
4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * |
5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * |
6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * |
7 | * ( at your option ) any later version. * | 7 | * ( at your option ) any later version. * |
8 | * * | 8 | * * |
9 | **************************************************************************/ | 9 | **************************************************************************/ |
10 | 10 | ||
11 | #ifndef _DATATABLE_H | ||
12 | #define _DATATABLE_H | ||
13 | |||
14 | |||
11 | #include <qtable.h> | 15 | #include <qtable.h> |
12 | 16 | ||
13 | class dataTable : public QTable | 17 | class OxydataTable : public QTable |
14 | { | 18 | { |
15 | Q_OBJECT | 19 | Q_OBJECT |
16 | 20 | ||
17 | public: | 21 | public: |
18 | dataTable(); | 22 | OxydataTable(); |
23 | OxydataTable( int numRows, int numCols, | ||
24 | QWidget *parent = 0, const char *name = 0 ); | ||
19 | 25 | ||
20 | protected: | 26 | protected: |
27 | /* | ||
28 | * This method is reimplemented form QTable. It implements the colourisation | ||
29 | * of every second row. | ||
30 | */ | ||
21 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); | 31 | virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected ); |
22 | }; | 32 | }; |
33 | |||
34 | #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 @@ | |||
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> | 13 | #include <qtable.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
16 | #include <qlayout.h> | 16 | #include <qlayout.h> |
17 | 17 | ||
18 | dataWidgetUI::dataWidgetUI() : QDialog() | 18 | dataWidgetUI::dataWidgetUI() : QDialog() |
19 | { | 19 | { |
20 | this->setCaption("foo"); | 20 | this->setCaption("foo"); |
21 | 21 | ||
22 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 22 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
23 | 23 | ||
24 | dataCombo = new QComboBox( this ); | 24 | dataCombo = new QComboBox( this ); |
25 | DataTable = new QTable( 7,2, this ); | 25 | DataTable = new OxydataTable( 7,2, this ); |
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(){ |
50 | DataTable->horizontalHeader()->hide(); | 50 | DataTable->horizontalHeader()->hide(); |
51 | DataTable->verticalHeader()->hide(); | 51 | DataTable->verticalHeader()->hide(); |
52 | DataTable->setTopMargin( 0 ); | 52 | DataTable->setTopMargin( 0 ); |
53 | DataTable->setLeftMargin( 0 ); | 53 | DataTable->setLeftMargin( 0 ); |
54 | 54 | ||
55 | DataTable->setText( 0,0,"Weight:" ); | 55 | DataTable->setText( 0,0,"Weight:" ); |
56 | DataTable->setText( 1,0,"Block" ); | 56 | DataTable->setText( 1,0,"Block" ); |
57 | DataTable->setText( 2,0,"Group" ); | 57 | DataTable->setText( 2,0,"Group" ); |
58 | DataTable->setText( 3,0,"Electronegativity" ); | 58 | DataTable->setText( 3,0,"Electronegativity" ); |
59 | DataTable->setText( 4,0,"Atomic radius" ); | 59 | DataTable->setText( 4,0,"Atomic radius" ); |
60 | DataTable->setText( 5,0,"Ionizationenergie" ); | 60 | DataTable->setText( 5,0,"Ionizationenergie" ); |
61 | DataTable->setText( 6,0,"Density" ); | 61 | DataTable->setText( 6,0,"Density" ); |
62 | DataTable->setText( 7,0,"Boilingpoint" ); | 62 | DataTable->setText( 7,0,"Boilingpoint" ); |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | void dataWidgetUI::slotShowData(int number){ | 66 | void dataWidgetUI::slotShowData(int number){ |
67 | Config test( "/home/opie/Settings/oxygendata", Config::File ); | 67 | Config test( "/home/opie/Settings/oxygendata", Config::File ); |
68 | test.setGroup( QString::number( number+1 )); | 68 | test.setGroup( QString::number( number+1 )); |
69 | QString weight = test.readEntry( "Weight" ); | 69 | QString weight = test.readEntry( "Weight" ); |
70 | DataTable->setText( 0,1,weight ); | 70 | DataTable->setText( 0,1,weight ); |
71 | QString block = test.readEntry( "Block" ); | 71 | QString block = test.readEntry( "Block" ); |
72 | DataTable->setText( 1,1,block ); | 72 | DataTable->setText( 1,1,block ); |
73 | QString grp = test.readEntry( "Group" ); | 73 | QString grp = test.readEntry( "Group" ); |
74 | DataTable->setText( 2,1,grp ); | 74 | DataTable->setText( 2,1,grp ); |
75 | QString en = test.readEntry( "EN" ); | 75 | QString en = test.readEntry( "EN" ); |
76 | DataTable->setText( 3,1,en ); | 76 | DataTable->setText( 3,1,en ); |
77 | QString ar = test.readEntry( "AR" ); | 77 | QString ar = test.readEntry( "AR" ); |
78 | DataTable->setText( 4,1,ar ) ; | 78 | DataTable->setText( 4,1,ar ) ; |
79 | QString ion = test.readEntry( "IE" ); | 79 | QString ion = test.readEntry( "IE" ); |
80 | DataTable->setText( 5,1,ion ); | 80 | DataTable->setText( 5,1,ion ); |
81 | QString dens = test.readEntry( "Density" ); | 81 | QString dens = test.readEntry( "Density" ); |
82 | DataTable->setText( 6,1,dens ); | 82 | DataTable->setText( 6,1,dens ); |
83 | QString bp = test.readEntry( "BP" ); | 83 | QString bp = test.readEntry( "BP" ); |
84 | DataTable->setText( 7,1,bp ); | 84 | DataTable->setText( 7,1,bp ); |
85 | } | 85 | } |
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 @@ | |||
1 | 1 | ||
2 | /*************************************************************************** | 2 | /*************************************************************************** |
3 | * * | 3 | * * |
4 | * This program is free software; you can redistribute it and/or modify * | 4 | * This program is free software; you can redistribute it and/or modify * |
5 | * it under the terms of the GNU General Public License as published by * | 5 | * it under the terms of the GNU General Public License as published by * |
6 | * the Free Software Foundation; either version 2 of the License, or * | 6 | * the Free Software Foundation; either version 2 of the License, or * |
7 | * ( at your option ) any later version. * | 7 | * ( at your option ) any later version. * |
8 | * * | 8 | * * |
9 | **************************************************************************/ | 9 | **************************************************************************/ |
10 | #include "dataTable.h" | 10 | #include "dataTable.h" |
11 | #include <qdialog.h> | 11 | #include <qdialog.h> |
12 | 12 | ||
13 | class QTable; | 13 | class QTable; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | 15 | ||
16 | class dataWidgetUI : public QDialog | 16 | class dataWidgetUI : public QDialog |
17 | { | 17 | { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | 19 | ||
20 | public: | 20 | public: |
21 | dataWidgetUI(); | 21 | dataWidgetUI(); |
22 | 22 | ||
23 | private: | 23 | private: |
24 | void createTableLayout(); | 24 | void createTableLayout(); |
25 | QTable *DataTable; | 25 | OxydataTable *DataTable; |
26 | QComboBox *dataCombo; | 26 | QComboBox *dataCombo; |
27 | 27 | ||
28 | private slots: | 28 | private slots: |
29 | void slotShowData(int); | 29 | void slotShowData(int); |
30 | }; | 30 | }; |