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