Symbian fixes.
[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 public slots:
48 #ifdef Q_OS_SYMBIAN
49     void show();
50 #endif
51
52 protected slots:
53     void onSelectionChanged(const QItemSelection &selected,
54                             const QItemSelection &deselected);
55 #ifdef Q_WS_MAEMO_5
56     void onModelChanged();
57 #else
58     void activateItemButtons();
59 #endif
60
61 protected:
62 #ifdef Q_WS_MAEMO_5
63     bool eventFilter(QObject *obj, QEvent *event);
64     void closeEvent(QCloseEvent *event);
65     QMenu *popup;
66 #else
67     QDialogButtonBox *buttonBox;
68     QList<QPushButton *> itemButtons;
69 #endif // Q_WS_MAEMO_5
70 #ifdef Q_OS_SYMBIAN
71     FlickCharm *charm;
72 #endif
73     QBoxLayout *contentLayout;
74     ListView *list;
75 };
76
77 #endif // LISTWINDOW_H