Smoothen switch between full screen/normal view on Maemo.
[dorian] / widgets / listwindow.cpp
index e44a781..5e6fa34 100644 (file)
@@ -37,6 +37,10 @@ ListWindow::ListWindow(const QString &noItems_, QWidget *parent):
 
     connect(list, SIGNAL(activated(const QModelIndex &)),
             this, SLOT(onItemActivated(const QModelIndex &)));
+    connect(list, SIGNAL(itemSelectionChanged()),
+            this, SLOT(onItemSelectionChanged()));
+    connect(list, SIGNAL(itemSelectionChanged()),
+            this, SIGNAL(itemSelectionChanged()));
 }
 
 void ListWindow::populateList()
@@ -125,7 +129,7 @@ void ListWindow::addItemButton(const QString &title, QObject *receiver,
     Q_UNUSED(title);
     Q_UNUSED(receiver);
     Q_UNUSED(slot);
-    Q_UNUSED(iconPath);
+    Q_UNUSED(iconName);
 #else
     QAction *toolBarAction =
             addToolBarAction(receiver, slot, iconName, title, true);
@@ -169,7 +173,8 @@ void ListWindow::onItemActivated(const QModelIndex &index)
     }
 
     int row = index.row() - buttons.count();
-    qDebug() << "Activated" << index.row() << ", emit activated(" << row << ")";
+    qDebug() << "Activated" << index.row() << ", emit activated(" << row
+            << ")";
     emit activated(mModel->index(row, 0));
 }
 
@@ -202,3 +207,12 @@ void ListWindow::closeEvent(QCloseEvent *event)
 }
 
 #endif // Q_WS_MAEMO_5
+
+void ListWindow::onItemSelectionChanged()
+{
+    TRACE;
+    bool enabled = currentItem().isValid();
+    foreach (QAction *action, itemActions) {
+        action->setEnabled(enabled);
+    }
+}