[Kst] extragear/graphics/kst/src/libkstapp

George Staikos staikos at kde.org
Mon Nov 27 22:04:20 CET 2006


SVN commit 608545 by staikos:

fix some crashes in click handling and try to make it behave a bit more as
expected.  There's one issue where double clicking on the '+' to
expand/collapse triggers a double click event on the -selected- item (which may
not be even near where the double click happened).  I think this is a Qt bug
and it's not worth hacking around.


 M  +26 -3     kstdatamanager_i.cpp  
 M  +2 -0      kstdatamanager_i.h  


--- trunk/extragear/graphics/kst/src/libkstapp/kstdatamanager_i.cpp #608544:608545
@@ -587,8 +587,8 @@
       this, SLOT(edit_I()));
   connect(DataView, SIGNAL(currentChanged(QListViewItem *)),
       this, SLOT(currentChanged(QListViewItem *)));
-  connect(DataView, SIGNAL(selectionChanged(QListViewItem *)),
-      this, SLOT(currentChanged(QListViewItem *)));
+  connect(DataView, SIGNAL(selectionChanged()),
+      this, SLOT(selectionChanged()));
   connect(DataView, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), this, SLOT(contextMenu(QListViewItem*, const QPoint&, int)));
 }
 
@@ -597,6 +597,12 @@
 }
 
 
+void KstDataManagerI::doubleClicked(QListViewItem *i) {
+  if (i && DataView->selectedItems().contains(i)) {
+    edit_I();
+  }
+}
+
 void KstDataManagerI::show_I() {
   show();
   raise();
@@ -801,6 +807,9 @@
 
 void KstDataManagerI::delete_I() {
   QListViewItem *qi = DataView->selectedItems().at(0);
+  if (!qi) {
+    return;
+  }
   KstObjectItem *koi = static_cast<KstObjectItem*>(qi);
 
   if (koi->removable()) {
@@ -1059,12 +1068,26 @@
 
 
 void KstDataManagerI::currentChanged(QListViewItem *i) {
-  if (i) {
+  if (i && !DataView->selectedItems().isEmpty()) {
     KstObjectItem *koi = static_cast<KstObjectItem*>(i);
     koi->updateButtons();
+  } else {
+    Edit->setEnabled(false);
+    Delete->setEnabled(false);
   }
 }
 
 
+void KstDataManagerI::selectionChanged() {
+  if (!DataView->selectedItems().isEmpty()) {
+    KstObjectItem *koi = static_cast<KstObjectItem*>(DataView->selectedItems().first());
+    koi->updateButtons();
+  } else {
+    Edit->setEnabled(false);
+    Delete->setEnabled(false);
+  }
+}
+
+
 #include "kstdatamanager_i.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/src/libkstapp/kstdatamanager_i.h #608544:608545
@@ -48,6 +48,8 @@
     void doUpdates();
     void contextMenu(QListViewItem *i, const QPoint& p, int c);
     void currentChanged(QListViewItem *);
+    void selectionChanged();
+    void doubleClicked(QListViewItem *);
 
   private:
     KstDoc *doc;


More information about the Kst mailing list