-rw-r--r-- | noncore/apps/oxygen/psewidget.cpp | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp index 4f990b0..be5185b 100644 --- a/noncore/apps/oxygen/psewidget.cpp +++ b/noncore/apps/oxygen/psewidget.cpp | |||
@@ -1,198 +1,198 @@ | |||
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, 2003 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 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qlist.h> | 21 | #include <qlist.h> |
22 | #include "dataTable.h" | 22 | #include "dataTable.h" |
23 | #include "psewidget.h" | 23 | #include "psewidget.h" |
24 | #include "oxyframe.h" | 24 | #include "oxyframe.h" |
25 | 25 | ||
26 | 26 | ||
27 | PSEWidget::PSEWidget(const QStringList &list) : QWidget() | 27 | PSEWidget::PSEWidget(const QStringList &list) : QWidget() |
28 | { | 28 | { |
29 | this->setCaption( tr( "Periodic System" ) ); | 29 | this->setCaption( tr( "Periodic System" ) ); |
30 | 30 | ||
31 | lastElement=1; | 31 | lastElement=1; |
32 | names = list; | 32 | names = list; |
33 | 33 | ||
34 | QVBoxLayout *vlay = new QVBoxLayout( this ); | 34 | QVBoxLayout *vlay = new QVBoxLayout( this ); |
35 | 35 | ||
36 | QGridLayout *grid = new QGridLayout( 18,10 ); | 36 | QGridLayout *grid = new QGridLayout( 18,10 ); |
37 | int h=0, v=0; | 37 | int h=0, v=0; |
38 | 38 | ||
39 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); | 39 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); |
40 | for( int n = 0 ; n < 109 ; n++ ) | 40 | for( int n = 0 ; n < 109 ; n++ ) |
41 | { | 41 | { |
42 | configobj.setGroup( QString::number( n+1 )); | 42 | configobj.setGroup( QString::number( n+1 )); |
43 | 43 | ||
44 | position( n+1,h,v ); | 44 | position( n+1,h,v ); |
45 | PSEframe.append( new OxyFrame( this , QString::number(n), configobj.readEntry( "Symbol" ) ) ); | 45 | PSEframe.append( new OxyFrame( this , QString::number(n), configobj.readEntry( "Symbol" ) ) ); |
46 | grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); | 46 | grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); |
47 | PSEframe.current()->setMinimumHeight( 11 ); | 47 | PSEframe.current()->setMinimumHeight( 11 ); |
48 | PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); | 48 | PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); |
49 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); | 49 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); |
50 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( inverseColor(QString) )); | 50 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( inverseColor(QString) )); |
51 | } | 51 | } |
52 | 52 | ||
53 | oxyDW = new OxydataWidget(this, "PSEWidget_oxyDW", names); | 53 | oxyDW = new OxydataWidget(this, "PSEWidget_oxyDW", names); |
54 | oxyDW->setElement( 0 ); | 54 | oxyDW->setElement( 0 ); |
55 | oxyDW->setLayout(); | 55 | oxyDW->setLayout(); |
56 | 56 | ||
57 | vlay->addLayout( grid ); | 57 | vlay->addLayout( grid ); |
58 | vlay->addWidget( oxyDW ); | 58 | vlay->addWidget( oxyDW ); |
59 | } | 59 | } |
60 | 60 | ||
61 | QColor PSEWidget::PSEColor( QString block ) const | 61 | QColor PSEWidget::PSEColor( QString block ) const |
62 | { | 62 | { |
63 | QColor c; | 63 | QColor c; |
64 | if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); | 64 | if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); |
65 | else if ( block == "d" ) c.setRgb( 200,230,160 ); | 65 | else if ( block == "d" ) c.setRgb( 200,230,160 ); |
66 | else if ( block == "p" ) c.setRgb( 238,146,138 ); | 66 | else if ( block == "p" ) c.setRgb( 238,146,138 ); |
67 | else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); | 67 | else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); |
68 | return c; | 68 | return c; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | void PSEWidget::inverseColor( QString number) | 71 | void PSEWidget::inverseColor( QString number) |
72 | { | 72 | { |
73 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); | 73 | Config configobj( QPEApplication::qpeDir() +"share/oxygen/oxygendata", Config::File ); |
74 | configobj.setGroup( number ); | 74 | configobj.setGroup( number ); |
75 | QString block = configobj.readEntry( "Block" ); | 75 | QString block = configobj.readEntry( "Block" ); |
76 | QColor c, d; | 76 | QColor c, d; |
77 | c = PSEColor( block ); | 77 | c = PSEColor( block ); |
78 | d = c.dark(); | 78 | d = c.dark(); |
79 | 79 | ||
80 | PSEframe.at( number.toUInt() )->setPalette( QPalette( d ) ); | 80 | PSEframe.at( number.toUInt() )->setPalette( QPalette( d ) ); |
81 | 81 | ||
82 | configobj.setGroup( QString::number( lastElement+1 ) ); | 82 | configobj.setGroup( QString::number( lastElement+1 ) ); |
83 | block = configobj.readEntry( "Block" ); | 83 | block = configobj.readEntry( "Block" ); |
84 | c = PSEColor( block ); | 84 | c = PSEColor( block ); |
85 | PSEframe.at( lastElement )->setPalette( QPalette( c ) ); | 85 | PSEframe.at( lastElement )->setPalette( QPalette( c ) ); |
86 | 86 | ||
87 | lastElement=number.toInt(); | 87 | lastElement=number.toInt(); |
88 | } | 88 | } |
89 | 89 | ||
90 | void PSEWidget::slotShowElement(QString number) | 90 | void PSEWidget::slotShowElement(QString number) |
91 | { | 91 | { |
92 | oxyDW->setElement( number.toInt() ); | 92 | oxyDW->setElement( number.toInt() ); |
93 | }; | 93 | }; |
94 | 94 | ||
95 | void PSEWidget::position(int n, int& h, int& v) | 95 | void PSEWidget::position(int n, int& h, int& v) |
96 | { | 96 | { |
97 | //Hydrogen | 97 | //Hydrogen |
98 | if (n == 1) | 98 | if (n == 1) |
99 | { | 99 | { |
100 | h=0; v=0; | 100 | h=0; v=0; |
101 | } | 101 | } |
102 | |||
103 | |||
104 | //Helium | ||
105 | if (n == 2) | ||
106 | { | ||
107 | h=680; v=0; | ||
108 | } | ||
109 | |||
110 | |||
111 | //Lithium | ||
112 | if (n == 3) | ||
113 | { | ||
114 | h=0; v=40; | ||
115 | } | ||
116 | 102 | ||
117 | 103 | ||
118 | //Beryllium | 104 | //Helium |
119 | if (n == 4) | 105 | if (n == 2) |
120 | { | 106 | { |
121 | h=40; v=40; | 107 | h=680; v=0; |
122 | } | 108 | } |
123 | 109 | ||
124 | 110 | ||
125 | //Boron-->Neon or Aluminum --> Argon | 111 | //Lithium |
126 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) | 112 | if (n == 3) |
127 | for (int i = 1; i <= (6-(10-n)); i++) | ||
128 | { | 113 | { |
129 | h=((i*40)+440); | 114 | h=0; v=40; |
130 | v = 40; | ||
131 | if (n >= 13) | ||
132 | { | ||
133 | v=80; | ||
134 | h=(h-320); | ||
135 | } | ||
136 | } | 115 | } |
137 | 116 | ||
138 | 117 | ||
139 | //Sodium | 118 | //Beryllium |
140 | if (n == 11) | 119 | if (n == 4) |
141 | { | 120 | { |
142 | h=0; v=80; | 121 | h=40; v=40; |
143 | } | 122 | } |
144 | 123 | ||
145 | 124 | ||
146 | //Magnesium | 125 | //Boron-->Neon or Aluminum --> Argon |
147 | if (n == 12) | 126 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) |
148 | { | 127 | for (int i = 1; i <= (6-(10-n)); i++) |
149 | h=40; v=80; | 128 | { |
150 | } | 129 | h=((i*40)+440); |
130 | v = 40; | ||
131 | if (n >= 13) | ||
132 | { | ||
133 | v=80; | ||
134 | h=(h-320); | ||
135 | } | ||
136 | } | ||
151 | 137 | ||
152 | 138 | ||
153 | //Potassium --> Uuo without La and Ac | 139 | //Sodium |
154 | if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104) | 140 | if (n == 11) |
155 | for (int i = 1; i <= 18; i++) | ||
156 | { | 141 | { |
157 | int f = n; | 142 | h=0; v=80; |
158 | if (n > 18) | ||
159 | f = n-18; | ||
160 | if (n > 36) | ||
161 | f = n-36; | ||
162 | if (n > 54) | ||
163 | f = n-54; | ||
164 | if (n > 71) | ||
165 | f = n-68; | ||
166 | if (n > 86) | ||
167 | f = n-86; | ||
168 | if (n > 103) | ||
169 | f = n-100; | ||
170 | |||
171 | h=((f*40)-40); | ||
172 | |||
173 | v = 120; | ||
174 | if (n >= 37) | ||
175 | v=160; | ||
176 | if (n >= 55) | ||
177 | v=200; | ||
178 | if (n >= 87) | ||
179 | v=240; | ||
180 | } | 143 | } |
181 | 144 | ||
182 | 145 | ||
183 | //Lanthanum --> Lutetium and Actinum --> Lawrencium | 146 | //Magnesium |
184 | if ((n >= 57 && n <= 71) || (n >= 89 && n <= 103)) | 147 | if (n == 12) |
185 | for (int i = 1; i <= 14; i++) | ||
186 | { | 148 | { |
187 | int f = n; | 149 | h=40; v=80; |
188 | if (n > 56) | ||
189 | f = n-55; | ||
190 | if (n > 88) | ||
191 | f = n-87; | ||
192 | h=(f*40); | ||
193 | v = 290; | ||
194 | if (n >= 89) | ||
195 | v=330; | ||
196 | } | 150 | } |
197 | v += 10; | 151 | |
152 | |||
153 | //Potassium --> Uuo without La and Ac | ||
154 | if ((n >= 19 && n <= 57) || (n >= 72 && n <= 89) || n >= 104) | ||
155 | for (int i = 1; i <= 18; i++) | ||
156 | { | ||
157 | int f = n; | ||
158 | if (n > 18) | ||
159 | f = n-18; | ||
160 | if (n > 36) | ||
161 | f = n-36; | ||
162 | if (n > 54) | ||
163 | f = n-54; | ||
164 | if (n > 71) | ||
165 | f = n-68; | ||
166 | if (n > 86) | ||
167 | f = n-86; | ||
168 | if (n > 103) | ||
169 | f = n-100; | ||
170 | |||
171 | h=((f*40)-40); | ||
172 | |||
173 | v = 120; | ||
174 | if (n >= 37) | ||
175 | v=160; | ||
176 | if (n >= 55) | ||
177 | v=200; | ||
178 | if (n >= 87) | ||
179 | v=240; | ||
180 | } | ||
181 | |||
182 | |||
183 | //Lanthanum --> Lutetium and Actinum --> Lawrencium | ||
184 | if ((n >= 58 && n <= 71) || (n >= 90 && n <= 103)) | ||
185 | for (int i = 1; i <= 14; i++) | ||
186 | { | ||
187 | int f = n; | ||
188 | if (n > 57) | ||
189 | f = n-55; | ||
190 | if (n > 88) | ||
191 | f = n-87; | ||
192 | h=(f*40); | ||
193 | v = 290; | ||
194 | if (n >= 90) | ||
195 | v=330; | ||
196 | } | ||
197 | v += 10; | ||
198 | } | 198 | } |