[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Thu Jun 17 22:37:08 UTC 2010


SVN commit 1139263 by fischer:

Only close the diagrams when clicking on the tab close button instead of deleting the diagram. Better usability. Add tool tips for the tabs showing the diagram name.

 M  +21 -11    uml.cpp  
 M  +2 -1      uml.h  


--- branches/work/soc-umbrello/umbrello/uml.cpp #1139262:1139263
@@ -659,7 +659,7 @@
     m_tabWidget = new KTabWidget(this);
     m_tabWidget->setAutomaticResizeTabs(true);
     m_tabWidget->setTabsClosable(true);
-    connect(m_tabWidget, SIGNAL(closeRequest(QWidget*)), SLOT(slotDeleteDiagram(QWidget*)));
+    connect(m_tabWidget, SIGNAL(closeRequest(QWidget*)), SLOT(slotCloseDiagram(QWidget*)));
 
     m_newSessionButton = new QToolButton(m_tabWidget);
     m_newSessionButton->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Tab_New));
@@ -1648,7 +1648,10 @@
                     UMLScene *scene = view->umlScene();
                     m_viewStack->removeWidget(view);
                     m_tabWidget->addTab(view, scene->name());
-                    m_tabWidget->setTabIcon(m_tabWidget->indexOf(view), Icon_Utils::iconSet(scene->type()));
+                    int tabIndex = m_tabWidget->indexOf(view);
+                    m_tabWidget->setTabIcon(tabIndex, Icon_Utils::iconSet(scene->type()));
+                    m_tabWidget->setTabToolTip(tabIndex, scene->name());
+                    m_tabWidget->setTabWhatsThis(tabIndex, scene->name());
                 }
                 m_layout->addWidget(m_tabWidget);
                 m_tabWidget->show();
@@ -2381,21 +2384,25 @@
 }
 
 /**
- * Deletes the current diagram.
- * @param tab   Widget's tab to close
+ * Deletes the current diagram. Called from menu action.
  */
-void UMLApp::slotDeleteDiagram(QWidget* tab)
+void UMLApp::slotDeleteDiagram()
 {
-    if (tab == NULL) {  // called from menu action
  // [PORT]
         m_doc->removeDiagram( currentView()->umlScene()->getID() );
     }
-    else {  // clicked on close button
+
+/**
+ * Close the current diagram. Clicked on tab close button.
+ */
+void UMLApp::slotCloseDiagram(QWidget* tab)
+{
+    if (tab) {
         UMLView* view = (UMLView*)tab;
         if (view != currentView()) {
             setCurrentView(view);
         }
-        m_doc->removeDiagram( view->umlScene()->getID() );
+        m_tabWidget->removeTab(m_tabWidget->indexOf(view));
     }
 }
 
@@ -2574,11 +2581,14 @@
 
     Settings::OptionState optionState = Settings::getOptionState();
     if (optionState.generalState.tabdiagrams) {
-        if ( m_tabWidget->indexOf(view) < 0 ) {
+        int tabIndex = m_tabWidget->indexOf(view);
+        if (tabIndex < 0) {
             m_tabWidget->addTab(view, view->umlScene()->name());
-            m_tabWidget->setTabIcon(m_tabWidget->indexOf(view), Icon_Utils::iconSet(view->umlScene()->type()));
+            m_tabWidget->setTabIcon(tabIndex, Icon_Utils::iconSet(view->umlScene()->type()));
+            m_tabWidget->setTabToolTip(tabIndex, view->umlScene()->name());
+            m_tabWidget->setTabWhatsThis(tabIndex, view->umlScene()->name());
         }
-        m_tabWidget->setCurrentIndex(m_tabWidget->indexOf(view));
+        m_tabWidget->setCurrentIndex(tabIndex);
     }
     else {
         if (m_viewStack->indexOf(view) < 0) {
--- branches/work/soc-umbrello/umbrello/uml.h #1139262:1139263
@@ -239,7 +239,8 @@
     void slotShowGridToggled(bool gridOn);
     void slotSelectAll();
     void slotDeleteSelectedWidget();
-    void slotDeleteDiagram(QWidget* tab = NULL);
+    void slotDeleteDiagram();
+    void slotCloseDiagram(QWidget* tab);
 
     void slotSetZoom(QAction* action);
     void slotZoomSliderMoved(int value);




More information about the umbrello-devel mailing list