#include <stdlib.h>
#include <kiconloader.h>
-#include <qpainter.h>
+#include <QPainter>
//Added by qt3to4:
#include <QMouseEvent>
#include <kdebug.h>
-LeitnerSystemView::LeitnerSystemView(QWidget * parent, const char* name, Qt::WFlags f)
- : Q3ScrollView(parent, name, f)
+LeitnerSystemView::LeitnerSystemView( QWidget* parent ) : QWidget( parent )
{
m_highlightedBox = -1;
}
{
}
-void LeitnerSystemView::drawSystem(QPainter* p)
+void LeitnerSystemView::drawSystem( QPainter* p )
{
m_imageY = height() / 2 - 32;
}
}
-void LeitnerSystemView::setSystem(LeitnerSystem* leitnersystem)
+void LeitnerSystemView::setSystem( LeitnerSystem* leitnersystem )
{
m_leitnerSystem = leitnersystem;
//calculate the new sizes
calculateSize();
- updateContents();
+ update();
}
void LeitnerSystemView::highlightBox(int box)
{
m_highlightedBox = box;
- updateContents();
+ update();
}
-void LeitnerSystemView::drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph)
+void LeitnerSystemView::paintEvent( QPaintEvent* )
{
- p->eraseRect(0,0,width(),height());
+ QPainter p( this );
+ p.eraseRect( 0, 0, width(), height() );
- drawSystem( p );
+ drawSystem( &p );
- drawConnections( p );
+ drawConnections( &p );
}
void LeitnerSystemView::calculateSize()
height += 24+64;
- resizeContents( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
+// resizeContents( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
setMinimumSize( numberOfBoxes * 64 + (numberOfBoxes - 1)*10 + 2 * 12, height );
}
{
kdDebug() << "mouseClick" << endl;
//if the user has clicked into a box
- if( e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < contentsWidth() )
+ if( e->y() > m_imageY && e->y() < m_imageY + 64 && e->x() < width() )
{
int d = (e->x()-12)/74;
emit boxClicked( d );
m_highlightedBox = d;
- updateContents();
+ update();
}
}
}
#ifndef LEITNERSYSTEMVIEW_H
#define LEITNERSYSTEMVIEW_H
-#include <q3scrollview.h>
-#include <qpixmap.h>
-//Added by qt3to4:
+#include <QWidget>
+#include <QPixmap>
#include <QMouseEvent>
class LeitnerSystem;
/**
-@author Martin Pfeiffer
-*/
+ * This class displays a given LeitnerSystem on a QWidget
+ * It is used to configurate a LeitnerSystem and easily remove
+ * and add boxes within a GUI.
+ * @author Martin Pfeiffer
+ */
-class LeitnerSystemView : public Q3ScrollView
+class LeitnerSystemView : public QWidget
{
Q_OBJECT
public:
- LeitnerSystemView(QWidget* parent = 0, const char* name = 0, Qt::WFlags f = 0);
+ /**
+ * The public constructor
+ * @param parent the QWidget that is the parent widget
+ */
+ LeitnerSystemView( QWidget* parent = 0 );
- ~LeitnerSystemView();
+ ~LeitnerSystemView();
- void setSystem(LeitnerSystem* system); //set a new system to view on
- void highlightBox(int box); //highlight a box
+ /**
+ * Sets the LeitnerSystem to be displayed in the LeitnerSystemView
+ * @param system the LeitnerSystem to be displayed
+ */
+ void setSystem( LeitnerSystem* system );
+ /**
+ * Highlight a special box to indicate that this one is selected
+ * @param box the number of the box to be highlighted
+ */
+ void highlightBox( int box );
+
signals:
void boxClicked(int box); //is emited if the user clicks on a box
protected:
- virtual void drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph);
- virtual void mousePressEvent(QMouseEvent* e);
+ virtual void paintEvent( QPaintEvent* );
+// virtual void drawContents(QPainter* p, int clipx, int clipy, int clipw, int cliph);
+ virtual void mousePressEvent(QMouseEvent* e);
private:
LeitnerSystem* m_leitnerSystem; //the system which is shown
void drawSystem(QPainter*); //paints the boxes
- void drawConnections(QPainter*); //paints the arrows between the boxes
+ void drawConnections(QPainter*); //paints the arrows between the boxes
void calculateSize();
int m_imageY; //high border of the images
#include "leitnersystemview.h"
#include "leitnersystem.h"
-#include <qlayout.h>
-#include <qcombobox.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
+#include <QLayout>
+#include <QComboBox>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QScrollArea>
#include <kdebug.h>
-PrefLeitner::PrefLeitner(QWidget * parent, LeitnerSystem* system) : QDialog(parent)
+PrefLeitner::PrefLeitner( QWidget* parent ) : QDialog( parent )
{
- setupUi(this);
- m_selectedSystem = system;
+ setupUi( this );
+
+ m_selectedSystem = 0;
m_selectedBox = 0;
- //create new leitnersystemview, show and connect it
- m_leitnerSystemView = new LeitnerSystemView( this, 0 );
- ///@todo port PrefLeitnerBaseLayout->addWidget( m_leitnerSystemView, 1, 0 );
- ///@todo port PrefLeitnerBaseLayout->setOrigin( Qt::BottomLeftCorner );
+ QScrollArea *helperSV = new QScrollArea( this );
+
+ m_leitnerSystemView = new LeitnerSystemView( helperSV->viewport() );
+ m_leitnerSystemView->setObjectName( "LeitnerSystemView" );
+
+ helperSV->setWidget( m_leitnerSystemView );
connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) );
+}
+
+PrefLeitner::PrefLeitner( QWidget* parent, LeitnerSystem* system ) : QDialog( parent )
+{
+ setupUi( this );
+
+ m_selectedBox = 0;
+
+ QScrollArea *helperSV = new QScrollArea( this );
+ m_leitnerSystemView = new LeitnerSystemView( helperSV->viewport() );
+ m_leitnerSystemView->setObjectName( "LeitnerSystemView" );
+
+ helperSV->setWidget( m_leitnerSystemView );
+
+ connect( m_leitnerSystemView, SIGNAL( boxClicked( int ) ), this, SLOT( slotBoxClicked( int ) ) );
+
+ m_selectedSystem = system;
+
//insert the list of box' names in the comboboxes
cmbWrong->insertStringList( m_selectedSystem->getBoxNameList() );
cmbCorrect->insertStringList( m_selectedSystem->getBoxNameList() );
close();
}
-LeitnerSystem* PrefLeitner::getSystem()
+LeitnerSystem* PrefLeitner::system()
{
return m_selectedSystem;
}
-//
-// C++ Interface: prefleitner
-//
-// Description: the part of the preferences to change the settings for the LeitnerSystem
-//
-//
-// Author: Martin Pfeiffer <martin-pfeiffer-bensheim@web.de>, (C) 2005
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
#ifndef PREFLEITNER_H
#define PREFLEITNER_H
+/***************************************************************************
+ * Copyright (C) 2005 by Martin Pfeiffer *
+ * hubipete@gmx.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ **************************************************************************/
+
#include "prefleitnerbase.h"
class LeitnerSystemView;
class LeitnerBox;
/**
-@author Martin Pfeiffer
-*/
+ * This class is a dialogue for configuring a LeitnerSystem
+ * @author Martin Pfeiffer <hubipete@gmx.net>
+ */
class PrefLeitner : public QDialog, public Ui::PrefLeitnerBase
{
Q_OBJECT
public:
- PrefLeitner(QWidget * parent, LeitnerSystem* system);
+ /**
+ * The public contructor
+ */
+ PrefLeitner( QWidget* parent = 0 );
+
+ /**
+ * The public contructur which sets also the LeitnerSystem
+ * @param system a pointer to the LeitnerSystem to configure
+ */
+ PrefLeitner( QWidget* parent = 0 , LeitnerSystem* system = 0 );
- LeitnerSystem* getSystem();
+ /**
+ * Sets the LeitnerSystem for the dialogue
+ * @param system a pointer to the LeitnerSystem to configure
+ */
+ void setLeitnerSystem( LeitnerSystem* system );
+
+ /**
+ * Get the LeitnerSystem that is set to the dialogue
+ * @return a pointer to the actual set LeitnerSystem
+ */
+ LeitnerSystem* system();
public slots:
void slotCorrectWord( const QString& newBox );
void slotApply();
private slots:
- void slotBoxClicked(int); //catches the signal from the view if user clicks on box
-
+ /**
+ * catches the signal from the view if user clicks on a box
+ */
+ void slotBoxClicked( int );
private:
LeitnerSystemView* m_leitnerSystemView; //the LeitnerSystemView which shows the selected system
LeitnerSystem* m_selectedSystem; //the currently selected system to be changed
void newSystem();
};
-#endif
+#endif //PREFLEITNER_H