]> Git trees. - libqmvoc.git/commitdiff
port to QScrollArea, some APIDOX
authorMartin Pfeiffer <hubipete@gmx.net>
Thu, 3 Nov 2005 21:32:51 +0000 (21:32 +0000)
committerMartin Pfeiffer <hubipete@gmx.net>
Thu, 3 Nov 2005 21:32:51 +0000 (21:32 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=477353

kdeeducore/leitnersystemview.cpp
kdeeducore/leitnersystemview.h
kdeeducore/prefleitner.cpp
kdeeducore/prefleitner.h

index 42658a8afde4109b849bbe7a1b7e38058b993670..a2865bc0856293fa2924b57340def69d825066df 100644 (file)
 
 #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;
 }
@@ -33,7 +32,7 @@ LeitnerSystemView::~LeitnerSystemView()
 {
 }
 
-void LeitnerSystemView::drawSystem(QPainter* p)
+void LeitnerSystemView::drawSystem( QPainter* p )
 {
        m_imageY = height() / 2 - 32;
 
@@ -110,28 +109,29 @@ void LeitnerSystemView::drawConnections(QPainter* p)
        }
 }
 
-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()
@@ -178,7 +178,7 @@ 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 );
 }
 
@@ -186,7 +186,7 @@ void LeitnerSystemView::mousePressEvent(QMouseEvent* e)
 {
        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;
 
@@ -196,7 +196,7 @@ void LeitnerSystemView::mousePressEvent(QMouseEvent* e)
                        emit boxClicked( d );
                        m_highlightedBox = d;
 
-                       updateContents();
+                       update();
                }
        }
 }
index 5642b02f94216ab3cc3e13bae65919a9ddeb9be0..99ab626bc71fd1b54396efa61ef274105b2d7c47 100644 (file)
 #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
index 839366afee42046da2141d88b13290b1e4011ca2..bb7226a7d2964e1deef57ce9ba76470ea0174a5a 100644 (file)
 #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() );
@@ -119,7 +141,7 @@ void PrefLeitner::slotDiscard()
        close();
 }
 
-LeitnerSystem* PrefLeitner::getSystem()
+LeitnerSystem* PrefLeitner::system()
 {
        return m_selectedSystem;
 }
index 4a3acb713be9f6610c2a307ccbebfdd290ba5ea7..b942c2191c53e49fc5fc62224f52940d95b05f39 100644 (file)
@@ -1,17 +1,26 @@
-//
-// 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;
@@ -19,16 +28,36 @@ class LeitnerSystem;
 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 );
@@ -40,8 +69,10 @@ public slots:
        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
@@ -51,4 +82,4 @@ private:
        void newSystem();
 };
 
-#endif
+#endif //PREFLEITNER_H