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

Gilles Caulier caulier.gilles at gmail.com
Sun Nov 25 20:56:40 GMT 2007


SVN commit 741527 by cgilles:

digiKam 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

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



 M  +69 -1     albumfolderview.cpp  
 M  +5 -0      albumfolderview.h  
 M  +86 -11    digikamview.cpp  
 M  +34 -1     searchfolderview.cpp  
 M  +9 -0      searchfolderview.h  
 M  +68 -0     tagfilterview.cpp  
 M  +5 -0      tagfilterview.h  
 M  +68 -0     tagfolderview.cpp  
 M  +5 -0      tagfolderview.h  


--- branches/extragear/kde3/graphics/digikam/digikam/albumfolderview.cpp #741526:741527
@@ -266,6 +266,74 @@
     delete d;
 }
 
+void AlbumFolderView::slotFolderFilterChanged(const QString& filter)
+{
+    QString search = filter.lower();
+
+    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().lower().contains(search);
+        if (!match)
+        {
+            // check if any of the parents match the search
+            Album* parent = palbum->parent();
+            while (parent && !parent->isRoot())
+            {
+                if (parent->title().lower().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().lower().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)
@@ -415,7 +483,7 @@
 
 void AlbumFolderView::slotSelectionChanged()
 {
-    if(!active())
+    if (!active())
         return;
 
     QListViewItem* selItem = 0;
--- branches/extragear/kde3/graphics/digikam/digikam/albumfolderview.h #741526:741527
@@ -70,7 +70,12 @@
 signals:
     
     void signalAlbumModified();
+    void signalFolderFilterMatch(bool);
 
+public slots:
+
+    void slotFolderFilterChanged(const QString&);
+
 private slots:
 
     void slotGotThumbnailFromIcon(Album *album, const QPixmap& thumbnail);
--- branches/extragear/kde3/graphics/digikam/digikam/digikamview.cpp #741526:741527
@@ -24,11 +24,13 @@
 
 // Qt Includes.
 
+#include <qvbox.h>
 #include <qstring.h>
 #include <qstringlist.h>
 #include <qstrlist.h>
 #include <qfileinfo.h>
 #include <qdir.h>
+#include <qlabel.h>
 #include <qimage.h>
 #include <qevent.h>
 #include <qapplication.h>
@@ -43,6 +45,7 @@
 #include <klocale.h>
 #include <kapplication.h>
 #include <kconfig.h>
+#include <kdialogbase.h>
 #include <krun.h>
 #include <kiconloader.h>
 #include <kstandarddirs.h>
@@ -72,6 +75,7 @@
 #include "datefolderview.h"
 #include "tagfolderview.h"
 #include "searchfolderview.h"
+#include "searchtextbar.h"
 #include "statusprogressbar.h"
 #include "tagfilterview.h"
 #include "thumbnailsize.h"
@@ -89,6 +93,14 @@
 
     DigikamViewPriv()
     {
+        folderBox             = 0;
+        tagBox                = 0;
+        searchBox             = 0;
+        tagFilterBox          = 0;
+        folderSearchBar       = 0;
+        tagSearchBar          = 0;
+        searchSearchBar       = 0;
+        tagFilterSearchBar    = 0;
         splitter              = 0;
         parent                = 0;
         iconView              = 0;
@@ -120,6 +132,16 @@
     QTimer                   *selectionTimer;
     QTimer                   *thumbSizeTimer;
 
+    QVBox                    *folderBox;
+    QVBox                    *tagBox;
+    QVBox                    *searchBox;
+    QVBox                    *tagFilterBox;
+
+    SearchTextBar            *folderSearchBar;
+    SearchTextBar            *tagSearchBar;
+    SearchTextBar            *searchSearchBar;
+    SearchTextBar            *tagFilterSearchBar;
+
     DigikamApp               *parent;
 
     AlbumIconView            *iconView;
@@ -161,19 +183,46 @@
                                                    Sidebar::Right, true);
 
     // To the left.
-    d->folderView       = new AlbumFolderView(this);
+
+    // Folders sidebar tab contents.
+    d->folderBox       = new QVBox(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 QVBox(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 QVBox(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("date"), i18n("Dates"));
-    d->leftSideBar->appendTab(d->tagFolderView, SmallIcon("tag"), i18n("Tags"));
-    d->leftSideBar->appendTab(d->searchFolderView, SmallIcon("find"), i18n("Searches"));
+    d->leftSideBar->appendTab(d->tagBox, SmallIcon("tag"), i18n("Tags"));
+    d->leftSideBar->appendTab(d->searchBox, SmallIcon("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 QVBox(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();
@@ -330,6 +379,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()),
@@ -1172,9 +1247,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)
--- branches/extragear/kde3/graphics/digikam/digikam/searchfolderview.cpp #741526:741527
@@ -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
@@ -125,6 +126,38 @@
 {    
 }
 
+void SearchFolderView::slotSearchFilterChanged(const QString& filter)
+{
+    QString search = filter.lower();
+
+    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().lower().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;
@@ -316,7 +349,7 @@
 {
     if (!active())
         return;
-    
+
     QListViewItem* selItem = 0;
     
     QListViewItemIterator it( this );
--- branches/extragear/kde3/graphics/digikam/digikam/searchfolderview.h #741526:741527
@@ -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
@@ -51,6 +52,14 @@
 
     void searchDelete(SAlbum* album);
     
+signals:
+
+    void signalSearchFilterMatch(bool);
+
+public slots:
+
+    void slotSearchFilterChanged(const QString&);
+
 private slots:
 
     void slotAlbumAdded(Album* album);
--- branches/extragear/kde3/graphics/digikam/digikam/tagfilterview.cpp #741526:741527
@@ -265,6 +265,74 @@
     delete d;
 }
 
+void TagFilterView::slotTagFilterChanged(const QString& filter)
+{
+    QString search = filter.lower();
+
+    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().lower().contains(search);
+        if (!match)
+        {
+            // check if any of the parents match the search
+            Album* parent = talbum->parent();
+            while (parent && !parent->isRoot())
+            {
+                if (parent->title().lower().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().lower().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;            
--- branches/extragear/kde3/graphics/digikam/digikam/tagfilterview.h #741526:741527
@@ -61,7 +61,12 @@
 
     void signalProgressBarMode(int, const QString&);
     void signalProgressValue(int);
+    void signalTagFilterMatch(bool);
 
+public slots:
+
+    void slotTagFilterChanged(const QString&);
+
 protected:
 
     QDragObject* dragObject();
--- branches/extragear/kde3/graphics/digikam/digikam/tagfolderview.cpp #741526:741527
@@ -188,6 +188,74 @@
     delete d;
 }
 
+void TagFolderView::slotTagFilterChanged(const QString& filter)
+{
+    QString search = filter.lower();
+
+    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().lower().contains(search);
+        if (!match)
+        {
+            // check if any of the parents match the search
+            Album* parent = talbum->parent();
+            while (parent && !parent->isRoot())
+            {
+                if (parent->title().lower().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().lower().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)
--- branches/extragear/kde3/graphics/digikam/digikam/tagfolderview.h #741526:741527
@@ -60,7 +60,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