bugfixes, confirm dialogs for remove actions
authortmarki <tmarki@gmail.com>
Sun, 8 Aug 2010 20:48:15 +0000 (22:48 +0200)
committertmarki <tmarki@gmail.com>
Sun, 8 Aug 2010 20:48:15 +0000 (22:48 +0200)
mainwindow.cpp
playlistmanager.cpp

index 14cf5ee..2f8022b 100644 (file)
@@ -504,6 +504,8 @@ void MainWindow::setupActions()
 
 void MainWindow::removeSelectedItem()
 {
+    if (QMessageBox::question(this, "Confirm remove", "Are you sure you want to remove this item?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
+        return;
     int row = musicTable->currentRow();
     if (row >= 0)
         plman.removeItem(row);
@@ -511,6 +513,8 @@ void MainWindow::removeSelectedItem()
 
 void MainWindow::removeAllButSelectedItem()
 {
+    if (QMessageBox::question(this, "Confirm remove", "Are you sure you want to remove all other items?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
+        return;
     int row = musicTable->currentRow();
     if (row >= 0)
     {
index 5ddfcf4..4488583 100644 (file)
@@ -58,7 +58,8 @@ void PlaylistManager::parseAndAddFolder(const QString &dir, bool recursive)
             items.append(PlaylistItem (PlaylistItem (fname)));
         }
     }
-    if (!items.isEmpty())
+//    if (!items.isEmpty())
+    if (items.size () > index)
     {
         metaInformationResolver->setCurrentSource(items.at(index).source);
         lastMetaRead = index;
@@ -78,7 +79,8 @@ void PlaylistManager::addStringList(const QStringList& list)
             items.append(PlaylistItem (string));
         }
     }
-    if (!items.isEmpty())
+//    if (!items.isEmpty())
+    if (items.size () > index)
     {
         metaInformationResolver->setCurrentSource(items.at(index).source);
         lastMetaRead = index;
@@ -200,7 +202,8 @@ void PlaylistManager::addPlaylist(const QString& filename)
         appendPlaylist(filename);
     else if (filename.right(4).toLower() == ".pls")
         appendPlaylistPLS(filename);
-    if (!items.isEmpty())
+    if (items.size () > index)
+//    if (!items.isEmpty())
     {
         metaInformationResolver->setCurrentSource(items.at(index).source);
         lastMetaRead = index;