[Kst] branches/work/kst/portto4/kst/src

Barth Netterfield netterfield at astro.utoronto.ca
Fri Aug 10 23:48:34 UTC 2012


SVN commit 1310166 by netterfield:

BUG:
Fix a bug where if you drag a window to a new tab, it wasn't picked up by future autoformats.



 M  +10 -0     libkst/namedobject.cpp  
 M  +2 -0      libkst/namedobject.h  
 M  +1 -0      libkstapp/scene.cpp  
 M  +21 -0     libkstapp/view.cpp  
 M  +2 -0      libkstapp/view.h  
 M  +2 -7      libkstapp/viewitem.cpp  
 D             libkstapp/viewitemmanager.cpp  
 D             libkstapp/viewitemmanager.h  


--- branches/work/kst/portto4/kst/src/libkst/namedobject.cpp #1310165:1310166
@@ -273,6 +273,16 @@
   max_dsnum = 0;
 }
 
+// for sorting a list in order of creation (ie, short name number)
+bool shortNameLessThan(NamedObject *o1, NamedObject *o2) {
+  QString n1 = o1->shortName();
+  QString n2 = o2->shortName();
+
+  n1.remove(0,1);
+  n2.remove(0,1);
+  return (n1.toInt() < n2.toInt());
+}
+
 //void NamedObject::_initializeShortName() {
 //}
 
--- branches/work/kst/portto4/kst/src/libkst/namedobject.h #1310165:1310166
@@ -126,5 +126,7 @@
     int _initial_dsnum; // datasource
 };
 
+bool shortNameLessThan(NamedObject *n1, NamedObject *n2);
+
 }
 #endif
--- branches/work/kst/portto4/kst/src/libkstapp/scene.cpp #1310165:1310166
@@ -95,6 +95,7 @@
       }
       m->item->setParentViewItem(0);
       addItem(m->item);
+
     }
     m->item->show();
     QPointF viewpos = view->mapFromScene(event->scenePos());
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1310165:1310166
@@ -712,6 +712,27 @@
   //kstApp->mainWindow()->document()->setChanged(true);
 }
 
+
+QList<ViewItem*> View::layoutableViewItems() {
+  QList<QGraphicsItem*> graphics_items = scene()->items();
+  QList<ViewItem *> layoutable_view_items;
+
+  foreach(QGraphicsItem* graphics_item, graphics_items) {
+    ViewItem *item = dynamic_cast<ViewItem*>(graphics_item);
+    if (item && (!item->hasStaticGeometry()) &&
+        item->isVisible() &&
+        item->allowsLayout() &&
+        ((dynamic_cast<LayoutBoxItem*>(item->parentViewItem())!=0) || (!item->parentViewItem()))) {
+      layoutable_view_items.append(item);
 }
+  }
 
+  qSort(layoutable_view_items.begin(), layoutable_view_items.end(), shortNameLessThan);
+
+  return layoutable_view_items;
+
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #1310165:1310166
@@ -123,6 +123,8 @@
     void referenceFontsToView() { _referenceFontSizeToView = true;}
     void referenceFontsToPainter() { _referenceFontSizeToView = false;}
 
+    QList<ViewItem*> layoutableViewItems();
+
   Q_SIGNALS:
     void viewModeChanged(View::ViewMode oldMode);
     void mouseModeChanged(View::MouseMode oldMode);
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1310165:1310166
@@ -20,13 +20,10 @@
 #include "datacollection.h"
 #include "formatgridhelper.h"
 #include "dialogdefaults.h"
-#include "viewitemmanager.h"
 #include "cartesianrenderitem.h"
 
 #include "layoutboxitem.h"
 
-//#include "gridlayouthelper.h"
-
 #include <math.h>
 
 #include <QMenu>
@@ -135,12 +132,10 @@
   // only drop plots onto TabBar
   setAcceptDrops(false);
 
-  ViewItemManager::self()->addViewItem(this);
 }
 
 
 ViewItem::~ViewItem() {
-  ViewItemManager::self()->removeViewItem(this);
 }
 
 void ViewItem::_initializeShortName() {
@@ -2446,7 +2441,7 @@
     return; //not added to undostack
   }
 
-  viewItems = ViewItemManager::layoutableViewItemsForView(_item->view());
+  viewItems = _item->view()->layoutableViewItems();
 
   if (viewItems.isEmpty()) {
     return; //not added to undostack
@@ -2527,7 +2522,7 @@
 
 
   QList<ViewItem*> viewItems;
-  viewItems = ViewItemManager::layoutableViewItemsForView(_item->view());
+  viewItems = _item->view()->layoutableViewItems();
 
   _layout = new ViewGridLayout(_item);
 


More information about the Kst mailing list