summaryrefslogtreecommitdiff
authorcniehaus <cniehaus>2002-09-18 13:54:36 (UTC)
committer cniehaus <cniehaus>2002-09-18 13:54:36 (UTC)
commit6008e7d286293a87fca4ff43729bdfa66d700989 (patch) (side-by-side diff)
treebd0b5067e9914f0aca79540511dceea662a11d62
parent15ecc4aa71878039ad40ce270fae06282d8e98c2 (diff)
downloadopie-6008e7d286293a87fca4ff43729bdfa66d700989.zip
opie-6008e7d286293a87fca4ff43729bdfa66d700989.tar.gz
opie-6008e7d286293a87fca4ff43729bdfa66d700989.tar.bz2
This is far better: I use 2 more classes, everything is far more OO
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/dataTable.cpp77
-rw-r--r--noncore/apps/oxygen/dataTable.h31
-rw-r--r--noncore/apps/oxygen/datawidgetui.cpp76
-rw-r--r--noncore/apps/oxygen/datawidgetui.h5
4 files changed, 116 insertions, 73 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp
index bb786ea..642a8be 100644
--- a/noncore/apps/oxygen/dataTable.cpp
+++ b/noncore/apps/oxygen/dataTable.cpp
@@ -6,13 +6,90 @@
* ( at your option ) any later version. *
* *
**************************************************************************/
+#include <qpe/config.h>
+
#include "dataTable.h"
+#include <qwidget.h>
+#include <qhbox.h>
+#include <qvbox.h>
+#include <qlabel.h>
+#include <qfont.h>
+#include <qlayout.h>
+
+OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent)
+{
+ QGridLayout *qgrid = new QGridLayout( this, 2,1 );
+ QHBox *hbox = new QHBox( this );
+ left = new QLabel( hbox );
+ middle = new QLabel( hbox );
+ right = new QLabel( hbox );
+
+ DataTable = new OxydataTable( 9,2, this );
+
+ QFont bf;
+ bf.setBold( true );
+ bf.setPointSize( bf.pointSize()+2 );
+ middle->setFont( bf );
+
+ setTable();
+
+ qgrid->addWidget( hbox,0,0 );
+ qgrid->addWidget( DataTable,1,0 );
+}
+
+void OxydataWidget::setElement( int el )
+{
+ Config test( "/home/opie/Settings/oxygendata", Config::File );
+ test.setGroup( QString::number( el+1 ));
+
+ left->setText( test.readEntry( "Symbol" ) );
+ middle->setText( test.readEntry( "Name" ) );
+ right->setText( QString::number( el+1 ) );
+
+ QString weight = test.readEntry( "Weight" );
+ DataTable->setText( 0,1,weight );
+ QString block = test.readEntry( "Block" );
+ DataTable->setText( 1,1,block );
+ QString grp = test.readEntry( "Group" );
+ DataTable->setText( 2,1,grp );
+ QString en = test.readEntry( "EN" );
+ DataTable->setText( 3,1,en );
+ QString ar = test.readEntry( "AR" );
+ DataTable->setText( 4,1,ar ) ;
+ QString ion = test.readEntry( "IE" );
+ DataTable->setText( 5,1,ion );
+ QString dens = test.readEntry( "Density" );
+ DataTable->setText( 6,1,dens );
+ QString bp = test.readEntry( "BP" );
+ DataTable->setText( 7,1,bp );
+ QString mp = test.readEntry( "MP" );
+ DataTable->setText( 8,1,mp );
+}
+
+void OxydataWidget::setTable()
+{
+ DataTable->setText( 0,0, tr( "Weight:" ) );
+ DataTable->setText( 1,0, tr( "Block" )) ;
+ DataTable->setText( 2,0, tr( "Group" )) ;
+ DataTable->setText( 3,0, tr( "Electronegativity" )) ;
+ DataTable->setText( 4,0, tr( "Atomic radius" )) ;
+ DataTable->setText( 5,0, tr( "Ionizationenergie" )) ;
+ DataTable->setText( 6,0, tr( "Density" )) ;
+ DataTable->setText( 7,0, tr( "Boilingpoint" ) );
+ DataTable->setText( 8,0, tr( "Meltingpoint" ) );
+}
OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent,
const char *name) : QTable(numRows, numRows, parent, name)
{
+ this->setShowGrid( false );
+ this->setHScrollBarMode(QScrollView::AlwaysOff);
+ this->horizontalHeader()->hide();
+ this->verticalHeader()->hide();
+ this->setTopMargin( 0 );
+ this->setLeftMargin( 0 );
}
void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected)
{
diff --git a/noncore/apps/oxygen/dataTable.h b/noncore/apps/oxygen/dataTable.h
index 908d241..624e8bd 100644
--- a/noncore/apps/oxygen/dataTable.h
+++ b/noncore/apps/oxygen/dataTable.h
@@ -10,10 +10,39 @@
#ifndef _DATATABLE_H
#define _DATATABLE_H
+#include <qwidget.h>
#include <qtable.h>
+class QLabel;
+class OxydataTable;
+
+class OxydataWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ OxydataWidget(QWidget *parent=0);
+
+ QLabel *left, *middle, *right;
+
+ private:
+ OxydataTable *DataTable;
+ void setTable();
+
+ public slots:
+ void setElement( int );
+};
+
+/*
+ * A OxydataTable is derived from QTable. I recoded the paintCell to have
+ * different colors in the backgound. Furthermore this widget never has a
+ * grid, thus I removed that code in paintCell.
+ *
+ * Author: Carsten Niehaus <cniehaus@handhelds.org>
+ */
+
class OxydataTable : public QTable
{
Q_OBJECT
@@ -25,8 +54,8 @@ class OxydataTable : public QTable
/*
* This method is reimplemented form QTable. It implements the colourisation
* of every second row.
*/
- virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
+ virtual void paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected );
};
#endif
diff --git a/noncore/apps/oxygen/datawidgetui.cpp b/noncore/apps/oxygen/datawidgetui.cpp
index 7256777..fa3f40d 100644
--- a/noncore/apps/oxygen/datawidgetui.cpp
+++ b/noncore/apps/oxygen/datawidgetui.cpp
@@ -6,11 +6,11 @@
* ( at your option ) any later version. *
* *
**************************************************************************/
#include "oxygen.h"
+#include "datawidgetui.h"
#include <qpe/config.h>
-#include "datawidgetui.h"
#include <qstring.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <qtable.h>
@@ -20,28 +20,17 @@
dataWidgetUI::dataWidgetUI() : QDialog()
{
this->setCaption("Chemical Data");
- QVBoxLayout *vbox = new QVBoxLayout( this );
+ QGridLayout *qgrid = new QGridLayout( this, 2,1 );
dataCombo = new QComboBox( this );
- DataTable = new OxydataTable( 8,2, this );
- DataTable->setShowGrid( false );
- DataTable->setHScrollBarMode(QScrollView::AlwaysOff);
-
- QHBox *hbox = new QHBox( this );
- left = new QLabel( hbox );
- middle = new QLabel( hbox );
- right = new QLabel( hbox );
-
- vbox->addWidget( dataCombo );
- vbox->addWidget( hbox );
- vbox->addWidget( DataTable );
+ OxydataWidget *oxyDW = new OxydataWidget(this);
+ oxyDW->setElement( 1 );
+ qgrid->addWidget( dataCombo, 0,0);
+ qgrid->addWidget( oxyDW , 1,0 );
- DataTable->show();
- dataCombo->show();
-
- connect ( dataCombo, SIGNAL( activated(int) ), this, SLOT( slotShowData(int) ) );
+ connect ( dataCombo, SIGNAL( activated(int) ), oxyDW, SLOT( setElement(int) ) );
Config test( "/home/opie/Settings/oxygendata", Config::File );
//read in all names of the 118 elements
for ( int i = 1 ; i < 119 ; i++ )
@@ -49,60 +38,11 @@ dataWidgetUI::dataWidgetUI() : QDialog()
test.setGroup( QString::number( i ) );
QString foo = test.readEntry( "Name" );
dataCombo->insertItem( foo );
}
-
- createTableLayout();
- slotShowData( 1 ); //this way we do always get data here
-
}
-void dataWidgetUI::createTableLayout(){
- DataTable->horizontalHeader()->hide();
- DataTable->verticalHeader()->hide();
- DataTable->setTopMargin( 0 );
- DataTable->setLeftMargin( 0 );
-
- DataTable->setText( 0,0,"Weight:" );
- DataTable->setText( 1,0,"Block" );
- DataTable->setText( 2,0,"Group" );
- DataTable->setText( 3,0,"Electronegativity" );
- DataTable->setText( 4,0,"Atomic radius" );
- DataTable->setText( 5,0,"Ionizationenergie" );
- DataTable->setText( 6,0,"Density" );
- DataTable->setText( 7,0, tr( "Boilingpoint" ) );
- DataTable->setText( 8,0, tr( "Meltingpoint" ) );
-}
void dataWidgetUI::slotShowData(int number){
- Config test( "/home/opie/Settings/oxygendata", Config::File );
- test.setGroup( QString::number( number+1 ));
-
- left->setText( test.readEntry( "Symbol" ) );
- middle->setText( test.readEntry( "Name" ) );
- right->setText( QString::number( number+1 ) );
-
- QFont bf;
- bf.setBold( true );
- bf.setPointSize( bf.pointSize()+2 );
- middle->setFont( bf );
-
- QString weight = test.readEntry( "Weight" );
- DataTable->setText( 0,1,weight );
- QString block = test.readEntry( "Block" );
- DataTable->setText( 1,1,block );
- QString grp = test.readEntry( "Group" );
- DataTable->setText( 2,1,grp );
- QString en = test.readEntry( "EN" );
- DataTable->setText( 3,1,en );
- QString ar = test.readEntry( "AR" );
- DataTable->setText( 4,1,ar ) ;
- QString ion = test.readEntry( "IE" );
- DataTable->setText( 5,1,ion );
- QString dens = test.readEntry( "Density" );
- DataTable->setText( 6,1,dens );
- QString bp = test.readEntry( "BP" );
- DataTable->setText( 7,1,bp );
- QString mp = test.readEntry( "MP" );
- DataTable->setText( 7,1,mp );
+ oxyDW->setElement( 6 );
}
diff --git a/noncore/apps/oxygen/datawidgetui.h b/noncore/apps/oxygen/datawidgetui.h
index 64599a7..20622db 100644
--- a/noncore/apps/oxygen/datawidgetui.h
+++ b/noncore/apps/oxygen/datawidgetui.h
@@ -9,24 +9,21 @@
**************************************************************************/
#include "dataTable.h"
#include <qdialog.h>
-class QTable;
class QComboBox;
-class QLabel;
class dataWidgetUI : public QDialog
{
Q_OBJECT
public:
dataWidgetUI();
+ OxydataWidget *oxyDW;
private:
- void createTableLayout();
OxydataTable *DataTable;
QComboBox *dataCombo;
- QLabel *left, *middle, *right;
private slots:
void slotShowData(int);
};