1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2009-04-20
7  * Description : Qt model-view for items - category drawer
8  *
9  * Copyright (C) 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_ITEM_CATEGORY_DRAWER_H
25 #define DIGIKAM_ITEM_CATEGORY_DRAWER_H
26 
27 // Local includes
28 
29 #include "dcategorydrawer.h"
30 
31 class QStyleOptionViewItem;
32 
33 namespace Digikam
34 {
35 
36 class ItemCategorizedView;
37 class Album;
38 class PAlbum;
39 class TAlbum;
40 class SAlbum;
41 class DAlbum;
42 
43 class ItemCategoryDrawer : public DCategoryDrawer
44 {
45     Q_OBJECT
46 
47 public:
48 
49     explicit ItemCategoryDrawer(ItemCategorizedView* const parent);
50     ~ItemCategoryDrawer()                                                                                                  override;
51 
52     int categoryHeight(const QModelIndex& index, const QStyleOption& option)                                         const override;
53     void drawCategory(const QModelIndex& index, int sortRole, const QStyleOption& option, QPainter* painter)         const override;
54     virtual int maximumHeight()                                                                                      const;
55 
56     void setLowerSpacing(int spacing);
57     void setDefaultViewOptions(const QStyleOptionViewItem& option);
58     void invalidatePaintingCache();
59 
60 private:
61 
62     void updateRectsAndPixmaps(int width);
63     void viewHeaderText(const QModelIndex& index, QString* header, QString* subLine)                                 const;
64     void textForAlbum(const QModelIndex& index, QString* header, QString* subLine)                                   const;
65     void textForPAlbum(PAlbum* a, bool recursive, int count, QString* header, QString* subLine)                      const;
66     void textForTAlbum(TAlbum* a, bool recursive, int count, QString* header, QString* subLine)                      const;
67     void textForSAlbum(SAlbum* a, int count, QString* header, QString* subLine)                                      const;
68     void textForDAlbum(DAlbum* a, int count, QString* header, QString* subLine)                                      const;
69     void textForFormat(const QModelIndex& index, QString* header, QString* subLine)                                  const;
70     void textForMonth(const QModelIndex& index, QString* header, QString* subLine)                                   const;
71     void textForFace(const QModelIndex& index, QString* header, QString* subLine)                                    const;
72 
73 private:
74 
75     class Private;
76     Private* const d;
77 };
78 
79 } // namespace Digikam
80 
81 #endif // DIGIKAM_ITEM_CATEGORY_DRAWER_H
82