]> cloud.milkyroute.net Git - dolphin.git/blob - src/versioncontrol/fileviewsvnplugin.h
Restore the "Edit->Selection" menu from Konqueror 3 for file
[dolphin.git] / src / versioncontrol / fileviewsvnplugin.h
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef FILEVIEWSVNPLUGIN_H
21 #define FILEVIEWSVNPLUGIN_H
22
23 #include <kfileitem.h>
24 #include <kversioncontrolplugin.h>
25 #include <QHash>
26 #include <QProcess>
27 #include <QTemporaryFile>
28
29 // TODO: This class will be moved to kdevplatform as soon as kdevplatform will
30 // be released. Moving it to kdevplatform allows to reuse code for the context
31 // menu actions like commit, add, update, ...
32 class FileViewSvnPlugin : public KVersionControlPlugin
33 {
34 Q_OBJECT
35
36 public:
37 FileViewSvnPlugin(QObject* parent, const QList<QVariant>& args);
38 virtual ~FileViewSvnPlugin();
39 virtual QString fileName() const;
40 virtual bool beginRetrieval(const QString& directory);
41 virtual void endRetrieval();
42 virtual KVersionControlPlugin::VersionState versionState(const KFileItem& item);
43 virtual QList<QAction*> contextMenuActions(const KFileItemList& items);
44 virtual QList<QAction*> contextMenuActions(const QString& directory);
45
46 private slots:
47 void updateFiles();
48 void showLocalChanges();
49 void commitFiles();
50 void addFiles();
51 void removeFiles();
52
53 void slotOperationCompleted(int exitCode, QProcess::ExitStatus exitStatus);
54 void slotOperationError();
55
56 private:
57 /**
58 * Executes the command "svn {svnCommand}" for the files that have been
59 * set by getting the context menu actions (see contextMenuActions()).
60 * @param infoMsg Message that should be shown before the command is executed.
61 * @param errorMsg Message that should be shown if the execution of the command
62 * has been failed.
63 * @param operationCompletedMsg
64 * Message that should be shown if the execution of the command
65 * has been completed successfully.
66 */
67 void execSvnCommand(const QString& svnCommand,
68 const QString& infoMsg,
69 const QString& errorMsg,
70 const QString& operationCompletedMsg);
71
72 void startSvnCommandProcess();
73
74 private:
75 QHash<QString, VersionState> m_versionInfoHash;
76 QList<QString> m_versionInfoKeys; // cache for accessing the keys of the hash
77
78 QAction* m_updateAction;
79 QAction* m_showLocalChangesAction;
80 QAction* m_commitAction;
81 QAction* m_addAction;
82 QAction* m_removeAction;
83
84 QString m_command;
85 QString m_errorMsg;
86 QString m_operationCompletedMsg;
87
88 QString m_contextDir;
89 KFileItemList m_contextItems;
90
91 QTemporaryFile m_tempFile;
92 };
93 #endif // FILEVIEWSVNPLUGIN_H
94