[Digikam-devel] extragear/graphics/digikam/digikam

Gilles Caulier caulier.gilles at gmail.com
Mon Nov 26 08:42:54 GMT 2007


SVN commit 741717 by cgilles:

backport commits #741527 from KDE3 branch: new text filters have been added to the bottom of left and right sidebars. View listed below can be filtered:
- Album folder view.
- Tags folder view.
- Search folder view
- Tags Filter folder view.

When user type a string, a search is performed to tree view contents and only items including the strings are displayed.
A screenshot of digiKam in action is available at this url:

http://digikam3rdparty.free.fr/Screenshots/digikam0.9.3-searchfolderbar.png

CCBUGS: 133191
CCBUGS: 146364
CCBUGS: 110136
CCMAIL: digikam-devel at kde.org


 M  +69 -0     albumfolderview.cpp  
 M  +7 -1      albumfolderview.h  
 M  +85 -12    digikamview.cpp  
 M  +33 -0     searchfolderview.cpp  
 M  +10 -1     searchfolderview.h  
 M  +68 -0     tagfilterview.cpp  
 M  +5 -0      tagfilterview.h  
 M  +68 -0     tagfolderview.cpp  
 M  +5 -0      tagfolderview.h  


--- trunk/extragear/graphics/digikam/digikam/albumfolderview.cpp #741716:741717
@@ -7,6 +7,7 @@
  * Description : Albums folder view.
  *
  * Copyright (C) 2005-2006 by Joern Ahrens <joern.ahrens at kdemail.net>
+ * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -252,6 +253,74 @@
     delete d;
 }
 
+void AlbumFolderView::slotFolderFilterChanged(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;
+            }
+        }
+    
+        AlbumFolderViewItem* viewItem = (AlbumFolderViewItem*) palbum->extraData(this);
+
+        if (match)
+        {
+            atleastOneMatch = true;
+
+            if (viewItem)
+                viewItem->setVisible(true);
+        }
+        else
+        {
+            if (viewItem)
+            {
+                viewItem->setVisible(false);
+            }
+        }
+    }
+
+    emit signalFolderFilterMatch(atleastOneMatch);
+}
+
 void AlbumFolderView::slotAlbumAdded(Album *album)
 {
     if(!album)
--- trunk/extragear/graphics/digikam/digikam/albumfolderview.h #741716:741717
@@ -7,6 +7,7 @@
  * Description : Albums folder view.
  *
  * Copyright (C) 2005-2006 by Joern Ahrens <joern.ahrens at kdemail.net>
+ * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -68,9 +69,14 @@
     void setCurrentAlbum(Album *album);
 
 signals:
-    
+
     void signalAlbumModified();
+    void signalFolderFilterMatch(bool);
 
+public slots:
+
+    void slotFolderFilterChanged(const QString&);
+
 private slots:
 
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
--- trunk/extragear/graphics/digikam/digikam/digikamview.cpp #741716:741717
@@ -33,6 +33,7 @@
 #include <QApplication>
 #include <QSplitter>
 #include <QTimer>
+#include <QLabel>
 #include <QListView>
 
 // KDE includes.
@@ -41,6 +42,7 @@
 #include <klocale.h>
 #include <kapplication.h>
 #include <kconfig.h>
+#include <kdialog.h>
 #include <krun.h>
 #include <kiconloader.h>
 #include <kstandarddirs.h>
@@ -68,6 +70,7 @@
 #include "collectionmanager.h"
 #include "slideshow.h"
 #include "sidebar.h"
+#include "searchtextbar.h"
 #include "imagepropertiessidebardb.h"
 #include "imageinfoalbumsjob.h"
 #include "imagepreviewview.h"
@@ -91,6 +94,14 @@
 
     DigikamViewPriv()
     {
+        folderBox             = 0;
+        tagBox                = 0;
+        searchBox             = 0;
+        tagFilterBox          = 0;
+        folderSearchBar       = 0;
+        tagSearchBar          = 0;
+        searchSearchBar       = 0;
+        tagFilterSearchBar    = 0;
         splitter              = 0;
         parent                = 0;
         iconView              = 0;
@@ -122,6 +133,16 @@
     QTimer                   *selectionTimer;
     QTimer                   *thumbSizeTimer;
 
+    KVBox                    *folderBox;
+    KVBox                    *tagBox;
+    KVBox                    *searchBox;
+    KVBox                    *tagFilterBox;
+
+    SearchTextBar            *folderSearchBar;
+    SearchTextBar            *tagSearchBar;
+    SearchTextBar            *searchSearchBar;
+    SearchTextBar            *tagFilterSearchBar;
+
     DigikamApp               *parent;
 
     AlbumIconView            *iconView;
@@ -129,7 +150,7 @@
     AlbumManager             *albumManager;
     AlbumHistory             *albumHistory;
     AlbumWidgetStack         *albumWidgetStack;
-    
+
     Sidebar                  *leftSideBar;
     ImagePropertiesSideBarDB *rightSideBar;
 
@@ -167,19 +188,45 @@
     d->rightSideBar->setObjectName("Digikam Right Sidebar");
 
     // To the left.
-    d->folderView       = new AlbumFolderView(this);
+    // Folders sidebar tab contents.
+    d->folderBox       = new KVBox(this);
+    d->folderView      = new AlbumFolderView(d->folderBox);
+    d->folderSearchBar = new SearchTextBar(d->folderBox);
+    d->folderBox->setSpacing(KDialog::spacingHint());
+    d->folderBox->setMargin(0);
+
+    // Tags sidebar tab contents.
+    d->tagBox        = new KVBox(this);
+    d->tagFolderView = new TagFolderView(d->tagBox);
+    d->tagSearchBar  = new SearchTextBar(d->tagBox);
+    d->tagBox->setSpacing(KDialog::spacingHint());
+    d->tagBox->setMargin(0);
+
+    // Search sidebar tab contents.
+    d->searchBox        = new KVBox(this);
+    d->searchFolderView = new SearchFolderView(d->searchBox);
+    d->searchSearchBar  = new SearchTextBar(d->searchBox);
+    d->searchBox->setSpacing(KDialog::spacingHint());
+    d->searchBox->setMargin(0);
+
     d->dateFolderView   = new DateFolderView(this);
-    d->tagFolderView    = new TagFolderView(this);
-    d->searchFolderView = new SearchFolderView(this);
-    d->leftSideBar->appendTab(d->folderView, SmallIcon("folder-image"), i18n("Albums"));
+
+    d->leftSideBar->appendTab(d->folderBox, SmallIcon("folder-image"), i18n("Albums"));
     d->leftSideBar->appendTab(d->dateFolderView, SmallIcon("view-calendar-month"), i18n("Dates"));
-    d->leftSideBar->appendTab(d->tagFolderView, SmallIcon("tag"), i18n("Tags"));
-    d->leftSideBar->appendTab(d->searchFolderView, SmallIcon("edit-find"), i18n("Searches"));
+    d->leftSideBar->appendTab(d->tagBox, SmallIcon("tag"), i18n("Tags"));
+    d->leftSideBar->appendTab(d->searchBox, SmallIcon("edit-find"), i18n("Searches"));
 
     // To the right.
-    d->tagFilterView = new TagFilterView(this);
-    d->rightSideBar->appendTab(d->tagFilterView, SmallIcon("tag-assigned"), i18n("Tag Filters"));
 
+    // Tags Filter sidebar tab contents.
+    d->tagFilterBox       = new KVBox(this);
+    d->tagFilterView      = new TagFilterView(d->tagFilterBox);
+    d->tagFilterSearchBar = new SearchTextBar(d->tagFilterBox);
+    d->tagFilterBox->setSpacing(KDialog::spacingHint());
+    d->tagFilterBox->setMargin(0);
+
+    d->rightSideBar->appendTab(d->tagFilterBox, SmallIcon("tag-assigned"), i18n("Tag Filters"));
+
     d->selectionTimer = new QTimer(this);
 
     setupConnections();
@@ -336,6 +383,32 @@
     connect(d->tagFolderView, SIGNAL(signalProgressValue(int)),
             d->parent, SLOT(slotProgressValue(int)));
 
+    // -- Filter Bars Connections ---------------------------------
+
+    connect(d->folderSearchBar, SIGNAL(signalTextChanged(const QString&)),
+            d->folderView, SLOT(slotFolderFilterChanged(const QString&)));
+
+    connect(d->tagSearchBar, SIGNAL(signalTextChanged(const QString&)),
+            d->tagFolderView, SLOT(slotTagFilterChanged(const QString&)));
+
+    connect(d->searchSearchBar, SIGNAL(signalTextChanged(const QString&)),
+            d->searchFolderView, SLOT(slotSearchFilterChanged(const QString&)));
+
+    connect(d->tagFilterSearchBar, SIGNAL(signalTextChanged(const QString&)),
+            d->tagFilterView, SLOT(slotTagFilterChanged(const QString&)));
+
+    connect(d->folderView, SIGNAL(signalFolderFilterMatch(bool)),
+            d->folderSearchBar, SLOT(slotSearchResult(bool)));
+
+    connect(d->tagFolderView, SIGNAL(signalTagFilterMatch(bool)),
+            d->tagSearchBar, SLOT(slotSearchResult(bool)));
+
+    connect(d->searchFolderView, SIGNAL(signalSearchFilterMatch(bool)),
+            d->searchSearchBar, SLOT(slotSearchResult(bool)));
+
+    connect(d->tagFilterView, SIGNAL(signalTagFilterMatch(bool)),
+            d->tagFilterSearchBar, SLOT(slotSearchResult(bool)));
+
     // -- Preview image widget Connections ------------------------
 
     connect(d->albumWidgetStack, SIGNAL(signalNextItem()),
@@ -1180,9 +1253,9 @@
     // So this is the place which causes the behavior that when the left sidebar
     // tab is changed, the current album is changed as well.
     d->dateFolderView->setActive(w == d->dateFolderView);
-    d->folderView->setActive(w == d->folderView);
-    d->tagFolderView->setActive(w == d->tagFolderView);
-    d->searchFolderView->setActive(w == d->searchFolderView);
+    d->folderView->setActive(w == d->folderBox);
+    d->tagFolderView->setActive(w == d->tagBox);
+    d->searchFolderView->setActive(w == d->searchBox);
 }
 
 void DigikamView::slotAssignRating(int rating)
--- trunk/extragear/graphics/digikam/digikam/searchfolderview.cpp #741716:741717
@@ -7,6 +7,7 @@
  * Description : Searches folder view 
  * 
  * Copyright (C) 2005 by Renchi Raju <renchi at pooh.tam.uiuc.edu>
+ * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -120,6 +121,38 @@
 {    
 }
 
+void SearchFolderView::slotSearchFilterChanged(const QString& filter)
+{
+    QString search = filter.toLower();
+
+    bool atleastOneMatch = false;
+
+    AlbumList sList = AlbumManager::instance()->allSAlbums();
+    for (AlbumList::iterator it = sList.begin(); it != sList.end(); ++it)
+    {
+        SAlbum* salbum             = (SAlbum*)(*it);
+        SearchFolderItem* viewItem = (SearchFolderItem*) salbum->extraData(this);
+
+        bool match = salbum->title().toLower().contains(search);
+        if (match)
+        {
+            atleastOneMatch = true;
+
+            if (viewItem)
+                viewItem->setVisible(true);
+        }
+        else
+        {
+            if (viewItem)
+            {
+                viewItem->setVisible(false);
+            }
+        }
+    }
+
+    emit signalSearchFilterMatch(atleastOneMatch);
+}
+
 void SearchFolderView::quickSearchNew()
 {
     KUrl url;
--- trunk/extragear/graphics/digikam/digikam/searchfolderview.h #741716:741717
@@ -7,6 +7,7 @@
  * Description : Searches folder view 
  *
  * Copyright (C) 2005 by Renchi Raju <renchi at pooh.tam.uiuc.edu>
+ * Copyright (C) 2006-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
@@ -50,7 +51,15 @@
     void extendedSearchEdit(SAlbum* album);
 
     void searchDelete(SAlbum* album);
-    
+
+signals:
+
+    void signalSearchFilterMatch(bool);
+
+public slots:
+
+    void slotSearchFilterChanged(const QString&);
+
 private slots:
 
     void slotAlbumAdded(Album* album);
--- trunk/extragear/graphics/digikam/digikam/tagfilterview.cpp #741716:741717
@@ -268,6 +268,74 @@
     delete d;
 }
 
+void TagFilterView::slotTagFilterChanged(const QString& filter)
+{
+    QString search = filter.toLower();
+
+    bool atleastOneMatch = false;
+
+    AlbumList tList = AlbumManager::instance()->allTAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        TAlbum* talbum  = (TAlbum*)(*it);
+
+        // don't touch the root Album
+        if (talbum->isRoot())
+            continue;
+
+        bool match = talbum->title().toLower().contains(search);
+        if (!match)
+        {
+            // check if any of the parents match the search
+            Album* parent = talbum->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(talbum);
+            while (it.current())
+            {
+                if ((*it)->title().toLower().contains(search))
+                {
+                    match = true;
+                    break;
+                }
+                ++it;
+            }
+        }
+    
+        TagFilterViewItem* viewItem = (TagFilterViewItem*) talbum->extraData(this);
+
+        if (match)
+        {
+            atleastOneMatch = true;
+
+            if (viewItem)
+                viewItem->setVisible(true);
+        }
+        else
+        {
+            if (viewItem)
+            {
+                viewItem->setVisible(false);
+            }
+        }
+    }
+
+    emit signalTagFilterMatch(atleastOneMatch);
+}
+
 void TagFilterView::stateChanged(TagFilterViewItem* item)
 {
     ToggleAutoTags oldAutoTags = d->toggleAutoTags;            
--- trunk/extragear/graphics/digikam/digikam/tagfilterview.h #741716:741717
@@ -67,7 +67,12 @@
 
     void signalProgressBarMode(int, const QString&);
     void signalProgressValue(int);
+    void signalTagFilterMatch(bool);
 
+public slots:
+
+    void slotTagFilterChanged(const QString&);
+
 protected:
 
     Q3DragObject* dragObject();
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.cpp #741716:741717
@@ -187,6 +187,74 @@
     delete d;
 }
 
+void TagFolderView::slotTagFilterChanged(const QString& filter)
+{
+    QString search = filter.toLower();
+
+    bool atleastOneMatch = false;
+
+    AlbumList tList = AlbumManager::instance()->allTAlbums();
+    for (AlbumList::iterator it = tList.begin(); it != tList.end(); ++it)
+    {
+        TAlbum* talbum  = (TAlbum*)(*it);
+
+        // don't touch the root Album
+        if (talbum->isRoot())
+            continue;
+
+        bool match = talbum->title().toLower().contains(search);
+        if (!match)
+        {
+            // check if any of the parents match the search
+            Album* parent = talbum->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(talbum);
+            while (it.current())
+            {
+                if ((*it)->title().toLower().contains(search))
+                {
+                    match = true;
+                    break;
+                }
+                ++it;
+            }
+        }
+    
+        TagFolderViewItem* viewItem = (TagFolderViewItem*) talbum->extraData(this);
+
+        if (match)
+        {
+            atleastOneMatch = true;
+
+            if (viewItem)
+                viewItem->setVisible(true);
+        }
+        else
+        {
+            if (viewItem)
+            {
+                viewItem->setVisible(false);
+            }
+        }
+    }
+
+    emit signalTagFilterMatch(atleastOneMatch);
+}
+
 void TagFolderView::slotAlbumAdded(Album *album)
 {
     if(!album)
--- trunk/extragear/graphics/digikam/digikam/tagfolderview.h #741716:741717
@@ -65,7 +65,12 @@
 
     void signalProgressBarMode(int, const QString&);
     void signalProgressValue(int);
+    void signalTagFilterMatch(bool);
 
+public slots:
+
+    void slotTagFilterChanged(const QString&);
+
 protected:
 
     void contentsDropEvent(QDropEvent *e);



More information about the Digikam-devel mailing list