-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index 8f619b4..e3906be 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp | |||
@@ -1,152 +1,152 @@ | |||
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 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | OxydataWidget::OxydataWidget(QWidget *parent, const char *name, const QStringList &list ) : QWidget( parent,name ), names( list ) | 30 | OxydataWidget::OxydataWidget(QWidget *parent, const char *name, const QStringList &list ) : QWidget( parent,name ), names( list ) |
31 | { | 31 | { |
32 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); | 32 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); |
33 | 33 | ||
34 | QHBox *hbox = new QHBox( this ); | 34 | QHBox *hbox = new QHBox( this ); |
35 | left = new QLabel( hbox ); | 35 | left = new QLabel( hbox ); |
36 | middle = new QLabel( hbox ); | 36 | middle = new QLabel( hbox ); |
37 | right = new QLabel( hbox ); | 37 | right = new QLabel( hbox ); |
38 | 38 | ||
39 | right->setAlignment( AlignRight ); | 39 | right->setAlignment( AlignRight ); |
40 | middle->setAlignment( AlignHCenter ); | 40 | middle->setAlignment( AlignHCenter ); |
41 | 41 | ||
42 | QFont bf; | 42 | QFont bf; |
43 | bf.setBold( true ); | 43 | bf.setBold( true ); |
44 | bf.setPointSize( bf.pointSize()+2 ); | 44 | bf.setPointSize( bf.pointSize()+2 ); |
45 | middle->setFont( bf ); | 45 | middle->setFont( bf ); |
46 | 46 | ||
47 | DataTable = new OxydataTable( 9,2, this ); | 47 | DataTable = new OxydataTable( 9,2, this ); |
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 | QStringList::ConstIterator it = names.at(el); | 56 | QStringList::ConstIterator it = names.at(el); |
57 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); | 57 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); |
58 | 58 | ||
59 | configobj.setGroup( QString::number( el+1 )); | 59 | configobj.setGroup( QString::number( el+1 )); |
60 | 60 | ||
61 | left->setText( configobj.readEntry( "Symbol" ) ); | 61 | left->setText( configobj.readEntry( "Symbol" ) ); |
62 | middle->setText( *it ); | 62 | middle->setText( *it ); |
63 | right->setText( QString::number( el+1 ) ); | 63 | right->setText( QString::number( el+1 ) ); |
64 | 64 | ||
65 | 65 | ||
66 | DataTable->setText( 0,1,tr( "%1 u" ).arg( configobj.readEntry( "Weight" ) ) ); | 66 | DataTable->setText( 0,1,tr( "%1 u" ).arg( configobj.readEntry( "Weight" ) ) ); |
67 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); | 67 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); |
68 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); | 68 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); |
69 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); | 69 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); |
70 | DataTable->setText( 4,1,tr( "%1 pm" ).arg( configobj.readEntry( "AR" ) ) ) ; | 70 | DataTable->setText( 4,1,tr( "%1 pm" ).arg( configobj.readEntry( "AR" ) ) ) ; |
71 | DataTable->setText( 5,1,tr( "%1 J" ).arg( configobj.readEntry( "IE" ) ) ); | 71 | DataTable->setText( 5,1,tr( "%1 J" ).arg( configobj.readEntry( "IE" ) ) ); |
72 | DataTable->setText( 6,1,tr( "%1 g/cm^3" ).arg( configobj.readEntry( "Density" ) ) ); | 72 | DataTable->setText( 6,1,tr( "%1 g/cm^3" ).arg( configobj.readEntry( "Density" ) ) ); |
73 | DataTable->setText( 7,1,tr( "%1 K" ).arg( configobj.readEntry( "BP" ) ) ); | 73 | DataTable->setText( 7,1,tr( "%1 K" ).arg( configobj.readEntry( "BP" ) ) ); |
74 | DataTable->setText( 8,1,tr( "%1 K" ).arg( configobj.readEntry( "MP" ) ) ); | 74 | DataTable->setText( 8,1,tr( "%1 K" ).arg( configobj.readEntry( "MP" ) ) ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void OxydataWidget::setTable() const | 77 | void OxydataWidget::setTable() const |
78 | { | 78 | { |
79 | DataTable->setText( 0,0, tr( "Weight" ) ); | 79 | DataTable->setText( 0,0, tr( "Weight" ) ); |
80 | DataTable->setText( 1,0, tr( "Block" )) ; | 80 | DataTable->setText( 1,0, tr( "Block" )) ; |
81 | DataTable->setText( 2,0, tr( "Group" )) ; | 81 | DataTable->setText( 2,0, tr( "Group" )) ; |
82 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; | 82 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; |
83 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; | 83 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; |
84 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; | 84 | DataTable->setText( 5,0, tr( "Ionization Energy" )) ; |
85 | DataTable->setText( 6,0, tr( "Density" )) ; | 85 | DataTable->setText( 6,0, tr( "Density" )) ; |
86 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); | 86 | DataTable->setText( 7,0, tr( "Boiling point" ) ); |
87 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); | 87 | DataTable->setText( 8,0, tr( "Melting point" ) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void OxydataWidget::setLayout() | 90 | void OxydataWidget::setLayout() |
91 | { | 91 | { |
92 | #warning this is not working and I have no idea why! | 92 | #warning this is not working and I have no idea why! |
93 | // DataTable->setColumnWidth ( 0 , this->width()/2 ); | 93 | // DataTable->setColumnWidth ( 0 , this->width()/2 ); |
94 | // DataTable->setColumnWidth ( 1 , this->width()/2 ); | 94 | // DataTable->setColumnWidth ( 1 , this->width()/2 ); |
95 | 95 | ||
96 | //X DataTable->setColumnWidth ( 0 , 110 ); | 96 | //X DataTable->setColumnWidth ( 0 , 110 ); |
97 | //X DataTable->setColumnWidth ( 1 , 110 ); | 97 | //X DataTable->setColumnWidth ( 1 , 110 ); |
98 | } | 98 | } |
99 | 99 | ||
100 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, | 100 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
101 | const char *name) : QTable(numRows, numCols,parent, name) | 101 | const char *name) : QTable(numRows, numCols,parent, name) |
102 | { | 102 | { |
103 | 103 | ||
104 | for (int zeile = 0; zeile < numRows; zeile++) | 104 | for (int zeile = 0; zeile < numRows; zeile++) |
105 | for ( int spalte = 0; spalte < numCols; spalte++ ) | 105 | for ( int spalte = 0; spalte < numCols; spalte++ ) |
106 | { | 106 | { |
107 | OxydataQTI *testus = new OxydataQTI (this, OxydataQTI::Never, "hm" ); | 107 | OxydataQTI *testus = new OxydataQTI (this, OxydataQTI::Never, "hm" ); |
108 | setItem(zeile, spalte, (QTableItem*)testus); | 108 | setItem(zeile, spalte, (QTableItem*)testus); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | this->setShowGrid( false ); | 112 | this->setShowGrid( false ); |
113 | this->setHScrollBarMode(QScrollView::AlwaysOff); | 113 | this->setHScrollBarMode(QScrollView::AlwaysOff); |
114 | this->horizontalHeader()->hide(); | 114 | this->horizontalHeader()->hide(); |
115 | this->verticalHeader()->hide(); | 115 | this->verticalHeader()->hide(); |
116 | this->setTopMargin( 0 ); | 116 | this->setTopMargin( 0 ); |
117 | this->setLeftMargin( 0 ); | 117 | this->setLeftMargin( 0 ); |
118 | } | 118 | } |
119 | 119 | ||
120 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | 120 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) |
121 | { | 121 | { |
122 | if ( cr.width() == 0 || cr.height() == 0 ) | 122 | if ( cr.width() == 0 || cr.height() == 0 ) |
123 | return; | 123 | return; |
124 | selected = FALSE; | 124 | selected = FALSE; |
125 | 125 | ||
126 | QTableItem *itm = item( row, col ); | 126 | QTableItem *itm = item( row, col ); |
127 | QColorGroup colgrp = colorGroup(); | 127 | QColorGroup colgrp = colorGroup(); |
128 | if ( itm ) | 128 | if ( itm ) |
129 | { | 129 | { |
130 | if ( row%2 ) | 130 | if ( row%2 ) |
131 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); | 131 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); |
132 | else | 132 | else |
133 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); | 133 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); |
134 | p->save(); | 134 | p->save(); |
135 | itm->paint( p, colgrp, cr, selected ); | 135 | itm->paint( p, colgrp, cr, selected ); |
136 | p->restore(); | 136 | p->restore(); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | OxydataQTI::OxydataQTI(QTable * table, EditType et, const QString & text ) | 140 | OxydataQTI::OxydataQTI(QTable * table, EditType et, const QString & text ) |
141 | : QTableItem ( table, et, text ) | 141 | : QTableItem ( table, et, text ) |
142 | { | 142 | { |
143 | } | 143 | } |
144 | 144 | ||
145 | int OxydataQTI::alignment() const | 145 | int OxydataQTI::alignment() const |
146 | { | 146 | { |
147 | if ( col()%2 ) | 147 | if ( col()%2 ) |
148 | { | 148 | { |
149 | return AlignRight | AlignVCenter; | 149 | return AlignRight | AlignVCenter; |
150 | }else return AlignLeft | AlignVCenter; | 150 | }else return AlignLeft | AlignVCenter; |
151 | }; | 151 | }; |
152 | 152 | ||