Diffstat (limited to 'noncore/apps/oxygen/psewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/psewidget.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp index 78e54d5..a3bb505 100644 --- a/noncore/apps/oxygen/psewidget.cpp +++ b/noncore/apps/oxygen/psewidget.cpp | |||
@@ -1,97 +1,105 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | application: : Oxygen | ||
3 | |||
4 | begin : September 2002 | ||
5 | copyright : ( C ) 2002 by Carsten Niehaus | ||
6 | email : cniehaus@handhelds.org | ||
7 | **************************************************************************/ | ||
8 | |||
9 | /*************************************************************************** | ||
2 | * * | 10 | * * |
3 | * 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 * |
4 | * 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 * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * ( at your option ) any later version. * | 14 | * ( at your option ) any later version. * |
7 | * * | 15 | * * |
8 | **************************************************************************/ | 16 | **************************************************************************/ |
9 | 17 | ||
10 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
11 | #include <qlayout.h> | 19 | #include <qlayout.h> |
12 | #include <qlist.h> | 20 | #include <qlist.h> |
13 | #include "dataTable.h" | 21 | #include "dataTable.h" |
14 | #include "psewidget.h" | 22 | #include "psewidget.h" |
15 | #include "oxyframe.h" | 23 | #include "oxyframe.h" |
16 | 24 | ||
17 | 25 | ||
18 | PSEWidget::PSEWidget() : QWidget() | 26 | PSEWidget::PSEWidget() : QWidget() |
19 | { | 27 | { |
20 | this->setCaption( tr( "Periodic System" ) ); | 28 | this->setCaption( tr( "Periodic System" ) ); |
21 | 29 | ||
22 | QVBoxLayout *vlay = new QVBoxLayout( this ); | 30 | QVBoxLayout *vlay = new QVBoxLayout( this ); |
23 | 31 | ||
24 | QGridLayout *grid = new QGridLayout( 18,10 ); | 32 | QGridLayout *grid = new QGridLayout( 18,10 ); |
25 | int h=0, v=0; | 33 | int h=0, v=0; |
26 | 34 | ||
27 | Config configobj( "oxygendata" ); | 35 | Config configobj( "oxygendata" ); |
28 | for( int n = 0 ; n < 118 ; n++ ) | 36 | for( int n = 0 ; n < 118 ; n++ ) |
29 | { | 37 | { |
30 | configobj.setGroup( QString::number( n+1 )); | 38 | configobj.setGroup( QString::number( n+1 )); |
31 | 39 | ||
32 | position( n+1,h,v ); | 40 | position( n+1,h,v ); |
33 | QList<OxyFrame> PSEframe; | 41 | QList<OxyFrame> PSEframe; |
34 | PSEframe.append( new OxyFrame( this , QString::number(n) ) ); | 42 | PSEframe.append( new OxyFrame( this , QString::number(n) ) ); |
35 | grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); | 43 | grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); |
36 | PSEframe.current()->setMinimumHeight( 11 ); | 44 | PSEframe.current()->setMinimumHeight( 11 ); |
37 | PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); | 45 | PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); |
38 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); | 46 | connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); |
39 | } | 47 | } |
40 | 48 | ||
41 | oxyDW = new OxydataWidget(this); | 49 | oxyDW = new OxydataWidget(this); |
42 | oxyDW->setElement( 1 ); | 50 | oxyDW->setElement( 1 ); |
43 | 51 | ||
44 | vlay->addLayout( grid ); | 52 | vlay->addLayout( grid ); |
45 | vlay->addWidget( oxyDW ); | 53 | vlay->addWidget( oxyDW ); |
46 | } | 54 | } |
47 | 55 | ||
48 | QColor PSEWidget::PSEColor( QString block ) | 56 | QColor PSEWidget::PSEColor( QString block ) |
49 | { | 57 | { |
50 | QColor c; | 58 | QColor c; |
51 | if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); | 59 | if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); |
52 | else if ( block == "d" ) c.setRgb( 200,230,160 ); | 60 | else if ( block == "d" ) c.setRgb( 200,230,160 ); |
53 | else if ( block == "p" ) c.setRgb( 238,146,138 ); | 61 | else if ( block == "p" ) c.setRgb( 238,146,138 ); |
54 | else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); | 62 | else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); |
55 | return c; | 63 | return c; |
56 | }; | 64 | }; |
57 | 65 | ||
58 | void PSEWidget::slotShowElement(QString number) | 66 | void PSEWidget::slotShowElement(QString number) |
59 | { | 67 | { |
60 | oxyDW->setElement( number.toInt() ); | 68 | oxyDW->setElement( number.toInt() ); |
61 | }; | 69 | }; |
62 | 70 | ||
63 | void PSEWidget::position(int n, int& h, int& v) | 71 | void PSEWidget::position(int n, int& h, int& v) |
64 | { | 72 | { |
65 | //Hydrogen | 73 | //Hydrogen |
66 | if (n == 1) | 74 | if (n == 1) |
67 | { | 75 | { |
68 | h=0; v=0; | 76 | h=0; v=0; |
69 | } | 77 | } |
70 | 78 | ||
71 | 79 | ||
72 | //Helium | 80 | //Helium |
73 | if (n == 2) | 81 | if (n == 2) |
74 | { | 82 | { |
75 | h=680; v=0; | 83 | h=680; v=0; |
76 | } | 84 | } |
77 | 85 | ||
78 | 86 | ||
79 | //Lithium | 87 | //Lithium |
80 | if (n == 3) | 88 | if (n == 3) |
81 | { | 89 | { |
82 | h=0; v=40; | 90 | h=0; v=40; |
83 | } | 91 | } |
84 | 92 | ||
85 | 93 | ||
86 | //Beryllium | 94 | //Beryllium |
87 | if (n == 4) | 95 | if (n == 4) |
88 | { | 96 | { |
89 | h=40; v=40; | 97 | h=40; v=40; |
90 | } | 98 | } |
91 | 99 | ||
92 | 100 | ||
93 | //Boron-->Neon or Aluminum --> Argon | 101 | //Boron-->Neon or Aluminum --> Argon |
94 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) | 102 | if ((n >= 5 && n <= 10) || (n >= 13 && n <= 18)) |
95 | for (int i = 1; i <= (6-(10-n)); i++) | 103 | for (int i = 1; i <= (6-(10-n)); i++) |
96 | { | 104 | { |
97 | h=((i*40)+440); | 105 | h=((i*40)+440); |