~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/models/imagesortsettings.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
{
44
44
 
45
45
class ImageInfo;
46
 
namespace DatabaseFields { class Set; }
 
46
namespace DatabaseFields
 
47
{
 
48
class Set;
 
49
}
47
50
 
48
51
class DIGIKAM_DATABASE_EXPORT ImageSortSettings
49
52
{
51
54
 
52
55
    ImageSortSettings();
53
56
 
54
 
    bool operator==(const ImageSortSettings &other) const;
 
57
    bool operator==(const ImageSortSettings& other) const;
55
58
 
56
59
    /** Compares the categories of left and right.
57
60
     *  Return -1 if left is less than right, 0 if both fall in the same category,
137
140
 
138
141
    /** Returns a < b if sortOrder is Ascending, or b < a if order is descending */
139
142
    template <typename T>
140
 
    static inline bool lessThanByOrder(const T &a, const T&b, Qt::SortOrder sortOrder)
 
143
    static inline bool lessThanByOrder(const T& a, const T& b, Qt::SortOrder sortOrder)
141
144
    {
142
145
        if (sortOrder == Qt::AscendingOrder)
 
146
        {
143
147
            return a < b;
 
148
        }
144
149
        else
 
150
        {
145
151
            return b < a;
 
152
        }
146
153
    }
147
154
 
148
155
    /** Returns the usual compare result of -1, 0, or 1 for lessThan, equals and greaterThan. */
149
156
    template <typename T>
150
 
    static inline int compareValue(const T &a, const T&b)
 
157
    static inline int compareValue(const T& a, const T& b)
151
158
    {
152
159
        if (a == b)
 
160
        {
153
161
            return 0;
 
162
        }
 
163
 
154
164
        if (a < b)
 
165
        {
155
166
            return -1;
 
167
        }
156
168
        else
 
169
        {
157
170
            return 1;
 
171
        }
158
172
    }
159
173
 
160
174
    /** Takes a typical result from a compare method (0 is equal, -1 is less than, 1 is greater than)
162
176
    static inline int compareByOrder(int compareResult,  Qt::SortOrder sortOrder)
163
177
    {
164
178
        if (sortOrder == Qt::AscendingOrder)
 
179
        {
165
180
            return compareResult;
 
181
        }
166
182
        else
 
183
        {
167
184
            return - compareResult;
 
185
        }
168
186
    }
169
187
 
170
188
    template <typename T>
171
 
    static inline int compareByOrder(const T &a, const T&b, Qt::SortOrder sortOrder)
 
189
    static inline int compareByOrder(const T& a, const T& b, Qt::SortOrder sortOrder)
172
190
    {
173
191
        return compareByOrder(compareValue(a, b), sortOrder);
174
192
    }
175
193
 
176
194
    /** Compares the two string by natural comparison and adheres to given sort order */
177
 
    static inline int naturalCompare(const QString &a, const QString &b, Qt::SortOrder sortOrder,
178
 
                                    Qt::CaseSensitivity caseSensitive = Qt::CaseSensitive)
 
195
    static inline int naturalCompare(const QString& a, const QString& b, Qt::SortOrder sortOrder,
 
196
                                     Qt::CaseSensitivity caseSensitive = Qt::CaseSensitive)
179
197
    {
180
198
        return compareByOrder(KStringHandler::naturalCompare(a, b, caseSensitive),
181
199
                              sortOrder);