Add context dependent actions to LibraryDialog. Make folder delete work on non-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
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     explicit ListWindow(QWidget *parent = 0);
22
23     /** Add a list view to the window. */
24     void addList(QListView *list);
25
26     /**
27      * Add an action to the window: either a button, or, on Maemo, a top
28      * level menu item.
29      * Activating the action invokes the slot with no parameters.
30      */
31     void addAction(const QString &title, QObject *receiver, const char *slot,
32         QDialogButtonBox::ButtonRole role = QDialogButtonBox::ActionRole);
33
34     /**
35      * Add an action to the selected item in the list: either a button which is
36      * enabled when a list item is selected, or, on Maemo, a pop-up menu item
37      * which is displayed when a list item is long-pressed.
38      * Activating the action invokes the slot with no parameters.
39      */
40     void addItemAction(const QString &title, QObject *receiver,
41                        const char *slot);
42
43 protected slots:
44     void onSelectionChanged(const QItemSelection &selected,
45                             const QItemSelection &deselected);
46 #ifndef Q_WS_MAEMO_5
47     void activateItemButtons();
48 #endif
49
50 protected:
51 #ifdef Q_WS_MAEMO_5
52     void closeEvent(QCloseEvent *event);
53 #else
54     QDialogButtonBox *buttonBox;
55     QList<QPushButton *> itemButtons;
56 #endif
57     QHBoxLayout *frameLayout;
58     QListView *list;
59 };
60
61 #endif // LISTWINDOW_H