Bug 104636 - Adjust layout assumes the number of columns in plot->edit plot->number of columns.
Summary: Adjust layout assumes the number of columns in plot->edit plot->number of col...
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Rick Chern
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-27 11:05 UTC by Enzo Pascale
Modified: 2005-05-24 19:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enzo Pascale 2005-04-27 11:05:18 UTC
Version:           1.1.0_beta1 (using KDE 3.3.2,  (3.1))
Compiler:          gcc version 3.3.5 (Debian 1:3.3.5-8)
OS:                Linux (i686) release 2.6.8-2-686

It would be nice that adjust layout figures out how many columns I have. Currently it gets the number of columns from the plot dialog.
Comment 1 Andrew Walker 2005-05-10 21:45:41 UTC
Could you provide some more information as to what you are trying to achieve here?
By "adjust layout" are you referring to the "Cleanup layout" context menu item in layout mode (which will regrid everything to the number of columns specifiec in the plot dialog)?
Comment 2 Nicolas Brisset 2005-05-19 12:00:41 UTC
I think this request is somehow linked with the wish I reported in bug #95030, which basically says that it is not natural and sometimes surprising to access the number of columns in the context menu of plots whereas it is a window property.
To illustrate the problem the user reported (if I understand it correctly), imagine the following scenario:
- you load 9 vectors from a given datasource through the data wizard and let it choose the number of columns automatically: it will set the number of columns to 3
- you delete the graphs in the right column and call "Cleanup layout" from the context menu in layout mode: the remaining 6 plots are laid out in 3 columns whereas visually, you'd expect the empty third column to just disappear so that you have 6 plots in 2 columns at the end.

Now, I believe it is not possible to "guess" the number of columns that the user wants just from the current layout as in the general case it can be very complex. However, if the user could easily change the number of columns or even see it displayed before "cleanup layout" is called (which is basically what I asked for in #95030), the solution to the problem reported here would be just ONE click away.
I suppose the idea would be to display the number of columns in a combo box (editable with preset values 1...10) in the toolbar (or context menu, or even better: customisable), and call "cleanup layout" whenever this value is changed.

In the example above, when the user has 6 plots with empty space, he could either:
1) select "2" from the combobox and get a nice 2-column layout
2) call "Cleanup layout" with 3 columns displayed in a visible area, and not be surprised to get a layout in 3 columns.

I don't know whether this solution is the proper one, but in any case I believe there is a usability problem in having a window property (number of columns) in the plot dialog (and only there).
Comment 3 Rick Chern 2005-05-24 19:36:25 UTC
SVN commit 417805 by rchern:

Make cleanup layout use a default approximately square grid, and allow custom columns as well

CCMAIL: 104636-done@bugs.kde.org

 M  +52 -3     ksttoplevelview.cpp  
 M  +2 -1      ksttoplevelview.h  
 M  +2 -1      kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #417804:417805
@@ -17,11 +17,14 @@
 
 #include <assert.h>
 #include <stdlib.h>
+#include <math.h>
 
 // include files for Qt
 
 // include files for KDE
 #include <kdebug.h>
+#include <kinputdialog.h>
+#include <klineeditdlg.h>
 #include <klocale.h>
 
 // application specific includes
@@ -720,7 +723,10 @@
     if (rc) {
       menu->insertSeparator();
     }
-    menu->insertItem(i18n("Cleanup Layout"), this, SLOT(cleanupAction()));
+    KPopupMenu *subMenu = new KPopupMenu(menu);
+    subMenu->insertItem(i18n("Default Tile"), this, SLOT(cleanupDefault()));
+    subMenu->insertItem(i18n("Custom..."), this, SLOT(cleanupCustom()));
+    menu->insertItem(i18n("Cleanup Layout"), subMenu);
     rc = true;
   }
 
@@ -1035,12 +1041,55 @@
   return _w;
 }
 
-
-void KstTopLevelView::cleanupAction() {
+void KstTopLevelView::cleanupDefault()
+{
+  // roughly layout in a square
   cleanup();
 }
 
+void KstTopLevelView::cleanupCustom()
+{
+  bool ok = false;
+#if KDE_VERSION >= KDE_MAKE_VERSION(3,3,0)
+  int numCols = KInputDialog::getInteger (i18n("Number of Columns"), 
+                                          i18n("Select number of columns:"), 
+                                          (int)sqrt(_children.count()), 
+                                          1, 
+                                          _children.count(), 
+                                          1, 
+                                          &ok, 
+                                          0L);
+  if (ok)
+  {
+    cleanup(numCols);
+  } 
+#else
+  bool done = false;
+  while (!done)
+  { 
+    QString numColsString = KLineEditDlg::getText(i18n("Enter number of columns:"), i18n("Number of Columns"), &ok, 0L);
+    if (ok)
+    {
+      int numCols = numColsString.toInt();
+      if (numCols < 1 || numCols > _children.count())
+      {
+        KMessageBox::sorry(0L, i18n("Please enter a number of columns between 1 and %d").arg(_selectionList.count()));
+      }
+      else
+      {
+        done = true;
+        cleanup(numCols);
+      }
+    }
+    else
+    {
+      done = true;
+    }
+  }
+#endif
+}
 
+
 void KstTopLevelView::release() {
   _hoverFocus = 0L;
   _pressTarget = 0L;
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #417804:417805
@@ -78,7 +78,8 @@
     void packVertically();
     void packHorizontally();
     void groupSelection();
-    void cleanupAction();
+    void cleanupDefault();
+    void cleanupCustom();
 
   protected:
     void resized(const QSize& size);
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #417804:417805
@@ -519,7 +519,8 @@
   } else {
     if (cols > 0) {
       _columns = cols;
-    } else if (_columns <= 0) {
+//    } else if (_columns <= 0) {
+    } else if (cols <= 0){
       _columns = QMAX(1, int(sqrt(_children.count())));
     }
   }