Bug 124090 - Add plot manager to Kst
Summary: Add plot manager to Kst
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-22 18:53 UTC by Andrew Walker
Modified: 2006-05-10 18:22 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2006-03-22 18:53:52 UTC
Version:           HEAD (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
OS:                Linux

At present the data manager provides the user a central location to view and modify the data objects within Kst.

Similarly, it would be useful to havea  plot manager which would provide a central location to view and modify the plot objects (windows, plots, curves, etc.) within Kst. Initially this would simply provide a means to view the hierarchy of windows, plots, etc.
Comment 1 Andrew Walker 2006-03-22 19:02:23 UTC
Geroge, the code for a draft version of this seems to have gotten lost during your code reorganisation. Could you let me know where it is or could you add it back to SVN.
Comment 2 George Staikos 2006-03-22 19:31:16 UTC
They're still there:
./libkstapp/kstviewmanager_i.cpp
./libkstapp/kstviewmanager_i.h
./libkstapp/kstviewmanager.ui
Comment 3 Nicolas Brisset 2006-03-23 12:24:51 UTC
If it not too complicated to go from a view of the current hierarchy to a drag&dropable list (like the bookmark manager for konqueror) it would already be very useful :-)
Comment 4 Andrew Walker 2006-04-03 20:33:29 UTC
SVN commit 526059 by arwalker:

CCBUG:124090 Start adding plot manager

 M  +5 -0      kstviewwidget.cpp  
 M  +2 -1      kstviewwidget.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewwidget.cpp #526058:526059
@@ -140,6 +140,11 @@
 }
 
 
+void KstViewWidget::dropped(QDropEvent *e) {
+  dropEvent(e);
+}
+
+
 // Optimize: cache previous child here to make it faster? How to invalidate?
 void KstViewWidget::mouseMoveEvent(QMouseEvent *e) {
   if (_view->viewMode() == KstTopLevelView::DisplayMode) {
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewwidget.h #526058:526059
@@ -42,7 +42,8 @@
     void paint(const QRegion& region);
 
     KstViewObjectPtr findChildFor(const QPoint& pos);
-
+    void dropped(QDropEvent *e);
+    
   protected:
     virtual void enterEvent(QEvent *e);
     virtual void leaveEvent(QEvent *e);
Comment 5 Andrew Walker 2006-04-03 20:36:10 UTC
SVN commit 526060 by arwalker:

CCBUG:124090 Continue adding plot manager

 M  +38 -7     kst.cpp  
 M  +11 -4     kst.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kst.cpp #526059:526060
@@ -43,7 +43,6 @@
 #include <qdatetime.h>
 
 // application specific includes
-#include "datawizard.h"
 #include "extensiondlg.h"
 #include "extensionmgr.h"
 #include "kst.h"
@@ -56,6 +55,7 @@
 #include "kstcsddialog_i.h"
 #include "kstdatamanager_i.h"
 #include "kstdatanotifier.h"
+#include "kstdatawizard_i.h"
 #include "kstdebugdialog_i.h"
 #include "kstdebugnotifier.h"
 #include "kstdoc.h"
@@ -82,6 +82,7 @@
 #include "kstuinames.h"
 #include "kstvectordefaults.h"
 #include "kstvectordialog_i.h"
+#include "kstviewmanager_i.h"
 #include "kstviewscalarsdialog_i.h"
 #include "kstviewvectorsdialog_i.h"
 #include "kstviewmatricesdialog_i.h"
@@ -144,6 +145,7 @@
   debugDialog = new KstDebugDialogI(this);
   _plotDialog = new KstPlotDialogI(doc, this);
   dataManager = new KstDataManagerI(doc, this);
+  viewManager = new KstViewManagerI(doc, this);
   viewScalarsDialog = new KstViewScalarsDialogI(this);
   viewVectorsDialog = new KstViewVectorsDialogI(this);
   viewMatricesDialog = new KstViewMatricesDialogI(this);
@@ -505,6 +507,13 @@
                                        "to manage data."));
 
   /************/
+  ViewManagerAction = new KAction(i18n("&View Manager"), "kst_viewmanager", 0,
+                                  viewManager, SLOT(show_I()),
+                                  actionCollection(), "viewmanager_action");
+  ViewManagerAction->setWhatsThis(i18n("Bring up a dialog box\n"
+                                       "to manage views."));
+  
+  /************/
   VectorDialogAction = new KAction(i18n("New &Vector..."), "kst_vectornew", 0,
                                  KstVectorDialogI::globalInstance(),
                                  SLOT(show()), actionCollection(),
@@ -1985,6 +1994,11 @@
 }
 
 
+void KstApp::showViewManager() {
+  viewManager->show_I();
+}
+
+
 void KstApp::showViewScalarsDialog() {
   viewScalarsDialog->showViewScalarsDialog();
 }
@@ -2066,7 +2080,7 @@
 }
 
 
-void KstApp::updateDataDialogs(bool dm) {
+void KstApp::updateDataDialogs(bool dm, bool vm) {
   if (!viewScalarsDialog->isHidden()) {
     viewScalarsDialog->updateViewScalarsDialog();
   }
@@ -2083,7 +2097,10 @@
   if (dm) {
     dataManager->updateContents();
   }
-
+  if (vm) {
+    viewManager->updateContents();
+  }
+  
   updateMemoryStatus();
 }
 
@@ -2154,9 +2171,8 @@
     if (!onlyVisible || vectorSaveDialog->isShown()) {
       vectorSaveDialog->init();
     }
-    if (!onlyVisible || dataManager->isShown()) {
-      dataManager->update();
-    }
+    updateDataManager(onlyVisible);
+    updateViewManager(onlyVisible);
     kstdDebug() << "Dialogs updated in " << t.elapsed() << "ms" << endl;
   }
 }
@@ -2170,12 +2186,27 @@
     KstPsdDialogI::globalInstance()->updateWindow();
     KstCurveDialogI::globalInstance()->updateWindow();
     KstImageDialogI::globalInstance()->updateWindow();
-    dataManager->update();
+    updateDataManager(false);
+    updateViewManager(false);
     _plotDialog->updateWindow();
   }
 }
 
 
