author | cniehaus <cniehaus> | 2002-09-19 10:50:12 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-19 10:50:12 (UTC) |
commit | f339a98665a80dd6d5497629c3392cf63a456917 (patch) (unidiff) | |
tree | 4208439fa475476d9d6611944411a2c871ffbc15 | |
parent | 7bf6b71e9d7eadc9311af6a839b3425297346c2c (diff) | |
download | opie-f339a98665a80dd6d5497629c3392cf63a456917.zip opie-f339a98665a80dd6d5497629c3392cf63a456917.tar.gz opie-f339a98665a80dd6d5497629c3392cf63a456917.tar.bz2 |
this code should be smarter ;)
-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index 5c7b35c..7516b06 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp | |||
@@ -1,111 +1,102 @@ | |||
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 | 9 | ||
10 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
11 | 11 | ||
12 | #include "dataTable.h" | 12 | #include "dataTable.h" |
13 | #include <qwidget.h> | 13 | #include <qwidget.h> |
14 | #include <qhbox.h> | 14 | #include <qhbox.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qfont.h> | 16 | #include <qfont.h> |
17 | #include <qlayout.h> | 17 | #include <qlayout.h> |
18 | 18 | ||
19 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) | 19 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) |
20 | { | 20 | { |
21 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); | 21 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); |
22 | QHBox *hbox = new QHBox( this ); | 22 | QHBox *hbox = new QHBox( this ); |
23 | left = new QLabel( hbox ); | 23 | left = new QLabel( hbox ); |
24 | middle = new QLabel( hbox ); | 24 | middle = new QLabel( hbox ); |
25 | right = new QLabel( hbox ); | 25 | right = new QLabel( hbox ); |
26 | 26 | ||
27 | DataTable = new OxydataTable( 9,2, this ); | 27 | DataTable = new OxydataTable( 9,2, this ); |
28 | 28 | ||
29 | QFont bf; | 29 | QFont bf; |
30 | bf.setBold( true ); | 30 | bf.setBold( true ); |
31 | bf.setPointSize( bf.pointSize()+2 ); | 31 | bf.setPointSize( bf.pointSize()+2 ); |
32 | middle->setFont( bf ); | 32 | middle->setFont( bf ); |
33 | 33 | ||
34 | setTable(); | 34 | setTable(); |
35 | 35 | ||
36 | qgrid->addWidget( hbox,0,0 ); | 36 | qgrid->addWidget( hbox,0,0 ); |
37 | qgrid->addWidget( DataTable,1,0 ); | 37 | qgrid->addWidget( DataTable,1,0 ); |
38 | } | 38 | } |
39 | 39 | ||
40 | void OxydataWidget::setElement( int el ) | 40 | void OxydataWidget::setElement( int el ) |
41 | { | 41 | { |
42 | Config configobj( "oxygendata" ); | 42 | Config configobj( "oxygendata" ); |
43 | configobj.setGroup( QString::number( el+1 )); | 43 | configobj.setGroup( QString::number( el+1 )); |
44 | 44 | ||
45 | left->setText( configobj.readEntry( "Symbol" ) ); | 45 | left->setText( configobj.readEntry( "Symbol" ) ); |
46 | middle->setText( configobj.readEntry( "Name" ) ); | 46 | middle->setText( configobj.readEntry( "Name" ) ); |
47 | right->setText( QString::number( el+1 ) ); | 47 | right->setText( QString::number( el+1 ) ); |
48 | 48 | ||
49 | QString weight = configobj.readEntry( "Weight" ); | 49 | DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); |
50 | DataTable->setText( 0,1,weight ); | 50 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); |
51 | QString block = configobj.readEntry( "Block" ); | 51 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); |
52 | DataTable->setText( 1,1,block ); | 52 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); |
53 | QString grp = configobj.readEntry( "Group" ); | 53 | DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; |
54 | DataTable->setText( 2,1,grp ); | 54 | DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); |
55 | QString en = configobj.readEntry( "EN" ); | 55 | DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); |
56 | DataTable->setText( 3,1,en ); | 56 | DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); |
57 | QString ar = configobj.readEntry( "AR" ); | 57 | DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); |
58 | DataTable->setText( 4,1,ar ) ; | ||
59 | QString ion = configobj.readEntry( "IE" ); | ||
60 | DataTable->setText( 5,1,ion ); | ||
61 | QString dens = configobj.readEntry( "Density" ); | ||
62 | DataTable->setText( 6,1,dens ); | ||
63 | QString bp = configobj.readEntry( "BP" ); | ||
64 | DataTable->setText( 7,1,bp ); | ||
65 | QString mp = configobj.readEntry( "MP" ); | ||
66 | DataTable->setText( 8,1,mp ); | ||
67 | } | 58 | } |
68 | 59 | ||
69 | void OxydataWidget::setTable() | 60 | void OxydataWidget::setTable() |
70 | { | 61 | { |
71 | DataTable->setText( 0,0, tr( "Weight:" ) ); | 62 | DataTable->setText( 0,0, tr( "Weight:" ) ); |
72 | DataTable->setText( 1,0, tr( "Block" )) ; | 63 | DataTable->setText( 1,0, tr( "Block" )) ; |
73 | DataTable->setText( 2,0, tr( "Group" )) ; | 64 | DataTable->setText( 2,0, tr( "Group" )) ; |
74 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; | 65 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; |
75 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; | 66 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; |
76 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; | 67 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; |
77 | DataTable->setText( 6,0, tr( "Density" )) ; | 68 | DataTable->setText( 6,0, tr( "Density" )) ; |
78 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); | 69 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); |
79 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); | 70 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); |
80 | } | 71 | } |
81 | 72 | ||
82 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, | 73 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
83 | const char *name) : QTable(numRows, numRows, parent, name) | 74 | const char *name) : QTable(numRows, numRows, parent, name) |
84 | { | 75 | { |
85 | this->setShowGrid( false ); | 76 | this->setShowGrid( false ); |
86 | this->setHScrollBarMode(QScrollView::AlwaysOff); | 77 | this->setHScrollBarMode(QScrollView::AlwaysOff); |
87 | this->horizontalHeader()->hide(); | 78 | this->horizontalHeader()->hide(); |
88 | this->verticalHeader()->hide(); | 79 | this->verticalHeader()->hide(); |
89 | this->setTopMargin( 0 ); | 80 | this->setTopMargin( 0 ); |
90 | this->setLeftMargin( 0 ); | 81 | this->setLeftMargin( 0 ); |
91 | } | 82 | } |
92 | 83 | ||
93 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | 84 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) |
94 | { | 85 | { |
95 | if ( cr.width() == 0 || cr.height() == 0 ) | 86 | if ( cr.width() == 0 || cr.height() == 0 ) |
96 | return; | 87 | return; |
97 | selected = FALSE; | 88 | selected = FALSE; |
98 | 89 | ||
99 | QTableItem *itm = item( row, col ); | 90 | QTableItem *itm = item( row, col ); |
100 | QColorGroup colgrp = colorGroup(); | 91 | QColorGroup colgrp = colorGroup(); |
101 | if ( itm ) | 92 | if ( itm ) |
102 | { | 93 | { |
103 | if ( row%2 ) | 94 | if ( row%2 ) |
104 | colgrp.setColor( QColorGroup::Base, QColor( cyan ) ); | 95 | colgrp.setColor( QColorGroup::Base, QColor( cyan ) ); |
105 | else | 96 | else |
106 | colgrp.setColor( QColorGroup::Base, QColor( white ) ); | 97 | colgrp.setColor( QColorGroup::Base, QColor( white ) ); |
107 | p->save(); | 98 | p->save(); |
108 | itm->paint( p, colgrp, cr, selected ); | 99 | itm->paint( p, colgrp, cr, selected ); |
109 | p->restore(); | 100 | p->restore(); |
110 | } | 101 | } |
111 | } | 102 | } |