[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kget
From:       Matthias Fuchs <mat69 () gmx ! net>
Date:       2011-08-09 17:00:50
Message-ID: 20110809170050.5C8E1AC87A () svn ! kde ! org
[Download RAW message or body]

SVN commit 1246039 by mfuchs:

"Delete Selected" also removes groups if only groups are selected.

 M  +11 -3     core/kget.cpp  
 M  +1 -1      core/kget.h  
 M  +12 -2     mainwindow.cpp  
 M  +2 -10     ui/contextmenu.cpp  


--- trunk/KDE/kdenetwork/kget/core/kget.cpp #1246038:1246039
@@ -472,8 +472,11 @@
     return finishedTransfers;
 }
 
-QList<TransferGroupHandler *> KGet::selectedTransferGroups()
+QList<TransferGroupHandler *> KGet::selectedTransferGroups(bool *mainSelected)
 {
+    if (mainSelected) {
+        *mainSelected = false;
+    }
     QList<TransferGroupHandler *> selectedTransferGroups;
 
     QModelIndexList selectedIndexes = m_selectionModel->selectedRows();
@@ -481,9 +484,14 @@
     foreach(const QModelIndex &currentIndex, selectedIndexes)
     {
         ModelItem * item = m_transferTreeModel->itemFromIndex(currentIndex);
-        if (item->isGroup())
-            selectedTransferGroups.append(item->asGroup()->groupHandler());
+        if (item->isGroup()) {
+            TransferGroupHandler *group = item->asGroup()->groupHandler();
+            if (mainSelected && group->name() == i18n("My Downloads")) {
+                *mainSelected = true;
     }
+            selectedTransferGroups.append(group);
+        }
+    }
 
     return selectedTransferGroups;
 }
--- trunk/KDE/kdenetwork/kget/core/kget.h #1246038:1246039
@@ -208,7 +208,7 @@
          * @returns the list of selected groups
          */
         static QList<TransferGroupHandler *>
-        selectedTransferGroups();
+        selectedTransferGroups(bool *mainSelected = 0);
 
         /**
          * @returns a pointer to the TransferTreeModel object
--- trunk/KDE/kdenetwork/kget/mainwindow.cpp #1246038:1246039
@@ -544,8 +544,12 @@
 
 void MainWindow::slotDeleteGroup()
 {
-    KGet::delGroups(KGet::selectedTransferGroups());
+    bool mainSelected;
+    QList<TransferGroupHandler*> groups = KGet::selectedTransferGroups(&mainSelected);
+    if (!mainSelected) {
+        KGet::delGroups(groups);
 }
+}
 
 void MainWindow::slotRenameGroup()
 {
@@ -645,11 +649,17 @@
         }
     }
 
-    foreach (TransferHandler * it, KGet::selectedTransfers()) {
+    const QList<TransferHandler*> selectedTransfers = KGet::selectedTransfers();
+    if (!selectedTransfers.isEmpty()) {
+        foreach (TransferHandler *it, selectedTransfers) {
         m_viewsContainer->closeTransferDetails(it);//TODO make it take QList?
     }
     KGet::delTransfers(KGet::selectedTransfers());
+    } else {
+        //no transfers selected, delete groups if any are selected
+        slotDeleteGroup();
 }
+}
 
 void MainWindow::slotRedownloadSelected()
 {
--- trunk/KDE/kdenetwork/kget/ui/contextmenu.cpp #1246038:1246039
@@ -134,16 +134,8 @@
     popup->addAction(KGet::actionCollection()->action("transfer_group_settings"));
     popup->addSeparator();
 
-    QList<TransferGroupHandler *> transferGroups = KGet::selectedTransferGroups();
-    bool containsMainGroup = false;
-    foreach(TransferGroupHandler *transHandler, transferGroups)
-    {
-        if(transHandler->name() == i18n("My Downloads"))
-        {
-            containsMainGroup = true;
-            break;
-        }
-    }
+    bool containsMainGroup;
+    QList<TransferGroupHandler *> transferGroups = KGet::selectedTransferGroups(&containsMainGroup);
     if(!containsMainGroup) {
         const int numGroups = transferGroups.count();
         QAction *action = KGet::actionCollection()->action("delete_groups");
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic