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

Andi Fischer andi.fischer at hispeed.ch
Sun Aug 17 08:46:40 UTC 2008


SVN commit 848176 by fischer:

Replacing all q3 widgets.

 M  +123 -120  dialogs/diagramprintpage.cpp  
 M  +18 -18    dialogs/diagramprintpage.h  
 M  +2 -1      umlnamespace.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/diagramprintpage.cpp #848175:848176
@@ -1,5 +1,4 @@
 /***************************************************************************
- *                                                                         *
  *   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     *
@@ -12,119 +11,111 @@
 // own header
 #include "diagramprintpage.h"
 
-// qt/kde includes
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QLayout>
-#include <q3listbox.h>
-#include <QtGui/QRadioButton>
-#include <q3buttongroup.h>
-#include <q3groupbox.h>
+// local includes
+#include "uml.h"
+#include "umldoc.h"
+#include "umlview.h"
+#include "umlviewlist.h"
+#include "umlnamespace.h"
+#include "model_utils.h"
 
+// kde includes
 #include <kcombobox.h>
+#include <kdebug.h>
 #include <klocale.h>
 
-// local includes
-#include "../uml.h"
-#include "../umldoc.h"
-#include "../umlview.h"
-#include "../umlviewlist.h"
-#include "../umlnamespace.h"
-#include "../model_utils.h"
+// qt includes
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QListWidget>
+#include <QtGui/QRadioButton>
+#include <QtGui/QGroupBox>
 
-DiagramPrintPage::DiagramPrintPage(QWidget * parent, UMLDoc * m_pDoc) : QWidget(parent), m_pDoc(m_pDoc) {
+DiagramPrintPage::DiagramPrintPage(QWidget * parent, UMLDoc * m_pDoc) : QWidget(parent), m_pDoc(m_pDoc)
+{
     int margin = fontMetrics().height();
     setWindowTitle(i18n("&Diagrams"));
     QHBoxLayout * mainLayout = new QHBoxLayout(this);
-    mainLayout -> setSpacing(10);
-    mainLayout -> setMargin(margin);
+    mainLayout->setSpacing(10);
+    mainLayout->setMargin(margin);
 
-    m_pFilterBG = new Q3ButtonGroup(i18n("Filter"), this);
-    mainLayout -> addWidget(m_pFilterBG);
-    m_pFilterBG -> setExclusive(true);
+    m_pFilterGB = new QGroupBox(i18n("Filter"), this);
+    mainLayout->addWidget(m_pFilterGB);
 
-    QVBoxLayout * filter = new QVBoxLayout(m_pFilterBG);
-    filter -> setSpacing(10);
-    filter-> setMargin(margin);
+    QVBoxLayout * filter = new QVBoxLayout(m_pFilterGB);
+    filter->setSpacing(10);
+    filter->setMargin(margin);
 
-    m_pCurrentRB = new QRadioButton(i18n("&Current diagram"), m_pFilterBG);
-    filter -> addWidget(m_pCurrentRB);
-    m_pCurrentRB -> setChecked(true);
-    m_pFilterBG -> insert(m_pCurrentRB, Current);
+    m_pCurrentRB = new QRadioButton(i18n("&Current diagram"), m_pFilterGB);
+    filter->addWidget(m_pCurrentRB);
+    m_pCurrentRB->setChecked(true);
 
-    m_pAllRB = new QRadioButton(i18n("&All diagrams"), m_pFilterBG);
-    filter -> addWidget(m_pAllRB);
-    m_pFilterBG -> insert(m_pAllRB, All);
+    m_pAllRB = new QRadioButton(i18n("&All diagrams"), m_pFilterGB);
+    filter->addWidget(m_pAllRB);
 
-    m_pSelectRB = new QRadioButton(i18n("&Select diagrams"), m_pFilterBG);
-    filter -> addWidget(m_pSelectRB);
-    m_pFilterBG -> insert(m_pSelectRB, Select);
+    m_pSelectRB = new QRadioButton(i18n("&Select diagrams"), m_pFilterGB);
+    filter->addWidget(m_pSelectRB);
 
-    m_pTypeRB = new QRadioButton(i18n("&Type of diagram"), m_pFilterBG);
-    filter -> addWidget(m_pTypeRB);
-    m_pFilterBG -> insert(m_pTypeRB, Type);
+    m_pTypeRB = new QRadioButton(i18n("&Type of diagram"), m_pFilterGB);
+    filter->addWidget(m_pTypeRB);
 
-    m_pSelectGB = new Q3GroupBox(i18nc("diagram selection for printing", "Selection"), this);
-    mainLayout -> addWidget(m_pSelectGB);
+    m_pSelectGB = new QGroupBox(i18nc("diagram selection for printing", "Selection"), this);
+    mainLayout->addWidget(m_pSelectGB);
 
     QVBoxLayout * select = new QVBoxLayout(m_pSelectGB);
-    select -> setSpacing(10);
-    select-> setMargin(margin);
+    select->setSpacing(10);
+    select->setMargin(margin);
 
     m_pTypeCB = new KComboBox(m_pSelectGB);
-    select -> addWidget(m_pTypeCB);
-    m_pTypeCB -> setEnabled(false);
+    select->addWidget(m_pTypeCB);
+    m_pTypeCB->setEnabled(false);
 
-    m_pSelectLB = new Q3ListBox(m_pSelectGB);
-    select -> addWidget(m_pSelectLB);
-    m_pSelectLB -> setEnabled(false);
-    m_pSelectLB -> setSelectionMode(Q3ListBox::Multi);
-    m_pSelectLB -> insertItem(UMLApp::app()->getCurrentView()->getName());
-    m_pSelectLB -> setSelected(0, true);
+    m_pSelectLW = new QListWidget(m_pSelectGB);
+    select->addWidget(m_pSelectLW);
+    m_pSelectLW->setEnabled(false);
+    m_pSelectLW->setSelectionMode(QAbstractItemView::MultiSelection);
+    m_pSelectLW->addItem(UMLApp::app()->getCurrentView()->getName());
+    m_pSelectLW->setCurrentRow(0);
     m_nIdList.clear();
     m_nIdList.append(UMLApp::app()->getCurrentView()->getID());
 
+    m_ViewType = Uml::dt_Class;
+    connect(m_pAllRB, SIGNAL(clicked()), this, SLOT(slotClicked()));
+    connect(m_pCurrentRB, SIGNAL(clicked()), this, SLOT(slotClicked()));
+    connect(m_pSelectRB, SIGNAL(clicked()), this, SLOT(slotClicked()));
+    connect(m_pTypeRB, SIGNAL(clicked()), this, SLOT(slotClicked()));
 
-
-    m_ViewType = Uml::dt_Class;
-    connect(m_pFilterBG, SIGNAL(clicked(int)), this, SLOT(slotClicked(int)));
     connect(m_pTypeCB, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
 
     QStringList types;
     // diagramNo 1 is Uml::dt_Class
     // digaramNo 9 is Uml::dt_EntityRelationship
-    for (int diagramNo=1; diagramNo < 10; diagramNo++) {
-        types<< Model_Utils::diagramTypeToString( ( Uml::Diagram_Type )diagramNo ) ;
+    for (int diagramNo = 1; diagramNo < Uml::N_DIAGRAMTYPES; diagramNo++) {
+        types << Model_Utils::diagramTypeToString( ( Uml::Diagram_Type )diagramNo ) ;
     }
 
-    m_pTypeCB -> insertItems(0, types);
+    m_pTypeCB->insertItems(0, types);
 }
 
 DiagramPrintPage::~DiagramPrintPage()
 {
 }
 
-int DiagramPrintPage::printUmlCount() {
-    int listCount = m_pSelectLB -> count();
-    int count = 0;
-
-    for(int     i=0;i<listCount;i++) {
-        if(m_pSelectLB -> isSelected(i)) {
-            count++;
-        }
-    }
-    return count;
+int DiagramPrintPage::printUmlCount()
+{
+    QList<QListWidgetItem *> selectedItems = m_pSelectLW->selectedItems();
+    return selectedItems.count();
 }
 
-QString DiagramPrintPage::printUmlDiagram(int sel){
-    int listCount = m_pSelectLB -> count();
+QString DiagramPrintPage::printUmlDiagram(int sel)
+{
     int count = 0;
 
-    for(int i = 0; i < listCount; i++) {
-        if(m_pSelectLB -> isSelected(i)) {
-            if(count==sel) {
-                UMLView *view = (UMLView *)m_pDoc -> findView(m_nIdList[i]);
-                QString sID = QString("%1").arg(ID2STR(view -> getID()));
+    for (int i = 0; i < m_pSelectLW->count(); i++) {
+        if (isSelected(i)) {
+            if (count == sel) {
+                UMLView *view = (UMLView *)m_pDoc->findView(m_nIdList[i]);
+                QString sID = QString("%1").arg(ID2STR(view->getID()));
                 return sID;
             }
             count++;
@@ -133,11 +124,12 @@
     return QString();
 }
 
-bool DiagramPrintPage::isValid( QString& msg ) {
-    int listCount = m_pSelectLB -> count();
+bool DiagramPrintPage::isValid( QString& msg )
+{
+    int listCount = m_pSelectLW->count();
     bool sel = false;
-    for(int i =0;i<listCount;i++) {
-        if(m_pSelectLB -> isSelected(i)) {
+    for(int i = 0; i < listCount; i++) {
+        if (isSelected(i)) {
             sel = true;
             i = listCount;
         }
@@ -146,77 +138,88 @@
     return sel;
 }
 
-void DiagramPrintPage::slotClicked(int id) {
-    UMLViewList list = m_pDoc -> getViewIterator();
+bool DiagramPrintPage::isSelected(int index)
+{
+    QList<QListWidgetItem *> selectedItems = m_pSelectLW->selectedItems();
+    QListWidgetItem* itemAtIndex = m_pSelectLW->item(index);
+    if (selectedItems.contains(itemAtIndex)) {
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+void DiagramPrintPage::slotClicked()
+{
+    UMLViewList list = m_pDoc->getViewIterator();
     QString type;
 
     // clear list with diagrams to print
     m_nIdList.clear();
 
-    switch(id) {
-    case Current:
-        m_pTypeCB -> setEnabled(false);
-        m_pSelectLB -> setEnabled(false);
-        m_pSelectLB -> clear();
-        m_pSelectLB -> insertItem(UMLApp::app()->getCurrentView()->getName());
-        m_pSelectLB -> setSelected(0, true);
+    if (m_pCurrentRB->isChecked()) {
+        m_pTypeCB->setEnabled(false);
+        m_pSelectLW->setEnabled(false);
+        m_pSelectLW->clear();
+        m_pSelectLW->addItem(UMLApp::app()->getCurrentView()->getName());
+        m_pSelectLW->setCurrentRow(0);
         m_nIdList.append(UMLApp::app()->getCurrentView()->getID());
-        break;
+    }
 
-    case All:
-
-        m_pTypeCB -> setEnabled(false);
-        m_pSelectLB -> setEnabled(false);
-        m_pSelectLB -> clear();
+    if (m_pAllRB->isChecked()) {
+        m_pTypeCB->setEnabled(false);
+        m_pSelectLW->setEnabled(false);
+        m_pSelectLW->clear();
         foreach ( UMLView * view , list ) {
-            m_pSelectLB -> insertItem(view -> getName());
-            m_nIdList.append(view -> getID());
+            m_pSelectLW->addItem(view->getName());
+            m_nIdList.append(view->getID());
         }
-        m_pSelectLB -> selectAll(true);
-        break;
+        m_pSelectLW->selectAll();
+    }
 
-    case Select:
-        m_pTypeCB -> setEnabled(false);
-        m_pSelectLB -> setEnabled(true);
-        m_pSelectLB -> clear();
+    if (m_pSelectRB->isChecked()) {
+        m_pTypeCB->setEnabled(false);
+        m_pSelectLW->setEnabled(true);
+        m_pSelectLW->clear();
         foreach ( UMLView * view , list) {
-            m_pSelectLB -> insertItem(view -> getName());
-            m_nIdList.append(view -> getID());
+            m_pSelectLW->addItem(view->getName());
+            m_nIdList.append(view->getID());
         }
-        break;
+    }
 
-    case Type:
-        m_pTypeCB -> setEnabled(true);
-        m_pSelectLB -> setEnabled(true);
-        m_pSelectLB -> clear();
+    if (m_pTypeRB->isChecked()) {
+        m_pTypeCB->setEnabled(true);
+        m_pSelectLW->setEnabled(true);
+        m_pSelectLW->clear();
         foreach ( UMLView * view , list) {
-            if(view -> getType() == m_ViewType) {
-                m_pSelectLB -> insertItem(view -> getName());
-                m_nIdList.append(view -> getID());
+            if(view->getType() == m_ViewType) {
+                m_pSelectLW->addItem(view->getName());
+                m_nIdList.append(view->getID());
             }
         }
-        m_pSelectLB -> selectAll(true);
-        break;
+        m_pSelectLW->selectAll();
     }
 }
 
-void DiagramPrintPage::slotActivated(int index) {
-    UMLViewList list = m_pDoc -> getViewIterator();
+void DiagramPrintPage::slotActivated(int index)
+{
+    UMLViewList list = m_pDoc->getViewIterator();
 
     // combo box entries start from 0 index
     // valid diagram_type enum values start from 1
     m_ViewType = ( Uml::Diagram_Type )( index + 1 );
 
-    m_pSelectLB -> clear();
+    m_pSelectLW->clear();
 
     m_nIdList.clear();
-    foreach ( UMLView * view , list) {
-        if(view -> getType() == m_ViewType) {
-            m_pSelectLB -> insertItem(view -> getName());
-            m_nIdList.append(view -> getID());
+    foreach (UMLView * view , list) {
+        if (view->getType() == m_ViewType) {
+            m_pSelectLW->addItem(view->getName());
+            m_nIdList.append(view->getID());
         }
     }
-    m_pSelectLB -> selectAll(true);
+    m_pSelectLW->selectAll();
 }
 
 #include "diagramprintpage.moc"
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/diagramprintpage.h #848175:848176
@@ -1,28 +1,26 @@
 /***************************************************************************
- *                                                                         *
  *   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 DIAGRAMPRINTPAGE_H
 #define DIAGRAMPRINTPAGE_H
 
-class Q3ListBox;
+#include "umldoc.h"
+#include "umlview.h"
+
+#include <QtCore/QList>
+
+class QListWidget;
 class QRadioButton;
-class Q3ButtonGroup;
-class Q3GroupBox;
-
+class QGroupBox;
 class KComboBox;
 
-#include <Q3ValueList>
-
-#include "../umldoc.h"
-#include "../umlview.h"
 /**
  * This is a page on the print dialog to select what diagram(s)
  * you wish to print.  You add it to the @ref KPrinter instance.
@@ -34,13 +32,12 @@
  * @see    KPrinter
  * Bugs and comments to uml-devel at lists.sf.net or http://bugs.kde.org
  */
