summaryrefslogtreecommitdiffstats
path: root/digikam/digikam/albumlister.h
blob: 7c14e4c167e92b5c4acd8ac9e923fde5a7868ac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* ============================================================
 *
 * This file is a part of digiKam project
 * http://www.digikam.org
 *
 * Date        : 2004-06-26
 * Description : Albums lister.
 *
 * Copyright (C) 2004-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
 * Copyright (C) 2007-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
 * Copyright (C) 2007 by Arnd Baecker <arnd dot baecker at web dot de>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

#ifndef ALBUMLISTER_H
#define ALBUMLISTER_H

/** @file albumlister.h */

// TQt includes.

#include <tqobject.h>
#include <tqcstring.h>

// Local includes.

#include "imageinfo.h"

namespace TDEIO
{
class Job;
}

namespace Digikam
{

class Album;
class AlbumListerPriv;

/**
 * Manages imageinfo
 *
 * does listing of imageinfo for the current album and controls the lifetime 
 * of the imageinfo. tdeioslaves are used for listing the imageinfo
 * corresponding to an album. Similar to the albummanager, frontend entities need
 * to connect to the AlbumLister for notifications of new Images, deletion of
 * Images or refreshing of currently listed Image.
 */
class AlbumLister : public TQObject
{
    TQ_OBJECT

public:

    /** @enum MatchingCondition
     * Possible logical matching condition used to sort tags id.
     */
    enum MatchingCondition
    {
        OrCondition = 0,
        AndCondition
    };

    /** @enum RatingCondition
     * Possible conditions used to filter rating: >=, =, <=.
     */
    enum RatingCondition
    {
        GreaterEqualCondition = 0,
        EqualCondition,
        LessEqualCondition
    };

public:

    static AlbumLister* instance();

    ~AlbumLister();

    /**
     * Opens an album to lists its items
     */
    void openAlbum(Album *album);
    void stop();

    /**
     * Reread an albums item list
     */
    void refresh();

    void setNamesFilter(const TQString& namesFilter);

    void setDayFilter(const TQValueList<TQDateTime>& days);

    void setTagFilter(const TQValueList<int>& tags, const MatchingCondition& matchingCond, 
                      bool showUnTagged=false);

    void setRatingFilter(int rating, const RatingCondition& ratingCond);

    void setMimeTypeFilter(int mimeTypeFilter);

    void setTextFilter(const TQString& text);

    void setRecurseAlbums(bool recursive);
    void setRecurseTags(bool recursive);

    /**
      * Trigger a recreation of the given ImageInfo object
      * for the next refresh.
      */
    void invalidateItem(const ImageInfo *item);

    bool tagFiltersIsActive();

signals:

    void signalNewItems(const ImageInfoList& items);
    void signalDeleteItem(ImageInfo* item);
    void signalNewFilteredItems(const ImageInfoList& items);
    void signalDeleteFilteredItem(ImageInfo* item);
    void signalClear();
    void signalCompleted();
    void signalItemsTextFilterMatch(bool);
    void signalItemsFilterMatch(bool);

private slots:

    void slotFilterItems();

    void slotResult(TDEIO::Job* job);
    void slotData(TDEIO::Job* job, const TQByteArray& data);

private:

    AlbumLister();
    bool matchesFilter(const ImageInfo* info, bool& foundText);

private:

    AlbumListerPriv    *d;

    static AlbumLister *m_instance; 

};

}  // namespace Digikam

#endif /* ALBUMLISTER_H */