+void KstApp::updateDataManager(bool onlyVisible) {
+  if (!onlyVisible || dataManager->isShown()) {
+    dataManager->update();
+  }
+}
+
+
+void KstApp::updateViewManager(bool onlyVisible) {
+  if (!onlyVisible || viewManager->isShown()) {
+    viewManager->update();
+  }
+}
+
+
 void KstApp::showPluginManager() {
   PluginManager *pm = new PluginManager(this, "Plugin Manager");
   pm->exec();
--- trunk/extragear/graphics/kst/src/libkstapp/kst.h #526059:526060
@@ -59,6 +59,7 @@
 class KstQuickStartDialogI;
 class KstTopLevelView;
 class KstViewFitsDialogI;
+class KstViewManagerI;
 class KstViewMatricesDialogI;
 class KstViewScalarsDialogI;
 class KstViewVectorsDialogI;
@@ -305,7 +306,8 @@
 
     /** just calls dataManager->show_I(0) */
     void showDataManager();
-
+    void showViewManager();
+    
     /** just calls changeFileDialog->showChangeFileDialog(0) */
     void showChangeFileDialog();
     
@@ -367,10 +369,12 @@
     void updateVisibleDialogs();
     // is there ever a reason to update hidden dialogs?
     void updateDialogs(bool onlyVisible = true);
-    void updateDataDialogs(bool dataManager = true);
+    void updateDataDialogs(bool dataManager = true, bool viewManager = true);
     void updateDialogsForWindow();
     void updateDataNotifier();
-
+    void updateDataManager(bool onlyVisible);
+    void updateViewManager(bool onlyVisible);
+    
     /*** shows doc as modified, updates doc and dialogs */
     void registerDocChange();
 
@@ -436,7 +440,8 @@
     
     /* Dialog for looking at data */
     KstDataManagerI *dataManager;
-
+    KstViewManagerI *viewManager;
+    
     /* Dialog for looking at debug information */
     KstDebugDialogI *debugDialog;
 
@@ -498,6 +503,8 @@
     KAction *PsdDialogAction;
     /* Data Manager Action */
     KAction *DataManagerAction;
+    /* View Manager Action */    
+    KAction *ViewManagerAction;
     /* Plugin Plot Edit Action */
     KAction *PluginDialogAction;
     /* Vector Save Action */
Comment 6 Andrew Walker 2006-04-03 20:40:46 UTC
SVN commit 526063 by arwalker:

CCBUG:124090 Continue adding plot manager.

 M  +2 -0      Makefile.am  


--- trunk/extragear/graphics/kst/src/libkstapp/Makefile.am #526062:526063
@@ -71,6 +71,7 @@
 	extensionmgr.cpp \
 	ksteditviewobjectdialog_i.cpp \
 	kstdatamanager_i.cpp \
+	kstviewmanager_i.cpp \
 	kstvectordialog_i.cpp \
 	kstcsddialog_i.cpp \
 	ksteqdialog_i.cpp \
@@ -113,6 +114,7 @@
 	viewfitsdialog.ui \
 	changenptsdialog.ui \
 	datamanager.ui \
+	kstviewmanager.ui \
 	vectorsavedialog.ui \
 	kstsettingsdlg.ui \
 	quickstartdialog.ui \
Comment 7 Andrew Walker 2006-04-03 20:44:57 UTC
SVN commit 526066 by arwalker:

CCBUG:124090 Continue adding plot manager.

 M  +2 -0      kstui.rc  


--- trunk/extragear/graphics/kst/src/kst/kstui.rc #526065:526066
@@ -13,6 +13,7 @@
     <Action name="reload"/>
     <Separator/>
     <Action name="datamanager_action"/>
+    <Action name="viewmanager_action"/>
     <Separator/>
     <Action name="vectordialog_action"/>
     <Action name="curvedialog_action"/>
@@ -83,6 +84,7 @@
   <Separator/>
   <Action name="datawizard_action"/>
   <Action name="datamanager_action"/>
+  <Action name="viewmanager_action"/>
   <Action name="plotdialog_action"/>
   <Action name="changefiledialog_action"/>
   <Action name="changenptsdialog_action"/>
Comment 8 Andrew Walker 2006-04-03 20:51:32 UTC
SVN commit 526068 by arwalker:

CCBUG:124090 First draft of plot manager. Missing: Updates of plot manager when plots/curves/etc manipulated externally. Additional drag/drop options.

 M  +1 -1      Makefile.am  
 AM            kst_viewmanager.png  


--- trunk/extragear/graphics/kst/src/kst/pics/Makefile.am #526067:526068
@@ -13,7 +13,7 @@
 	kst_gfx_rectangle.png kst_gfx_rounded_rectangle.png \
 	kst_gfx_ellipse.png kst_gfx_polyline.png kst_gfx_polygon.png \
 	kst_gfx_arrow.png kst_gfx_picture.png kst_choosecolor.png \
-	kst_csdnew.png kst_differentiatecurves.png
+	kst_csdnew.png kst_differentiatecurves.png kst_viewmanager.png
 
 
 
** trunk/extragear/graphics/kst/src/kst/pics/kst_viewmanager.png #property svn:mime-type
   + application/octet-stream
Comment 9 Netterfield 2006-04-04 17:28:21 UTC
First Glance Bugs and UI Tweaks:
 -DnD should move, not copy
 -The tree should update on changes (already mentioned above)
 -rmb option on curves should be "remove" not "delete"
 -"cleanup layout" should be available from the rmb menu for windows.
Comment 10 Nicolas Brisset 2006-04-04 23:26:40 UTC
COOL ! This has a lot of potential. Let's just make it perfect ;-)

> -DnD should move, not copy 
Not necessarily. I think both are needed. Maybe either modifier keys to choose (Ctrl+drag = copy, simple drag = move) or konqueror's way (with a popup dialog) ?

>  -The tree should update on changes (already mentioned above)
Sure. 

>  -rmb option on curves should be "remove" not "delete" 
I agree. I have not looked at the code to see whether it removes the curve from the plot or destroys the curve, but it should only be removed.

>  -"cleanup layout" should be available from the rmb menu for windows. 
Good idea.

Now, if you'll allow I'd like to add some:
1) I'd move the menu entry to the "Tools" menu, and call it "Plot organizer" or "Plot manager" instead of "view manager" which I think is too vague. While we are at it, maybe we should also move the data manager to the Tools menu ?
2) the dialog should allow to drag and drop curves around in the plots (and plots in the windows), by using an approach like keditbookmarks (the drop targets are inserted between items, making it clear what the final order will be). Note that organizing the order of curves within plots of that of plots within windows is an often requested feature (hence bug #120329).
3) it would be nice to have shortcuts to develop and collapse all or just one window(s) (maybe rmb menu for window entries ?)
4) adding a "properties" colum like in the data manager sounds like a good idea: there is plenty of room and sometimes names aren't so explicit
5) view objects seem to have a tendency to grow bigger when they are moved (or rather copied, as it stands) to other plots. 
Comment 11 Andrew Walker 2006-05-04 18:31:45 UTC
SVN commit 537371 by arwalker:

