From: Pino Toscano Date: Fri, 12 May 2006 13:04:18 +0000 (+0000) Subject: a public inheritance on a ui4 generated file is a bad thing for a class in a public... X-Git-Tag: v3.80.2~85 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=d0d2746f4b8b6e9a203362a4455babb0f5258f0a;p=libqmvoc.git a public inheritance on a ui4 generated file is a bad thing for a class in a public library; add init() c'tor svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=540047 --- diff --git a/kdeeducore/prefleitner.cpp b/kdeeducore/prefleitner.cpp index 3473c1b..3be0378 100644 --- a/kdeeducore/prefleitner.cpp +++ b/kdeeducore/prefleitner.cpp @@ -20,6 +20,7 @@ #include "leitnersystemview.h" #include "leitnersystem.h" +#include "ui_prefleitnerbase.h" #include #include @@ -31,24 +32,23 @@ PrefLeitner::PrefLeitner( QWidget* parent ) : QDialog( parent ) { - setupUi( this ); - - m_selectedSystem = 0; - m_selectedBox = 0; - - QScrollArea *helperSV = new QScrollArea( this ); + init( 0L ); +} - m_leitnerSystemView = new LeitnerSystemView( helperSV->viewport() ); - m_leitnerSystemView->setObjectName( "LeitnerSystemView" ); - - helperSV->setWidget( m_leitnerSystemView ); +PrefLeitner::PrefLeitner( QWidget* parent, LeitnerSystem* system ) : QDialog( parent ) +{ + init( system ); +} - connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) ); +PrefLeitner::~PrefLeitner() +{ + delete m_base; } -PrefLeitner::PrefLeitner( QWidget* parent, LeitnerSystem* system ) : QDialog( parent ) +void PrefLeitner::init( LeitnerSystem* system ) { - setupUi( this ); + m_base = new Ui::PrefLeitnerBase(); + m_base->setupUi( this ); m_selectedBox = 0; @@ -61,14 +61,17 @@ PrefLeitner::PrefLeitner( QWidget* parent, LeitnerSystem* system ) : QDialog( pa connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) ); - m_selectedSystem = system; - - //insert the list of box' names in the comboboxes - cmbWrong->addItems( m_selectedSystem->getBoxNameList() ); - cmbCorrect->addItems( m_selectedSystem->getBoxNameList() ); + m_selectedSystem = system; - //show leitnersystem - m_leitnerSystemView->setSystem( m_selectedSystem ); + if ( m_selectedSystem ) + { + //insert the list of box' names in the comboboxes + m_base->cmbWrong->addItems( m_selectedSystem->getBoxNameList() ); + m_base->cmbCorrect->addItems( m_selectedSystem->getBoxNameList() ); + + //show leitnersystem + m_leitnerSystemView->setSystem( m_selectedSystem ); + } } void PrefLeitner::slotCorrectWord( const QString& newBox ) @@ -102,8 +105,8 @@ void PrefLeitner::slotBoxName( const QString& newName ) void PrefLeitner::newSystem() { - cmbCorrect->addItems( m_selectedSystem->getBoxNameList() ); - cmbWrong->addItems( m_selectedSystem->getBoxNameList() ); + m_base->cmbCorrect->addItems( m_selectedSystem->getBoxNameList() ); + m_base->cmbWrong->addItems( m_selectedSystem->getBoxNameList() ); refreshSystemView(); } @@ -117,9 +120,9 @@ void PrefLeitner::slotBoxClicked( int box ) { m_selectedBox = m_selectedSystem->boxWithNumber( box ); - cmbCorrect->setCurrentIndex( m_selectedSystem->correctBoxNumber( box ) ); - cmbWrong->setCurrentIndex( m_selectedSystem->wrongBoxNumber( box ) ); - lndBoxName->setText( m_selectedBox->boxName() ); + m_base->cmbCorrect->setCurrentIndex( m_selectedSystem->correctBoxNumber( box ) ); + m_base->cmbWrong->setCurrentIndex( m_selectedSystem->wrongBoxNumber( box ) ); + m_base->lndBoxName->setText( m_selectedBox->boxName() ); } void PrefLeitner::slotAddBox() diff --git a/kdeeducore/prefleitner.h b/kdeeducore/prefleitner.h index 0a5b078..9f04378 100644 --- a/kdeeducore/prefleitner.h +++ b/kdeeducore/prefleitner.h @@ -23,17 +23,21 @@ #include -#include "ui_prefleitnerbase.h" +#include class LeitnerSystemView; class LeitnerSystem; class LeitnerBox; +namespace Ui +{ + class PrefLeitnerBase; +} /** * This class is a dialog for configuring a LeitnerSystem * @author Martin Pfeiffer */ -class EDUCORE_EXPORT PrefLeitner : public QDialog, public Ui::PrefLeitnerBase +class EDUCORE_EXPORT PrefLeitner : public QDialog { Q_OBJECT @@ -51,6 +55,11 @@ public: */ PrefLeitner( QWidget* parent = 0 , LeitnerSystem* system = 0 ); + /** + * The public destructor + */ + ~PrefLeitner(); + /** * Sets the LeitnerSystem for the dialog * @param system a pointer to the LeitnerSystem to configure @@ -82,6 +91,10 @@ private: LeitnerSystem* m_selectedSystem; //the currently selected system to be changed LeitnerBox* m_selectedBox; //the currently selected box + Ui::PrefLeitnerBase* m_base; + + void init( LeitnerSystem* system ); + void refreshSystemView(); //refresh the LeitnerSystemView void newSystem(); };