X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=widgets%2Flistwindow.cpp;h=291da6b28b1cb8e363af081fbe0f17f49b0bc9f0;hb=4d3999dc36d1f07fd1a1b25ac932b2326d29de3d;hp=b0691bcedd5704d731ba9f83b6ba6ca8495fd32b;hpb=183951ae5a26f05d3e66a1e62b3ddae57528f08e;p=dorian diff --git a/widgets/listwindow.cpp b/widgets/listwindow.cpp index b0691bc..291da6b 100644 --- a/widgets/listwindow.cpp +++ b/widgets/listwindow.cpp @@ -11,7 +11,7 @@ #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); @@ -20,16 +20,19 @@ ListWindow::ListWindow(const QString &noItems_, QWidget *parent): list = new QListWidget(this); list->setSelectionMode(QAbstractItemView::SingleSelection); +#if defined(Q_OS_SYMBIAN) + list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +#endif populateList(); setCentralWidget(list); #ifdef Q_OS_SYMBIAN charm = new FlickCharm(this); - charm->activateOn(list); + // charm->activateOn(list); 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 &)), @@ -65,6 +68,9 @@ void ListWindow::insertButton(int row, const Button &b) { QPushButton *pushButton = new QPushButton( QIcon(Platform::instance()->icon(b.iconName)), b.title, this); +#ifdef Q_OS_SYMBIAN + pushButton->setFixedWidth(list->width()); +#endif connect(pushButton, SIGNAL(clicked()), b.receiver, b.slot); QListWidgetItem *item = new QListWidgetItem(); item->setFlags(Qt::NoItemFlags); @@ -98,14 +104,38 @@ void ListWindow::addButton(const QString &title, QObject *receiver, { TRACE; +#if defined(Q_WS_MAEMO_5) Button b; b.title = title; b.receiver = receiver; b.slot = slot; 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 } QAction *ListWindow::addMenuAction(const QString &title, QObject *receiver, @@ -127,13 +157,21 @@ QAction *ListWindow::addMenuAction(const QString &title, QObject *receiver, Q_UNUSED(slot); action = new QAction(this); #endif - action->setCheckable(true); return action; } void ListWindow::onItemActivated(const QModelIndex &index) { TRACE; + + // Work around Qt/Symbian^3 bug: Disabled list items still can be selected + if (!mModel) { + return; + } + if (!mModel->rowCount()) { + return; + } + int row = index.row() - buttons.count(); qDebug() << "Activated" << index.row() << ", emit activated(" << row << ")"; emit activated(mModel->index(row, 0)); @@ -163,20 +201,8 @@ void ListWindow::closeEvent(QCloseEvent *event) { // Work around Maemo/Qt bug: Menu items are not removed on close menuBar()->clear(); - // FIXME: Is this needed? event->accept(); + event->accept(); QMainWindow::closeEvent(event); } #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