]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectionmanager.cpp
The feature freeze is near: Add video support to the Information Panel. Phonon is...
[dolphin.git] / src / selectionmanager.cpp
index 26ea3626a983433e10b35e7f55107f4e3c06ffa0..1722bc3c5d20f7ba39a0f0899187686a29dce7fd 100644 (file)
@@ -106,15 +106,17 @@ void SelectionManager::setItemSelected(bool selected)
 {
     emit selectionChanged();
 
-    const QModelIndex index = indexForUrl(m_toggle->url());
-    if (index.isValid()) {
-        QItemSelectionModel* selModel = m_view->selectionModel();
-        if (selected) {
-            selModel->select(index, QItemSelectionModel::Select);
-        } else {
-            selModel->select(index, QItemSelectionModel::Deselect);
+    if (!m_toggle->url().isEmpty()) {
+        const QModelIndex index = indexForUrl(m_toggle->url());
+        if (index.isValid()) {
+            QItemSelectionModel* selModel = m_view->selectionModel();
+            if (selected) {
+                selModel->select(index, QItemSelectionModel::Select);
+            } else {
+                selModel->select(index, QItemSelectionModel::Deselect);
+            }
+            selModel->setCurrentIndex(index, QItemSelectionModel::Current);
         }
-        selModel->setCurrentIndex(index, QItemSelectionModel::Current);
     }
 }
 
@@ -132,14 +134,16 @@ void SelectionManager::slotSelectionChanged(const QItemSelection& selected,
     // The selection has been changed outside the scope of the selection manager
     // (e. g. by the rubberband or the "Select All" action). Take care updating
     // the state of the toggle button.
-    const QModelIndex index = indexForUrl(m_toggle->url());
-    if (index.isValid()) {
-        if (selected.contains(index)) {
-            m_toggle->setChecked(true);
-        }
-
-        if (deselected.contains(index)) {
-            m_toggle->setChecked(false);
+    if (!m_toggle->url().isEmpty()) {
+        const QModelIndex index = indexForUrl(m_toggle->url());
+        if (index.isValid()) {
+            if (selected.contains(index)) {
+                m_toggle->setChecked(true);
+            }
+
+            if (deselected.contains(index)) {
+                m_toggle->setChecked(false);
+            }
         }
     }
 }