More 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
17 /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */
18 class ListWindow: public QMainWindow
19 {
20     Q_OBJECT
21
22 public:
23     explicit ListWindow(QWidget *parent = 0);
24
25     /** Add a list view to the window. */
26     void addList(ListView *list);
27
28     /**
29      * Add an action to the window: either a button, or, on Maemo, a top
30      * level menu item.
31      * Activating the action invokes the slot with no parameters.
32      */
33     void addAction(const QString &title, QObject *receiver, const char *slot,
34         const QString &iconPath = QString(),
35         QDialogButtonBox::ButtonRole role = QDialogButtonBox::ActionRole);
36
37     /**
38      * Add an action to the selected item in the list: either a button which is
39      * enabled when a list item is selected, or, on Maemo, a pop-up menu item
40      * which is displayed when a list item is long-pressed.
41      * Activating the action invokes the slot with no parameters.
42      */
43     void addItemAction(const QString &title, QObject *receiver,
44                        const char *slot);
45
46 public slots:
47 #ifdef Q_OS_SYMBIAN
48     void show();
49 #endif
50
51 protected slots:
52     void onSelectionChanged(const QItemSelection &selected,
53                             const QItemSelection &deselected);
54 #ifdef Q_WS_MAEMO_5
55     void onModelChanged();
56 #else
57     void activateItemButtons();
58 #endif
59
60 protected:
61 #ifdef Q_WS_MAEMO_5
62     bool eventFilter(QObject *obj, QEvent *event);
63     void closeEvent(QCloseEvent *event);
64     QMenu *popup;
65 #else
66     QDialogButtonBox *buttonBox;
67     QList<QPushButton *> itemButtons;
68 #endif // Q_WS_MAEMO_5
69     QBoxLayout *contentLayout;
70     ListView *list;
71 };
72
73 #endif // LISTWINDOW_H