Re-design ListWindow.
[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 QString;
9 class QPushButton;
10 class FlickCharm;
11 class QAbstractItemModel;
12 class QListWidget;
13 class QModelIndex;
14
15 /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */
16 class ListWindow: public QMainWindow
17 {
18     Q_OBJECT
19
20 public:
21     /**
22      * Constructor.
23      * @param   model   Model for the list widget contents.
24      * @param   parent  Parent widget.
25      */
26     explicit ListWindow(QWidget *parent = 0);
27
28     /**
29      * Set the model for the list.
30      */
31     void setModel(QAbstractItemModel *model);
32
33     /**
34      * Add an action button to the beginning of the list.
35      */
36     void addButton(const QString &title, QObject *receiver, const char *slot,
37                    const QString &iconPath = QString());
38
39     /**
40       * Add an action to the menu.
41       */
42     QAction *addMenuAction(const QString &title, QObject *receiver,
43                            const char *slot);
44
45 public slots:
46 #ifdef Q_OS_SYMBIAN
47     void show();
48 #endif
49
50 protected slots:
51     void onItemActivated(const QModelIndex &);
52     void populateList();
53
54 protected:
55     QListWidget *list;
56     QAbstractItemModel *model;
57     QList<QPushButton *> buttons;
58 #ifdef Q_OS_SYMBIAN
59     FlickCharm *charm;
60 #endif
61 };
62
63 #endif // LISTWINDOW_H