1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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. *
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. *
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 ***************************************************************************/
20 #ifndef REVISIONCONTROLPLUGIN_H
21 #define REVISIONCONTROLPLUGIN_H
23 #include <libdolphin_export.h>
34 * @brief Base class for revision control plugins.
36 * Enables the file manager to show the revision state
37 * of a revisioned file.
39 class LIBDOLPHINPRIVATE_EXPORT RevisionControlPlugin
: public QObject
46 /** The file is not under revision control. */
49 * The file is under revision control and represents
54 * The file is under revision control and a newer
55 * version exists on the main branch.
57 UpdateRequiredRevision
,
59 * The file is under revision control and has been
62 LocallyModifiedRevision
,
64 * The file has not been under revision control but
65 * has been marked to get added with the next commit.
69 * The file is under revision control but has been marked
70 * for getting removed with the next commit.
74 * The file is under revision control and has been locally
75 * modified. A modification has also been done on the main
81 RevisionControlPlugin();
82 virtual ~RevisionControlPlugin();
85 * Returns the name of the file which stores
86 * the revision control informations.
87 * (e. g. .svn, .cvs, .git).
89 virtual QString
fileName() const = 0;
92 * Is invoked whenever the revision control
93 * information will get retrieved for the directory
94 * \p directory. It is assured that the directory
95 * contains a trailing slash.
97 virtual bool beginRetrieval(const QString
& directory
) = 0;
100 * Is invoked after the revision control information has been
101 * received. It is assured that
102 * RevisionControlPlugin::beginInfoRetrieval() has been
105 virtual void endRetrieval() = 0;
108 * Returns the revision state for the file \p item.
109 * It is assured that RevisionControlPlugin::beginInfoRetrieval() has been
110 * invoked before and that the file is part of the directory specified
111 * in beginInfoRetrieval().
113 virtual RevisionState
revisionState(const KFileItem
& item
) = 0;
116 * Returns the list of actions that should be shown in the context menu
117 * for the files \p items. It is assured that the passed list is not empty.
118 * If an action triggers a change of the revisions, the signal
119 * RevisionControlPlugin::revisionStatesChanged() must be emitted.
121 virtual QList
<QAction
*> contextMenuActions(const KFileItemList
& items
) = 0;
124 * Returns the list of actions that should be shown in the context menu
125 * for the directory \p directory. If an action triggers a change of the revisions,
126 * the signal RevisionControlPlugin::revisionStatesChanged() must be emitted.
128 virtual QList
<QAction
*> contextMenuActions(const QString
& directory
) = 0;
132 * Should be emitted when the revision state of files has been changed
133 * after the last retrieval. The file manager will be triggered to
134 * update the revision states of the directory \p directory by invoking
135 * RevisionControlPlugin::beginRetrieval(),
136 * RevisionControlPlugin::revisionState() and
137 * RevisionControlPlugin::endRetrieval().
139 void revisionStatesChanged(const QString
& directory
);
145 // TODO: This is just a temporary test class. It will be made available as
146 // plugin outside Dolphin later.
148 #include <kfileitem.h>
151 class LIBDOLPHINPRIVATE_EXPORT SubversionPlugin
: public RevisionControlPlugin
157 virtual ~SubversionPlugin();
158 virtual QString
fileName() const;
159 virtual bool beginRetrieval(const QString
& directory
);
160 virtual void endRetrieval();
161 virtual RevisionControlPlugin::RevisionState
revisionState(const KFileItem
& item
);
162 virtual QList
<QAction
*> contextMenuActions(const KFileItemList
& items
);
163 virtual QList
<QAction
*> contextMenuActions(const QString
& directory
);
167 void showLocalChanges();
174 * Executes the command "svn {svnCommand}" for the files that have been
175 * set by getting the context menu actions (see contextMenuActions()).
177 void execSvnCommand(const QString
& svnCommand
);
180 QHash
<QString
, RevisionState
> m_revisionInfoHash
;
181 QList
<QString
> m_revisionInfoKeys
; // cache for accessing the keys of the hash
183 QAction
* m_updateAction
;
184 QAction
* m_showLocalChangesAction
;
185 QAction
* m_commitAction
;
186 QAction
* m_addAction
;
187 QAction
* m_removeAction
;
188 mutable QString m_contextDir
;
189 mutable KFileItemList m_contextItems
;
191 #endif // REVISIONCONTROLPLUGIN_H