[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/extragear/graphics/digikam
From: Michael Georg Hansen <mike () mghansen ! de>
Date: 2011-01-24 19:35:48
Message-ID: 20110124193548.9D5BBAC8B9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1216785 by mghansen:
Selecting thumbnails on the map now sets their representative marker (the image which \
is used as the thumbnail) as the current index in the selection model.
M +25 -10 core/utilities/gpssearch/gpsmarkertiler.cpp
M +2 -1 core/utilities/gpssearch/gpsmarkertiler.h
M +2 -1 extra/libkmap/libkmap/abstractmarkertiler.cpp
M +4 -2 extra/libkmap/libkmap/abstractmarkertiler.h
M +24 -8 extra/libkmap/libkmap/itemmarkertiler.cpp
M +2 -1 extra/libkmap/libkmap/itemmarkertiler.h
M +19 -19 extra/libkmap/libkmap/kmap_widget.cpp
--- branches/extragear/graphics/digikam/core/utilities/gpssearch/gpsmarkertiler.cpp \
#1216784:1216785 @@ -781,8 +781,11 @@
emit(signalTilesOrSelectionChanged());
}
-void GPSMarkerTiler::onIndicesClicked(const KMap::TileIndex::List& tileIndicesList, \
const KMap::KMapGroupState& groupSelectionState, KMap::MouseMode currentMouseMode) \
+void GPSMarkerTiler::onIndicesClicked(const KMap::TileIndex::List& tileIndicesList, \
const QVariant& representativeIndex, + const \
KMap::KMapGroupState& groupSelectionState, const KMap::MouseModes currentMouseMode) \
{ + /// @todo Also handle the representative index
+
QList<qlonglong> clickedImagesId;
for (int i=0; i<tileIndicesList.count(); ++i)
@@ -791,31 +794,43 @@
clickedImagesId << getTileMarkerIds(tileIndex);
}
- if (currentMouseMode == KMap::MouseModeSelectThumbnail)
+ int repImageId = -1;
+ if (representativeIndex.canConvert<QPair<KMap::TileIndex, int> >())
{
+ repImageId = representativeIndex.value<QPair<KMap::TileIndex, int> \
>().second; + }
+
+ if (currentMouseMode == KMap::MouseModeSelectThumbnail && d->selectionModel)
+ {
/**
* @todo This does not work properly, because not all images in a tile
* may be selectable because some of them are outside of the region \
selection
*/
- const bool doSelect = groupSelectionState != KMap::KMapSelectedAll;
+ const bool doSelect = (groupSelectionState & KMap::KMapSelectedMask) != \
KMap::KMapSelectedAll;
- if (d->selectionModel)
- {
+ const QItemSelectionModel::SelectionFlags selectionFlags =
+ (doSelect ? QItemSelectionModel::Select : \
QItemSelectionModel::Deselect) + | QItemSelectionModel::Rows;
+
for (int i=0; i<clickedImagesId.count(); ++i)
{
const QModelIndex currentIndex = \
d->imageFilterModel->indexForImageId(clickedImagesId.at(i));
if (d->selectionModel->isSelected(currentIndex) != doSelect)
{
- d->selectionModel->select(
- currentIndex,
- (doSelect ? QItemSelectionModel::Select : \
QItemSelectionModel::Deselect)
- | QItemSelectionModel::Rows
- );
+ d->selectionModel->select(currentIndex, selectionFlags);
}
}
+
+ if (repImageId>=0)
+ {
+ const QModelIndex repImageIndex = \
d->imageFilterModel->indexForImageId(repImageId); + if \
(repImageIndex.isValid()) + {
+ d->selectionModel->setCurrentIndex(repImageIndex, selectionFlags);
}
}
+ }
else if (currentMouseMode == KMap::MouseModeFilter)
{
setPositiveFilterIsActive(true);
--- branches/extragear/graphics/digikam/core/utilities/gpssearch/gpsmarkertiler.h \
#1216784:1216785 @@ -90,7 +90,8 @@
virtual KMap::KMapGroupState getTileGroupState(const KMap::TileIndex& \
tileIndex); virtual KMap::KMapGroupState getGlobalGroupState();
- virtual void onIndicesClicked(const KMap::TileIndex::List& tileIndicesList, \
const KMap::KMapGroupState& groupSelectionState, KMap::MouseMode currentMouseMode); + \
virtual void onIndicesClicked(const KMap::TileIndex::List& tileIndicesList, const \
QVariant& representativeIndex, + const \
KMap::KMapGroupState& groupSelectionState, const KMap::MouseModes currentMouseMode); \
virtual void setActive(const bool state);
--- branches/extragear/graphics/digikam/extra/libkmap/libkmap/abstractmarkertiler.cpp \
#1216784:1216785 @@ -407,7 +407,8 @@
return d->rootTile;
}
-void AbstractMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, \
const KMapGroupState& groupSelectionState, MouseMode currentMouseMode) +void \
AbstractMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, const \
QVariant& representativeIndex, + const \
KMapGroupState& groupSelectionState, const MouseModes currentMouseMode) {
Q_UNUSED(tileIndicesList);
Q_UNUSED(groupSelectionState);
--- branches/extragear/graphics/digikam/extra/libkmap/libkmap/abstractmarkertiler.h \
#1216784:1216785 @@ -207,8 +207,10 @@
// these can be implemented if you want to react to actions in kmap
/// @todo Make currentMouseMode const
- virtual void onIndicesClicked(const TileIndex::List& tileIndicesList, const \
KMapGroupState& groupSelectionState, MouseMode currentMouseMode);
- virtual void onIndicesMoved(const TileIndex::List& tileIndicesList, const \
GeoCoordinates& targetCoordinates, const QPersistentModelIndex& targetSnapIndex); + \
virtual void onIndicesClicked(const TileIndex::List& tileIndicesList, const QVariant& \
representativeIndex, + const KMapGroupState& \
groupSelectionState, const MouseModes currentMouseMode); + virtual void \
onIndicesMoved(const TileIndex::List& tileIndicesList, const GeoCoordinates& \
targetCoordinates, + const QPersistentModelIndex& \
targetSnapIndex);
virtual void setActive(const bool state) = 0;
Tile* rootTile();
--- branches/extragear/graphics/digikam/extra/libkmap/libkmap/itemmarkertiler.cpp \
#1216784:1216785 @@ -611,7 +611,8 @@
return a.value<QPersistentModelIndex>()==b.value<QPersistentModelIndex>();
}
-void ItemMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, const \
KMapGroupState& groupSelectionState, MouseMode currentMouseMode) +void \
ItemMarkerTiler::onIndicesClicked(const TileIndex::List& tileIndicesList, const \
QVariant& representativeIndex, + const \
KMapGroupState& groupSelectionState, const MouseModes currentMouseMode) {
QList<QPersistentModelIndex> clickedMarkers;
for (int i=0; i<tileIndicesList.count(); ++i)
@@ -620,30 +621,45 @@
clickedMarkers << getTileMarkerIndices(tileIndex);
}
- if (currentMouseMode == MouseModeSelectThumbnail)
+
+ const QPersistentModelIndex representativeModelIndex = \
representativeIndex.value<QPersistentModelIndex>(); +
+ if (currentMouseMode == MouseModeSelectThumbnail && d->selectionModel)
{
- const bool doSelect = groupSelectionState!=KMapSelectedAll;
- if (d->selectionModel)
- {
+ const bool doSelect = (groupSelectionState & KMapSelectedMask) != \
KMapSelectedAll; +
+ const QItemSelectionModel::SelectionFlags selectionFlags =
+ (doSelect ? QItemSelectionModel::Select : \
QItemSelectionModel::Deselect) + | QItemSelectionModel::Rows;
+
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); + \
d->selectionModel->select(clickedMarkers.at(i), selectionFlags); }
}
+
+ if (representativeModelIndex.isValid())
+ {
+ d->selectionModel->setCurrentIndex(representativeModelIndex, \
selectionFlags); }
- // TODO: when do we report the clicks to the modelHelper?
+ /**
+ * @todo When do we report the clicks to the modelHelper?
+ * Or do we only report selection changes to the selection model?
+ */
//d->modelHelper->onIndicesClicked(clickedMarkers);
}
else if (currentMouseMode == MouseModeFilter)
{
+ /// @todo Also forward the representative index in this call
d->modelHelper->onIndicesClicked(clickedMarkers);
}
}
-void ItemMarkerTiler::onIndicesMoved(const TileIndex::List& tileIndicesList, const \
GeoCoordinates& targetCoordinates, const QPersistentModelIndex& targetSnapIndex) \
+void ItemMarkerTiler::onIndicesMoved(const TileIndex::List& tileIndicesList, const \
GeoCoordinates& targetCoordinates, + const \
QPersistentModelIndex& targetSnapIndex) {
QList<QPersistentModelIndex> movedMarkers;
if (tileIndicesList.isEmpty())
--- branches/extragear/graphics/digikam/extra/libkmap/libkmap/itemmarkertiler.h \
#1216784:1216785 @@ -71,7 +71,8 @@
virtual KMapGroupState getTileGroupState(const TileIndex& tileIndex);
virtual KMapGroupState getGlobalGroupState();
- virtual void onIndicesClicked(const TileIndex::List& tileIndicesList, const \
KMapGroupState& groupSelectionState, MouseMode currentMouseMode); + virtual void \
onIndicesClicked(const TileIndex::List& tileIndicesList, const QVariant& \
representativeIndex, + const KMapGroupState& \
groupSelectionState, const MouseModes currentMouseMode);
virtual void onIndicesMoved(const TileIndex::List& tileIndicesList, const \
GeoCoordinates& targetCoordinates,
const QPersistentModelIndex& targetSnapIndex);
--- branches/extragear/graphics/digikam/extra/libkmap/libkmap/kmap_widget.cpp \
#1216784:1216785 @@ -1319,14 +1319,18 @@
slotClustersNeedUpdating();
}
+/**
+ * @todo Clicking on several clusters at once is not actually possible
+ */
void KMapWidget::slotClustersClicked(const QIntList& clusterIndices)
{
kDebug()<<clusterIndices;
+ if ( (s->currentMouseMode == MouseModeZoomIntoGroup)
+ || (s->currentMouseMode == MouseModeRegionSelectionFromIcon) )
+ {
int maxTileLevel = 0;
- if ((s->currentMouseMode == MouseModeZoomIntoGroup) || (s->currentMouseMode == \
MouseModeRegionSelectionFromIcon))
- {
Marble::GeoDataLineString tileString;
for (int i=0; i<clusterIndices.count(); ++i)
@@ -1356,7 +1360,9 @@
\
Marble::GeoDataCoordinates::Degree);
if (maxTileLevel < currentTileIndex.level())
+ {
maxTileLevel = currentTileIndex.level();
+ }
tileString.append(tileCoordinate);
}
@@ -1383,6 +1389,7 @@
// }
if (s->currentMouseMode == MouseModeZoomIntoGroup)
{
+ /// @todo Very small latLonBoxes can crash Marble
d->currentBackend->centerOn(latLonBox);
}
else
@@ -1399,32 +1406,25 @@
emit(signalRegionSelectionChanged());
}
}
- else if ((s->currentMouseMode == MouseModeFilter && \
s->selectionRectangle.first.hasCoordinates()) || (s->currentMouseMode == \
MouseModeSelectThumbnail)) + else if ( (s->currentMouseMode == MouseModeFilter \
&& s->selectionRectangle.first.hasCoordinates()) + || \
(s->currentMouseMode == MouseModeSelectThumbnail) ) {
- // update the selection state of the clusters
+ // update the selection and filtering state of the clusters
for (int i=0; i<clusterIndices.count(); ++i)
{
const int clusterIndex = clusterIndices.at(i);
const KMapCluster currentCluster = s->clusterList.at(clusterIndex);
- /// @todo use a consistent format for tile indices
- TileIndex::List tileIndices;
- for (int j=0; j<currentCluster.tileIndicesList.count(); ++j)
- {
- const TileIndex& currentTileIndex = \
currentCluster.tileIndicesList.at(j);
- tileIndices << currentTileIndex;
+ const TileIndex::List tileIndices = currentCluster.tileIndicesList;
+
+ /// @todo Isn't this cached in the cluster?
+ const QVariant representativeIndex = \
getClusterRepresentativeMarker(clusterIndex, s->sortKey); +
+ s->markerModel->onIndicesClicked(tileIndices, representativeIndex,
+ currentCluster.groupState, \
s->currentMouseMode); }
- if (s->currentMouseMode == MouseModeFilter)
- {
- s->markerModel->onIndicesClicked(tileIndices, \
currentCluster.groupState, MouseModeFilter); }
- else
- {
- s->markerModel->onIndicesClicked(tileIndices, \
currentCluster.groupState, MouseModeSelectThumbnail); }
- }
- }
-}
void KMapWidget::dragEnterEvent(QDragEnterEvent* event)
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic