Commit 822cf19c authored by Michael Georg Hansen's avatar Michael Georg Hansen
Browse files

Add a geolocation filter option to the filtering sidebar.

The setting of the filter is not yet restored when digikam is restarted.

CCBUG: 254131
parent d90474b7
......@@ -1405,6 +1405,7 @@ IF(DIGIKAM_CAN_BE_COMPILED)
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/filterstatusbar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/filtersidebarwidget.cpp
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/geolocationfilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/textfilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/mimefilter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/digikam/filters/colorlabelfilter.cpp
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2010 by Johannes Wienke <languitar at semipol dot de>
* Copyright (C) 2010-2011 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -48,6 +49,7 @@
#include "albumsettings.h"
#include "colorlabelfilter.h"
#include "geolocationfilter.h"
#include "picklabelfilter.h"
#include "ratingfilter.h"
#include "mimefilter.h"
......@@ -99,6 +101,7 @@ public:
ImageFilterSettings::MatchingCondition tagMatchCond;
ColorLabelFilter* colorLabelFilter;
GeolocationFilter* geolocationFilter;
PickLabelFilter* pickLabelFilter;
RatingFilter* ratingFilter;
MimeFilter* mimeFilter;
......@@ -137,6 +140,13 @@ FilterSideBarWidget::FilterSideBarWidget(QWidget* parent, TagModel* tagFilterMod
// --------------------------------------------------------------------------------------------------------
d->geolocationFilter = new GeolocationFilter(d->expbox);
d->expbox->addItem(d->geolocationFilter, SmallIcon("applications-internet"),
i18n("Geolocation Filter"), QString("TypeGeolocationFilter"), true);
// --------------------------------------------------------------------------------------------------------
QWidget* box3 = new QWidget(d->expbox);
d->tagFilterModel = tagFilterModel;
d->tagFilterView = new TagFilterView(box3, tagFilterModel);
......@@ -206,6 +216,9 @@ FilterSideBarWidget::FilterSideBarWidget(QWidget* parent, TagModel* tagFilterMod
connect(d->mimeFilter, SIGNAL(activated(int)),
this, SIGNAL(signalMimeTypeFilterChanged(int)));
connect(d->geolocationFilter, SIGNAL(signalFilterChanged(ImageFilterSettings::GeolocationCondition)),
this, SIGNAL(signalGeolocationFilterChanged(ImageFilterSettings::GeolocationCondition)));
connect(d->textFilter, SIGNAL(signalSearchTextFilterSettings(SearchTextFilterSettings)),
this, SIGNAL(signalSearchTextFilterChanged(SearchTextFilterSettings)));
......@@ -275,6 +288,7 @@ void FilterSideBarWidget::slotResetFilters()
{
d->textFilter->reset();
d->mimeFilter->setMimeFilter(MimeFilter::AllFiles);
d->geolocationFilter->setGeolocationFilter(ImageFilterSettings::GeolocationNoFilter);
d->tagFilterView->slotResetCheckState();
d->withoutTagCheckBox->setChecked(false);
d->colorLabelFilter->reset();
......@@ -379,6 +393,8 @@ void FilterSideBarWidget::setConfigGroup(const KConfigGroup& group)
void FilterSideBarWidget::doLoadState()
{
/// @todo mime type and geolocation filter states are not loaded/saved
KConfigGroup group = getConfigGroup();
#if KDCRAW_VERSION >= 0x020000
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2010 by Johannes Wienke <languitar at semipol dot de>
* Copyright (C) 2010-2011 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -95,6 +96,7 @@ Q_SIGNALS:
void signalRatingFilterChanged(int, ImageFilterSettings::RatingCondition);
void signalMimeTypeFilterChanged(int);
void signalGeolocationFilterChanged(ImageFilterSettings::GeolocationCondition);
void signalSearchTextFilterChanged(const SearchTextFilterSettings&);
public Q_SLOTS:
......
......@@ -7,6 +7,7 @@
* Description : a bar to indicate icon-view filters status
*
* Copyright (C) 2007-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -155,6 +156,11 @@ void FilterStatusBar::slotFilterMatches(bool match)
{
filtersList.append(i18n("<br/><nobr><i>Mime Type</i></nobr>"));
}
if (d->settings.isFilteringByGeolocation())
{
filtersList.append(i18n("<br/><nobr><i>Geolocation</i></nobr>"));
}
if (d->settings.isFilteringByRating())
{
......
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2007-10-22
* Description : a widget to filter album contents by geolocation
*
* Copyright (C) 2007-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#include "geolocationfilter.moc"
// KDE includes
#include <klocale.h>
namespace Digikam
{
GeolocationFilter::GeolocationFilter(QWidget* parent)
: KComboBox(parent)
{
addItem( i18n("No geo filtering"), QVariant::fromValue(ImageFilterSettings::GeolocationNoFilter) );
addItem( i18n("Images with coordinates"), QVariant::fromValue(ImageFilterSettings::GeolocationHasCoordinates) );
addItem( i18n("Images without coordinates"), QVariant::fromValue(ImageFilterSettings::GeolocationNoCoordinates) );
setToolTip(i18n("Filter by geolocation"));
setWhatsThis(i18n("Select how geolocation should affect the images which are shown."));
setGeolocationFilter(ImageFilterSettings::GeolocationNoFilter);
connect(this, SIGNAL(activated(int)),
this, SLOT(slotFilterChanged()));
}
GeolocationFilter::~GeolocationFilter()
{
}
void GeolocationFilter::setGeolocationFilter(const ImageFilterSettings::GeolocationCondition& condition)
{
// findData does not seem to work...
// const int newIndex = findData(QVariant::fromValue<ImageFilterSettings::GeolocationCondition>(condition));
for (int i=0; i<count(); ++i)
{
const ImageFilterSettings::GeolocationCondition currentdata = itemData(i).value<ImageFilterSettings::GeolocationCondition>();
if (currentdata == condition)
{
setCurrentIndex(i);
emit signalFilterChanged(condition);
break;
}
}
}
ImageFilterSettings::GeolocationCondition GeolocationFilter::geolocationFilter() const
{
return itemData(currentIndex()).value<ImageFilterSettings::GeolocationCondition>();
}
void GeolocationFilter::slotFilterChanged()
{
emit signalFilterChanged(geolocationFilter());
}
} // namespace Digikam
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2007-10-22
* Description : a widget to filter album contents by geolocation
*
* Copyright (C) 2007-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef GEOLOCATIONFILTER_H
#define GEOLOCATIONFILTER_H
// KDE includes
#include <kcombobox.h>
// local includes
#include "imagefiltersettings.h"
namespace Digikam
{
class GeolocationFilter : public KComboBox
{
Q_OBJECT
public:
GeolocationFilter(QWidget* parent);
~GeolocationFilter();
void setGeolocationFilter(const ImageFilterSettings::GeolocationCondition& condition);
ImageFilterSettings::GeolocationCondition geolocationFilter() const;
Q_SIGNALS:
void signalFilterChanged(const ImageFilterSettings::GeolocationCondition& condition);
private Q_SLOTS:
void slotFilterChanged();
};
} // namespace Digikam
#endif // GEOLOCATIONFILTER_H
......@@ -10,6 +10,7 @@
* Copyright (C) 2002-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2009-2011 by Johannes Wienke <languitar at semipol dot de>
* Copyright (C) 2010-2011 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -470,6 +471,9 @@ void DigikamView::setupConnections()
connect(d->filterWidget, SIGNAL(signalMimeTypeFilterChanged(int)),
model, SLOT(setMimeTypeFilter(int)));
connect(d->filterWidget, SIGNAL(signalGeolocationFilterChanged(ImageFilterSettings::GeolocationCondition)),
model, SLOT(setGeolocationFilter(ImageFilterSettings::GeolocationCondition)));
// -- Preview image widget Connections ------------------------
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2010 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -615,6 +616,13 @@ void ImageFilterModel::setMimeTypeFilter(int mimeTypeFilter)
setImageFilterSettings(d->filter);
}
void ImageFilterModel::setGeolocationFilter(const ImageFilterSettings::GeolocationCondition& condition)
{
Q_D(ImageFilterModel);
d->filter.setGeolocationFilter(condition);
setImageFilterSettings(d->filter);
}
void ImageFilterModel::setTextFilter(const SearchTextFilterSettings& settings)
{
Q_D(ImageFilterModel);
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2010 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -181,6 +182,7 @@ public Q_SLOTS:
const QList<int>& clTagIds, const QList<int>& plTagIds);
void setRatingFilter(int rating, ImageFilterSettings::RatingCondition ratingCond);
void setMimeTypeFilter(int mimeTypeFilter);
void setGeolocationFilter(const ImageFilterSettings::GeolocationCondition& condition);
void setTextFilter(const SearchTextFilterSettings& settings);
void setCategorizationMode(ImageSortSettings::CategorizationMode mode);
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2010 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -45,11 +46,12 @@ namespace Digikam
ImageFilterSettings::ImageFilterSettings()
{
m_untaggedFilter = false;
m_ratingFilter = 0;
m_mimeTypeFilter = MimeFilter::AllFiles;
m_ratingCond = GreaterEqualCondition;
m_matchingCond = OrCondition;
m_untaggedFilter = false;
m_ratingFilter = 0;
m_mimeTypeFilter = MimeFilter::AllFiles;
m_ratingCond = GreaterEqualCondition;
m_matchingCond = OrCondition;
m_geolocationCondition = GeolocationNoFilter;
}
DatabaseFields::Set ImageFilterSettings::watchFlags() const
......@@ -77,6 +79,11 @@ DatabaseFields::Set ImageFilterSettings::watchFlags() const
set |= DatabaseFields::Category;
set |= DatabaseFields::Format;
}
if (isFilteringByGeolocation())
{
set |= DatabaseFields::ImagePositionsAll;
}
if (isFilteringByColorLabels())
{
......@@ -151,6 +158,11 @@ bool ImageFilterSettings::isFilteringByTypeMime() const
return false;
}
bool ImageFilterSettings::isFilteringByGeolocation() const
{
return (m_geolocationCondition != GeolocationNoFilter);
}
bool ImageFilterSettings::isFilteringByRating() const
{
if (m_ratingFilter != 0 || m_ratingCond != GreaterEqualCondition)
......@@ -174,7 +186,8 @@ bool ImageFilterSettings::isFiltering() const
isFilteringByRating() ||
isFilteringByTypeMime() ||
isFilteringByColorLabels() ||
isFilteringByPickLabels();
isFilteringByPickLabels() ||
isFilteringByGeolocation();
}
void ImageFilterSettings::setDayFilter(const QList<QDateTime>& days)
......@@ -213,6 +226,11 @@ void ImageFilterSettings::setMimeTypeFilter(int mime)
m_mimeTypeFilter = (MimeFilter::TypeMimeFilter)mime;
}
void ImageFilterSettings::setGeolocationFilter(const GeolocationCondition& condition)
{
m_geolocationCondition = condition;
}
void ImageFilterSettings::setTextFilter(const SearchTextFilterSettings& settings)
{
m_textFilterSettings = settings;
......@@ -515,6 +533,25 @@ bool ImageFilterSettings::matches(const ImageInfo& info, bool* foundText) const
break;
}
}
//-- Filter by geolocation ----------------------------------------------------
if (m_geolocationCondition!=GeolocationNoFilter)
{
if (m_geolocationCondition==GeolocationNoCoordinates)
{
if (info.hasCoordinates())
{
match = false;
}
}
else if (m_geolocationCondition==GeolocationHasCoordinates)
{
if (!info.hasCoordinates())
{
match = false;
}
}
}
//-- Filter by text -----------------------------------------------------------
......
......@@ -9,6 +9,7 @@
* Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
* Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2010 by Andi Clemens <andi dot clemens at gmx dot net>
* Copyright (C) 2011 by Michael G. Hansen <mike at mghansen dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
......@@ -152,6 +153,18 @@ public:
/// --- Mime filter ---
void setMimeTypeFilter(int mimeTypeFilter);
public:
/// --- Geolocation filter
enum GeolocationCondition
{
GeolocationNoFilter = 0,
GeolocationNoCoordinates = 1 << 1,
GeolocationHasCoordinates = 1 << 2
};
void setGeolocationFilter(const GeolocationCondition& condition);
public:
......@@ -160,6 +173,9 @@ public:
/// Returns if the type mime is a filter criteria
bool isFilteringByTypeMime() const;
/// Returns whether geolocation is a filter criteria
bool isFilteringByGeolocation() const;
/// Returns if the rating is a filter criteria
bool isFilteringByRating() const;
......@@ -232,6 +248,9 @@ private:
/// --- Mime filter ---
MimeFilter::TypeMimeFilter m_mimeTypeFilter;
/// --- Geolocation filter
GeolocationCondition m_geolocationCondition;
/// --- URL whitelist filter
QHash<QString,KUrl::List> m_urlWhitelists;
......@@ -324,4 +343,6 @@ protected:
} // namespace Digikam
Q_DECLARE_METATYPE(Digikam::ImageFilterSettings::GeolocationCondition)
#endif // IMAGEFILTERSETTINGS_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment