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. The methods
38 * RevisionControlPlugin::beginRetrieval(),
39 * RevisionControlPlugin::endRetrieval() and
40 * RevisionControlPlugin::revisionState() are invoked
41 * from a separate thread to assure that the GUI thread
42 * won't be blocked. All other methods are invoked in the
43 * scope of the GUI thread.
45 class LIBDOLPHINPRIVATE_EXPORT RevisionControlPlugin
: public QObject
54 UpdateRequiredRevision
,
60 RevisionControlPlugin();
61 virtual ~RevisionControlPlugin();
64 * Returns the name of the file which stores
65 * the revision control informations.
66 * (e. g. .svn, .cvs, .git).
68 virtual QString
fileName() const = 0;
71 * Is invoked whenever the revision control
72 * information will get retrieved for the directory
73 * \p directory. It is assured that the directory
74 * contains a trailing slash.
76 virtual bool beginRetrieval(const QString
& directory
) = 0;
79 * Is invoked after the revision control information has been
80 * received. It is assured that
81 * RevisionControlPlugin::beginInfoRetrieval() has been
84 virtual void endRetrieval() = 0;
87 * Returns the revision state for the file \p item.
88 * It is assured that RevisionControlPlugin::beginInfoRetrieval() has been
89 * invoked before and that the file is part of the directory specified
90 * in beginInfoRetrieval().
92 virtual RevisionState
revisionState(const KFileItem
& item
) = 0;
95 * Returns the list of actions that should be shown in the context menu
96 * for the files \p items. If no files are provided by \p items, the context
97 * menu is valid for the current directory (see RevisionControlPlugin::beginRetrieval()).
98 * If an action triggers a change of the revisions, the signal
99 * RevisionControlPlugin::revisionStatesChanged() must be emitted.
101 virtual QList
<QAction
*> contextMenuActions(const KFileItemList
& items
) const = 0;
105 * Should be emitted when the revision state of files has been changed
106 * after the last retrieval. The file manager will be triggered to
107 * update the revision states of the directory \p directory by invoking
108 * RevisionControlPlugin::beginRetrieval(),
109 * RevisionControlPlugin::revisionState() and
110 * RevisionControlPlugin::endRetrieval().
112 void revisionStatesChanged(const QString
& directory
);
118 // TODO: This is just a temporary test class. It will be made available as
119 // plugin outside Dolphin later.
121 #include <QFileInfoList>
124 class LIBDOLPHINPRIVATE_EXPORT SubversionPlugin
: public RevisionControlPlugin
128 virtual ~SubversionPlugin();
129 virtual QString
fileName() const;
130 virtual bool beginRetrieval(const QString
& directory
);
131 virtual void endRetrieval();
132 virtual RevisionControlPlugin::RevisionState
revisionState(const KFileItem
& item
);
133 virtual QList
<QAction
*> contextMenuActions(const KFileItemList
& items
) const;
137 * Returns true, if the content of the local file \p name is equal to the
138 * content of the revisioned file.
140 bool equalRevisionContent(const QString
& name
) const;
150 QHash
<QString
, RevisionInfo
> m_revisionInfoHash
;
152 QAction
* m_updateAction
;
153 QAction
* m_commitAction
;
154 QAction
* m_addAction
;
155 QAction
* m_removeAction
;
157 #endif // REVISIONCONTROLPLUGIN_H