Relicense all GPLv2 only code to GPLv2+.
[kdenetwork.git] / kget / core / plugin / transferfactory.cpp
blob0a47ad7bfd1f5a5eac066abeb1b2b79eb6969588
1 /* This file is part of the KDE project
3 Copyright (C) 2004 Dario Massarin <nekkar@libero.it>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
11 #include "transferfactory.h"
13 #include "kget.h"
15 #include <kmenu.h>
16 #include <klocale.h>
18 TransferFactory::TransferFactory()
23 KMenu * TransferFactory::createPopupMenu(QList<TransferHandler *> transfers)
25 if( transfers.empty() )
26 return 0;
28 //First check whether all the transfers in the list belong to the same
29 //transferfactory
30 bool sameFactory = true;
32 QList<TransferHandler *>::iterator it = transfers.begin();
33 QList<TransferHandler *>::iterator itEnd = transfers.end();
35 for(; (it!=itEnd) && (sameFactory) ; ++it)
37 sameFactory = ( (*it)->m_transfer->factory() ==
38 transfers.first()->m_transfer->factory() );
41 //Get the right factory for the given list of transfers
42 QList<KAction *> actionList;
44 if(sameFactory)
45 actionList = transfers.first()->m_transfer->factory()->actions();
46 else
47 actionList = this->actions();
49 KMenu * popup = new KMenu( 0 );
50 // popup->addTitle( i18np("1 Download selected", "%1 Downloads selected", transfers.count()) );
52 //Plug all the actions in the popup menu
53 popup->addAction( KGet::actionCollection()->action("start_selected_download") );
54 popup->addAction( KGet::actionCollection()->action("stop_selected_download") );
55 popup->addAction( KGet::actionCollection()->action("delete_selected_download") );
56 popup->addSeparator();
58 foreach(KAction * it, actionList)
60 //Plug each action in the popup menu
61 popup->addAction( it );
64 if(!actionList.isEmpty())
65 popup->addSeparator();
67 popup->addAction( KGet::actionCollection()->action("transfer_open_dest") );
68 popup->addAction( KGet::actionCollection()->action("transfer_show_details") );
69 popup->addAction( KGet::actionCollection()->action("transfer_copy_source_url") );
71 return popup;