summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -9,3 +9,74 @@
+#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" ) );
+}
@@ -14,2 +85,8 @@ OxydataTable::OxydataTable(int numRows, int numCols, QWidget *parent,
{
+ this->setShowGrid( false );
+ this->setHScrollBarMode(QScrollView::AlwaysOff);
+ this->horizontalHeader()->hide();
+ this->verticalHeader()->hide();
+ this->setTopMargin( 0 );
+ this->setLeftMargin( 0 );
}
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
@@ -13,4 +13,33 @@
+#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
@@ -28,3 +57,3 @@ class OxydataTable : public QTable
*/
- 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 );
};
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
@@ -9,5 +9,5 @@
#include "oxygen.h"
+#include "datawidgetui.h"
#include <qpe/config.h>
-#include "datawidgetui.h"
#include <qstring.h>
@@ -23,22 +23,11 @@ dataWidgetUI::dataWidgetUI() : QDialog()
- 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 );
@@ -52,24 +41,4 @@ dataWidgetUI::dataWidgetUI() : QDialog()
}
-
- 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" ) );
-}
@@ -77,32 +46,3 @@ void dataWidgetUI::createTableLayout(){
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
@@ -12,5 +12,3 @@
-class QTable;
class QComboBox;
-class QLabel;
@@ -22,8 +20,7 @@ class dataWidgetUI : public QDialog
dataWidgetUI();
+ OxydataWidget *oxyDW;
private:
- void createTableLayout();
OxydataTable *DataTable;
QComboBox *dataCombo;
- QLabel *left, *middle, *right;