[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/graphics/digikam/utilities/kipiiface
From: Gilles Caulier <caulier.gilles () gmail ! com>
Date: 2008-04-11 12:47:24
Message-ID: 1207918044.375717.32105.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 795795 by cgilles:
added search bar
M +83 -4 kipiuploadwidget.cpp
M +4 -0 kipiuploadwidget.h
--- trunk/extragear/graphics/digikam/utilities/kipiiface/kipiuploadwidget.cpp #795794:795795
@@ -31,6 +31,7 @@
// KDE includes.
#include <klocale.h>
+#include <kdialog.h>
// Local includes.
@@ -39,6 +40,7 @@
#include "album.h"
#include "albumthumbnailloader.h"
#include "treefolderitem.h"
+#include "searchtextbar.h"
#include "kipiinterface.h"
#include "kipiimagecollection.h"
#include "kipiuploadwidget.h"
@@ -55,11 +57,14 @@
{
albumsView = 0;
iface = 0;
+ searchBar = 0;
}
QTreeWidget *albumsView;
KipiInterface *iface;
+
+ SearchTextBar *searchBar;
};
KipiUploadWidget::KipiUploadWidget(KipiInterface* iface, QWidget *parent)
@@ -74,11 +79,14 @@
d->albumsView->setAcceptDrops(false);
d->albumsView->header()->hide();
- QHBoxLayout *hlay = new QHBoxLayout(this);
- hlay->addWidget(d->albumsView);
- hlay->setMargin(0);
- hlay->setSpacing(0);
+ d->searchBar = new SearchTextBar(this, "KipiUploadWidgetSearchBar");
+ QVBoxLayout *vlay = new QVBoxLayout(this);
+ vlay->addWidget(d->albumsView, 10);
+ vlay->addWidget(d->searchBar);
+ vlay->setMargin(0);
+ vlay->setSpacing(KDialog::spacingHint());
+
// ------------------------------------------------------------------------------------
populateTreeView(AlbumManager::instance()->allPAlbums(), d->albumsView);
@@ -87,6 +95,9 @@
connect(d->albumsView, SIGNAL(itemSelectionChanged()),
this, SIGNAL(selectionChanged()));
+
+ connect(d->searchBar, SIGNAL(textChanged(const QString&)),
+ this, SLOT(slotSearchTextChanged(const QString&)));
}
KipiUploadWidget::~KipiUploadWidget()
@@ -152,4 +163,72 @@
return collection;
}
+void KipiUploadWidget::slotSearchTextChanged(const QString& filter)
+{
+ QString search = filter.toLower();
+
+ bool atleastOneMatch = false;
+
+ AlbumList pList = AlbumManager::instance()->allPAlbums();
+ for (AlbumList::iterator it = pList.begin(); it != pList.end(); ++it)
+ {
+ PAlbum* palbum = (PAlbum*)(*it);
+
+ // don't touch the root Album
+ if (palbum->isRoot())
+ continue;
+
+ bool match = palbum->title().toLower().contains(search);
+ if (!match)
+ {
+ // check if any of the parents match the search
+ Album* parent = palbum->parent();
+ while (parent && !parent->isRoot())
+ {
+ if (parent->title().toLower().contains(search))
+ {
+ match = true;
+ break;
+ }
+
+ parent = parent->parent();
+ }
+ }
+
+ if (!match)
+ {
+ // check if any of the children match the search
+ AlbumIterator it(palbum);
+ while (it.current())
+ {
+ if ((*it)->title().toLower().contains(search))
+ {
+ match = true;
+ break;
+ }
+ ++it;
+ }
+ }
+
+ TreeAlbumCheckListItem* viewItem = (TreeAlbumCheckListItem*) palbum->extraData(d->albumsView);
+
+ if (match)
+ {
+ atleastOneMatch = true;
+
+ if (viewItem)
+ viewItem->setHidden(false);
+ }
+ else
+ {
+ if (viewItem)
+ {
+ viewItem->setHidden(true);
+ }
+ }
+ }
+
+ d->searchBar->slotSearchResult(atleastOneMatch);
+}
+
} // namespace Digikam
--- trunk/extragear/graphics/digikam/utilities/kipiiface/kipiuploadwidget.h #795794:795795
@@ -57,6 +57,10 @@
void populateTreeView(const AlbumList& aList, QTreeWidget *view);
+private slots:
+
+ void slotSearchTextChanged(const QString&);
+
private:
KipiUploadWidgetPriv *d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic