[Uml-devel] KDE/kdesdk/umbrello/umbrello/dialogs

Andi Fischer andi.fischer at hispeed.ch
Wed Aug 20 20:17:34 UTC 2008


SVN commit 850125 by fischer:

Replacing all q3 widgets.

 M  +66 -62    selectopdlg.cpp  
 M  +19 -19    selectopdlg.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/selectopdlg.cpp #850124:850125
@@ -1,11 +1,10 @@
 /***************************************************************************
- *                                                                         *
  *   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.                                   *
  *                                                                         *
- *   copyright (C) 2002-2006                                               *
+ *   copyright (C) 2002-2008                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -13,20 +12,24 @@
 #include "selectopdlg.h"
 
 // qt includes
-#include <QLayout>
-#include <QVBoxLayout>
-#include <QGridLayout>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QGridLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QRadioButton>
+#include <QtGui/QGroupBox>
 
 // kde includes
+#include <klineedit.h>
+#include <kcombobox.h>
 #include <klocale.h>
 #include <kdebug.h>
 
 // local includes
-#include "../attribute.h"
-#include "../operation.h"
-#include "../umlclassifierlistitemlist.h"
-#include "../umlview.h"
-#include "../dialog_utils.h"
+#include "attribute.h"
+#include "operation.h"
+#include "umlclassifierlistitemlist.h"
+#include "umlview.h"
+#include "dialog_utils.h"
 
 SelectOpDlg::SelectOpDlg(UMLView * parent, UMLClassifier * c)
         : KDialog( parent)
@@ -43,50 +46,44 @@
     m_pView = parent;
     QVBoxLayout * topLayout = new QVBoxLayout(frame);
 
-    m_pOpGB = new Q3GroupBox(i18n("Select Operation"), frame);
-    topLayout -> addWidget(m_pOpGB);
+    m_pOpGB = new QGroupBox(i18n("Select Operation"), frame);
+    topLayout->addWidget(m_pOpGB);
 
     QGridLayout * mainLayout = new QGridLayout(m_pOpGB);
-    mainLayout -> setSpacing(spacingHint());
-    mainLayout -> setMargin(fontMetrics().height());
+    mainLayout->setSpacing(spacingHint());
+    mainLayout->setMargin(fontMetrics().height());
 
     Dialog_Utils::makeLabeledEditField( m_pOpGB, mainLayout, 0,
                                     m_pSeqL, i18n("Sequence number:"),
                                     m_pSeqLE );
 
     m_pOpRB = new QRadioButton(i18n("Class operation:"), m_pOpGB);
-    mainLayout -> addWidget(m_pOpRB, 1, 0);
+    connect(m_pOpRB, SIGNAL(clicked()), this, SLOT(slotSelectedOp()));
+    mainLayout->addWidget(m_pOpRB, 1, 0);
 
     m_pOpCB = new KComboBox(m_pOpGB);
     m_pOpCB->setCompletionMode( KGlobalSettings::CompletionPopup );
-    m_pOpCB->setDuplicatesEnabled(false);//only allow one of each type in box
-    mainLayout -> addWidget(m_pOpCB, 1, 1);
+    m_pOpCB->setDuplicatesEnabled(false); // only allow one of each type in box
+    mainLayout->addWidget(m_pOpCB, 1, 1);
 
     m_pCustomRB = new QRadioButton(i18n("Custom operation:"), m_pOpGB);
-    mainLayout -> addWidget(m_pCustomRB, 2, 0);
+    connect(m_pCustomRB, SIGNAL(clicked()), this, SLOT(slotSelectedCustom()));
+    mainLayout->addWidget(m_pCustomRB, 2, 0);
 
     m_pOpLE = new KLineEdit(m_pOpGB);
-    mainLayout -> addWidget(m_pOpLE, 2, 1);
+    mainLayout->addWidget(m_pOpLE, 2, 1);
 
-    m_pOpBG = new Q3ButtonGroup(0);
-    m_pOpBG -> insert(m_pOpRB, OP);
-    m_pOpBG -> insert(m_pCustomRB, CUSTOM);
-    m_pOpBG -> setExclusive(true);
-    m_pOpBG -> setButton(OP);
-
-    UMLOperationList list = c -> getOpList(true);
+    UMLOperationList list = c->getOpList(true);
     foreach (UMLOperation* obj, list ) {
-        insertOperation( obj->toString(Uml::st_SigNoVis) );
+        insertOperation( obj->toString(Uml::st_SigNoVis), list.count() );
     }
-    //disableResize();
-    connect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
-    m_nOpCount = c -> operations();
-    slotSelected(OP);
+
+    m_nOpCount = c->operations();
+    m_pOpRB->click();
 }
 
-SelectOpDlg::~SelectOpDlg() {
-    disconnect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
-    delete m_pOpBG;
+SelectOpDlg::~SelectOpDlg()
+{
 }
 
 void SelectOpDlg::insertOperation( const QString& type, int index )
@@ -95,58 +92,65 @@
     m_pOpCB->completionObject()->addItem( type );
 }
 
-QString SelectOpDlg::getOpText() {
-    if(m_pOpRB -> isChecked())
-        return m_pOpCB -> currentText();
+QString SelectOpDlg::getOpText()
+{
+    if (m_pOpRB->isChecked())
+        return m_pOpCB->currentText();
     else
-        return m_pOpLE -> text();
+        return m_pOpLE->text();
 }
 
-bool SelectOpDlg::isClassOp() const {
+bool SelectOpDlg::isClassOp() const
+{
     return (m_id == OP);
 }
 
-void SelectOpDlg::slotSelected(int id) {
-    if(id == OP) {
-        m_pOpLE -> setEnabled(false);
-        if(m_nOpCount > 0)
-            m_pOpCB -> setEnabled(true);
-    } else {
-        m_pOpLE -> setEnabled(true);
-        m_pOpCB -> setEnabled(false);
+void SelectOpDlg::slotSelectedOp()
+{
+    m_pOpLE->setEnabled(false);
+    if (m_nOpCount > 0) {
+        m_pOpCB->setEnabled(true);
     }
-    m_id = id;
+    m_id = OP;
 }
 
-void SelectOpDlg::setCustomOp(const QString &op) {
-    m_pOpLE -> setText(op);
-    if(op.length() > 0) {
-        slotSelected(CUSTOM);
-        m_pCustomRB -> setChecked(true);
+void SelectOpDlg::slotSelectedCustom()
+{
+    m_pOpLE->setEnabled(true);
+    m_pOpCB->setEnabled(false);
+    m_id = CUSTOM;
+}
+
+void SelectOpDlg::setCustomOp(const QString &op)
+{
+    m_pOpLE->setText(op);
+    if (op.length() > 0) {
+        slotSelectedCustom();
+        m_pCustomRB->setChecked(true);
     }
 }
 
-bool SelectOpDlg::setClassOp(const QString &op) {
-    for (int i = 1; i!= m_pOpCB->count(); ++i)
-    {
+bool SelectOpDlg::setClassOp(const QString &op)
+{
+    for (int i = 1; i!= m_pOpCB->count(); ++i) {
         if ( m_pOpCB->itemText(i) == op ) {
             m_pOpCB->setCurrentIndex(i);
-            m_pCustomRB -> setChecked(false);
-            slotSelected(OP);
+            m_pCustomRB->setChecked(false);
+            slotSelectedOp();
             return true;
         }
     }
     return false;
 }
 
-QString SelectOpDlg::getSeqNumber() {
+QString SelectOpDlg::getSeqNumber()
+{
     return m_pSeqLE->text();
 }
 
-void SelectOpDlg::setSeqNumber(const QString &num) {
+void SelectOpDlg::setSeqNumber(const QString &num)
+{
     m_pSeqLE->setText(num);
 }
 
-
-
 #include "selectopdlg.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/selectopdlg.h #850124:850125
@@ -1,34 +1,27 @@
 /***************************************************************************
- *                                                                         *
  *   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.                                   *
  *                                                                         *
- *   copyright (C) 2002-2006                                               *
+ *   copyright (C) 2002-2008                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
-
 #ifndef SELECTOPDLG_H
 #define SELECTOPDLG_H
 
-#include <q3groupbox.h>
-#include <qradiobutton.h>
-#include <qlabel.h>
-#include <q3buttongroup.h>
+#include "classifier.h"
 
-#include <klineedit.h>
-#include <kcombobox.h>
 #include <kdialog.h>
 
-#include "../classifier.h"
-
 class UMLView;
+class KComboBox;
+class KLineEdit;
+class QGroupBox;
+class QLabel;
+class QRadioButton;
 
-#define OP     0
-#define CUSTOM  1
-
 /**
  * A dialog used to select an operation.
  *
@@ -90,6 +83,7 @@
      *  @param op The operation to set as the custom operation.
      */
     void setCustomOp(const QString &op);
+
     /**
      * Set the class operation text.
      *
@@ -97,24 +91,30 @@
      * @return false if no such operation exists.
      */
     bool setClassOp(const QString &op);
+
 protected:
     /**
-    * Inserts @p type into the type-combobox as well as its completion object.
-    */
+     * Inserts @p type into the type-combobox as well as its completion object.
+     */
     void insertOperation( const QString& type, int index = -1 );
+
 private:
-    Q3GroupBox * m_pOpGB;
+    static const int OP     = 0;
+    static const int CUSTOM = 1;
+
+    QGroupBox * m_pOpGB;
     KComboBox * m_pOpCB;
     QLabel * m_pSeqL;
     KLineEdit * m_pOpLE, * m_pSeqLE;
     QRadioButton * m_pCustomRB, * m_pOpRB;
-    Q3ButtonGroup * m_pOpBG, * m_pDocGB;
     QString m_Text;
     int m_nOpCount;
     int m_id;  ///< takes on the value OP or CUSTOM according to what the user selected
     UMLView *m_pView;
+
 public slots:
-    void slotSelected(int id);
+    void slotSelectedOp();
+    void slotSelectedCustom();
 };
 
 #endif




More information about the umbrello-devel mailing list