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

Mike Fenton mike at staikos.net
Mon May 25 17:50:17 CEST 2009


SVN commit 972758 by fenton:

Add ContentTab double click actions.  Fix multiple selection.


 M  +28 -12    contenttab.cpp  
 M  +2 -0      contenttab.h  
 M  +77 -68    contenttab.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/contenttab.cpp #972757:972758
@@ -40,6 +40,9 @@
   connect(_up, SIGNAL(clicked()), this, SIGNAL(modified()));
   connect(_down, SIGNAL(clicked()), this, SIGNAL(modified()));
 
+  connect(_availableRelationList, SIGNAL(itemDoubleClicked ( QListWidgetItem * )), this, SLOT(availableDoubleClicked(QListWidgetItem *)));
+  connect(_displayedRelationList, SIGNAL(itemDoubleClicked ( QListWidgetItem * )), this, SLOT(displayedDoubleClicked(QListWidgetItem *)));
+
   connect(_availableRelationList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
   connect(_displayedRelationList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
 }
@@ -67,29 +70,42 @@
 
 
 void ContentTab::removeButtonClicked() {
-  for (int i = 0; i < _displayedRelationList->count(); i++) {
-    if (_displayedRelationList->item(i) && _displayedRelationList->item(i)->isSelected()) {
-      _availableRelationList->addItem(_displayedRelationList->takeItem(i));
-      _availableRelationList->clearSelection();
-      _availableRelationList->item(_availableRelationList->count() - 1)->setSelected(true);
-    }
+  foreach (QListWidgetItem* item, _displayedRelationList->selectedItems()) {
+    _availableRelationList->addItem(_displayedRelationList->takeItem(_displayedRelationList->row(item)));
   }
+
+  _availableRelationList->clearSelection();
   updateButtons();
 }
 
 
+void ContentTab::displayedDoubleClicked(QListWidgetItem * item) {
+  if (item) {
+    _availableRelationList->addItem(_displayedRelationList->takeItem(_displayedRelationList->row(item)));
+    _availableRelationList->clearSelection();
+    updateButtons();
+  }
+}
+
+
 void ContentTab::addButtonClicked() {
-  for (int i = 0; i < _availableRelationList->count(); i++) {
-    if (_availableRelationList->item(i) && _availableRelationList->item(i)->isSelected()) {
-      _displayedRelationList->addItem(_availableRelationList->takeItem(i));
-      _displayedRelationList->clearSelection();
-    }
+  foreach (QListWidgetItem* item, _availableRelationList->selectedItems()) {
+    _displayedRelationList->addItem(_availableRelationList->takeItem(_availableRelationList->row(item)));
   }
-  _displayedRelationList->setCurrentRow(_displayedRelationList->count() - 1);;
+  _displayedRelationList->clearSelection();
   updateButtons();
 }
 
 
+void ContentTab::availableDoubleClicked(QListWidgetItem * item) {
+  if (item) {
+    _displayedRelationList->addItem(_availableRelationList->takeItem(_availableRelationList->row(item)));
+    _displayedRelationList->clearSelection();
+    updateButtons();
+  }
+}
+
+
 void ContentTab::upButtonClicked() {
   _displayedRelationList->setFocus();
 
--- branches/work/kst/portto4/kst/src/libkstapp/contenttab.h #972757:972758
@@ -41,6 +41,8 @@
     void removeButtonClicked();
     void upButtonClicked();
     void downButtonClicked();
+    void availableDoubleClicked(QListWidgetItem * item);
+    void displayedDoubleClicked(QListWidgetItem * item);
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/contenttab.ui #972757:972758
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>ContentTab</class>
- <widget class="QWidget" name="ContentTab" >
-  <property name="geometry" >
+ <widget class="QWidget" name="ContentTab">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,19 +10,19 @@
     <height>469</height>
    </rect>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
+  <layout class="QGridLayout">
+   <property name="margin">
     <number>0</number>
    </property>
-   <item row="0" column="1" >
+   <item row="0" column="1">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeType" >
+     <property name="sizeType">
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>31</width>
        <height>50</height>
@@ -29,15 +30,15 @@
      </property>
     </spacer>
    </item>
-   <item row="2" column="1" >
+   <item row="2" column="1">
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeType" >
+     <property name="sizeType">
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>31</width>
        <height>110</height>
@@ -45,153 +46,161 @@
      </property>
     </spacer>
    </item>
-   <item rowspan="3" row="0" column="0" >
-    <layout class="QVBoxLayout" >
-     <property name="margin" >
+   <item row="0" column="0" rowspan="3">
+    <layout class="QVBoxLayout">
+     <property name="margin">
       <number>0</number>
      </property>
      <item>
-      <widget class="QLabel" name="TextLabel4_4_2" >
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+      <widget class="QLabel" name="TextLabel4_4_2">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="text" >
+       <property name="text">
         <string>&amp;Available objects:</string>
        </property>
-       <property name="wordWrap" >
+       <property name="wordWrap">
         <bool>false</bool>
        </property>
-       <property name="buddy" >
+       <property name="buddy">
         <cstring>_availableRelationList</cstring>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QListWidget" name="_availableRelationList" />
+      <widget class="QListWidget" name="_availableRelationList">
+       <property name="selectionMode">
+        <enum>QAbstractItemView::ExtendedSelection</enum>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
-   <item rowspan="3" row="0" column="2" >
-    <layout class="QVBoxLayout" >
-     <property name="margin" >
+   <item row="0" column="2" rowspan="3">
+    <layout class="QVBoxLayout">
+     <property name="margin">
       <number>0</number>
      </property>
      <item>
-      <widget class="QLabel" name="TextLabel3_3_2" >
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+      <widget class="QLabel" name="TextLabel3_3_2">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="text" >
+       <property name="text">
         <string>&amp;Displayed objects:</string>
        </property>
-       <property name="wordWrap" >
+       <property name="wordWrap">
         <bool>false</bool>
        </property>
-       <property name="buddy" >
+       <property name="buddy">
         <cstring>_displayedRelationList</cstring>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QListWidget" name="_displayedRelationList" />
+      <widget class="QListWidget" name="_displayedRelationList">
+       <property name="selectionMode">
+        <enum>QAbstractItemView::ExtendedSelection</enum>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
-   <item row="1" column="1" >
-    <layout class="QGridLayout" >
-     <property name="margin" >
+   <item row="1" column="1">
+    <layout class="QGridLayout">
+     <property name="margin">
       <number>0</number>
      </property>
-     <item row="1" column="1" >
-      <widget class="QPushButton" name="_up" >
-       <property name="enabled" >
+     <item row="1" column="1">
+      <widget class="QPushButton" name="_up">
+       <property name="enabled">
         <bool>false</bool>
        </property>
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="toolTip" >
+       <property name="toolTip">
         <string>Raise in plot order: Alt+up</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Alt+Up</string>
        </property>
       </widget>
      </item>
-     <item row="3" column="1" >
-      <widget class="QPushButton" name="_down" >
-       <property name="enabled" >
+     <item row="3" column="1">
+      <widget class="QPushButton" name="_down">
+       <property name="enabled">
         <bool>false</bool>
        </property>
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="toolTip" >
+       <property name="toolTip">
         <string>Lower in plot order: Alt+down</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Alt+Down</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="2" >
-      <widget class="QPushButton" name="_add" >
-       <property name="enabled" >
+     <item row="2" column="2">
+      <widget class="QPushButton" name="_add">
+       <property name="enabled">
         <bool>false</bool>
        </property>
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="toolTip" >
+       <property name="toolTip">
         <string>Select: Alt+s</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Alt+S</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="0" >
-      <widget class="QPushButton" name="_remove" >
-       <property name="enabled" >
+     <item row="2" column="0">
+      <widget class="QPushButton" name="_remove">
+       <property name="enabled">
         <bool>false</bool>
        </property>
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="toolTip" >
+       <property name="toolTip">
         <string>Remove: Alt+r</string>
        </property>
-       <property name="text" >
+       <property name="text">
         <string/>
        </property>
-       <property name="shortcut" >
+       <property name="shortcut">
         <string>Alt+R</string>
        </property>
       </widget>


More information about the Kst mailing list