Commit b9f92c29 authored by hjk's avatar hjk
Browse files

vcsmanager: coding convention

parent c5fb5bb4
...@@ -129,7 +129,7 @@ VariableManager *CoreImpl::variableManager() const ...@@ -129,7 +129,7 @@ VariableManager *CoreImpl::variableManager() const
return m_mainwindow->variableManager(); return m_mainwindow->variableManager();
} }
VCSManager *CoreImpl::vcsManager() const VcsManager *CoreImpl::vcsManager() const
{ {
return m_mainwindow->vcsManager(); return m_mainwindow->vcsManager();
} }
......
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
ProgressManager *progressManager() const; ProgressManager *progressManager() const;
ScriptManager *scriptManager() const; ScriptManager *scriptManager() const;
VariableManager *variableManager() const; VariableManager *variableManager() const;
VCSManager *vcsManager() const; VcsManager *vcsManager() const;
ModeManager *modeManager() const; ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const; MimeDatabase *mimeDatabase() const;
HelpManager *helpManager() const; HelpManager *helpManager() const;
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
*/ */
/*! /*!
\fn VCSManager *ICore::vcsManager() const \fn VcsManager *ICore::vcsManager() const
\brief Returns the application's vcs manager. \brief Returns the application's vcs manager.
The vcs manager can be used to e.g. retrieve information about The vcs manager can be used to e.g. retrieve information about
......
...@@ -59,7 +59,7 @@ class ScriptManager; ...@@ -59,7 +59,7 @@ class ScriptManager;
class SettingsDatabase; class SettingsDatabase;
class UniqueIDManager; class UniqueIDManager;
class VariableManager; class VariableManager;
class VCSManager; class VcsManager;
class CORE_EXPORT ICore : public QObject class CORE_EXPORT ICore : public QObject
{ {
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
virtual ProgressManager *progressManager() const = 0; virtual ProgressManager *progressManager() const = 0;
virtual ScriptManager *scriptManager() const = 0; virtual ScriptManager *scriptManager() const = 0;
virtual VariableManager *variableManager() const = 0; virtual VariableManager *variableManager() const = 0;
virtual VCSManager *vcsManager() const = 0; virtual VcsManager *vcsManager() const = 0;
virtual ModeManager *modeManager() const = 0; virtual ModeManager *modeManager() const = 0;
virtual MimeDatabase *mimeDatabase() const = 0; virtual MimeDatabase *mimeDatabase() const = 0;
virtual HelpManager *helpManager() const = 0; virtual HelpManager *helpManager() const = 0;
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
* Returns whether files in this directory should be managed with this * Returns whether files in this directory should be managed with this
* version control. * version control.
* If \a topLevel is non-null, it should return the topmost directory, * If \a topLevel is non-null, it should return the topmost directory,
* for which this IVersionControl should be used. The VCSManager assumes * for which this IVersionControl should be used. The VcsManager assumes
* that all files in the returned directory are managed by the same IVersionControl. * that all files in the returned directory are managed by the same IVersionControl.
*/ */
......
...@@ -131,7 +131,7 @@ MainWindow::MainWindow() : ...@@ -131,7 +131,7 @@ MainWindow::MainWindow() :
m_progressManager(new ProgressManagerPrivate()), m_progressManager(new ProgressManagerPrivate()),
m_scriptManager(new ScriptManagerPrivate(this)), m_scriptManager(new ScriptManagerPrivate(this)),
m_variableManager(new VariableManager), m_variableManager(new VariableManager),
m_vcsManager(new VCSManager), m_vcsManager(new VcsManager),
m_statusBarManager(0), m_statusBarManager(0),
m_modeManager(0), m_modeManager(0),
m_mimeDatabase(new MimeDatabase), m_mimeDatabase(new MimeDatabase),
...@@ -1000,7 +1000,7 @@ MessageManager *MainWindow::messageManager() const ...@@ -1000,7 +1000,7 @@ MessageManager *MainWindow::messageManager() const
return m_messageManager; return m_messageManager;
} }
VCSManager *MainWindow::vcsManager() const VcsManager *MainWindow::vcsManager() const
{ {
return m_vcsManager; return m_vcsManager;
} }
......
...@@ -62,7 +62,7 @@ class ScriptManager; ...@@ -62,7 +62,7 @@ class ScriptManager;
class SettingsDatabase; class SettingsDatabase;
class UniqueIDManager; class UniqueIDManager;
class VariableManager; class VariableManager;
class VCSManager; class VcsManager;
namespace Internal { namespace Internal {
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
Core::MimeDatabase *mimeDatabase() const; Core::MimeDatabase *mimeDatabase() const;
Core::HelpManager *helpManager() const; Core::HelpManager *helpManager() const;
VCSManager *vcsManager() const; VcsManager *vcsManager() const;
QSettings *settings(QSettings::Scope scope) const; QSettings *settings(QSettings::Scope scope) const;
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; } inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
virtual QPrinter *printer() const; virtual QPrinter *printer() const;
...@@ -186,7 +186,7 @@ private: ...@@ -186,7 +186,7 @@ private:
ProgressManagerPrivate *m_progressManager; ProgressManagerPrivate *m_progressManager;
ScriptManager *m_scriptManager; ScriptManager *m_scriptManager;
QScopedPointer<VariableManager> m_variableManager; QScopedPointer<VariableManager> m_variableManager;
VCSManager *m_vcsManager; VcsManager *m_vcsManager;
StatusBarManager *m_statusBarManager; StatusBarManager *m_statusBarManager;
ModeManager *m_modeManager; ModeManager *m_modeManager;
MimeDatabase *m_mimeDatabase; MimeDatabase *m_mimeDatabase;
......
...@@ -59,22 +59,24 @@ static inline VersionControlList allVersionControls() ...@@ -59,22 +59,24 @@ static inline VersionControlList allVersionControls()
// ---- VCSManagerPrivate: // ---- VCSManagerPrivate:
// Maintains a cache of top-level directory->version control. // Maintains a cache of top-level directory->version control.
struct VCSManagerPrivate { class VcsManagerPrivate
{
public:
VersionControlCache m_cachedMatches; VersionControlCache m_cachedMatches;
}; };
VCSManager::VCSManager(QObject *parent) : VcsManager::VcsManager(QObject *parent) :
QObject(parent), QObject(parent),
m_d(new VCSManagerPrivate) m_d(new VcsManagerPrivate)
{ {
} }
VCSManager::~VCSManager() VcsManager::~VcsManager()
{ {
delete m_d; delete m_d;
} }
void VCSManager::extensionsInitialized() void VcsManager::extensionsInitialized()
{ {
// Change signal connections // Change signal connections
FileManager *fileManager = ICore::instance()->fileManager(); FileManager *fileManager = ICore::instance()->fileManager();
...@@ -91,7 +93,7 @@ static bool longerThanPath(QPair<QString, IVersionControl *> &pair1, QPair<QStri ...@@ -91,7 +93,7 @@ static bool longerThanPath(QPair<QString, IVersionControl *> &pair1, QPair<QStri
return pair1.first.size() > pair2.first.size(); return pair1.first.size() > pair2.first.size();
} }
IVersionControl* VCSManager::findVersionControlForDirectory(const QString &directory, IVersionControl* VcsManager::findVersionControlForDirectory(const QString &directory,
QString *topLevelDirectory) QString *topLevelDirectory)
{ {
typedef VersionControlCache::const_iterator VersionControlCacheConstIterator; typedef VersionControlCache::const_iterator VersionControlCacheConstIterator;
...@@ -181,14 +183,14 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc ...@@ -181,14 +183,14 @@ IVersionControl* VCSManager::findVersionControlForDirectory(const QString &direc
return 0; return 0;
} }
bool VCSManager::promptToDelete(const QString &fileName) bool VcsManager::promptToDelete(const QString &fileName)
{ {
if (IVersionControl *vc = findVersionControlForDirectory(QFileInfo(fileName).absolutePath())) if (IVersionControl *vc = findVersionControlForDirectory(QFileInfo(fileName).absolutePath()))
return promptToDelete(vc, fileName); return promptToDelete(vc, fileName);
return true; return true;
} }
IVersionControl *VCSManager::checkout(const QString &versionControlType, IVersionControl *VcsManager::checkout(const QString &versionControlType,
const QString &directory, const QString &directory,
const QByteArray &url) const QByteArray &url)
{ {
...@@ -205,7 +207,7 @@ IVersionControl *VCSManager::checkout(const QString &versionControlType, ...@@ -205,7 +207,7 @@ IVersionControl *VCSManager::checkout(const QString &versionControlType,
return 0; return 0;
} }
bool VCSManager::findVersionControl(const QString &versionControlType) bool VcsManager::findVersionControl(const QString &versionControlType)
{ {
foreach (IVersionControl * versionControl, allVersionControls()) { foreach (IVersionControl * versionControl, allVersionControls()) {
if (versionControl->displayName() == versionControlType) if (versionControl->displayName() == versionControlType)
...@@ -214,7 +216,7 @@ bool VCSManager::findVersionControl(const QString &versionControlType) ...@@ -214,7 +216,7 @@ bool VCSManager::findVersionControl(const QString &versionControlType)
return false; return false;
} }
QString VCSManager::repositoryUrl(const QString &directory) QString VcsManager::repositoryUrl(const QString &directory)
{ {
IVersionControl *vc = findVersionControlForDirectory(directory); IVersionControl *vc = findVersionControlForDirectory(directory);
...@@ -223,15 +225,14 @@ QString VCSManager::repositoryUrl(const QString &directory) ...@@ -223,15 +225,14 @@ QString VCSManager::repositoryUrl(const QString &directory)
return QString(); return QString();
} }
bool VCSManager::promptToDelete(IVersionControl *vc, const QString &fileName) bool VcsManager::promptToDelete(IVersionControl *vc, const QString &fileName)
{ {
QTC_ASSERT(vc, return true) QTC_ASSERT(vc, return true)
if (!vc->supportsOperation(IVersionControl::DeleteOperation)) if (!vc->supportsOperation(IVersionControl::DeleteOperation))
return true; return true;
const QString title = QCoreApplication::translate("VCSManager", "Version Control"); const QString title = tr("Version Control");
const QString msg = QCoreApplication::translate("VCSManager", const QString msg = tr("Would you like to remove this file from the version control system (%1)?\n"
"Would you like to remove this file from the version control system (%1)?\n" "Note: This might remove the local file.").arg(vc->displayName());
"Note: This might remove the local file.").arg(vc->displayName());
const QMessageBox::StandardButton button = const QMessageBox::StandardButton button =
QMessageBox::question(0, title, msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::question(0, title, msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (button != QMessageBox::Yes) if (button != QMessageBox::Yes)
...@@ -239,7 +240,7 @@ bool VCSManager::promptToDelete(IVersionControl *vc, const QString &fileName) ...@@ -239,7 +240,7 @@ bool VCSManager::promptToDelete(IVersionControl *vc, const QString &fileName)
return vc->vcsDelete(fileName); return vc->vcsDelete(fileName);
} }
CORE_EXPORT QDebug operator<<(QDebug in, const VCSManager &v) CORE_EXPORT QDebug operator<<(QDebug in, const VcsManager &v)
{ {
QDebug nospace = in.nospace(); QDebug nospace = in.nospace();
const VersionControlCache::const_iterator cend = v.m_d->m_cachedMatches.constEnd(); const VersionControlCache::const_iterator cend = v.m_d->m_cachedMatches.constEnd();
......
...@@ -41,12 +41,12 @@ QT_END_NAMESPACE ...@@ -41,12 +41,12 @@ QT_END_NAMESPACE
namespace Core { namespace Core {
struct VCSManagerPrivate; class VcsManagerPrivate;
class IVersionControl; class IVersionControl;
/* VCSManager: /* VcsManager:
* 1) Provides functionality for finding the IVersionControl * for a given * 1) Provides functionality for finding the IVersionControl * for a given
* filename (findVersionControlForDirectory). Note that the VCSManager assumes * filename (findVersionControlForDirectory). Note that the VcsManager assumes
* that if a IVersionControl * manages a directory, then it also manages * that if a IVersionControl * manages a directory, then it also manages
* all the files and all the subdirectories. * all the files and all the subdirectories.
* It works by asking all IVersionControl * if they manage the file, and ask * It works by asking all IVersionControl * if they manage the file, and ask
...@@ -56,13 +56,12 @@ class IVersionControl; ...@@ -56,13 +56,12 @@ class IVersionControl;
* branching repositories and routes them to its signals (repositoryChanged, * branching repositories and routes them to its signals (repositoryChanged,
* filesChanged). */ * filesChanged). */
class CORE_EXPORT VCSManager : public QObject class CORE_EXPORT VcsManager : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(VCSManager)
public: public:
explicit VCSManager(QObject *parent = 0); explicit VcsManager(QObject *parent = 0);
virtual ~VCSManager(); virtual ~VcsManager();
void extensionsInitialized(); void extensionsInitialized();
...@@ -82,16 +81,16 @@ public: ...@@ -82,16 +81,16 @@ public:
bool promptToDelete(const QString &fileName); bool promptToDelete(const QString &fileName);
bool promptToDelete(IVersionControl *versionControl, const QString &fileName); bool promptToDelete(IVersionControl *versionControl, const QString &fileName);
friend CORE_EXPORT QDebug operator<<(QDebug in, const VCSManager &); friend CORE_EXPORT QDebug operator<<(QDebug in, const VcsManager &);
signals: signals:
void repositoryChanged(const QString &repository); void repositoryChanged(const QString &repository);
private: private:
VCSManagerPrivate *m_d; VcsManagerPrivate *m_d;
}; };
CORE_EXPORT QDebug operator<<(QDebug in, const VCSManager &); CORE_EXPORT QDebug operator<<(QDebug in, const VcsManager &);
} // namespace Core } // namespace Core
......
...@@ -102,7 +102,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) ...@@ -102,7 +102,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
// Objects // Objects
m_modelManager = new CppModelManager(this); m_modelManager = new CppModelManager(this);
Core::VCSManager *vcsManager = core->vcsManager(); Core::VcsManager *vcsManager = core->vcsManager();
Core::FileManager *fileManager = core->fileManager(); Core::FileManager *fileManager = core->fileManager();
connect(vcsManager, SIGNAL(repositoryChanged(QString)), connect(vcsManager, SIGNAL(repositoryChanged(QString)),
m_modelManager, SLOT(updateModifiedSourceFiles())); m_modelManager, SLOT(updateModifiedSourceFiles()));
......
...@@ -1036,7 +1036,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType, ...@@ -1036,7 +1036,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
QFileInfo fi(m_projectFilePath); QFileInfo fi(m_projectFilePath);
if (!fi.isWritable()) { if (!fi.isWritable()) {
// Try via vcs manager // Try via vcs manager
Core::VCSManager *vcsManager = Core::ICore::instance()->vcsManager(); Core::VcsManager *vcsManager = Core::ICore::instance()->vcsManager();
Core::IVersionControl *versionControl = vcsManager->findVersionControlForDirectory(fi.absolutePath()); Core::IVersionControl *versionControl = vcsManager->findVersionControlForDirectory(fi.absolutePath());
if (!versionControl || versionControl->vcsOpen(m_projectFilePath)) { if (!versionControl || versionControl->vcsOpen(m_projectFilePath)) {
bool makeWritable = QFile::setPermissions(m_projectFilePath, fi.permissions() | QFile::WriteUser); bool makeWritable = QFile::setPermissions(m_projectFilePath, fi.permissions() | QFile::WriteUser);
......
...@@ -202,7 +202,7 @@ void StateListener::slotStateChanged() ...@@ -202,7 +202,7 @@ void StateListener::slotStateChanged()
{ {
const ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); const ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
const Core::ICore *core = Core::ICore::instance(); const Core::ICore *core = Core::ICore::instance();
Core::VCSManager *vcsManager = core->vcsManager(); Core::VcsManager *vcsManager = core->vcsManager();
// Get the current file. Are we on a temporary submit editor indicated by // Get the current file. Are we on a temporary submit editor indicated by
// temporary path prefix or does the file contains a hash, indicating a project // temporary path prefix or does the file contains a hash, indicating a project
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment