digikam
albumfiltermodel.h
Go to the documentation of this file.00001 /* ============================================================ 00002 * 00003 * This file is a part of digiKam project 00004 * http://www.digikam.org 00005 * 00006 * Date : 2009-03-24 00007 * Description : Qt Model for Albums - filter model 00008 * 00009 * Copyright (C) 2008-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 00010 * 00011 * This program is free software; you can redistribute it 00012 * and/or modify it under the terms of the GNU General 00013 * Public License as published by the Free Software Foundation; 00014 * either version 2, or (at your option) 00015 * any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * ============================================================ */ 00023 00024 #ifndef ALBUMFILTERMODEL_H 00025 #define ALBUMFILTERMODEL_H 00026 00027 // Qt includes 00028 00029 #include <QSortFilterProxyModel> 00030 00031 // Local includes 00032 00033 #include "albummodel.h" 00034 #include "searchtextbar.h" 00035 00036 namespace Digikam 00037 { 00038 00039 class AlbumFilterModel : public QSortFilterProxyModel 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 00045 AlbumFilterModel(QObject *parent = 0); 00046 00047 void setSourceAlbumModel(AbstractAlbumModel *source); 00048 00049 AbstractAlbumModel *sourceAlbumModel() const; 00050 00051 Album *albumForIndex(const QModelIndex& index) const; 00052 QModelIndex indexForAlbum(Album *album) const; 00053 QModelIndex rootAlbumIndex() const; 00054 00056 bool isFiltering() const; 00057 SearchTextSettings searchTextSettings() const; 00058 00063 enum MatchResult 00064 { 00066 NoMatch = 0, 00067 TitleMatch, 00068 ParentMatch, 00069 ChildMatch, 00070 SpecialMatch 00071 }; 00072 MatchResult matches(Album *album) const; 00073 MatchResult matches(const QModelIndex& index) const; 00074 00075 public Q_SLOTS: 00076 00077 void setSearchTextSettings(const SearchTextSettings& settings); 00078 00079 Q_SIGNALS: 00080 00081 void filterChanged(); 00082 00083 protected: 00084 00085 // use setSourceAlbumModel please 00086 virtual void setSourceModel(QAbstractItemModel* model); 00087 00088 bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; 00089 bool lessThan(const QModelIndex& left, const QModelIndex& right) const; 00090 00091 protected: 00092 00093 SearchTextSettings m_settings; 00094 }; 00095 00096 } // namespace Digikam 00097 00098 #endif // ALBUMFILTERMODEL_H
KDE 4.4 API Reference