4e663014068c37b6b93b08f4d02e0cd3c01c56f9
[dorian] / widgets / listwindow.h
1 #ifndef LISTWINDOW_H
2 #define LISTWINDOW_H
3
4 #include <QMainWindow>
5 #include <QDialogButtonBox>
6 #include <QList>
7
8 class QListView;
9 class QString;
10 class QBoxLayout;
11 class QPushButton;
12 class QModelIndex;
13 class QItemSelection;
14 class QEvent;
15 class ListView;
16 class FlickCharm;
17
18 /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */
19 class ListWindow: public QMainWindow
20 {
21     Q_OBJECT
22
23 public:
24     explicit ListWindow(QWidget *parent = 0);
25
26     /** Add a list view to the window. */
27     void addList(ListView *list);
28
29     /**
30      * Add an action to the window: either a button, or, on Maemo, a top
31      * level menu item.
32      * Activating the action invokes the slot with no parameters.
33      */
34     void addAction(const QString &title, QObject *receiver, const char *slot,
35         const QString &iconPath = QString(),
36         QDialogButtonBox::ButtonRole role = QDialogButtonBox::ActionRole);
37
38     /**
39      * Add an action to the selected item in the list: either a button which is
40      * enabled when a list item is selected, or, on Maemo, a pop-up menu item
41      * which is displayed when a list item is long-pressed.
42      * Activating the action invokes the slot with no parameters.
43      */
44     void addItemAction(const QString &title, QObject *receiver,
45                        const char *slot);
46
47     /**
48       * Add an action to the menu.
49       */
50     QAction *addMenuAction(const QString &title, QObject *receiver,
51                            const char *slot);
52
53 public slots:
54 #ifdef Q_OS_SYMBIAN
55     void show();
56 #endif
57
58 protected slots:
59     void onSelectionChanged(const QItemSelection &selected,
60                             const QItemSelection &deselected);
61 #ifdef Q_WS_MAEMO_5
62     void onModelChanged();
63 #else
64     void activateItemButtons();
65 #endif
66
67 protected:
68 #ifdef Q_WS_MAEMO_5
69     bool eventFilter(QObject *obj, QEvent *event);
70     void closeEvent(QCloseEvent *event);
71     QMenu *popup;
72 #else
73     QDialogButtonBox *buttonBox;
74     QList<QPushButton *> itemButtons;
75 #endif // Q_WS_MAEMO_5
76 #ifdef Q_OS_SYMBIAN
77     FlickCharm *charm;
78 #endif
79     QBoxLayout *contentLayout;
80     ListView *list;
81 };
82
83 #endif // LISTWINDOW_H