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