author | cniehaus <cniehaus> | 2002-09-20 21:45:30 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-20 21:45:30 (UTC) |
commit | d5db444cb70986baceda8ad1e01b0fb8384d12b4 (patch) (side-by-side diff) | |
tree | 65cab6b3cfb9c67336ce4f3e61d3e9df2476d8ca | |
parent | 20c93734a4eada53d056f13558cbf60d6eff5bac (diff) | |
download | opie-d5db444cb70986baceda8ad1e01b0fb8384d12b4.zip opie-d5db444cb70986baceda8ad1e01b0fb8384d12b4.tar.gz opie-d5db444cb70986baceda8ad1e01b0fb8384d12b4.tar.bz2 |
from now on I consider Oxygen as almost done :)
* the strange display-bug in the QTable is fixed. Now there are really only
two colums and not a million or so
* now the alingment is correct. I reimplemented virtual void alignment() in
a class derived from QTableItem
* s/setElement( 1 )/setElement( 0 )/ as that method starts with 0 and not 1
Credits to Robert Gogolok who did most of the reimplementation of the
alignment.
-rw-r--r-- | noncore/apps/oxygen/dataTable.cpp | 35 | ||||
-rw-r--r-- | noncore/apps/oxygen/dataTable.h | 23 | ||||
-rw-r--r-- | noncore/apps/oxygen/datawidgetui.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/oxygen/psewidget.cpp | 2 |
4 files changed, 42 insertions, 20 deletions
diff --git a/noncore/apps/oxygen/dataTable.cpp b/noncore/apps/oxygen/dataTable.cpp index ff01417..f034c45 100644 --- a/noncore/apps/oxygen/dataTable.cpp +++ b/noncore/apps/oxygen/dataTable.cpp @@ -50,73 +50,92 @@ OxydataWidget::OxydataWidget(QWidget *parent) : QWidget(parent) qgrid->addWidget( DataTable,1,0 ); } void OxydataWidget::setElement( int el ) { Config configobj( "oxygendata" ); configobj.setGroup( QString::number( el+1 )); left->setText( configobj.readEntry( "Symbol" ) ); middle->setText( configobj.readEntry( "Name" ) ); right->setText( QString::number( el+1 ) ); + DataTable->setText( 0,1,configobj.readEntry( "Weight" ) ); DataTable->setText( 1,1,configobj.readEntry( "Block" ) ); DataTable->setText( 2,1,configobj.readEntry( "Group" ) ); DataTable->setText( 3,1,configobj.readEntry( "EN" ) ); DataTable->setText( 4,1,configobj.readEntry( "AR" ) ) ; DataTable->setText( 5,1,configobj.readEntry( "IE" ) ); DataTable->setText( 6,1,configobj.readEntry( "Density" ) ); DataTable->setText( 7,1,configobj.readEntry( "BP" ) ); DataTable->setText( 8,1,configobj.readEntry( "MP" ) ); + } void OxydataWidget::setTable() const { 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) + const char *name) : QTable(numRows, numCols,parent, name) { + + for (int zeile = 0; zeile < numRows; zeile++) + for ( int spalte = 0; spalte < numCols; spalte++ ) + { + OxydataQTI *testus = new OxydataQTI (this, OxydataQTI::Never, "hm" ); + setItem(zeile, spalte, (QTableItem*)testus); + } + + this->setShowGrid( false ); this->setHScrollBarMode(QScrollView::AlwaysOff); this->horizontalHeader()->hide(); this->verticalHeader()->hide(); this->setTopMargin( 0 ); this->setLeftMargin( 0 ); } -int OxydataTable::alignment() const -{ - return AlignLeft | AlignVCenter; -}; - - - void OxydataTable::paintCell( QPainter *p, int row, int col, const QRect &cr, bool selected) { if ( cr.width() == 0 || cr.height() == 0 ) return; selected = FALSE; QTableItem *itm = item( row, col ); QColorGroup colgrp = colorGroup(); if ( itm ) { if ( row%2 ) colgrp.setColor( QColorGroup::Base, QColor( 180,200,210 ) ); else colgrp.setColor( QColorGroup::Base, QColor( 230,235,235 ) ); p->save(); itm->paint( p, colgrp, cr, selected ); p->restore(); } } + +OxydataQTI::OxydataQTI(QTable * table, EditType et, const QString & text ) + : QTableItem ( table, et, text ) +{ +} + +int OxydataQTI::alignment() const +{ + if ( col()%2 ) + { + return AlignRight | AlignVCenter; + }else return AlignLeft | AlignVCenter; +}; + diff --git a/noncore/apps/oxygen/dataTable.h b/noncore/apps/oxygen/dataTable.h index 00063d4..a4a3b18 100644 --- a/noncore/apps/oxygen/dataTable.h +++ b/noncore/apps/oxygen/dataTable.h @@ -7,25 +7,24 @@ * ( at your option ) any later version. * * * **************************************************************************/ #ifndef _DATATABLE_H #define _DATATABLE_H #include <qwidget.h> #include <qtable.h> class QLabel; class OxydataTable; -class QTableItem; /* * A OxydataWidget shows all known data of an element. It can * be used for both the PSE and the pure Data-Dialog. It is * a simple QHBox with 2 QStrings in it plus a OxydataTable * which contains the rest of the data. * * Author: Carsten Niehaus <cniehaus@handhelds.org> */ class OxydataWidget : public QWidget { @@ -51,31 +50,35 @@ class OxydataWidget : public QWidget * * Author: Carsten Niehaus <cniehaus@handhelds.org> */ class OxydataTable : public QTable { Q_OBJECT public: OxydataTable( int numRows, int numCols, QWidget *parent = 0, const char *name = 0 ); - virtual int alignment() const; -// virtual QTableItem *item( int row, int col ) const; - protected: /* * 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 ); }; +/* + * A OxydataQTI is a QTableItem which has the ability to set an alignment. + * In Oxygen we only have two colums so I can use the simple col()%2. + * + * Author: Robert Gogolok <robertgogolok@gmx.de> + */ -//X class OxydataQTI : QTableItem -//X { -//X Q_OBJECT -//X -//X public: -//X OxydataQTI( +class OxydataQTI : public QTableItem +{ + public: + OxydataQTI(QTable * table, EditType et, const QString & text ); + + virtual int alignment() const; +}; #endif diff --git a/noncore/apps/oxygen/datawidgetui.cpp b/noncore/apps/oxygen/datawidgetui.cpp index 4dab109..422b6f8 100644 --- a/noncore/apps/oxygen/datawidgetui.cpp +++ b/noncore/apps/oxygen/datawidgetui.cpp @@ -34,18 +34,18 @@ dataWidgetUI::dataWidgetUI() : QWidget() //read in all names of the 118 elements Config configobj( "oxygendata" ); for ( int i = 1 ; i < 119 ; i++ ) { configobj.setGroup( QString::number( i ) ); QString foo = configobj.readEntry( "Name" ); dataCombo->insertItem( foo ); } OxydataWidget *oxyDW = new OxydataWidget(this); connect ( dataCombo, SIGNAL( activated(int) ), oxyDW, SLOT( setElement(int) ) ); - oxyDW->setElement( 1 ); + oxyDW->setElement( 0 ); qgrid->addWidget( dataCombo, 0,0); qgrid->addWidget( oxyDW , 1,0 ); } diff --git a/noncore/apps/oxygen/psewidget.cpp b/noncore/apps/oxygen/psewidget.cpp index a3bb505..449afef 100644 --- a/noncore/apps/oxygen/psewidget.cpp +++ b/noncore/apps/oxygen/psewidget.cpp @@ -38,25 +38,25 @@ PSEWidget::PSEWidget() : QWidget() configobj.setGroup( QString::number( n+1 )); position( n+1,h,v ); QList<OxyFrame> PSEframe; PSEframe.append( new OxyFrame( this , QString::number(n) ) ); grid->addWidget( PSEframe.current() , v/40+1 , h/40 ); PSEframe.current()->setMinimumHeight( 11 ); PSEframe.current()->setPalette( QPalette( PSEColor( configobj.readEntry( "Block" ) ) ) ); connect( PSEframe.current(), SIGNAL( num(QString) ), this, SLOT( slotShowElement(QString) )); } oxyDW = new OxydataWidget(this); - oxyDW->setElement( 1 ); + oxyDW->setElement( 0 ); vlay->addLayout( grid ); vlay->addWidget( oxyDW ); } QColor PSEWidget::PSEColor( QString block ) { QColor c; if ( block == "s" ) c.setRgb( 213 , 233 , 231 ); else if ( block == "d" ) c.setRgb( 200,230,160 ); else if ( block == "p" ) c.setRgb( 238,146,138 ); else if ( block == "f" ) c.setRgb( 190 , 190 , 190 ); |