X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=widgets%2Flistwindow.h;h=3f75f78333bcf54564b14c59fecd056fa9cf1e26;hb=4d3999dc36d1f07fd1a1b25ac932b2326d29de3d;hp=ba5d77b1689543f050509b26819cefa25d38849e;hpb=86f8b4db28c0a66442d43ba292f3013cd0974a4e;p=dorian diff --git a/widgets/listwindow.h b/widgets/listwindow.h index ba5d77b..3f75f78 100644 --- a/widgets/listwindow.h +++ b/widgets/listwindow.h @@ -1,7 +1,8 @@ #ifndef LISTWINDOW_H #define LISTWINDOW_H -#include +#include "mainbase.h" + #include #include @@ -13,54 +14,78 @@ class QListWidget; class QModelIndex; /** A window with a list and menu actions (Maemo) or buttons (non-Maemo). */ -class ListWindow: public QMainWindow +class ListWindow: public MainBase { Q_OBJECT public: /** * Constructor. - * @param model Model for the list widget contents. + * @param noItems Text to display when the list has no items. * @param parent Parent widget. */ - explicit ListWindow(QWidget *parent = 0); + explicit ListWindow(const QString &noItems, QWidget *parent = 0); - /** - * Set the model for the list. - */ + /** Set the model for the list. */ void setModel(QAbstractItemModel *model); + /** Get model. */ + QAbstractItemModel *model() const; + /** - * Add an action button to the beginning of the list. + * Add an action button to the beginning of the list (Maemo) or to the + * tool bar (non-Maemo). */ void addButton(const QString &title, QObject *receiver, const char *slot, const QString &iconPath = QString()); /** - * Add an action to the menu. - */ + * Add an action button to the tool bar, which is only active if a list + * item is selected. + */ + void addItemButton(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: -#ifdef Q_OS_SYMBIAN - void show(); -#endif + /** Set the current (selected) item. */ + void setCurrentItem(const QModelIndex &item); 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); #endif + +private: QListWidget *list; - QAbstractItemModel *model; - QList buttons; + QAbstractItemModel *mModel; + QList