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