* maximal -> maximum
[kdenetwork.git] / kget / ui / contextmenu.cpp
blob125934d69f5bd66473dcda18ae7f93304cbf9a37
1 /* This file is part of the KDE project
3 Copyright (C) 2004 Dario Massarin <nekkar@libero.it>
4 Copyright (C) 2008 Lukas Appelhans <l.appelhans@gmx.de>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
12 #include "contextmenu.h"
14 #ifdef HAVE_NEPOMUK
15 #include "ui/nepomukwidget.h"
16 #endif
18 #include "core/kget.h"
19 #include "core/plugin/transferfactory.h"
20 #include "core/transferhandler.h"
21 #include "core/transfergrouphandler.h"
22 #include <KMenu>
23 #include <QWidgetAction>
26 KMenu * ContextMenu::createTransferContextMenu(QList<TransferHandler*> transfers, QWidget *parent)
28 if (transfers.empty())
29 return 0;
31 //First check whether all the transfers in the list belong to the same
32 //transferfactory
33 bool sameFactory = true;
35 QList<TransferHandler *>::iterator it = transfers.begin();
36 QList<TransferHandler *>::iterator itEnd = transfers.end();
38 for(; (it!=itEnd) && (sameFactory) ; ++it)
40 //sameFactory = ( (*it)->m_transfer->factory() == //Port factory() to transferhandler
41 // transfers.first()->m_transfer->factory() );
44 KMenu *popup = new KMenu(parent);
45 //Get the transfer factory actions
46 QList<QAction*> actionList = transfers.first()->factoryActions();
47 // popup->addTitle( i18np("1 Download selected", "%1 Downloads selected", transfers.count()) );
49 //Plug all the actions in the popup menu
50 popup->addActions(transfers.first()->contextActions());
51 popup->addSeparator();
52 popup->addAction( KGet::actionCollection()->action("transfer_settings") );
53 popup->addSeparator();
55 foreach(QAction * it, actionList)
57 //Plug each action in the popup menu
58 popup->addAction( it );
61 if(!actionList.isEmpty())
62 popup->addSeparator();
64 #ifdef HAVE_NEPOMUK
65 KMenu *nepomukMenu = new KMenu(i18n("Semantic desktop"), parent);
66 nepomukMenu->setIcon(KIcon("nepomuk"));
67 QWidgetAction *nepomukWidget = new QWidgetAction(parent);
68 nepomukWidget->setDefaultWidget(new NepomukWidget(transfers.first(), parent));
69 nepomukMenu->addAction(nepomukWidget);
70 popup->addMenu(nepomukMenu);
71 #endif
73 popup->addAction( KGet::actionCollection()->action("transfer_open_dest") );
74 popup->addAction( KGet::actionCollection()->action("transfer_open_file") );
75 popup->addAction( KGet::actionCollection()->action("transfer_show_details") );
76 popup->addAction( KGet::actionCollection()->action("transfer_copy_source_url") );
77 return popup;
80 KMenu * ContextMenu::createTransferContextMenu(TransferHandler* handler, QWidget *parent)
82 return ContextMenu::createTransferContextMenu(QList<TransferHandler*>() << handler, parent);
85 KMenu * ContextMenu::createTransferGroupContextMenu(TransferGroupHandler *handler, QWidget *parent)
87 if (!handler)
88 return 0;
90 KMenu * popup = new KMenu(parent);
91 // popup->addTitle( i18nc( "%1 is the name of the group", "%1 Group", name() ) );
93 popup->addActions(handler->actions());
94 popup->addSeparator();
95 popup->addAction(KGet::actionCollection()->action("transfer_group_settings"));
96 popup->addSeparator();
97 if(handler->name() != i18n("My Downloads")) {
98 popup->addAction( KGet::actionCollection()->action("delete_groups") );
99 popup->addAction( KGet::actionCollection()->action("rename_groups") );
101 popup->addAction( KGet::actionCollection()->action("seticon_groups") );
102 return popup;