From 114a878c64ce6f8223cfd22d76a20eb16d177e5e Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- lib/interfaces/extensions/kdevversioncontrol.h | 237 +++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 lib/interfaces/extensions/kdevversioncontrol.h (limited to 'lib/interfaces/extensions/kdevversioncontrol.h') diff --git a/lib/interfaces/extensions/kdevversioncontrol.h b/lib/interfaces/extensions/kdevversioncontrol.h new file mode 100644 index 00000000..d6e69e08 --- /dev/null +++ b/lib/interfaces/extensions/kdevversioncontrol.h @@ -0,0 +1,237 @@ +/* This file is part of the KDE project + Copyright (C) 2001 Matthias Hoelzer-Kluepfel + Copyright (C) 2002-2003 Roberto Raggi + Copyright (C) 2002 Simon Hausmann + Copyright (C) 2003 Mario Scalas + Copyright (C) 2004 Alexander Dymo + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +#ifndef KDEVVERSIONCONTROL_H +#define KDEVVERSIONCONTROL_H + +#include +#include +#include +#include +#include + +#include + +/** +@file kdevversioncontrol.h +Version control system interface and utility classes. +*/ + +/** +Info about file state in VCS. + +Used, for example in file views to display VCS related information about files. +*/ +struct VCSFileInfo +{ + /**State of the file.*/ + enum FileState { + Unknown /** VCSFileInfoMap; @endcode +*/ +typedef QMap VCSFileInfoMap; + +class KDevVCSFileInfoProvider; + + +/** +KDevelop version control system interface. +This is the abstract base class which encapsulates everything +necessary for communicating with version control systems. +VCS support plugins should implement this interface. + +Instances that implement this interface are available through extension architecture: +@code +KDevVersionControl *vcs = extension("KDevelop/VersionControl"); +if (vcs) { + // do something +} else { + // fail +} +@endcode +@sa KDevPlugin::extension method documentation. +*/ +class KDevVersionControl: public KDevPlugin +{ + Q_OBJECT + +public: + /**Constructs a VCS plugin. + @param info Important information about the plugin - plugin internal and generic + (GUI) name, description, a list of authors, etc. That information is used to show + plugin information in various places like "about application" dialog, plugin selector + dialog, etc. Plugin does not take ownership on info object, also its lifetime should + be equal to the lifetime of the plugin. + @param parent The parent object for the plugin. Parent object must implement @ref KDevApi + interface. Otherwise the plugin will not be constructed. + @param name The internal name which identifies the plugin.*/ + KDevVersionControl(const KDevPluginInfo *info, QObject *parent, const char *name ) + :KDevPlugin(info, parent, name ) {} + + /**Creates a new project in the passed path @p dir. This should instantiate + VCS infrastructure and import a project into the VCS in that directory. + @param dir The absolute path to the directory where VCS infrastructure should be + created.*/ + virtual void createNewProject(const QString& dir) = 0; + + /**Fetches a module from remote repository, so it can be used for importing. + @return true in case of success.*/ + virtual bool fetchFromRepository() = 0; + + /**@return The file info provider for this version control (0 if none is available).*/ + virtual KDevVCSFileInfoProvider *fileInfoProvider() const = 0; + + /**Checks if the directory is valid for this version control (for example + CVS may check for the presence of "/CVS/" subdir and something else) + @param dirPath The absolute path of the directory. + @return true if the directory is valid for this version control + warning: this returns false by default.*/ + virtual bool isValidDirectory(const QString &dirPath) const = 0; + + +signals: + /**Emitted when the Version Control has finished importing a module from remote + repository + @param destinationDir The directory where the module has been fetched.*/ + void finishedFetching(QString destinationDir); + +}; + +/** +Basic interface for providing info on file registered in a version control repository repository. +*/ +class KDevVCSFileInfoProvider: public QObject +{ + Q_OBJECT +public: + /**Constructor. + @param parent The parent VCS plugin. + @param name The name of a provider object.*/ + KDevVCSFileInfoProvider(KDevVersionControl *parent, const char *name) + : QObject( parent, name ), m_owner(parent) {} + + /**Gets the status for local files in the specified directory: + the info are collected locally so they are necessarily in sync with the repository + + This is a synchronous operation (blocking). + @param dirPath The relative (to project dir) directory path to stat. + @return Status for all registered files.*/ + virtual const VCSFileInfoMap *status(const QString &dirPath) = 0; + + /**Starts a request for directory status to the remote repository. + Requests and answers are asynchronous. + + This is an asynchronous operation for requesting data, so + for obvious reasons: the caller must connect the statusReady() signal and + check for the return value of this method. + @param dirPath The (relative to project directory) directory which status you are asking for. + @param callerData The pointer to some data you want the provider will return + to you when it has done. + @param recursive If false, retrieve information only for dirPath's immediate children. + @param checkRepos If true, contact remote repository and augment repository's status. + If false, retrieve only for local modification information. + @return true if the request has been successfully started, false otherwise.*/ + virtual bool requestStatus( const QString &dirPath, void *callerData, bool recursive = true, bool checkRepos = true ) = 0; + +signals: + /**Emitted when the status request to remote repository has finished. + @param fileInfoMap The status for registered in repository files. + @param callerData The pointer to some data you want the provider will return + to you when it has done + @see requestStatus for to find out when this signal should be used.*/ + void statusReady(const VCSFileInfoMap &fileInfoMap, void *callerData); + +protected: + /**@return The version control which owns this provider.*/ + KDevVersionControl *owner() const { return m_owner; } + +private: + KDevVersionControl *m_owner; + +private: + KDevVCSFileInfoProvider( const KDevVCSFileInfoProvider & ); + KDevVCSFileInfoProvider &operator=( const KDevVCSFileInfoProvider & ); +}; + +#endif -- cgit v1.2.1