#include "leitnersystemview.h"
#include "leitnersystem.h"
+#include "ui_prefleitnerbase.h"
#include <QLayout>
#include <QComboBox>
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;
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 )
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();
}
{
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()
#include <libkdeedu_core_export.h>
-#include "ui_prefleitnerbase.h"
+#include <QDialog>
class LeitnerSystemView;
class LeitnerSystem;
class LeitnerBox;
+namespace Ui
+{
+ class PrefLeitnerBase;
+}
/**
* This class is a dialog for configuring a LeitnerSystem
* @author Martin Pfeiffer <hubipete@gmx.net>
*/
-class EDUCORE_EXPORT PrefLeitner : public QDialog, public Ui::PrefLeitnerBase
+class EDUCORE_EXPORT PrefLeitner : public QDialog
{
Q_OBJECT
*/
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
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();
};