-
-class DiagramPrintPage : public QWidget {
+class DiagramPrintPage : public QWidget
+{
     Q_OBJECT
 public:
     /**
      *  Constructs the diagram print page.
-     *
      *  @param parent The parent to the page.
      *  @param doc      The @ref UMLDoc class instance being used.
      */
@@ -63,9 +60,11 @@
     bool isValid( QString& msg );
 
 private:
-    Q3ButtonGroup * m_pFilterBG;
-    Q3GroupBox * m_pSelectGB;
-    Q3ListBox * m_pSelectLB;
+    bool isSelected(int index);
+
+    QGroupBox * m_pFilterGB;
+    QGroupBox * m_pSelectGB;
+    QListWidget * m_pSelectLW;
     QRadioButton * m_pAllRB, * m_pCurrentRB, * m_pSelectRB, * m_pTypeRB;
     KComboBox * m_pTypeCB;
 
@@ -75,9 +74,10 @@
     /**
      * list containing the IDs of diagrams to print
      */
-    Q3ValueList<Uml::IDType> m_nIdList;
+    QList<Uml::IDType> m_nIdList;
 
     enum FilterType{Current = 0, All, Select, Type};
+
 public slots:
 
     /**
@@ -85,7 +85,7 @@
      * diagram, a selection of diagrams or diagrams by type. It will change the
      * listed diagrams in the diagram box.
      */
-    void slotClicked(int id);
+    void slotClicked();
 
     /**
      * Gets called when the user chooses another diagram type. Only diagrams of
--- trunk/KDE/kdesdk/umbrello/umbrello/umlnamespace.h #848175:848176
@@ -134,7 +134,8 @@
     dt_Activity,
     dt_Component,
     dt_Deployment,
-    dt_EntityRelationship
+    dt_EntityRelationship,
+    N_DIAGRAMTYPES   // must remain last 
 };
 
 enum Association_Type




More information about the umbrello-devel mailing list