CCBUG:124090 Address some of Barth's suggestions

 M  +4 -2      ksttoplevelview.h  
 M  +52 -14    kstviewmanager_i.cpp  
 M  +2 -0      kstviewmanager_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.h #537370:537371
@@ -75,6 +75,10 @@
     bool tiedZoomMode(int zoom, bool flag, double center, int mode, int modeExtra, const QString& plotName);
     bool tiedZoom(bool x, double xmin, double xmax, bool y, double ymin, double ymax, const QString& plotName);
 
+  public slots:
+    void cleanupDefault();
+    void cleanupCustom();      
+  
   private slots:
     void menuClosed();
     void makeSameWidth();
@@ -87,8 +91,6 @@
     void packVertically();
     void packHorizontally();
     void groupSelection();
-    void cleanupDefault();
-    void cleanupCustom();
 
   protected:
     void resized(const QSize& size);
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmanager_i.cpp #537370:537371
@@ -548,6 +548,36 @@
   }
 }
 
+void KstViewManagerI::cleanupDefault_I() {
+  QListViewItem *qi = ViewView->selectedItem();
+  KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
+  
+  if (koi) {
+    if (koi->rtti() == RTTI_OBJ_WINDOW) {
+      KstViewWindow *win = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(koi->tagName()));
+      if (win) {
+        win->view()->cleanupDefault();
+      }      
+    }
+  }  
+}
+
+
+void KstViewManagerI::cleanupCustom_I() {
+  QListViewItem *qi = ViewView->selectedItem();
+  KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
+  
+  if (koi) {
+    if (koi->rtti() == RTTI_OBJ_WINDOW) {
+      KstViewWindow *win = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(koi->tagName()));
+      if (win) {
+        win->view()->cleanupCustom();
+      }      
+    }
+  }  
+}
+
+
 void KstViewManagerI::select_I() {
   QListViewItem *qi = ViewView->selectedItem();
   KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
@@ -589,28 +619,36 @@
   
   if (i) {
     KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(i);
-    KPopupMenu *m = new KPopupMenu(this);
+    KPopupMenu *menu = new KPopupMenu(this);
     int id;
     
-    m->insertTitle(koi->text(0));
+    menu->insertTitle(koi->text(0));
     
     if (koi->rtti() == RTTI_OBJ_WINDOW) {
-      id = m->insertItem(i18n("&Rename..."), this, SLOT(edit_I()));
-      id = m->insertItem(i18n("&Close"), this, SLOT(delete_I()));
-      id = m->insertItem(i18n("&Activate"), this, SLOT(activate_I()));
+      id = menu->insertItem(i18n("&Rename..."), this, SLOT(edit_I()));
+      id = menu->insertItem(i18n("&Close"), this, SLOT(delete_I()));
+      id = menu->insertItem(i18n("&Activate"), this, SLOT(activate_I()));
+      
+      KPopupMenu *submenu = new KPopupMenu(menu);
+      if (submenu) {
+        menu->insertSeparator();
+        submenu->insertItem("Default Tile", this, SLOT(cleanupDefault_I()));
+        submenu->insertItem("Custom...", this, SLOT(cleanupCustom_I()));
+        id = menu->insertItem(i18n("Cleanup Layout"), submenu);
+      }
     } else if (koi->rtti() == RTTI_OBJ_VIEW_OBJECT) {
-      id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
-      id = m->insertItem(i18n("&Delete"), this, SLOT(delete_I()));
-      id = m->insertItem(i18n("&Select"), this, SLOT(select_I()));
-      m->setItemEnabled(id, KstApp::inst()->currentViewMode() == KstTopLevelView::LayoutMode);
-      id = m->insertItem(i18n("Dese&lect"), this, SLOT(deselect_I()));
-      m->setItemEnabled(id, KstApp::inst()->currentViewMode() == KstTopLevelView::LayoutMode);
+      id = menu->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
+      id = menu->insertItem(i18n("&Delete"), this, SLOT(delete_I()));
+      id = menu->insertItem(i18n("&Select"), this, SLOT(select_I()));
+      menu->setItemEnabled(id, KstApp::inst()->currentViewMode() == KstTopLevelView::LayoutMode);
+      id = menu->insertItem(i18n("Dese&lect"), this, SLOT(deselect_I()));
+      menu->setItemEnabled(id, KstApp::inst()->currentViewMode() == KstTopLevelView::LayoutMode);
     } else if (koi->rtti() == RTTI_OBJ_DATA_OBJECT) {
-      id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
-      id = m->insertItem(i18n("&Delete"), this, SLOT(delete_I()));
+      id = menu->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
+      id = menu->insertItem(i18n("&Remove"), this, SLOT(delete_I()));
     }
     
-    m->popup(p);
+    menu->popup(p);
   }
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmanager_i.h #537370:537371
@@ -74,6 +74,8 @@
     void edit_I();
     void delete_I();
     void activate_I();
+    void cleanupDefault_I();
+    void cleanupCustom_I();
     void select_I();
     void deselect_I();
 
Comment 12 Andrew Walker 2006-05-04 23:35:39 UTC
SVN commit 537481 by arwalker:

CCBUG:124090 Update view manager when view objects created.

 M  +1 -0      kstgfxarrowmousehandler.cpp  
 M  +1 -0      kstgfxellipsemousehandler.cpp  
 M  +1 -0      kstgfxlinemousehandler.cpp  
 M  +1 -0      kstgfxpicturemousehandler.cpp  
 M  +1 -0      kstgfxrectanglemousehandler.cpp  
 M  +1 -0      kstgfxtextmousehandler.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxarrowmousehandler.cpp #537480:537481
@@ -90,6 +90,7 @@
     }
     container->appendChild(KstViewObjectPtr(arrow));
     KstApp::inst()->document()->setModified();
+    KstApp::inst()->updateViewManager(true);
     view->paint(KstPainter::P_PAINT);
   }
   _prevBand = QRect(-1, -1, 0, 0);
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxellipsemousehandler.cpp #537480:537481
@@ -114,6 +114,7 @@
     }
     container->appendChild(KstViewObjectPtr(ellipse));
     KstApp::inst()->document()->setModified();
+    KstApp::inst()->updateViewManager(true);
     view->paint(KstPainter::P_PAINT);
   }
   _prevBand = QRect(-1, -1, 0, 0);
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxlinemousehandler.cpp #537480:537481
@@ -87,6 +87,7 @@
     }
     container->appendChild(KstViewObjectPtr(line));
     KstApp::inst()->document()->setModified();
+    KstApp::inst()->updateViewManager(true);
     view->paint(KstPainter::P_PAINT);
   }
   _prevBand = QRect(-1, -1, 0, 0);
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxpicturemousehandler.cpp #537480:537481
@@ -84,6 +84,7 @@
       }
       container->appendChild(KstViewObjectPtr(pic));
       KstApp::inst()->document()->setModified();
+      KstApp::inst()->updateViewManager(true);
     }
   }
   _prevBand = QRect(-1,-1, 0, 0);
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxrectanglemousehandler.cpp #537480:537481
@@ -88,6 +88,7 @@
     }
     container->appendChild(KstViewObjectPtr(box));
     KstApp::inst()->document()->setModified();
