author | cniehaus <cniehaus> | 2002-09-20 19:24:32 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-20 19:24:32 (UTC) |
commit | 681e6e75efaa5577d376d0bb191afdf323cb4e75 (patch) (unidiff) | |
tree | d35ee106655e5b288e73491a2701ddc0141f4fde /noncore/apps/oxygen/dataTable.cpp | |
parent | c958d7cb5069e06b5cf9e9df6e78bcb644ce26a2 (diff) | |
download | opie-681e6e75efaa5577d376d0bb191afdf323cb4e75.zip opie-681e6e75efaa5577d376d0bb191afdf323cb4e75.tar.gz opie-681e6e75efaa5577d376d0bb191afdf323cb4e75.tar.bz2 |
before starting to hack QTableItem I wanted to have a safe point in cvs
Diffstat (limited to 'noncore/apps/oxygen/dataTable.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index 70b5a6a..ff01417 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp | |||
@@ -1,57 +1,70 @@ | |||
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 | 19 | ||
12 | #include "dataTable.h" | 20 | #include "dataTable.h" |
13 | #include <qwidget.h> | 21 | #include <qwidget.h> |
14 | #include <qhbox.h> | 22 | #include <qhbox.h> |
15 | #include <qlabel.h> | 23 | #include <qlabel.h> |
16 | #include <qfont.h> | 24 | #include <qfont.h> |
17 | #include <qlayout.h> | 25 | #include <qlayout.h> |
18 | 26 | ||
19 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) | 27 | OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) |
20 | { | 28 | { |
21 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); | 29 | QGridLayout *qgrid = new QGridLayout( this, 2,1 ); |
30 | |||
22 | QHBox *hbox = new QHBox( this ); | 31 | QHBox *hbox = new QHBox( this ); |
23 | left = new QLabel( hbox ); | 32 | left = new QLabel( hbox ); |
24 | middle = new QLabel( hbox ); | 33 | middle = new QLabel( hbox ); |
25 | right = new QLabel( hbox ); | 34 | right = new QLabel( hbox ); |
26 | 35 | ||
27 | DataTable = new OxydataTable( 9,2, this ); | 36 | right->setAlignment( AlignRight ); |
37 | middle->setAlignment( AlignHCenter ); | ||
28 | 38 | ||
29 | QFont bf; | 39 | QFont bf; |
30 | bf.setBold( true ); | 40 | bf.setBold( true ); |
31 | bf.setPointSize( bf.pointSize()+2 ); | 41 | bf.setPointSize( bf.pointSize()+2 ); |
32 | middle->setFont( bf ); | 42 | middle->setFont( bf ); |
33 | 43 | ||
44 | DataTable = new OxydataTable( 9,2, this ); | ||
45 | DataTable->setColumnWidth ( 1 , 118 ); | ||
46 | DataTable->setColumnWidth ( 0 , 118 ); | ||
34 | setTable(); | 47 | setTable(); |
35 | 48 | ||
36 | qgrid->addWidget( hbox,0,0 ); | 49 | qgrid->addWidget( hbox,0,0 ); |
37 | qgrid->addWidget( DataTable,1,0 ); | 50 | qgrid->addWidget( DataTable,1,0 ); |
38 | } | 51 | } |
39 | 52 | ||
40 | void OxydataWidget::setElement( int el ) | 53 | void OxydataWidget::setElement( int el ) |
41 | { | 54 | { |
42 | Config configobj( "oxygendata" ); | 55 | Config configobj( "oxygendata" ); |
43 | configobj.setGroup( QString::number( el+1 )); | 56 | configobj.setGroup( QString::number( el+1 )); |
44 | 57 | ||
45 | left->setText( configobj.readEntry( "Symbol" ) ); | 58 | left->setText( configobj.readEntry( "Symbol" ) ); |
46 | middle->setText( configobj.readEntry( "Name" ) ); | 59 | middle->setText( configobj.readEntry( "Name" ) ); |
47 | right->setText( QString::number( el+1 ) ); | 60 | right->setText( QString::number( el+1 ) ); |
48 | 61 | ||
49 | DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); | 62 | DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); |
50 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); | 63 | DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); |
51 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); | 64 | DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); |
52 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); | 65 | DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); |
53 | DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; | 66 | DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; |
54 | DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); | 67 | DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); |
55 | DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); | 68 | DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); |
56 | DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); | 69 | DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); |
57 | DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); | 70 | DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); |
@@ -60,43 +73,50 @@ void OxydataWidget::setElement( int el ) | |||
60 | void OxydataWidget::setTable() const | 73 | void OxydataWidget::setTable() const |
61 | { | 74 | { |
62 | DataTable->setText( 0,0, tr( "Weight:" ) ); | 75 | DataTable->setText( 0,0, tr( "Weight:" ) ); |
63 | DataTable->setText( 1,0, tr( "Block" )) ; | 76 | DataTable->setText( 1,0, tr( "Block" )) ; |
64 | DataTable->setText( 2,0, tr( "Group" )) ; | 77 | DataTable->setText( 2,0, tr( "Group" )) ; |
65 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; | 78 | DataTable->setText( 3,0, tr( "Electronegativity" )) ; |
66 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; | 79 | DataTable->setText( 4,0, tr( "Atomic radius" )) ; |
67 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; | 80 | DataTable->setText( 5,0, tr( "Ionizationenergie" )) ; |
68 | DataTable->setText( 6,0, tr( "Density" )) ; | 81 | DataTable->setText( 6,0, tr( "Density" )) ; |
69 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); | 82 | DataTable->setText( 7,0, tr( "Boilingpoint" ) ); |
70 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); | 83 | DataTable->setText( 8,0, tr( "Meltingpoint" ) ); |
71 | } | 84 | } |
72 | 85 | ||
73 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, | 86 | OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent, |
74 | const char *name) : QTable(numRows, numRows, parent, name) | 87 | const char *name) : QTable(numRows, numRows, parent, name) |
75 | { | 88 | { |
76 | this->setShowGrid( false ); | 89 | this->setShowGrid( false ); |
77 | this->setHScrollBarMode(QScrollView::AlwaysOff); | 90 | this->setHScrollBarMode(QScrollView::AlwaysOff); |
78 | this->horizontalHeader()->hide(); | 91 | this->horizontalHeader()->hide(); |
79 | this->verticalHeader()->hide(); | 92 | this->verticalHeader()->hide(); |
80 | this->setTopMargin( 0 ); | 93 | this->setTopMargin( 0 ); |
81 | this->setLeftMargin( 0 ); | 94 | this->setLeftMargin( 0 ); |
82 | } | 95 | } |
83 | 96 | ||
97 | int OxydataTable::alignment() const | ||
98 | { | ||
99 | return AlignLeft | AlignVCenter; | ||
100 | }; | ||
101 | |||
102 | |||
103 | |||
84 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) | 104 | void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) |
85 | { | 105 | { |
86 | if ( cr.width() == 0 || cr.height() == 0 ) | 106 | if ( cr.width() == 0 || cr.height() == 0 ) |
87 | return; | 107 | return; |
88 | selected = FALSE; | 108 | selected = FALSE; |
89 | 109 | ||
90 | QTableItem *itm = item( row, col ); | 110 | QTableItem *itm = item( row, col ); |
91 | QColorGroup colgrp = colorGroup(); | 111 | QColorGroup colgrp = colorGroup(); |
92 | if ( itm ) | 112 | if ( itm ) |
93 | { | 113 | { |
94 | if ( row%2 ) | 114 | if ( row%2 ) |
95 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); | 115 | colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); |
96 | else | 116 | else |
97 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); | 117 | colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); |
98 | p->save(); | 118 | p->save(); |
99 | itm->paint( p, colgrp, cr, selected ); | 119 | itm->paint( p, colgrp, cr, selected ); |
100 | p->restore(); | 120 | p->restore(); |
101 | } | 121 | } |
102 | } | 122 | } |