X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=widgets%2Flistwindow.h;h=3b3c23518cbb8bc50db424d363308becd9a4f0ff;hb=ee43811f99a9f2f047ed4aceeea2bdbf411f2fe0;hp=f912df31824e2963465bf1bb4fb8fe9494714c6a;hpb=243b9c4cd5f75f9236b3aae437d2ac8c80470778;p=dorian diff --git a/widgets/listwindow.h b/widgets/listwindow.h index f912df3..3b3c235 100644 --- a/widgets/listwindow.h +++ b/widgets/listwindow.h @@ -5,12 +5,12 @@ #include #include -class QListView; class QString; -class QHBoxLayout; class QPushButton; +class FlickCharm; +class QAbstractItemModel; +class QListWidget; class QModelIndex; -class QItemSelection; /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */ class ListWindow: public QMainWindow @@ -18,44 +18,66 @@ class ListWindow: public QMainWindow Q_OBJECT public: - explicit ListWindow(QWidget *parent = 0); - - /** Add a list view to the window. */ - void addList(QListView *list); - /** - * Add an action to the window: either a button, or, on Maemo, a top - * level menu item. - * Activating the action invokes the slot with no parameters. + * Constructor. + * @param noItems Text to display when the list has no items. + * @param parent Parent widget. */ - void addAction(const QString &title, QObject *receiver, const char *slot, - QDialogButtonBox::ButtonRole role = QDialogButtonBox::ActionRole); + explicit ListWindow(const QString &noItems, QWidget *parent = 0); - /** - * Add an action to the selected item in the list: either a button which is - * enabled when a list item is selected, or, on Maemo, a pop-up menu item - * which is displayed when a list item is long-pressed. - * Activating the action invokes the slot with no parameters. - */ - void addItemAction(const QString &title, QObject *receiver, - const char *slot); + /** Set the model for the list. */ + void setModel(QAbstractItemModel *model); -protected slots: - void onSelectionChanged(const QItemSelection &selected, - const QItemSelection &deselected); -#ifndef Q_WS_MAEMO_5 - void activateItemButtons(); + /** Get model. */ + QAbstractItemModel *model() const; + + /** Add an action button to the beginning of the list. */ + void addButton(const QString &title, QObject *receiver, const char *slot, + const QString &iconPath = QString()); + + /** Add an action to the menu. */ + QAction *addMenuAction(const QString &title, QObject *receiver, + const char *slot); + + /** Get current (selected) item. */ + QModelIndex currentItem() const; + +signals: + /** Emitted when a list item is activated. */ + void activated(const QModelIndex &index); + +public slots: + /** Set the current (selected) item. */ + void setCurrentItem(const QModelIndex &item); + +#ifdef Q_OS_SYMBIAN + void show(); #endif +protected slots: + void onItemActivated(const QModelIndex &); + void populateList(); + protected: + struct Button { + QString title; + QObject *receiver; + const char *slot; + QString iconName; + }; + void insertButton(int row, const Button &button); #ifdef Q_WS_MAEMO_5 void closeEvent(QCloseEvent *event); -#else - QDialogButtonBox *buttonBox; - QList itemButtons; #endif - QHBoxLayout *frameLayout; - QListView *list; + +private: + QListWidget *list; + QAbstractItemModel *mModel; + QList