• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

ark

  • sources
  • kde-4.14
  • kdeutils
  • ark
  • app
extractHereDndPlugin.cpp
Go to the documentation of this file.
1 /*
2  * ark -- archiver for the KDE project
3  *
4  * Copyright (C) 2009 Harald Hvaal <haraldhv (at@at) stud.ntnu.no>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #include "extractHereDndPlugin.h"
23 #include "batchextract.h"
24 #include "kerfuffle/archive.h"
25 
26 #include <KAction>
27 #include <KDebug>
28 #include <KPluginFactory>
29 #include <KPluginLoader>
30 #include <KLocale>
31 #include <kfileitemlistproperties.h>
32 
33 K_PLUGIN_FACTORY(ExtractHerePluginFactory,
34  registerPlugin<ExtractHereDndPlugin>();
35  )
36 K_EXPORT_PLUGIN(ExtractHerePluginFactory("stupidname", "ark"))
37 
38 void ExtractHereDndPlugin::slotTriggered()
39 {
40  kDebug() << "Preparing job";
41  BatchExtract *batchJob = new BatchExtract();
42 
43  batchJob->setAutoSubfolder(true);
44  batchJob->setDestinationFolder(m_dest.pathOrUrl());
45  batchJob->setPreservePaths(true);
46  foreach(const KUrl& url, m_urls) {
47  batchJob->addInput(url);
48  }
49 
50  batchJob->start();
51  kDebug() << "Started job";
52 
53 }
54 
55 ExtractHereDndPlugin::ExtractHereDndPlugin(QObject* parent, const QVariantList&)
56  : KonqDndPopupMenuPlugin(parent)
57 {
58 }
59 
60 void ExtractHereDndPlugin::setup(const KFileItemListProperties& popupMenuInfo,
61  KUrl destination,
62  QList<QAction*>& userActions)
63 {
64  const QString extractHereMessage = i18nc("@action:inmenu Context menu shown when an archive is being drag'n'dropped", "Extract here");
65 
66  if (!Kerfuffle::supportedMimeTypes().contains(popupMenuInfo.mimeType())) {
67  kDebug() << popupMenuInfo.mimeType() << "is not a supported mimetype";
68  return;
69  }
70 
71  kDebug() << "Plugin executed";
72 
73  KAction *action = new KAction(KIcon(QLatin1String("archive-extract")),
74  extractHereMessage, NULL);
75  connect(action, SIGNAL(triggered()), this, SLOT(slotTriggered()));
76 
77  userActions.append(action);
78  m_dest = destination;
79  m_urls = popupMenuInfo.urlList();
80 }
81 
82 #include "extractHereDndPlugin.moc"
ExtractHereDndPlugin::setup
virtual void setup(const KFileItemListProperties &popupMenuInfo, KUrl destination, QList< QAction * > &userActions)
Definition: extractHereDndPlugin.cpp:60
extractHereDndPlugin.h
BatchExtract::addInput
bool addInput(const KUrl &url)
Adds a file to the list of files that will be extracted.
Definition: batchextract.cpp:207
archive.h
BatchExtract::setAutoSubfolder
void setAutoSubfolder(bool value)
Set whether a folder should be created when necessary so the archive is extracted to it...
Definition: batchextract.cpp:111
QList::append
void append(const T &value)
ExtractHereDndPlugin
Definition: extractHereDndPlugin.h:28
Kerfuffle::supportedMimeTypes
QStringList supportedMimeTypes()
Definition: archive.cpp:279
QObject
K_PLUGIN_FACTORY
K_PLUGIN_FACTORY(ExtractHerePluginFactory, registerPlugin< ExtractHereDndPlugin >();) void ExtractHereDndPlugin
Definition: extractHereDndPlugin.cpp:33
QString
QList
batchextract.h
BatchExtract::setPreservePaths
void setPreservePaths(bool value)
Sets whether paths should be preserved during extraction.
Definition: batchextract.cpp:252
QLatin1String
BatchExtract::start
void start()
A wrapper that calls slotStartJob() when the event loop has started.
Definition: batchextract.cpp:116
BatchExtract::setDestinationFolder
void setDestinationFolder(const QString &folder)
Sets the directory the archives will be extracted to.
Definition: batchextract.cpp:240
KonqDndPopupMenuPlugin
ExtractHereDndPlugin::ExtractHereDndPlugin
ExtractHereDndPlugin(QObject *parent, const QVariantList &)
Definition: extractHereDndPlugin.cpp:55
BatchExtract
This class schedules the extraction of all given compressed archives.
Definition: batchextract.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:37 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ark

Skip menu "ark"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal