author | cniehaus <cniehaus> | 2002-09-21 22:40:33 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-21 22:40:33 (UTC) |
commit | 54238c669808ceccaa6fb0ab0dcbf4565b370196 (patch) (unidiff) | |
tree | 2c72474c22fe5061c5611decd352250983175920 | |
parent | d9910f33f40afb465164fb434677d6641272623d (diff) | |
download | opie-54238c669808ceccaa6fb0ab0dcbf4565b370196.zip opie-54238c669808ceccaa6fb0ab0dcbf4565b370196.tar.gz opie-54238c669808ceccaa6fb0ab0dcbf4565b370196.tar.bz2 |
fixing some things. *grr*
-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index e027c16..20c2985 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp | |||
@@ -1,143 +1,142 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : Oxygen | 2 | application: : Oxygen |
3 | 3 | ||
4 | begin : September 2002 | 4 | begin : September 2002 |
5 | copyright : ( C ) 2002 by Carsten Niehaus | 5 | copyright : ( C ) 2002 by Carsten Niehaus |
6 | email : cniehaus@handhelds.org | 6 | email : cniehaus@handhelds.org |
7 | **************************************************************************/ | 7 | **************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
15 | * * | 15 | * * |
16 | **************************************************************************/ | 16 | **************************************************************************/ |
17 | 17 | ||
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | 19 | ||
20 | #include "dataTable.h" | 20 | #include "dataTable.h" |
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qfont.h> | 24 | #include <qfont.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) | 28 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) |
29 | { | 29 | { |
30 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); | 30 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); |
31 | 31 | ||
32 | QHBox *hbox = new QHBox( this ); | 32 | QHBox *hbox = new QHBox( this ); |
33 | left = new QLabel( hbox ); | 33 | left = new QLabel( hbox ); |
34 | middle = new QLabel( hbox ); | 34 | middle = new QLabel( hbox ); |
35 | right = new QLabel( hbox ); | 35 | right = new QLabel( hbox ); |
36 | 36 | ||
37 | right->setAlignment( AlignRight ); | 37 | right->setAlignment( AlignRight ); |
38 | middle->setAlignment( AlignHCenter ); | 38 | middle->setAlignment( AlignHCenter ); |
39 | 39 | ||
40 | QFont bf; | 40 | QFont bf; |
41 | bf.setBold( true ); | 41 | bf.setBold( true ); |
42 | bf.setPointSize( bf.pointSize()+2 ); | 42 | bf.setPointSize( bf.pointSize()+2 ); |
43 | middle->setFont( bf ); | 43 | middle->setFont( bf ); |
44 | 44 | ||
45 | DataTable = new OxydataTable( 9,2, this ); | 45 | DataTable = new OxydataTable( 9,2, this ); |
46 | // DataTable->setColumnWidth ( 1 , 118 ); | 46 | DataTable->setColumnWidth ( 1 , ( parent->width()) ); |
47 | // DataTable->setColumnWidth ( 0 , 118 ); | 47 | DataTable->setColumnWidth ( 0 , ( parent->width()) ); |
48 | setTable(); | 48 | setTable(); |
49 | 49 | ||
50 | qgrid->addWidget( hbox,0,0 ); | 50 | qgrid->addWidget( hbox,0,0 ); |
51 | qgrid->addWidget( DataTable,1,0 ); | 51 | qgrid->addWidget( DataTable,1,0 ); |
52 | } | 52 | } |
53 | 53 | ||
54 | void OxydataWidget::setElement( int el ) | 54 | void OxydataWidget::setElement( int el ) |
55 | { | 55 | { |
56 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); | 56 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); |
57 | 57 | ||
58 | configobj.setGroup( QString::number( el+1 )); | 58 | configobj.setGroup( QString::number( el+1 )); |
59 | 59 | ||
60 | left->setText( configobj.readEntry( "Symbol" ) ); | 60 | left->setText( configobj.readEntry( "Symbol" ) ); |
61 | middle->setText( configobj.readEntry( "Name" ) ); | 61 | middle->setText( configobj.readEntry( "Name" ) ); |
62 | right->setText( QString::number( el+1 ) ); | 62 | right->setText( QString::number( el+1 ) ); |
63 | 63 | ||
64 | 64 | ||
65 | DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); | 65 | DataTable->setText( 0,1,( configobj.readEntry( "Weight" ) )+" u" ); |
66 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); | 66 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); |
67 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); | 67 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); |
68 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); | 68 | DataTable->setText( 3,1,( configobj.readEntry( "EN" ) )+" J" ); |
69 | DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; | 69 | DataTable->setText( 4,1,configobj.readEntry( "AR" )+" nm" ) ; |
70 | DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); | 70 | DataTable->setText( 5,1,configobj.readEntry( "IE" )+" J" ); |
71 | DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); | 71 | DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); |
72 | DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); | 72 | DataTable->setText( 7,1,configobj.readEntry( "BP" )+" K" ); |
73 | DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); | 73 | DataTable->setText( 8,1,configobj.readEntry( "MP" )+" K" ); |
74 | |||
75 | } | 74 | } |
76 | 75 | ||
77 | void OxydataWidget::setTable() const | 76 | void OxydataWidget::setTable() const |
78 | { | 77 | { |
79 | DataTable->setText( 0,0, tr( "Weight:" ) ); | 78 | DataTable->setText( 0,0, tr( "Weight:" ) ); |
80 | DataTable->setText( 1,0, tr( "Block" )) ; | 79 | DataTable->setText( 1,0, tr( "Block" )) ; |
81 | DataTable->setText( 2,0, tr( "Group" )) ; | 80 | DataTable->setText( 2,0, tr( "Group" )) ; |
82 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; | 81 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; |
83 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; | 82 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; |
84 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; | 83 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; |
85 | DataTable->setText( 6,0, tr( "Density" )) ; | 84 | DataTable->setText( 6,0, tr( "Density" )) ; |
86 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); | 85 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); |
87 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); | 86 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); |
88 | 87 | ||
89 | } | 88 | } |
90 | 89 | ||
91 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, | 90 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
92 | const char *name) : QTable(numRows, numCols,parent, name) | 91 | const char *name) : QTable(numRows, numCols,parent, name) |
93 | { | 92 | { |
94 | 93 | ||
95 | for (int zeile = 0; zeile < numRows; zeile++) | 94 | for (int zeile = 0; zeile < numRows; zeile++) |
96 | for ( int spalte = 0; spalte < numCols; spalte++ ) | 95 | for ( int spalte = 0; spalte < numCols; spalte++ ) |
97 | { | 96 | { |
98 | OxydataQTI *testus = new OxydataQTI (this, OxydataQTI::Never, "hm" ); | 97 | OxydataQTI *testus = new OxydataQTI (this, OxydataQTI::Never, "hm" ); |
99 | setItem(zeile, spalte, (QTableItem*)testus); | 98 | setItem(zeile, spalte, (QTableItem*)testus); |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | this->setShowGrid( false ); | 102 | this->setShowGrid( false ); |
104 | this->setHScrollBarMode(QScrollView::AlwaysOff); | 103 | this->setHScrollBarMode(QScrollView::AlwaysOff); |
105 | this->horizontalHeader()->hide(); | 104 | this->horizontalHeader()->hide(); |
106 | this->verticalHeader()->hide(); | 105 | this->verticalHeader()->hide(); |
107 | this->setTopMargin( 0 ); | 106 | this->setTopMargin( 0 ); |
108 | this->setLeftMargin( 0 ); | 107 | this->setLeftMargin( 0 ); |
109 | } | 108 | } |
110 | 109 | ||
111 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | 110 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) |
112 | { | 111 | { |
113 | if ( cr.width() == 0 || cr.height() == 0 ) | 112 | if ( cr.width() == 0 || cr.height() == 0 ) |
114 | return; | 113 | return; |
115 | selected = FALSE; | 114 | selected = FALSE; |
116 | 115 | ||
117 | QTableItem *itm = item( row, col ); | 116 | QTableItem *itm = item( row, col ); |
118 | QColorGroup colgrp = colorGroup(); | 117 | QColorGroup colgrp = colorGroup(); |
119 | if ( itm ) | 118 | if ( itm ) |
120 | { | 119 | { |
121 | if ( row%2 ) | 120 | if ( row%2 ) |
122 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); | 121 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); |
123 | else | 122 | else |
124 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); | 123 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); |
125 | p->save(); | 124 | p->save(); |
126 | itm->paint( p, colgrp, cr, selected ); | 125 | itm->paint( p, colgrp, cr, selected ); |
127 | p->restore(); | 126 | p->restore(); |
128 | } | 127 | } |
129 | } | 128 | } |
130 | 129 | ||
131 | OxydataQTI::OxydataQTI(QTable * table, EditType et, const QString & text ) | 130 | OxydataQTI::OxydataQTI(QTable * table, EditType et, const QString & text ) |
132 | : QTableItem ( table, et, text ) | 131 | : QTableItem ( table, et, text ) |
133 | { | 132 | { |
134 | } | 133 | } |
135 | 134 | ||
136 | int OxydataQTI::alignment() const | 135 | int OxydataQTI::alignment() const |
137 | { | 136 | { |
138 | if ( col()%2 ) | 137 | if ( col()%2 ) |
139 | { | 138 | { |
140 | return AlignRight | AlignVCenter; | 139 | return AlignRight | AlignVCenter; |
141 | }else return AlignLeft | AlignVCenter; | 140 | }else return AlignLeft | AlignVCenter; |
142 | }; | 141 | }; |
143 | 142 | ||