-rw-r--r-- | noncore/apps/oxygen/psewidget.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/oxygen/psewidget.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp index b396046..4f990b0 100644 --- a/noncore/apps/oxygen/psewidget.cpp +++ b/noncore/apps/oxygen/psewidget.cpp | |||
@@ -1,189 +1,189 @@ | |||
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(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 ) | 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 | 102 | ||
103 | 103 | ||
104 | //Helium | 104 | //Helium |
105 | if (n == 2) | 105 | if (n == 2) |
106 | { | 106 | { |
107 | h=680; v=0; | 107 | h=680; v=0; |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | //Lithium | 111 | //Lithium |
112 | if (n == 3) | 112 | if (n == 3) |
113 | { | 113 | { |
114 | h=0; v=40; | 114 | h=0; v=40; |
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | //Beryllium | 118 | //Beryllium |
119 | if (n == 4) | 119 | if (n == 4) |
120 | { | 120 | { |
121 | h=40; v=40; | 121 | h=40; v=40; |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | //Boron-->Neon or Aluminum --> Argon | 125 | //Boron-->Neon or Aluminum --> Argon |
126 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) | 126 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) |
127 | for (int i = 1; i <= (6-(10-n)); i++) | 127 | for (int i = 1; i <= (6-(10-n)); i++) |
128 | { | 128 | { |
129 | h=((i*40)+440); | 129 | h=((i*40)+440); |
130 | v = 40; | 130 | v = 40; |
131 | if (n >= 13) | 131 | if (n >= 13) |
132 | { | 132 | { |
133 | v=80; | 133 | v=80; |
134 | h=(h-320); | 134 | h=(h-320); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | //Sodium | 139 | //Sodium |
140 | if (n == 11) | 140 | if (n == 11) |
141 | { | 141 | { |
142 | h=0; v=80; | 142 | h=0; v=80; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | //Magnesium | 146 | //Magnesium |
147 | if (n == 12) | 147 | if (n == 12) |
148 | { | 148 | { |
149 | h=40; v=80; | 149 | h=40; v=80; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | //Potassium --> Uuo without La and Ac | 153 | //Potassium --> Uuo without La and Ac |
154 | if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104) | 154 | if ((n >= 19 && n <= 56) || (n >= 72 && n <= 88) || n >= 104) |
155 | for (int i = 1; i <= 18; i++) | 155 | for (int i = 1; i <= 18; i++) |
156 | { | 156 | { |
157 | int f = n; | 157 | int f = n; |
158 | if (n > 18) | 158 | if (n > 18) |
159 | f = n-18; | 159 | f = n-18; |
160 | if (n > 36) | 160 | if (n > 36) |
161 | f = n-36; | 161 | f = n-36; |
162 | if (n > 54) | 162 | if (n > 54) |
163 | f = n-54; | 163 | f = n-54; |
164 | if (n > 71) | 164 | if (n > 71) |
165 | f = n-68; | 165 | f = n-68; |
166 | if (n > 86) | 166 | if (n > 86) |
167 | f = n-86; | 167 | f = n-86; |
168 | if (n > 103) | 168 | if (n > 103) |
169 | f = n-100; | 169 | f = n-100; |
170 | 170 | ||
171 | h=((f*40)-40); | 171 | h=((f*40)-40); |
172 | 172 | ||
173 | v = 120; | 173 | v = 120; |
174 | if (n >= 37) | 174 | if (n >= 37) |
175 | v=160; | 175 | v=160; |
176 | if (n >= 55) | 176 | if (n >= 55) |
177 | v=200; | 177 | v=200; |
178 | if (n >= 87) | 178 | if (n >= 87) |
179 | v=240; | 179 | v=240; |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | //Lanthanum --> Lutetium and Actinum --> Lawrencium | 183 | //Lanthanum --> Lutetium and Actinum --> Lawrencium |
184 | if ((n >= 57 && n <= 71) || (n >= 89 && n <= 103)) | 184 | if ((n >= 57 && n <= 71) || (n >= 89 && n <= 103)) |
185 | for (int i = 1; i <= 14; i++) | 185 | for (int i = 1; i <= 14; i++) |
186 | { | 186 | { |
187 | int f = n; | 187 | int f = n; |
188 | if (n > 56) | 188 | if (n > 56) |
189 | f = n-55; | 189 | f = n-55; |
diff --git a/noncore/apps/oxygen/psewidget.h b/noncore/apps/oxygen/psewidget.h index 42a2e38..ad40cf1 100644 --- a/noncore/apps/oxygen/psewidget.h +++ b/noncore/apps/oxygen/psewidget.h | |||
@@ -1,56 +1,56 @@ | |||
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 QStringList; | 25 | class QStringList; |
26 | 26 | ||
27 | class OxydataWidget; | 27 | class OxydataWidget; |
28 | class PSEframe; | 28 | class PSEframe; |
29 | 29 | ||
30 | class PSEWidget : public QWidget | 30 | class PSEWidget : public QWidget |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | 33 | ||
34 | public: | 34 | public: |
35 | PSEWidget(const QStringList &list=0); | 35 | PSEWidget(const QStringList &list=0); |
36 | QGridLayout *bottom_grid; | 36 | QGridLayout *bottom_grid; |
37 | OxydataWidget *oxyDW; | 37 | OxydataWidget *oxyDW; |
38 | 38 | ||
39 | QList<OxyFrame> PSEframe; | 39 | QList<OxyFrame> PSEframe; |
40 | 40 | ||
41 | int lastElement; | 41 | int lastElement; |
42 | 42 | ||
43 | private: | 43 | private: |
44 | QGridLayout *maingrid; | 44 | QGridLayout *maingrid; |
45 | 45 | ||
46 | void position( int, int&, int& ); | 46 | void position( int, int&, int& ); |
47 | QColor PSEColor( QString ); | 47 | QColor PSEColor( QString ) const; |
48 | QStringList names; | 48 | QStringList names; |
49 | 49 | ||
50 | public slots: | 50 | public slots: |
51 | void slotShowElement(QString); | 51 | void slotShowElement(QString); |
52 | void inverseColor( QString ); | 52 | void inverseColor( QString ); |
53 | 53 | ||
54 | }; | 54 | }; |
55 | 55 | ||
56 | #endif | 56 | #endif |