~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/semanticinfo/sorteddirmodel.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <lib/gwenviewlib_export.h>
33
33
#include <lib/mimetypeutils.h>
34
34
 
35
 
 
36
35
class KDirLister;
37
36
class KFileItem;
38
37
class KUrl;
39
38
 
40
 
namespace Gwenview {
 
39
namespace Gwenview
 
40
{
41
41
 
42
42
class AbstractSemanticInfoBackEnd;
43
43
struct SortedDirModelPrivate;
47
47
#endif
48
48
 
49
49
class SortedDirModel;
50
 
class GWENVIEWLIB_EXPORT AbstractSortedDirModelFilter : public QObject {
 
50
class GWENVIEWLIB_EXPORT AbstractSortedDirModelFilter : public QObject
 
51
{
51
52
public:
52
 
        AbstractSortedDirModelFilter(SortedDirModel* model);
53
 
        ~AbstractSortedDirModelFilter();
54
 
        SortedDirModel* model() const { return mModel; }
 
53
    AbstractSortedDirModelFilter(SortedDirModel* model);
 
54
    ~AbstractSortedDirModelFilter();
 
55
    SortedDirModel* model() const {
 
56
        return mModel;
 
57
    }
55
58
 
56
 
        virtual bool needsSemanticInfo() const = 0;
57
 
        /**
58
 
         * Returns true if index should be accepted.
59
 
         * Warning: index is a source index of SortedDirModel
60
 
         */
61
 
        virtual bool acceptsIndex(const QModelIndex& index) const = 0;
 
59
    virtual bool needsSemanticInfo() const = 0;
 
60
    /**
 
61
     * Returns true if index should be accepted.
 
62
     * Warning: index is a source index of SortedDirModel
 
63
     */
 
64
    virtual bool acceptsIndex(const QModelIndex& index) const = 0;
62
65
 
63
66
private:
64
 
        QPointer<SortedDirModel> mModel;
 
67
    QPointer<SortedDirModel> mModel;
65
68
};
66
69
 
67
70
/**
68
71
 * This model makes it possible to show all images in a folder.
69
72
 * It can filter images based on name and metadata.
70
73
 */
71
 
class GWENVIEWLIB_EXPORT SortedDirModel : public KDirSortFilterProxyModel {
72
 
        Q_OBJECT
 
74
class GWENVIEWLIB_EXPORT SortedDirModel : public KDirSortFilterProxyModel
 
75
{
 
76
    Q_OBJECT
73
77
public:
74
 
        SortedDirModel(QObject* parent=0);
75
 
        ~SortedDirModel();
76
 
        KDirLister* dirLister() const;
77
 
        KFileItem itemForIndex(const QModelIndex& index) const;
78
 
        KUrl urlForIndex(const QModelIndex& index) const;
79
 
        KFileItem itemForSourceIndex(const QModelIndex& sourceIndex) const;
80
 
        QModelIndex indexForItem(const KFileItem& item) const;
81
 
        QModelIndex indexForUrl(const KUrl& url) const;
82
 
 
83
 
        void setKindFilter(MimeTypeUtils::Kinds);
84
 
        MimeTypeUtils::Kinds kindFilter() const;
85
 
 
86
 
        void adjustKindFilter(MimeTypeUtils::Kinds, bool set);
87
 
 
88
 
        /**
89
 
         * A list of file extensions we should skip
90
 
         */
91
 
        void setBlackListedExtensions(const QStringList& list);
92
 
 
93
 
        void addFilter(AbstractSortedDirModelFilter*);
94
 
 
95
 
        void removeFilter(AbstractSortedDirModelFilter*);
96
 
 
97
 
        void reload();
98
 
 
99
 
        AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const;
 
78
    SortedDirModel(QObject* parent = 0);
 
79
    ~SortedDirModel();
 
80
    KDirLister* dirLister() const;
 
81
    KFileItem itemForIndex(const QModelIndex& index) const;
 
82
    KUrl urlForIndex(const QModelIndex& index) const;
 
83
    KFileItem itemForSourceIndex(const QModelIndex& sourceIndex) const;
 
84
    QModelIndex indexForItem(const KFileItem& item) const;
 
85
    QModelIndex indexForUrl(const KUrl& url) const;
 
86
 
 
87
    void setKindFilter(MimeTypeUtils::Kinds);
 
88
    MimeTypeUtils::Kinds kindFilter() const;
 
89
 
 
90
    void adjustKindFilter(MimeTypeUtils::Kinds, bool set);
 
91
 
 
92
    /**
 
93
     * A list of file extensions we should skip
 
94
     */
 
95
    void setBlackListedExtensions(const QStringList& list);
 
96
 
 
97
    void addFilter(AbstractSortedDirModelFilter*);
 
98
 
 
99
    void removeFilter(AbstractSortedDirModelFilter*);
 
100
 
 
101
    void reload();
 
102
 
 
103
    AbstractSemanticInfoBackEnd* semanticInfoBackEnd() const;
100
104
 
101
105
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
102
 
        SemanticInfo semanticInfoForSourceIndex(const QModelIndex& sourceIndex) const;
 
106
    SemanticInfo semanticInfoForSourceIndex(const QModelIndex& sourceIndex) const;
103
107
#endif
104
108
 
105
 
        bool hasDocuments() const;
 
109
    bool hasDocuments() const;
106
110
 
107
111
public Q_SLOTS:
108
112
    void applyFilters();
109
113
 
110
114
protected:
111
 
        bool filterAcceptsRow(int row, const QModelIndex& parent) const;
112
 
        bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
 
115
    bool filterAcceptsRow(int row, const QModelIndex& parent) const;
 
116
    bool lessThan(const QModelIndex& left, const QModelIndex& right) const;
113
117
 
114
118
private Q_SLOTS:
115
 
        void doApplyFilters();
 
119
    void doApplyFilters();
116
120
 
117
121
private:
118
 
        friend struct SortedDirModelPrivate;
119
 
        SortedDirModelPrivate * const d;
 
122
    friend struct SortedDirModelPrivate;
 
123
    SortedDirModelPrivate * const d;
120
124
};
121
125
 
122
126
} // namespace