[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/office/skrooge
From:       Stephane Mankowski <stephane () mankowski ! fr>
Date:       2010-11-18 20:19:00
Message-ID: 20101118201900.93363AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1198529 by smankowski:

FEATURE: Multi selection in report table and graph

 M  +1 -0      CHANGELOG  
 M  +26 -7     skgbasegui/skgtablewithgraph.cpp  
 M  +1 -1      skgbasegui/skgtablewithgraph.h  
 M  +24 -24    skgbasegui/skgtablewithgraph.ui  
 M  +15 -2     skrooge_report/skgreportpluginwidget.cpp  


--- trunk/extragear/office/skrooge/CHANGELOG #1198528:1198529
@@ -35,6 +35,7 @@
   *New feature: New contextual menu in html pages for export as pdf, odt, image and \
                copy
   *New feature: Possible to show/hide items in context list
   *New feature: Forecast based on budgets
+  *New feature: Multi selection in report table and graph
   
  -- maintainer Stephane MANKOWSKI <stephane@mankowski.fr>  xxx
  
--- trunk/extragear/office/skrooge/skgbasegui/skgtablewithgraph.cpp #1198528:1198529
@@ -764,19 +764,24 @@
     refresh();
 }
 
-void SKGTableWithGraph::onSelectionChanged(QTableWidgetItem* current, \
QTableWidgetItem* previous) +void SKGTableWithGraph::onSelectionChanged()
 {
     if(!m_graphVisible) return;
     _SKGTRACEIN(10, "SKGTableWithGraph::onSelectionChanged");
 
     //Unset color on previous selection
+    int nbRow = ui.kTable->rowCount();
+    int nbCol = ui.kTable->columnCount();
+    for(int r = 0; r < nbRow; ++r) {
+        for(int c = 0; c < nbCol; ++c) {
+            QTableWidgetItem* previous = ui.kTable->item(r, c);
     if(previous) {
         QAbstractGraphicsShapeItem * graphicItem = \
dynamic_cast<QAbstractGraphicsShapeItem *>((QGraphicsItem*) \
previous->data(1).toLongLong());  if(graphicItem) {
             graphicItem->setBrush(QBrush(QColor::fromHsv(graphicItem->data(DATA_COLOR_H).toInt(),
                
                                          graphicItem->data(DATA_COLOR_S).toInt(),
                                          graphicItem->data(DATA_COLOR_V).toInt())));
-            graphicItem->setSelected(false);
+                    if(graphicItem->isSelected()) graphicItem->setSelected(false);
         } else {
             QGraphicsLineItem * graphicItem = dynamic_cast<QGraphicsLineItem \
*>((QGraphicsItem*) previous->data(1).toLongLong());  if(graphicItem) {
@@ -785,28 +790,33 @@
                                              \
                graphicItem->data(DATA_COLOR_S).toInt(),
                                              \
graphicItem->data(DATA_COLOR_V).toInt()));  graphicItem->setPen(pen);
-                graphicItem->setSelected(false);
             }
         }
     }
+        }
+    }
 
     //Set highlight color on current selection
+    QList<QTableWidgetItem*> selected = ui.kTable->selectedItems();
+    int nb = selected.count();
+    for(int i = 0; i < nb; ++i) {
+        QTableWidgetItem* current = selected.at(i);
     if(current) {
         QAbstractGraphicsShapeItem * graphicItem = \
dynamic_cast<QAbstractGraphicsShapeItem *>((QGraphicsItem*) \
current->data(1).toLongLong());  if(graphicItem) {
             graphicItem->setBrush(QBrush(QApplication::palette().color(QPalette::Highlight)));
                
-            graphicItem->setSelected(true);
+                if(!graphicItem->isSelected()) graphicItem->setSelected(true);
         } else {
             QGraphicsLineItem * graphicItem = dynamic_cast<QGraphicsLineItem \
*>((QGraphicsItem*) current->data(1).toLongLong());  if(graphicItem) {
                 QPen pen = graphicItem->pen();
                 pen.setColor(QApplication::palette().color(QPalette::Highlight));
                 graphicItem->setPen(pen);
-                graphicItem->setSelected(false);
             }
         }
     }
 }
+}
 
 void SKGTableWithGraph::onDoubleClickGraph()
 {
@@ -828,11 +838,20 @@
 {
     _SKGTRACEIN(10, "SKGTableWithGraph::onSelectionChangedInGraph");
     if(m_scene) {
+        bool previous = ui.kTable->blockSignals(true);
+        ui.kTable->clearSelection();
+
         //Get selection
         QList<QGraphicsItem *> selectedGraphItems = m_scene->selectedItems();
-        if(selectedGraphItems.count()) {
-            ui.kTable->setCurrentCell(selectedGraphItems[0]->data(1).toInt(), \
selectedGraphItems[0]->data(2).toInt()); +        int nb = \
selectedGraphItems.count(); +        for(int i = 0; i < nb; ++i) {
+            ui.kTable->setCurrentCell(selectedGraphItems[i]->data(1).toInt(), \
selectedGraphItems[i]->data(2).toInt(), QItemSelectionModel::Select);  }
+        ui.kTable->blockSignals(previous);
+
+        previous = m_scene->blockSignals(true);
+        onSelectionChanged();
+        m_scene->blockSignals(previous);
     }
 }
 
--- trunk/extragear/office/skrooge/skgbasegui/skgtablewithgraph.h #1198528:1198529
@@ -242,7 +242,7 @@
 
 private Q_SLOTS:
     void onExport();
-    void onSelectionChanged(QTableWidgetItem* current, QTableWidgetItem* previous);
+    void onSelectionChanged();
     void onSelectionChangedInGraph();
     void onDoubleClick(int row, int column);
     void onDoubleClickGraph();
--- trunk/extragear/office/skrooge/skgbasegui/skgtablewithgraph.ui #1198528:1198529
@@ -106,6 +106,9 @@
             </item>
            </layout>
           </item>
+         </layout>
+        </widget>
+       </item>
           <item>
            <widget class="QTableWidget" name="kTable">
             <property name="editTriggers">
@@ -115,7 +118,7 @@
              <bool>true</bool>
             </property>
             <property name="selectionMode">
-             <enum>QAbstractItemView::SingleSelection</enum>
+          <enum>QAbstractItemView::ExtendedSelection</enum>
             </property>
             <property name="showGrid">
              <bool>false</bool>
@@ -125,9 +128,6 @@
             </property>
            </widget>
           </item>
-         </layout>
-        </widget>
-       </item>
        <item>
         <widget class="SKGWebView" name="kTextEdit"/>
        </item>
@@ -224,29 +224,13 @@
  <connections>
   <connection>
    <sender>kTable</sender>
-   <signal>currentItemChanged(QTableWidgetItem*,QTableWidgetItem*)</signal>
-   <receiver>skgtablewithgraph_base</receiver>
-   <slot>onSelectionChanged(QTableWidgetItem*,QTableWidgetItem*)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>234</x>
-     <y>110</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>572</x>
-     <y>234</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>kTable</sender>
    <signal>cellDoubleClicked(int,int)</signal>
    <receiver>skgtablewithgraph_base</receiver>
    <slot>onDoubleClick(int,int)</slot>
    <hints>
     <hint type="sourcelabel">
      <x>256</x>
-     <y>156</y>
+     <y>90</y>
     </hint>
     <hint type="destinationlabel">
      <x>571</x>
@@ -261,8 +245,8 @@
    <slot>onFilterModified()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>196</x>
-     <y>26</y>
+     <x>377</x>
+     <y>23</y>
     </hint>
     <hint type="destinationlabel">
      <x>569</x>
@@ -270,6 +254,22 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>kTable</sender>
+   <signal>itemSelectionChanged()</signal>
+   <receiver>skgtablewithgraph_base</receiver>
+   <slot>onSelectionChanged()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>132</x>
+     <y>57</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>623</x>
+     <y>110</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>onOneLevelLess()</slot>
@@ -280,7 +280,7 @@
   <slot>onZoomOriginal()</slot>
   <slot>onPrint()</slot>
   <slot>onZoom()</slot>
-  <slot>onSelectionChanged(QTableWidgetItem*,QTableWidgetItem*)</slot>
+  <slot>onSelectionChanged()</slot>
   <slot>onFilterModified()</slot>
  </slots>
 </ui>
--- trunk/extragear/office/skrooge/skrooge_report/skgreportpluginwidget.cpp \
#1198528:1198529 @@ -472,10 +472,23 @@
     SKGError err;
     SKGTRACEINRC(10, "SKGReportPluginWidget::onOpenReport", err);
     QList<QTableWidgetItem *> selection = \
                ui.kTableWithGraph->table()->selectedItems();
-    if(selection.count()) {
+    int nb = selection.count();
+    if(nb) {
         QString wc;
         QString title;
-        getWhereClauseAndTitleForSelection(selection.at(0)->row(), \
selection.at(0)->column(), wc, title); +        for(int i = 0; i < nb; ++i) {
+            QString wc2;
+            QString title2;
+            getWhereClauseAndTitleForSelection(selection.at(i)->row(), \
selection.at(i)->column(), wc2, title2); +            if(!wc2.isEmpty()) {
+                if(!wc.isEmpty()) wc = "(" + wc + ") OR (" + wc2 + ")";
+                else wc = wc2;
+            }
+            if(!title2.isEmpty()) {
+                if(!title.isEmpty()) title = i18n("(%1) or (%2)", title, title2);
+                else title = title2;
+            }
+        }
 
         //Call report plugin
         QDomDocument doc("SKGML");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic