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

List:       kde-commits
Subject:    branches/extragear/graphics/libkmap/libkmap
From:       Michael Georg Hansen <mike () mghansen ! de>
Date:       2010-07-31 13:56:43
Message-ID: 20100731135643.EC634AC783 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1157548 by mghansen:

Some refactoring: Handle clicks on items in abstractmarkertiler and derivatives now. This will need some \
adaption to mouse modes later.



 M  +2 -1      abstractmarkertiler.cpp  
 M  +1 -7      abstractmarkertiler.h  
 M  +20 -14    itemmarkertiler.cpp  
 M  +3 -6      itemmarkertiler.h  
 M  +5 -15     kmap.cpp  


--- branches/extragear/graphics/libkmap/libkmap/abstractmarkertiler.cpp #1157547:1157548
@@ -505,9 +505,10 @@
     return d->rootTile;
 }
 
-void AbstractMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList)
+void AbstractMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, const \
WMWSelectionState& groupSelectionState)  {
     Q_UNUSED(tileIndicesList);
+    Q_UNUSED(groupSelectionState);
 }
 
 void AbstractMarkerTiler::onIndicesMoved(const TileIndex::List& tileIndicesList, const WMWGeoCoordinate& \
                targetCoordinates,
--- branches/extragear/graphics/libkmap/libkmap/abstractmarkertiler.h #1157547:1157548
@@ -320,12 +320,6 @@
     AbstractMarkerTiler(QObject* const parent = 0);
     ~AbstractMarkerTiler();
 
-    // these should actually be removed later, after some refactoring
-    virtual bool isItemModelBased() const = 0;
-    virtual QItemSelectionModel* getSelectionModel() const = 0;
-    virtual QAbstractItemModel* getModel() const = 0;
-    virtual QList<QPersistentModelIndex> getTileMarkerIndices(const TileIndex& tileIndex) = 0;
-
     // these have to be implemented
     virtual void prepareTiles(const WMWGeoCoordinate& upperLeft, const WMWGeoCoordinate& lowerRight, int \
level) = 0;  virtual void regenerateTiles() = 0;
@@ -341,7 +335,7 @@
     virtual WMWSelectionState getTileSelectedState(const TileIndex& tileIndex) = 0;
 
     // these can be implemented if you want to react to actions in kmap
-    virtual void onIndicesClicked(const TileIndex::List& tileIndicesList);
+    virtual void onIndicesClicked(const TileIndex::List& tileIndicesList, const WMWSelectionState& \
                groupSelectionState);
     virtual void onIndicesMoved(const TileIndex::List& tileIndicesList, const WMWGeoCoordinate& \
targetCoordinates, const QPersistentModelIndex& targetSnapIndex);  
     Tile* rootTile();
--- branches/extragear/graphics/libkmap/libkmap/itemmarkertiler.cpp #1157547:1157548
@@ -55,16 +55,6 @@
     delete d;
 }
 
-QItemSelectionModel* ItemMarkerTiler::getSelectionModel() const
-{
-    return d->selectionModel;
-}
-
-QAbstractItemModel* ItemMarkerTiler::getModel() const
-{
-    return d->markerModel;
-}
-
 void ItemMarkerTiler::setMarkerModelHelper(WMWModelHelper* const modelHelper)
 {
     d->modelHelper    = modelHelper;
@@ -553,16 +543,32 @@
     return a.value<QPersistentModelIndex>()==b.value<QPersistentModelIndex>();
 }
 
-bool ItemMarkerTiler::isItemModelBased() const
+void ItemMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, const WMWSelectionState& \
groupSelectionState)  {
-    return true;
+    QList<QPersistentModelIndex> clickedMarkers;
+    for (int i=0; i<tileIndicesList.count(); ++i)
+    {
+        const AbstractMarkerTiler::TileIndex tileIndex = tileIndicesList.at(i);
+
+        clickedMarkers << getTileMarkerIndices(tileIndex);
 }
 
-void ItemMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList)
+    const bool doSelect = groupSelectionState!=WMWSelectedAll;
+    if (d->selectionModel)
 {
-    Q_UNUSED(tileIndicesList);
+        for (int i=0; i<clickedMarkers.count(); ++i)
+        {
+            if (d->selectionModel->isSelected(clickedMarkers.at(i))!=doSelect)
+            {
+                d->selectionModel->select(clickedMarkers.at(i), (doSelect ? QItemSelectionModel::Select \
: QItemSelectionModel::Deselect) | QItemSelectionModel::Rows);  }
+        }
+    }
 