+    KstApp::inst()->updateViewManager(true);
     view->paint(KstPainter::P_PAINT);
   }
   _prevBand = QRect(-1, -1, 0, 0);
--- trunk/extragear/graphics/kst/src/libkstapp/kstgfxtextmousehandler.cpp #537480:537481
@@ -113,6 +113,7 @@
       }
       container->appendChild(KstViewObjectPtr(label));
       KstApp::inst()->document()->setModified();
+      KstApp::inst()->updateViewManager(true);
     }
   }
   _prevBand = QRect(-1, -1, 0, 0);
Comment 13 Andrew Walker 2006-05-05 00:03:08 UTC
SVN commit 537491 by arwalker:

CCBUG:124090 More instances where view manager must be updated

 M  +8 -0      ksttoplevelview.cpp  
 M  +1 -0      kstviewwidget.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #537490:537491
@@ -972,12 +972,15 @@
   // something that includes none of those.  This is most likely the parent of
   // the returned object in that case.
   KstViewObjectPtr container = findDeepestChild(obj);
+  bool updateViewManager = false;
+  
   if (!container) {
     container = this;
   }
   if (container != _pressTarget && !container->children().contains(_pressTarget)) {
     _pressTarget->detach();
     container->appendChild(_pressTarget);
+    updateViewManager = true;
   }
   _pressTarget->move(obj.topLeft() + objOffset);
   for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
@@ -986,10 +989,15 @@
       if (container != thisObj && !container->children().contains(thisObj)) {
         thisObj->detach();
         container->appendChild(thisObj);
+        updateViewManager = true;
       }
       thisObj->move(_pressTarget->position() + thisObj->geometry().topLeft() - old.topLeft());
     }
   }
+  
+  if (updateViewManager) {
+    KstApp::inst()->updateViewManager(true);
+  }
   _onGrid = false;
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewwidget.cpp #537490:537491
@@ -432,6 +432,7 @@
     // FIXME: support both copy and move
     KstApp::inst()->paste(e, viewObject());
     e->acceptAction(true);
+    KstApp::inst()->updateViewManager(true);
     _view->paint(KstPainter::P_PAINT);
   } else if (_view->viewMode() != KstTopLevelView::LayoutMode) {
     KstViewObjectPtr vo = findChildFor(e->pos());
Comment 14 Andrew Walker 2006-05-08 20:41:40 UTC
SVN commit 538741 by arwalker:

CCBUG:124090 Add context menu for expanding and collapsing listview items

 M  +70 -2     kstviewmanager_i.cpp  
 M  +10 -3     kstviewmanager_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmanager_i.cpp #538740:538741
@@ -352,6 +352,15 @@
   _vm->Delete->setEnabled(true);
 }
 
+void KstViewObjectItem::openChildren(bool open) {
+  for (QListViewItem *qi = firstChild(); qi; qi = qi->nextSibling()) {
+    KstViewObjectItem *oi = static_cast<KstViewObjectItem*>(qi);
+    
+    oi->openChildren(open);
+    qi->setOpen(open);
+  }
+}
+
 // ==============================================
 
 KstViewManagerI::KstViewManagerI(KstDoc *in_doc, QWidget* parent, const char* name, bool modal, WFlags fl)
@@ -569,7 +578,6 @@
   }  
 }
 
