Commit 0d3b54f4 authored by Knut Petter Svendsen's avatar Knut Petter Svendsen
Browse files

ClearCase: Don't show Hijack button for dynamic view



The Hijack button (makeWriteableButton) should only
be shown for snapshot views.

Change-Id: I809981885d18b6057d82f73b5104b0f1041cd255
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 4c9d2e53
......@@ -85,7 +85,6 @@ bool BazaarControl::supportsOperation(Operation operation) const
case Core::IVersionControl::GetRepositoryRootOperation:
break;
case Core::IVersionControl::CheckoutOperation:
case Core::IVersionControl::OpenOperation:
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
......
......@@ -68,7 +68,6 @@ bool ClearCaseControl::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
case OpenOperation:
case AddOperation:
case DeleteOperation:
case MoveOperation:
......@@ -84,6 +83,14 @@ bool ClearCaseControl::supportsOperation(Operation operation) const
return rc;
}
Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode() const
{
if (m_plugin->isDynamic())
return IVersionControl::OpenMandatory; // Checkout is the only option for dynamic views
else
return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out
}
bool ClearCaseControl::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
......
......@@ -52,6 +52,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
OpenSupportMode openSupportMode() const;
bool vcsOpen(const QString &fileName);
SettingsFlags settingsFlags() const;
bool vcsAdd(const QString &fileName);
......
......@@ -158,6 +158,7 @@ public:
QString currentView() const { return m_viewData.name; }
void refreshActivities();
inline bool isUcm() const { return m_viewData.isUcm; }
inline bool isDynamic() const { return m_viewData.isDynamic; }
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
......
......@@ -813,7 +813,7 @@ DocumentManager::ReadOnlyAction
{
// Version Control: If automatic open is desired, open right away.
bool promptVCS = false;
if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
if (versionControl && versionControl->openSupportMode() != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen)
return RO_OpenVCS;
promptVCS = true;
......@@ -824,22 +824,30 @@ DocumentManager::ReadOnlyAction
tr("The file <i>%1</i> is read only.").arg(QDir::toNativeSeparators(fileName)),
QMessageBox::Cancel, parent);
QString makeWritableText;
QPushButton *vcsButton = 0;
if (promptVCS) {
vcsButton = msgBox.addButton(versionControl->vcsOpenText(), QMessageBox::AcceptRole);
makeWritableText = versionControl->vcsMakeWritableText();
}
if (makeWritableText.isEmpty())
makeWritableText = tr("Make &Writable");
QPushButton *makeWritableButton = msgBox.addButton(makeWritableText, QMessageBox::AcceptRole);
QString makeWritableText;
QPushButton *makeWritableButton = 0;
// If the VCS has OpenMandatory we don't show "Make Writable"
if (versionControl->openSupportMode() != IVersionControl::OpenMandatory) {
makeWritableText = versionControl->vcsMakeWritableText();
if (makeWritableText.isEmpty())
makeWritableText = tr("Make &Writable");
makeWritableButton = msgBox.addButton(makeWritableText, QMessageBox::AcceptRole);
}
QPushButton *saveAsButton = 0;
if (displaySaveAsButton)
saveAsButton = msgBox.addButton(tr("&Save As..."), QMessageBox::ActionRole);
msgBox.setDefaultButton(vcsButton ? vcsButton : makeWritableButton);
if (vcsButton)
msgBox.setDefaultButton(vcsButton);
else if (makeWritableButton)
msgBox.setDefaultButton(makeWritableButton);
msgBox.exec();
QAbstractButton *clickedButton = msgBox.clickedButton();
......
......@@ -1709,7 +1709,7 @@ void EditorManager::vcsOpenCurrentEditor()
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
if (!versionControl || !versionControl->supportsOperation(IVersionControl::OpenOperation))
if (!versionControl || versionControl->openSupportMode() == IVersionControl::NoOpen)
return;
if (!versionControl->vcsOpen(curEditor->document()->fileName())) {
......@@ -1763,7 +1763,7 @@ void EditorManager::updateMakeWritableWarning()
bool promptVCS = false;
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
if (versionControl && versionControl->openSupportMode() != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
vcsOpenCurrentEditor();
ww = false;
......
......@@ -46,4 +46,9 @@ QString IVersionControl::vcsTopic(const QString &)
return QString();
}
IVersionControl::OpenSupportMode IVersionControl::openSupportMode() const
{
return NoOpen;
}
}
......@@ -50,7 +50,7 @@ public:
Q_DECLARE_FLAGS(SettingsFlags, SettingsFlag)
enum Operation {
AddOperation, DeleteOperation, OpenOperation, MoveOperation,
AddOperation, DeleteOperation, MoveOperation,
CreateRepositoryOperation,
SnapshotOperations,
AnnotateOperation,
......@@ -58,6 +58,12 @@ public:
GetRepositoryRootOperation
};
enum OpenSupportMode {
NoOpen, /*!< Files can be edited without noticing the VCS */
OpenOptional, /*!< Files can be opened by the VCS, or hijacked */
OpenMandatory /*!< Files must always be opened by the VCS */
};
explicit IVersionControl(QObject *parent = 0) : QObject(parent) {}
virtual ~IVersionControl() {}
......@@ -85,6 +91,11 @@ public:
*/
virtual bool supportsOperation(Operation operation) const = 0;
/*!
* Returns the open support mode.
*/
virtual OpenSupportMode openSupportMode() const;
/*!
* Called prior to save, if the file is read only. Should be implemented if
* the scc requires a operation before editing the file, e.g. 'p4 edit'
......
......@@ -69,7 +69,6 @@ bool CvsControl::supportsOperation(Operation operation) const
case AddOperation:
case DeleteOperation:
case AnnotateOperation:
case OpenOperation:
break;
case MoveOperation:
case CreateRepositoryOperation:
......@@ -82,6 +81,11 @@ bool CvsControl::supportsOperation(Operation operation) const
return rc;
}
Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode() const
{
return OpenOptional;
}
bool CvsControl::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
......
......@@ -51,6 +51,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
OpenSupportMode openSupportMode() const;
bool vcsOpen(const QString &fileName);
bool vcsAdd(const QString &fileName);
bool vcsDelete(const QString &filename);
......
......@@ -80,8 +80,6 @@ bool GitVersionControl::supportsOperation(Operation operation) const
case CheckoutOperation:
case GetRepositoryRootOperation:
return true;
case OpenOperation:
break;
}
return false;
}
......
......@@ -85,7 +85,6 @@ bool MercurialControl::supportsOperation(Operation operation) const
case Core::IVersionControl::CheckoutOperation:
case Core::IVersionControl::GetRepositoryRootOperation:
break;
case Core::IVersionControl::OpenOperation:
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
......
......@@ -71,7 +71,6 @@ bool PerforceVersionControl::supportsOperation(Operation operation) const
case AddOperation:
case DeleteOperation:
case MoveOperation:
case OpenOperation:
case AnnotateOperation:
return supported;
case CreateRepositoryOperation:
......@@ -83,6 +82,11 @@ bool PerforceVersionControl::supportsOperation(Operation operation) const
return false;
}
Core::IVersionControl::OpenSupportMode PerforceVersionControl::openSupportMode() const
{
return OpenOptional;
}
bool PerforceVersionControl::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
......
......@@ -50,6 +50,7 @@ public:
bool isConfigured() const;
bool supportsOperation(Operation operation) const;
OpenSupportMode openSupportMode() const;
bool vcsOpen(const QString &fileName);
SettingsFlags settingsFlags() const;
bool vcsAdd(const QString &fileName);
......
......@@ -73,7 +73,6 @@ bool SubversionControl::supportsOperation(Operation operation) const
case CheckoutOperation:
case GetRepositoryRootOperation:
break;
case OpenOperation:
case CreateRepositoryOperation:
case SnapshotOperations:
rc = false;
......
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