setModel(model);
addButton(tr("Add bookmark"), this, SLOT(onAdd()), "add");
+ addItemButton(tr("Delete bookmark"), this, SLOT(onDelete()), "remove");
connect(this, SIGNAL(activated(const QModelIndex &)),
this, SLOT(onItemActivated(const QModelIndex &)));
#endif
ListWindow::ListWindow(const QString &noItems_, QWidget *parent):
- QMainWindow(parent), mModel(0), noItems(noItems_)
+ MainBase(parent), mModel(0), noItems(noItems_)
{
#if defined(Q_WS_MAEMO_5)
setAttribute(Qt::WA_Maemo5StackedWindow, true);
QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);
closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
- QMainWindow::addAction(closeAction);
+ MainBase::addAction(closeAction);
#endif // Q_OS_SYMBIAN
connect(list, SIGNAL(activated(const QModelIndex &)),
{
TRACE;
-#ifdef Q_OS_SYMBIAN
- Q_UNUSED(iconName);
- addMenuAction(title, receiver, slot);
-#else
+#if defined(Q_WS_MAEMO_5)
Button b;
b.title = title;
b.receiver = receiver;
b.iconName = iconName;
insertButton(buttons.length(), b);
buttons.append(b);
+#else
+ (void)addToolBarAction(receiver, slot, iconName, title, true);
+ (void)addMenuAction(title, receiver, slot);
+#endif
+}
+
+void ListWindow::addItemButton(const QString &title, QObject *receiver,
+ const char *slot, const QString &iconName)
+{
+ TRACE;
+#if defined(Q_WS_MAEMO_5)
+ Q_UNUSED(title);
+ Q_UNUSED(receiver);
+ Q_UNUSED(slot);
+ Q_UNUSED(iconPath);
+#else
+ QAction *toolBarAction =
+ addToolBarAction(receiver, slot, iconName, title, true);
+ // QAction *menuAction = addMenuAction(title, receiver, slot);
+ // toolBarAction->setEnabled(false);
+ // menuAction->setEnabled(false);
+ itemActions.append(toolBarAction);
+ // itemActions.append(menuAction);
#endif
}
Q_UNUSED(slot);
action = new QAction(this);
#endif
- action->setCheckable(true);
return action;
}
}
#endif // Q_WS_MAEMO_5
-
-#ifdef Q_OS_SYMBIAN
-
-void ListWindow::show()
-{
- foreach (QWidget *w, QApplication::allWidgets()) {
- w->setContextMenuPolicy(Qt::NoContextMenu);
- }
- showMaximized();
-}
-
-#endif // Q_OS_SYMBIAN
#ifndef LISTWINDOW_H
#define LISTWINDOW_H
-#include <QMainWindow>
+#include "mainbase.h"
+
#include <QDialogButtonBox>
#include <QList>
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
/** 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 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);
/** 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();
#ifdef Q_OS_SYMBIAN
FlickCharm *charm;
#endif
+ QList<QAction *>itemActions;
};
#endif // LISTWINDOW_H
TRACE;\r
qDebug() << "icon" << iconName << "text" << text;\r
QAction *action;\r
-#ifndef Q_OS_SYMBIAN\r
- Q_UNUSED(important);\r
- action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),\r
- text, receiver, member);\r
-#else\r
- if (!toolBar && important) {\r
- // Create tool bar if needed\r
- toolBar = new QToolBar("", this);\r
- // toolBar->setFixedHeight(63);\r
- toolBar->setStyleSheet("margin:0; border:0; padding:0");\r
- toolBar->setSizePolicy(QSizePolicy::MinimumExpanding,\r
- QSizePolicy::Maximum);\r
- addToolBar(Qt::BottomToolBarArea, toolBar);\r
- }\r
+#ifdef Q_OS_SYMBIAN\r
if (important) {\r
+ if (!toolBar) {\r
+ // Create tool bar if needed\r
+ toolBar = new QToolBar("", this);\r
+ toolBar->setStyleSheet("margin:0; border:0; padding:0");\r
+ addToolBar(Qt::BottomToolBarArea, toolBar);\r
+ }\r
// Add tool bar action\r
QPushButton *button = new QPushButton(this);\r
button->setIconSize(QSize(60, 60));\r
toolBar->addWidget(button);\r
}\r
// Add menu action, too\r
- action = new QAction(text, this);\r
- menuBar()->addAction(action);\r
+ action = menuBar()->addAction(text);\r
connect(action, SIGNAL(triggered()), receiver, member);\r
+#else\r
+ Q_UNUSED(important);\r
+ action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),\r
+ text, receiver, member);\r
#endif\r
\r
- action->setText("");\r
action->setToolTip("");\r
-\r
return action;\r
}\r
\r