-
 void KstViewManagerI::cleanupCustom_I() {
   QListViewItem *qi = ViewView->selectedItem();
   KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
@@ -584,7 +592,6 @@
   }  
 }
 
-
 void KstViewManagerI::select_I() {
   QListViewItem *qi = ViewView->selectedItem();
   KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
@@ -621,6 +628,47 @@
   }
 }
 
+void KstViewManagerI::open() {
+  QListViewItem *qi = ViewView->selectedItem();
+  
+  if (qi) {
+    qi->setOpen(true);
+  }
+}
+
+void KstViewManagerI::close() {
+  QListViewItem *qi = ViewView->selectedItem();
+  
+  if (qi) {
+    qi->setOpen(false);
+  }
+}
+
+void KstViewManagerI::open(bool open) {
+  QListViewItem *qi = ViewView->selectedItem();
+  KstViewObjectItem *koi = static_cast<KstViewObjectItem*>(qi);
+    
+  if (koi) {
+    koi->openChildren(open);
+    qi->setOpen(open);
+  } else {
+    for (qi = ViewView->firstChild(); qi; qi = qi->nextSibling()) {
+      koi = static_cast<KstViewObjectItem*>(qi);
+
+      koi->openChildren(open);
+      qi->setOpen(open);
+    }
+  }
+}
+
+void KstViewManagerI::openAll() {
+  open(true);
+}
+
+void KstViewManagerI::closeAll() {
+  open(false);
+}
+
 void KstViewManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) {
   Q_UNUSED(col)
   
@@ -655,7 +703,27 @@
       id = menu->insertItem(i18n("&Remove"), this, SLOT(delete_I()));
     }
     
+    menu->insertSeparator();
+    id = menu->insertItem(i18n("Expand"), this, SLOT(open()));
+    menu->setItemEnabled(id, !koi->isOpen());
+    id = menu->insertItem(i18n("Collapse"), this, SLOT(close()));
+    menu->setItemEnabled(id, koi->isOpen());
+    id = menu->insertItem(i18n("Expand All"), this, SLOT(openAll()));
+    menu->setItemEnabled(id, koi->firstChild());
+    id = menu->insertItem(i18n("Collapse All"), this, SLOT(closeAll()));
+    menu->setItemEnabled(id, koi->firstChild());
+  
     menu->popup(p);
+  } else {
+    KPopupMenu *menu = new KPopupMenu(this);
+    int id;
+        
+    id = menu->insertItem(i18n("Expand All"), this, SLOT(openAll()));
+    menu->setItemEnabled(id, ViewView->firstChild());
+    id = menu->insertItem(i18n("Collapse All"), this, SLOT(closeAll()));
+    menu->setItemEnabled(id, ViewView->firstChild());        
+    
+    menu->popup(p);
   }
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewmanager_i.h #538740:538741
@@ -51,7 +51,8 @@
     KstViewObjectPtr viewObject(KstViewWindow **win) const;
     bool removable() const { return _removable; }
     void updateButtons();
-
+    void openChildren(bool open);
+         
   private:
     int _rtti;
     QString _name;
@@ -66,7 +67,7 @@
     KstViewManagerI(KstDoc *doc, QWidget* parent = 0, const char *name = 0, 
                     bool modal = false, WFlags fl = 0);
     virtual ~KstViewManagerI();
-    
+        
   public slots:
     void update();
     void updateContents();
@@ -78,13 +79,19 @@
     void cleanupCustom_I();
     void select_I();
     void deselect_I();
+    void open();
+    void close();
+    void openAll();
+    void closeAll();
 
   private slots:
     void doUpdates();
     void contextMenu(QListViewItem *i, const QPoint& p, int c);
     void currentChanged(QListViewItem *);
+  
+  private:
+    void open(bool open);  
 
-  private:
     KstDoc *doc;
 
   protected:
Comment 15 Andrew Walker 2006-05-10 18:22:07 UTC
This has now been rendered obsolete by 127042.