[Digikam-devel] branches/extragear/kde3/graphics/digikam/digikam
Gilles Caulier
caulier.gilles at gmail.com
Sun Nov 18 14:09:01 GMT 2007
SVN commit 738271 by cgilles:
digiKam from KDE3 branch : new text filter on status bar to filter current album contents based on item name, comments and tags strings.
CCMAIL: digikam-devel at kde.org
BUG: 110136
CCBUGS: 139283
CCBUGS: 133191
M +1 -1 albumiconview.cpp
M +37 -9 albumlister.cpp
M +3 -1 albumlister.h
M +14 -0 albumsettings.cpp
M +3 -0 albumsettings.h
M +21 -0 digikamapp.cpp
M +1 -0 digikamapp.h
M +4 -0 digikamappprivate.h
--- branches/extragear/kde3/graphics/digikam/digikam/albumiconview.cpp #738270:738271
@@ -287,7 +287,7 @@
d->albumSettings = settings;
- d->imageLister->setNameFilter(d->albumSettings->getAllFileFilter());
+ d->imageLister->setNamesFilter(d->albumSettings->getAllFileFilter());
d->thumbSize = (ThumbnailSize::Size)d->albumSettings->getDefaultIconSize();
--- branches/extragear/kde3/graphics/digikam/digikam/albumlister.cpp #738270:738271
@@ -78,7 +78,7 @@
filterTimer = 0;
job = 0;
currAlbum = 0;
- filter = "*";
+ namesFilter = "*";
mimeTypeFilter = MimeFilter::AllFiles;
ratingCond = AlbumLister::GreaterEqualCondition;
matchingCond = AlbumLister::OrCondition;
@@ -86,7 +86,8 @@
bool untaggedFilter;
- QString filter;
+ QString namesFilter;
+ QString textFilter;
QMap<Q_LLONG, ImageInfo*> itemMap;
QMap<int,int> invalidatedItems;
@@ -161,7 +162,7 @@
QDataStream ds(ba, IO_WriteOnly);
ds << AlbumManager::instance()->getLibraryPath();
ds << album->kurl();
- ds << d->filter;
+ ds << d->namesFilter;
ds << AlbumSettings::instance()->getIconShowResolution();
// Protocol = digikamalbums -> kio_digikamalbums
@@ -199,7 +200,7 @@
QDataStream ds(ba, IO_WriteOnly);
ds << AlbumManager::instance()->getLibraryPath();
ds << d->currAlbum->kurl();
- ds << d->filter;
+ ds << d->namesFilter;
ds << AlbumSettings::instance()->getIconShowResolution();
d->job = new KIO::TransferJob(d->currAlbum->kurl(), KIO::CMD_SPECIAL,
@@ -244,9 +245,15 @@
d->filterTimer->start(100, true);
}
+void AlbumLister::setTextFilter(const QString& text)
+{
+ d->textFilter = text;
+ d->filterTimer->start(100, true);
+}
+
bool AlbumLister::matchesFilter(const ImageInfo* info) const
{
- if (d->dayFilter.isEmpty() && d->tagFilter.isEmpty() &&
+ if (d->dayFilter.isEmpty() && d->tagFilter.isEmpty() && d->textFilter.isEmpty() &&
!d->untaggedFilter && d->ratingFilter==-1)
return true;
@@ -298,7 +305,8 @@
match &= d->dayFilter.contains(info->dateTime().date().day());
}
- // Filter by rating.
+ //-- Filter by rating ---------------------------------------------------------
+
if (d->ratingFilter >= 0)
{
if (d->ratingCond == GreaterEqualCondition)
@@ -327,7 +335,8 @@
}
}
- // Filter by mime type.
+ // -- Filter by mime type -----------------------------------------------------
+
QFileInfo fi(info->filePath());
QString mimeType = fi.extension(false).upper();
@@ -377,6 +386,25 @@
break;
}
+ //-- Filter by text -----------------------------------------------------------
+
+ AlbumSettings *settings = AlbumSettings::instance();
+ if (settings->getIconShowName())
+ {
+ if (info->name().contains(d->textFilter) == false)
+ match = false;
+ }
+ else if (settings->getIconShowComments())
+ {
+ if (info->caption().contains(d->textFilter) == false)
+ match = false;
+ }
+ else if (settings->getIconShowTags())
+ {
+ if (info->tagNames().contains(d->textFilter) == false)
+ match = false;
+ }
+
return match;
}
@@ -396,9 +424,9 @@
}
}
-void AlbumLister::setNameFilter(const QString& nameFilter)
+void AlbumLister::setNamesFilter(const QString& namesFilter)
{
- d->filter = nameFilter;
+ d->namesFilter = namesFilter;
}
void AlbumLister::invalidateItem(const ImageInfo *item)
--- branches/extragear/kde3/graphics/digikam/digikam/albumlister.h #738270:738271
@@ -99,7 +99,7 @@
*/
void refresh();
- void setNameFilter(const QString& nameFilter);
+ void setNamesFilter(const QString& namesFilter);
void setDayFilter(const QValueList<int>& days);
@@ -109,6 +109,8 @@
void setRatingFilter(int rating, const RatingCondition& ratingCond);
void setMimeTypeFilter(int mimeTypeFilter);
+
+ void setTextFilter(const QString& text);
/**
* Trigger a recreation of the given ImageInfo object
--- branches/extragear/kde3/graphics/digikam/digikam/albumsettings.cpp #738270:738271
@@ -115,6 +115,7 @@
QString defaultMovieFilefilter;
QString defaultAudioFilefilter;
QString defaultRawFilefilter;
+ QString textFilter;
QString author;
QString authorTitle;
@@ -192,6 +193,7 @@
d->thumbnailSize = ThumbnailSize::Medium;
d->treeThumbnailSize = 32;
+ d->textFilter = QString();
d->mimeTypeFilter = MimeFilter::AllFiles;
d->ratingFilterValue = 0;
@@ -278,6 +280,7 @@
d->treeThumbnailSize = config->readNumEntry("Default Tree Icon Size", ThumbnailSize::Tiny);
d->currentTheme = config->readEntry("Theme", i18n("Default"));
+ d->textFilter = config->readEntry("Text Filter", QString());
d->mimeTypeFilter = config->readNumEntry("Mime Type Filter", MimeFilter::AllFiles);
d->ratingFilterValue = config->readNumEntry("Rating Filter Value", 0);
@@ -368,6 +371,7 @@
config->writeEntry("Raw File Filter", d->rawFilefilter);
config->writeEntry("Default Icon Size", QString::number(d->thumbnailSize));
config->writeEntry("Default Tree Icon Size", QString::number(d->treeThumbnailSize));
+ config->writeEntry("Text Filter", d->textFilter);
config->writeEntry("Mime Type Filter", d->mimeTypeFilter);
config->writeEntry("Rating Filter Value", d->ratingFilterValue);
config->writeEntry("Rating Filter Condition", d->ratingFilterCond);
@@ -605,6 +609,16 @@
return ((d->treeThumbnailSize < 8) || (d->treeThumbnailSize > 48)) ? 48 : d->treeThumbnailSize;
}
+void AlbumSettings::setTextFilter(const QString& text)
+{
+ d->textFilter = text;
+}
+
+QString AlbumSettings::getTextFilter() const
+{
+ return d->textFilter;
+}
+
void AlbumSettings::setMimeTypeFilter(int val)
{
d->mimeTypeFilter = val;
--- branches/extragear/kde3/graphics/digikam/digikam/albumsettings.h #738270:738271
@@ -119,6 +119,9 @@
void setDefaultTreeIconSize(int val);
int getDefaultTreeIconSize() const;
+ void setTextFilter(const QString& text);
+ QString getTextFilter() const;
+
void setMimeTypeFilter(int val);
int getMimeTypeFilter() const;
--- branches/extragear/kde3/graphics/digikam/digikam/digikamapp.cpp #738270:738271
@@ -29,12 +29,14 @@
#include <qlabel.h>
#include <qstringlist.h>
#include <qtooltip.h>
+#include <qwhatsthis.h>
#include <qsignalmapper.h>
#include <qdockarea.h>
#include <qhbox.h>
// KDE includes.
+#include <klineedit.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kstandarddirs.h>
@@ -196,6 +198,7 @@
if (d->view)
delete d->view;
+ d->albumSettings->setTextFilter(d->statusTextFilterBar->text());
d->albumSettings->setMimeTypeFilter(d->statusMimeFilterBar->mimeFilter());
d->albumSettings->setRatingFilterCond(d->statusRatingFilterBar->ratingFilterCondition());
d->albumSettings->setRatingFilterValue(d->statusRatingFilterBar->rating());
@@ -362,6 +365,15 @@
//------------------------------------------------------------------------------
+ d->statusTextFilterBar = new KLineEdit(statusBar());
+ d->statusTextFilterBar->setMaximumHeight(fontMetrics().height()+2);
+ QToolTip::add(d->statusTextFilterBar, i18n("Text pattern filter"));
+ QWhatsThis::add(d->statusTextFilterBar, i18n("Set here the text pattern to filter albums contents "
+ "based on items name, comments, and tags"));
+ statusBar()->addWidget(d->statusTextFilterBar, 30, true);
+
+ //------------------------------------------------------------------------------
+
d->statusMimeFilterBar = new MimeFilter(statusBar());
d->statusMimeFilterBar->setMaximumHeight(fontMetrics().height()+2);
statusBar()->addWidget(d->statusMimeFilterBar, 1, true);
@@ -393,6 +405,9 @@
connect(d->statusMimeFilterBar, SIGNAL(activated(int)),
this, SLOT(slotMimeTypeFilterChanged(int)));
+ connect(d->statusTextFilterBar, SIGNAL(textChanged(const QString&)),
+ this, SLOT(slotTextFilterChanged(const QString&)));
+
connect(d->statusZoomBar, SIGNAL(signalZoomMinusClicked()),
d->view, SLOT(slotZoomOut()));
@@ -1006,6 +1021,7 @@
d->albumSortAction->setCurrentItem((int)d->albumSettings->getAlbumSortOrder());
d->imageSortAction->setCurrentItem((int)d->albumSettings->getImageSortOrder());
+ d->statusTextFilterBar->setText(d->albumSettings->getTextFilter());
d->statusMimeFilterBar->setMimeFilter(d->albumSettings->getMimeTypeFilter());
d->statusRatingFilterBar->setRating(d->albumSettings->getRatingFilterValue());
@@ -1931,6 +1947,11 @@
AlbumLister::instance()->setMimeTypeFilter(mimeTypeFilter);
}
+void DigikamApp::slotTextFilterChanged(const QString& text)
+{
+ AlbumLister::instance()->setTextFilter(text);
+}
+
void DigikamApp::slotZoomSliderChanged(int size)
{
d->view->setThumbSize(size);
--- branches/extragear/kde3/graphics/digikam/digikam/digikamapp.h #738270:738271
@@ -123,6 +123,7 @@
void slotDonateMoney();
void slotRatingFilterChanged(int, AlbumLister::RatingCondition);
void slotMimeTypeFilterChanged(int);
+ void slotTextFilterChanged(const QString&);
void slotAboutToShowForwardMenu();
void slotAboutToShowBackwardMenu();
--- branches/extragear/kde3/graphics/digikam/digikam/digikamappprivate.h #738270:738271
@@ -60,6 +60,7 @@
class KToggleAction;
class KActionMenu;
class KSelectAction;
+class KLineEdit;
namespace Digikam
{
@@ -139,6 +140,7 @@
statusProgressBar = 0;
statusMimeFilterBar = 0;
statusRatingFilterBar = 0;
+ statusTextFilterBar = 0;
statusNavigateBar = 0;
statusZoomBar = 0;
kipiPluginLoader = 0;
@@ -171,6 +173,8 @@
KConfig *config;
+ KLineEdit *statusTextFilterBar;
+
// Album Actions
KAction *newAction;
KAction *deleteAction;
More information about the Digikam-devel
mailing list