+    // TODO: when do we report the clicks to the modelHelper?
+    d->modelHelper->onIndicesClicked(clickedMarkers);
+}
+
 void ItemMarkerTiler::onIndicesMoved(const TileIndex::List& tileIndicesList, const WMWGeoCoordinate& \
targetCoordinates, const QPersistentModelIndex& targetSnapIndex)  {
     QList<QPersistentModelIndex> movedMarkers;
--- branches/extragear/graphics/libkmap/libkmap/itemmarkertiler.h #1157547:1157548
@@ -43,11 +43,6 @@
     ItemMarkerTiler(WMWModelHelper* const modelHelper, QObject* const parent = 0);
     ~ItemMarkerTiler();
 
-    virtual bool isItemModelBased() const;
-    virtual QItemSelectionModel* getSelectionModel() const;
-    virtual QAbstractItemModel* getModel() const;
-    virtual QList<QPersistentModelIndex> getTileMarkerIndices(const TileIndex& tileIndex);
-
     virtual void prepareTiles(const WMWGeoCoordinate& upperLeft, const WMWGeoCoordinate& lowerRight, int \
level);  virtual void regenerateTiles();
     virtual Tile* getTile(const TileIndex& tileIndex, const bool stopIfEmpty = false);
@@ -60,7 +55,7 @@
     virtual bool indicesEqual(const QVariant& a, const QVariant& b) const;
     virtual WMWSelectionState getTileSelectedState(const TileIndex& tileIndex);
 
-    virtual void onIndicesClicked(const TileIndex::List& tileIndicesList);
+    virtual void onIndicesClicked(const TileIndex::List& tileIndicesList, const WMWSelectionState& \
                groupSelectionState);
     virtual void onIndicesMoved(const TileIndex::List& tileIndicesList, const WMWGeoCoordinate& \
                targetCoordinates,
                                 const QPersistentModelIndex& targetSnapIndex);
 
@@ -79,6 +74,8 @@
 
 private:
 
+    QList<QPersistentModelIndex> getTileMarkerIndices(const TileIndex& tileIndex);
+
     class ItemMarkerTilerPrivate;
     ItemMarkerTilerPrivate* const d;
 };
--- branches/extragear/graphics/libkmap/libkmap/kmap.cpp #1157547:1157548
@@ -1363,9 +1363,6 @@
 void KMap::slotClustersClicked(const QIntList& clusterIndices)
 {
     kDebug()<<clusterIndices;
-    QItemSelectionModel* const selectionModel = s->markerModel->getSelectionModel();
-    if (!selectionModel)
-        return;
 
     // update the selection state of the clusters
     for (int i=0; i<clusterIndices.count(); ++i)
@@ -1375,24 +1372,17 @@
         const WMWCluster currentCluster = s->clusterList.at(clusterIndex);
 
         const bool doSelect = (currentCluster.selectedState!=WMWSelectedAll);
-        kDebug()<<doSelect;
+
+        // TODO: use a consistent format for tile indices
+        AbstractMarkerTiler::TileIndex::List tileIndices;
         for (int j=0; j<currentCluster.tileIndicesList.count(); ++j)
         {
             const AbstractMarkerTiler::TileIndex& currentTileIndex = \
                AbstractMarkerTiler::TileIndex::fromIntList(currentCluster.tileIndicesList.at(j));
-
-            const QList<QPersistentModelIndex> currentMarkers = \
                s->markerModel->getTileMarkerIndices(currentTileIndex);
-            kDebug()<<currentTileIndex<<currentMarkers;
-            for (int k=0; k<currentMarkers.count(); ++k)
-            {
-                kDebug()<<k<<currentMarkers.at(k)<<doSelect;
-                if (selectionModel->isSelected(currentMarkers.at(k))!=doSelect)
-                {
-                    selectionModel->select(currentMarkers.at(k), (doSelect ? QItemSelectionModel::Select \
: QItemSelectionModel::Deselect) | QItemSelectionModel::Rows); +            tileIndices << \
currentTileIndex;  }
+        s->markerModel->onIndicesClicked(tileIndices, currentCluster.selectedState);
             }
         }
-    }
-}
 
 void KMap::dragEnterEvent(QDragEnterEvent* event)
 {


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

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