forked from qt-creator/qt-creator
File renaming
Reviewed-By: con Reviewed-By: Friedemann Kleint We now support renaming files. The version control system tries first to rename, if that doesn't support or can't rename the file we do a normal rename. (Note: git, hg, perforce > 2009.02 support renaming, cvs not. (perforce untested)). We correctly notify all editors of the renamed file and tell the project manager to rename the file in the project. Note: Only the qt4projectmanager knows how to rename files. Note: renaming folders, moving files to different folders, renaming .pro/.pri files is not supported. Those things can be later added after this has proven to work correctly in the simple case. Also we don't do any actions based on the renaming like renaming classes, changing include guards or #include lines.
This commit is contained in:
@@ -196,6 +196,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rename(const QString &newName) {
|
||||||
|
m_fileName = newName;
|
||||||
|
m_editor->editorInterface()->setDisplayName(QFileInfo(fileName()).fileName());
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
bool open(const QString &fileName) {
|
bool open(const QString &fileName) {
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
@@ -305,6 +311,7 @@ public:
|
|||||||
m_toolBar->addWidget(w);
|
m_toolBar->addWidget(w);
|
||||||
|
|
||||||
connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int)));
|
connect(m_editor, SIGNAL(cursorPositionChanged(int)), this, SLOT(updateCursorPosition(int)));
|
||||||
|
connect(m_file, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
~BinEditorInterface() {
|
~BinEditorInterface() {
|
||||||
delete m_editor;
|
delete m_editor;
|
||||||
|
@@ -155,6 +155,9 @@ ImageViewer::ImageViewer(QObject *parent)
|
|||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
m_imageView->setLayout(layout);
|
m_imageView->setLayout(layout);
|
||||||
layout->addWidget(m_label, 0, 0, 1, 1);
|
layout->addWidget(m_label, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
connect(m_file, SIGNAL(changed()),
|
||||||
|
this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageViewer::~ImageViewer()
|
ImageViewer::~ImageViewer()
|
||||||
|
@@ -70,6 +70,7 @@ public:
|
|||||||
explicit ImageViewerFile(ImageViewer *parent = 0);
|
explicit ImageViewerFile(ImageViewer *parent = 0);
|
||||||
|
|
||||||
bool save(const QString &fileName = QString()) { Q_UNUSED(fileName); return false; }
|
bool save(const QString &fileName = QString()) { Q_UNUSED(fileName); return false; }
|
||||||
|
void rename(const QString &newName) { m_fileName = newName; }
|
||||||
QString fileName() const { return m_fileName; }
|
QString fileName() const { return m_fileName; }
|
||||||
|
|
||||||
QString defaultPath() const { return QString(); }
|
QString defaultPath() const { return QString(); }
|
||||||
|
@@ -595,6 +595,13 @@ bool CMakeFile::isSaveAsAllowed() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMakeFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
Q_ASSERT(false);
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
// Can't happen....
|
||||||
|
}
|
||||||
|
|
||||||
Core::IFile::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
Core::IFile::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(state)
|
Q_UNUSED(state)
|
||||||
|
@@ -196,6 +196,8 @@ public:
|
|||||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||||
void reload(ReloadFlag flag, ChangeType type);
|
void reload(ReloadFlag flag, ChangeType type);
|
||||||
|
|
||||||
|
void rename(const QString &newName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMakeProject *m_project;
|
CMakeProject *m_project;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
|
@@ -43,8 +43,9 @@ bool CMakeProjectNode::hasBuildTargets() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectExplorer::ProjectNode::ProjectAction> CMakeProjectNode::supportedActions() const
|
QList<ProjectExplorer::ProjectNode::ProjectAction> CMakeProjectNode::supportedActions(Node *node) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(node);
|
||||||
return QList<ProjectAction>();
|
return QList<ProjectAction>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ class CMakeProjectNode : public ProjectExplorer::ProjectNode
|
|||||||
public:
|
public:
|
||||||
CMakeProjectNode(const QString &fileName);
|
CMakeProjectNode(const QString &fileName);
|
||||||
virtual bool hasBuildTargets() const;
|
virtual bool hasBuildTargets() const;
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions() const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool addFiles(const ProjectExplorer::FileType fileType,
|
virtual bool addFiles(const ProjectExplorer::FileType fileType,
|
||||||
|
@@ -123,6 +123,11 @@ struct FileManagerPrivate {
|
|||||||
QString m_lastVisitedDirectory;
|
QString m_lastVisitedDirectory;
|
||||||
QString m_projectsDirectory;
|
QString m_projectsDirectory;
|
||||||
bool m_useProjectsDirectory;
|
bool m_useProjectsDirectory;
|
||||||
|
// When we are callling into a IFile
|
||||||
|
// we don't want to receive a changed()
|
||||||
|
// signal
|
||||||
|
// That makes the code easier
|
||||||
|
IFile *m_blockedIFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
FileManagerPrivate::FileManagerPrivate(QObject *q, QMainWindow *mw) :
|
FileManagerPrivate::FileManagerPrivate(QObject *q, QMainWindow *mw) :
|
||||||
@@ -131,10 +136,11 @@ FileManagerPrivate::FileManagerPrivate(QObject *q, QMainWindow *mw) :
|
|||||||
m_blockActivated(false),
|
m_blockActivated(false),
|
||||||
m_lastVisitedDirectory(QDir::currentPath()),
|
m_lastVisitedDirectory(QDir::currentPath()),
|
||||||
#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder.
|
#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder.
|
||||||
m_useProjectsDirectory(true)
|
m_useProjectsDirectory(true),
|
||||||
#else
|
#else
|
||||||
m_useProjectsDirectory(false)
|
m_useProjectsDirectory(false),
|
||||||
#endif
|
#endif
|
||||||
|
m_blockedIFile(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +258,55 @@ void FileManager::updateFileInfo(IFile *file)
|
|||||||
d->m_states[fixedname].lastUpdatedState.insert(file, item);
|
d->m_states[fixedname].lastUpdatedState.insert(file, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Dumps the state of the file manager's map
|
||||||
|
/// For debugging purposes
|
||||||
|
void FileManager::dump()
|
||||||
|
{
|
||||||
|
QMap<QString, Internal::FileState>::const_iterator it, end;
|
||||||
|
it = d->m_states.constBegin();
|
||||||
|
end = d->m_states.constEnd();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
qDebug()<<" ";
|
||||||
|
qDebug() << it.key();
|
||||||
|
qDebug() << it.value().expected.modified;
|
||||||
|
|
||||||
|
QMap<IFile *, Internal::FileStateItem>::const_iterator jt, jend;
|
||||||
|
jt = it.value().lastUpdatedState.constBegin();
|
||||||
|
jend = it.value().lastUpdatedState.constEnd();
|
||||||
|
for (; jt != jend; ++jt) {
|
||||||
|
qDebug() << jt.key() << jt.value().modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileManager::renamedFile(const QString &from, QString &to)
|
||||||
|
{
|
||||||
|
QString fixedFrom = fixFileName(from);
|
||||||
|
QString fixedTo = fixFileName(to);
|
||||||
|
if (d->m_states.contains(fixedFrom)) {
|
||||||
|
QTC_ASSERT(!d->m_states.contains(to), return);
|
||||||
|
d->m_states.insert(fixedTo, d->m_states.value(fixedFrom));
|
||||||
|
d->m_states.remove(fixedFrom);
|
||||||
|
QFileInfo fi(to);
|
||||||
|
d->m_states[fixedTo].expected.modified = fi.lastModified();
|
||||||
|
d->m_states[fixedTo].expected.permissions = fi.permissions();
|
||||||
|
|
||||||
|
d->m_fileWatcher->removePath(fixedFrom);
|
||||||
|
d->m_fileWatcher->addPath(fixedTo);
|
||||||
|
|
||||||
|
QMap<IFile *, Internal::FileStateItem>::iterator it, end;
|
||||||
|
it = d->m_states[fixedTo].lastUpdatedState.begin();
|
||||||
|
end = d->m_states[fixedTo].lastUpdatedState.end();
|
||||||
|
|
||||||
|
for ( ; it != end; ++it) {
|
||||||
|
d->m_blockedIFile = it.key();
|
||||||
|
it.key()->rename(to);
|
||||||
|
d->m_blockedIFile = it.key();
|
||||||
|
it.value().modified = fi.lastModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Does not use file->fileName, as such is save to use
|
/// Does not use file->fileName, as such is save to use
|
||||||
/// with renamed files and deleted files
|
/// with renamed files and deleted files
|
||||||
@@ -336,6 +391,10 @@ bool FileManager::removeFile(IFile *file)
|
|||||||
void FileManager::checkForNewFileName()
|
void FileManager::checkForNewFileName()
|
||||||
{
|
{
|
||||||
IFile *file = qobject_cast<IFile *>(sender());
|
IFile *file = qobject_cast<IFile *>(sender());
|
||||||
|
// We modified the IFile
|
||||||
|
// Trust the other code to also update the m_states map
|
||||||
|
if (file == d->m_blockedIFile)
|
||||||
|
return;
|
||||||
QTC_ASSERT(file, return);
|
QTC_ASSERT(file, return);
|
||||||
const QString &fileName = fixFileName(file->fileName());
|
const QString &fileName = fixFileName(file->fileName());
|
||||||
|
|
||||||
@@ -751,6 +810,7 @@ void FileManager::checkForReload()
|
|||||||
end = lastUpdated.constEnd();
|
end = lastUpdated.constEnd();
|
||||||
for ( ; it != end; ++it) {
|
for ( ; it != end; ++it) {
|
||||||
IFile *file = it.key();
|
IFile *file = it.key();
|
||||||
|
d->m_blockedIFile = file;
|
||||||
// Compare
|
// Compare
|
||||||
if (it.value().modified == fi.lastModified()
|
if (it.value().modified == fi.lastModified()
|
||||||
&& it.value().permissions == fi.permissions()) {
|
&& it.value().permissions == fi.permissions()) {
|
||||||
@@ -832,6 +892,7 @@ void FileManager::checkForReload()
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateFileInfo(file);
|
updateFileInfo(file);
|
||||||
|
d->m_blockedIFile = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,6 +63,8 @@ public:
|
|||||||
bool isFileManaged(const QString &fileName) const;
|
bool isFileManaged(const QString &fileName) const;
|
||||||
QList<IFile *> modifiedFiles() const;
|
QList<IFile *> modifiedFiles() const;
|
||||||
|
|
||||||
|
void renamedFile(const QString &from, QString &to);
|
||||||
|
|
||||||
void blockFileChange(IFile *file);
|
void blockFileChange(IFile *file);
|
||||||
void unblockFileChange(IFile *file);
|
void unblockFileChange(IFile *file);
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ public:
|
|||||||
QStringList recentFiles() const;
|
QStringList recentFiles() const;
|
||||||
void saveRecentFiles();
|
void saveRecentFiles();
|
||||||
|
|
||||||
|
|
||||||
// current file
|
// current file
|
||||||
void setCurrentFile(const QString &filePath);
|
void setCurrentFile(const QString &filePath);
|
||||||
QString currentFile() const;
|
QString currentFile() const;
|
||||||
@@ -128,6 +131,7 @@ private slots:
|
|||||||
void syncWithEditor(Core::IContext *context);
|
void syncWithEditor(Core::IContext *context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void dump();
|
||||||
void addFileInfo(IFile *file);
|
void addFileInfo(IFile *file);
|
||||||
void removeFileInfo(IFile *file);
|
void removeFileInfo(IFile *file);
|
||||||
void removeFileInfo(const QString &fileName, IFile *file);
|
void removeFileInfo(const QString &fileName, IFile *file);
|
||||||
|
@@ -87,6 +87,7 @@ public:
|
|||||||
|
|
||||||
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const = 0;
|
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const = 0;
|
||||||
virtual void reload(ReloadFlag flag, ChangeType type) = 0;
|
virtual void reload(ReloadFlag flag, ChangeType type) = 0;
|
||||||
|
virtual void rename(const QString &newName) = 0;
|
||||||
|
|
||||||
virtual void checkPermissions() {}
|
virtual void checkPermissions() {}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ class CORE_EXPORT IVersionControl : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Operation {
|
enum Operation {
|
||||||
AddOperation, DeleteOperation, OpenOperation,
|
AddOperation, DeleteOperation, OpenOperation, MoveOperation,
|
||||||
CreateRepositoryOperation,
|
CreateRepositoryOperation,
|
||||||
SnapshotOperations,
|
SnapshotOperations,
|
||||||
AnnotateOperation
|
AnnotateOperation
|
||||||
@@ -101,6 +101,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool vcsDelete(const QString &filename) = 0;
|
virtual bool vcsDelete(const QString &filename) = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Called to rename a file, should do the actual on disk renaming
|
||||||
|
* (e.g. git mv, svn move, p4 move)
|
||||||
|
*/
|
||||||
|
virtual bool vcsMove(const QString &from, const QString &to) = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Called to initialize the version control system in a directory.
|
* Called to initialize the version control system in a directory.
|
||||||
*/
|
*/
|
||||||
|
@@ -54,6 +54,7 @@ bool CVSControl::supportsOperation(Operation operation) const
|
|||||||
case DeleteOperation:
|
case DeleteOperation:
|
||||||
case AnnotateOperation:
|
case AnnotateOperation:
|
||||||
break;
|
break;
|
||||||
|
case MoveOperation:
|
||||||
case OpenOperation:
|
case OpenOperation:
|
||||||
case CreateRepositoryOperation:
|
case CreateRepositoryOperation:
|
||||||
case SnapshotOperations:
|
case SnapshotOperations:
|
||||||
@@ -81,6 +82,11 @@ bool CVSControl::vcsDelete(const QString &fileName)
|
|||||||
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CVSControl::vcsMove(const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CVSControl::vcsCreateRepository(const QString &)
|
bool CVSControl::vcsCreateRepository(const QString &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -52,6 +52,7 @@ public:
|
|||||||
virtual bool vcsOpen(const QString &fileName);
|
virtual bool vcsOpen(const QString &fileName);
|
||||||
virtual bool vcsAdd(const QString &fileName);
|
virtual bool vcsAdd(const QString &fileName);
|
||||||
virtual bool vcsDelete(const QString &filename);
|
virtual bool vcsDelete(const QString &filename);
|
||||||
|
virtual bool vcsMove(const QString &from, const QString &to);
|
||||||
virtual bool vcsCreateRepository(const QString &directory);
|
virtual bool vcsCreateRepository(const QString &directory);
|
||||||
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
||||||
virtual QStringList vcsSnapshots(const QString &topLevel);
|
virtual QStringList vcsSnapshots(const QString &topLevel);
|
||||||
|
@@ -81,6 +81,7 @@ FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditor *editor,
|
|||||||
connect(&(d->m_file), SIGNAL(reload(QString)), this, SLOT(slotOpen(QString)));
|
connect(&(d->m_file), SIGNAL(reload(QString)), this, SLOT(slotOpen(QString)));
|
||||||
// Force update of open editors model.
|
// Force update of open editors model.
|
||||||
connect(&(d->m_file), SIGNAL(saved()), this, SIGNAL(changed()));
|
connect(&(d->m_file), SIGNAL(saved()), this, SIGNAL(changed()));
|
||||||
|
connect(&(d->m_file), SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
FormWindowEditor::~FormWindowEditor()
|
FormWindowEditor::~FormWindowEditor()
|
||||||
|
@@ -91,6 +91,15 @@ bool FormWindowFile::save(const QString &name /*= QString()*/)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormWindowFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
m_formWindow->setFileName(newName);
|
||||||
|
QFileInfo fi(newName);
|
||||||
|
m_fileName = fi.absoluteFilePath();
|
||||||
|
emit setDisplayName(fi.fileName());
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
QString FormWindowFile::fileName() const
|
QString FormWindowFile::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
|
@@ -60,6 +60,7 @@ public:
|
|||||||
virtual QString defaultPath() const;
|
virtual QString defaultPath() const;
|
||||||
virtual QString suggestedFileName() const;
|
virtual QString suggestedFileName() const;
|
||||||
virtual QString mimeType() const;
|
virtual QString mimeType() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
void setSuggestedFileName(const QString &fileName);
|
void setSuggestedFileName(const QString &fileName);
|
||||||
|
@@ -591,6 +591,13 @@ bool GenericProjectFile::isSaveAsAllowed() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericProjectFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
// Can't happen
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
|
||||||
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(state)
|
Q_UNUSED(state)
|
||||||
|
@@ -161,6 +161,7 @@ public:
|
|||||||
virtual bool isModified() const;
|
virtual bool isModified() const;
|
||||||
virtual bool isReadOnly() const;
|
virtual bool isReadOnly() const;
|
||||||
virtual bool isSaveAsAllowed() const;
|
virtual bool isSaveAsAllowed() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||||
void reload(ReloadFlag flag, ChangeType type);
|
void reload(ReloadFlag flag, ChangeType type);
|
||||||
|
@@ -170,8 +170,9 @@ bool GenericProjectNode::hasBuildTargets() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supportedActions() const
|
QList<ProjectExplorer::ProjectNode::ProjectAction> GenericProjectNode::supportedActions(Node *node) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(node);
|
||||||
return QList<ProjectAction>()
|
return QList<ProjectAction>()
|
||||||
<< AddFile
|
<< AddFile
|
||||||
<< RemoveFile;
|
<< RemoveFile;
|
||||||
|
@@ -55,7 +55,7 @@ public:
|
|||||||
|
|
||||||
virtual bool hasBuildTargets() const;
|
virtual bool hasBuildTargets() const;
|
||||||
|
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions() const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
|
@@ -525,6 +525,27 @@ bool GitClient::synchronousDelete(const QString &workingDirectory,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GitClient::synchronousMove(const QString &workingDirectory,
|
||||||
|
const QString &from,
|
||||||
|
const QString &to)
|
||||||
|
{
|
||||||
|
if (Git::Constants::debug)
|
||||||
|
qDebug() << Q_FUNC_INFO << workingDirectory << from << to;
|
||||||
|
QByteArray outputText;
|
||||||
|
QByteArray errorText;
|
||||||
|
QStringList arguments;
|
||||||
|
arguments << QLatin1String("mv");
|
||||||
|
arguments << (from);
|
||||||
|
arguments << (to);
|
||||||
|
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||||
|
if (!rc) {
|
||||||
|
const QString errorMessage = tr("Unable to move from %1 to %2: %3").
|
||||||
|
arg(from, to, commandOutputFromLocal8Bit(errorText));
|
||||||
|
outputWindow()->appendError(errorMessage);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
bool GitClient::synchronousReset(const QString &workingDirectory,
|
bool GitClient::synchronousReset(const QString &workingDirectory,
|
||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
|
@@ -101,6 +101,9 @@ public:
|
|||||||
bool synchronousDelete(const QString &workingDirectory,
|
bool synchronousDelete(const QString &workingDirectory,
|
||||||
bool force,
|
bool force,
|
||||||
const QStringList &files);
|
const QStringList &files);
|
||||||
|
bool synchronousMove(const QString &workingDirectory,
|
||||||
|
const QString &from,
|
||||||
|
const QString &to);
|
||||||
bool synchronousReset(const QString &workingDirectory,
|
bool synchronousReset(const QString &workingDirectory,
|
||||||
const QStringList &files = QStringList(),
|
const QStringList &files = QStringList(),
|
||||||
QString *errorMessage = 0);
|
QString *errorMessage = 0);
|
||||||
|
@@ -75,6 +75,9 @@ bool GitVersionControl::supportsOperation(Operation operation) const
|
|||||||
case DeleteOperation:
|
case DeleteOperation:
|
||||||
rc = true;
|
rc = true;
|
||||||
break;
|
break;
|
||||||
|
case MoveOperation:
|
||||||
|
rc = true;
|
||||||
|
break;
|
||||||
case OpenOperation:
|
case OpenOperation:
|
||||||
break;
|
break;
|
||||||
case CreateRepositoryOperation:
|
case CreateRepositoryOperation:
|
||||||
@@ -107,6 +110,13 @@ bool GitVersionControl::vcsDelete(const QString & fileName)
|
|||||||
return gitClient()->synchronousDelete(fi.absolutePath(), true, QStringList(fi.fileName()));
|
return gitClient()->synchronousDelete(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GitVersionControl::vcsMove(const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
const QFileInfo fromInfo(from);
|
||||||
|
const QFileInfo toInfo(to);
|
||||||
|
return gitClient()->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
bool GitVersionControl::vcsCreateRepository(const QString &directory)
|
bool GitVersionControl::vcsCreateRepository(const QString &directory)
|
||||||
{
|
{
|
||||||
return gitClient()->synchronousInit(directory);
|
return gitClient()->synchronousInit(directory);
|
||||||
|
@@ -53,6 +53,7 @@ public:
|
|||||||
virtual bool vcsOpen(const QString &fileName);
|
virtual bool vcsOpen(const QString &fileName);
|
||||||
virtual bool vcsAdd(const QString &fileName);
|
virtual bool vcsAdd(const QString &fileName);
|
||||||
virtual bool vcsDelete(const QString &filename);
|
virtual bool vcsDelete(const QString &filename);
|
||||||
|
virtual bool vcsMove(const QString &from, const QString &to);
|
||||||
virtual bool vcsCreateRepository(const QString &directory);
|
virtual bool vcsCreateRepository(const QString &directory);
|
||||||
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
||||||
virtual QStringList vcsSnapshots(const QString &topLevel);
|
virtual QStringList vcsSnapshots(const QString &topLevel);
|
||||||
|
@@ -95,6 +95,14 @@ bool MercurialClient::remove(const QString &workingDir, const QString &filename)
|
|||||||
return executeHgSynchronously(workingDir, args, &stdOut);
|
return executeHgSynchronously(workingDir, args, &stdOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MercurialClient::move(const QString &workingDir, const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args << QLatin1String("rename") << from << to;
|
||||||
|
QByteArray stdOut;
|
||||||
|
return executeHgSynchronously(workingDir, args, &stdOut);
|
||||||
|
}
|
||||||
|
|
||||||
bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename)
|
bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename)
|
||||||
{
|
{
|
||||||
// This only works when called from the repo and outputs paths relative to it.
|
// This only works when called from the repo and outputs paths relative to it.
|
||||||
|
@@ -62,6 +62,7 @@ public:
|
|||||||
~MercurialClient();
|
~MercurialClient();
|
||||||
bool add(const QString &workingDir, const QString &fileName);
|
bool add(const QString &workingDir, const QString &fileName);
|
||||||
bool remove(const QString &workingDir, const QString &fileName);
|
bool remove(const QString &workingDir, const QString &fileName);
|
||||||
|
bool move(const QString &workingDir, const QString &from, const QString &to);
|
||||||
bool manifestSync(const QString &repository, const QString &filename);
|
bool manifestSync(const QString &repository, const QString &filename);
|
||||||
QString branchQuerySync(const QString &repositoryRoot);
|
QString branchQuerySync(const QString &repositoryRoot);
|
||||||
bool parentRevisionsSync(const QString &workingDirectory,
|
bool parentRevisionsSync(const QString &workingDirectory,
|
||||||
|
@@ -65,6 +65,7 @@ bool MercurialControl::supportsOperation(Operation operation) const
|
|||||||
switch (operation) {
|
switch (operation) {
|
||||||
case Core::IVersionControl::AddOperation:
|
case Core::IVersionControl::AddOperation:
|
||||||
case Core::IVersionControl::DeleteOperation:
|
case Core::IVersionControl::DeleteOperation:
|
||||||
|
case Core::IVersionControl::MoveOperation:
|
||||||
case Core::IVersionControl::CreateRepositoryOperation:
|
case Core::IVersionControl::CreateRepositoryOperation:
|
||||||
case Core::IVersionControl::AnnotateOperation:
|
case Core::IVersionControl::AnnotateOperation:
|
||||||
break;
|
break;
|
||||||
@@ -94,6 +95,13 @@ bool MercurialControl::vcsDelete(const QString &filename)
|
|||||||
return mercurialClient->remove(fi.absolutePath(), fi.fileName());
|
return mercurialClient->remove(fi.absolutePath(), fi.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MercurialControl::vcsMove(const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
const QFileInfo fromInfo(from);
|
||||||
|
const QFileInfo toInfo(to);
|
||||||
|
return mercurialClient->move(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
bool MercurialControl::vcsCreateRepository(const QString &directory)
|
bool MercurialControl::vcsCreateRepository(const QString &directory)
|
||||||
{
|
{
|
||||||
return mercurialClient->createRepositorySync(directory);
|
return mercurialClient->createRepositorySync(directory);
|
||||||
|
@@ -56,6 +56,7 @@ public:
|
|||||||
bool vcsOpen(const QString &fileName);
|
bool vcsOpen(const QString &fileName);
|
||||||
bool vcsAdd(const QString &filename);
|
bool vcsAdd(const QString &filename);
|
||||||
bool vcsDelete(const QString &filename);
|
bool vcsDelete(const QString &filename);
|
||||||
|
bool vcsMove(const QString &from, const QString &to);
|
||||||
bool vcsCreateRepository(const QString &directory);
|
bool vcsCreateRepository(const QString &directory);
|
||||||
QString vcsCreateSnapshot(const QString &topLevel);
|
QString vcsCreateSnapshot(const QString &topLevel);
|
||||||
QStringList vcsSnapshots(const QString &topLevel);
|
QStringList vcsSnapshots(const QString &topLevel);
|
||||||
|
@@ -925,6 +925,22 @@ bool PerforcePlugin::vcsDelete(const QString &workingDir, const QString &fileNam
|
|||||||
return !deleteResult.error;
|
return !deleteResult.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PerforcePlugin::vcsMove(const QString &workingDir, const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
// TODO verify this works
|
||||||
|
QStringList args;
|
||||||
|
args << QLatin1String("edit") << from;
|
||||||
|
const PerforceResponse editResult = runP4Cmd(workingDir, args,
|
||||||
|
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
||||||
|
if (editResult.error)
|
||||||
|
return false;
|
||||||
|
args.clear();
|
||||||
|
args << QLatin1String("move") << from << to;
|
||||||
|
const PerforceResponse moveResult = runP4Cmd(workingDir, args,
|
||||||
|
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
||||||
|
return !moveResult.error;
|
||||||
|
}
|
||||||
|
|
||||||
static QString formatCommand(const QString &cmd, const QStringList &args)
|
static QString formatCommand(const QString &cmd, const QStringList &args)
|
||||||
{
|
{
|
||||||
const QChar blank = QLatin1Char(' ');
|
const QChar blank = QLatin1Char(' ');
|
||||||
|
@@ -89,6 +89,7 @@ public:
|
|||||||
bool vcsOpen(const QString &workingDir, const QString &fileName);
|
bool vcsOpen(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsDelete(const QString &workingDir, const QString &filename);
|
bool vcsDelete(const QString &workingDir, const QString &filename);
|
||||||
|
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
||||||
|
|
||||||
void p4Diff(const QString &workingDir, const QStringList &files);
|
void p4Diff(const QString &workingDir, const QStringList &files);
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@ bool PerforceVersionControl::supportsOperation(Operation operation) const
|
|||||||
switch (operation) {
|
switch (operation) {
|
||||||
case AddOperation:
|
case AddOperation:
|
||||||
case DeleteOperation:
|
case DeleteOperation:
|
||||||
|
case MoveOperation:
|
||||||
case OpenOperation:
|
case OpenOperation:
|
||||||
case AnnotateOperation:
|
case AnnotateOperation:
|
||||||
return true;
|
return true;
|
||||||
@@ -81,6 +82,13 @@ bool PerforceVersionControl::vcsDelete(const QString &fileName)
|
|||||||
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PerforceVersionControl::vcsMove(const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
const QFileInfo fromInfo(from);
|
||||||
|
const QFileInfo toInfo(to);
|
||||||
|
return m_plugin->vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
bool PerforceVersionControl::vcsCreateRepository(const QString &)
|
bool PerforceVersionControl::vcsCreateRepository(const QString &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -52,6 +52,7 @@ public:
|
|||||||
virtual bool vcsOpen(const QString &fileName);
|
virtual bool vcsOpen(const QString &fileName);
|
||||||
virtual bool vcsAdd(const QString &fileName);
|
virtual bool vcsAdd(const QString &fileName);
|
||||||
virtual bool vcsDelete(const QString &filename);
|
virtual bool vcsDelete(const QString &filename);
|
||||||
|
virtual bool vcsMove(const QString &from, const QString &to);
|
||||||
virtual bool vcsCreateRepository(const QString &directory);
|
virtual bool vcsCreateRepository(const QString &directory);
|
||||||
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
||||||
virtual QStringList vcsSnapshots(const QString &topLevel);
|
virtual QStringList vcsSnapshots(const QString &topLevel);
|
||||||
|
@@ -690,13 +690,15 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
globalcontext);
|
globalcontext);
|
||||||
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
|
|
||||||
// renamefile action (TODO: Not supported yet)
|
// renamefile action
|
||||||
d->m_renameFileAction = new QAction(tr("Rename"), this);
|
d->m_renameFileAction = new QAction(tr("Rename"), this);
|
||||||
cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
|
cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
|
||||||
globalcontext);
|
globalcontext);
|
||||||
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
mfilec->addAction(cmd, Constants::G_FILE_OTHER);
|
||||||
d->m_renameFileAction->setEnabled(false);
|
// Not yet used by anyone, so hide for now
|
||||||
d->m_renameFileAction->setVisible(false);
|
// mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
// msubProject->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
// mproject->addAction(cmd, Constants::G_FOLDER_FILES);
|
||||||
|
|
||||||
// target selector
|
// target selector
|
||||||
d->m_projectSelectorAction = new QAction(this);
|
d->m_projectSelectorAction = new QAction(this);
|
||||||
@@ -1232,7 +1234,7 @@ void ProjectExplorerPlugin::showContextMenu(const QPoint &globalPos, Node *node)
|
|||||||
contextMenu = d->m_sessionContextMenu;
|
contextMenu = d->m_sessionContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContextMenuActions();
|
updateContextMenuActions(d->m_currentNode);
|
||||||
if (contextMenu && contextMenu->actions().count() > 0) {
|
if (contextMenu && contextMenu->actions().count() > 0) {
|
||||||
contextMenu->popup(globalPos);
|
contextMenu->popup(globalPos);
|
||||||
}
|
}
|
||||||
@@ -1915,19 +1917,24 @@ void ProjectExplorerPlugin::goToTaskWindow()
|
|||||||
d->m_buildManager->gotoTaskWindow();
|
d->m_buildManager->gotoTaskWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::updateContextMenuActions()
|
void ProjectExplorerPlugin::updateContextMenuActions(Node *node)
|
||||||
{
|
{
|
||||||
d->m_addExistingFilesAction->setEnabled(false);
|
d->m_addExistingFilesAction->setEnabled(false);
|
||||||
d->m_addNewFileAction->setEnabled(false);
|
d->m_addNewFileAction->setEnabled(false);
|
||||||
d->m_removeFileAction->setEnabled(false);
|
d->m_removeFileAction->setEnabled(false);
|
||||||
|
|
||||||
if (FolderNode *folderNode = qobject_cast<FolderNode*>(d->m_currentNode)) {
|
QList<ProjectNode::ProjectAction> actions =
|
||||||
const bool addFilesEnabled = folderNode->projectNode()->supportedActions().contains(ProjectNode::AddFile);
|
d->m_currentNode->projectNode()->supportedActions(node);
|
||||||
|
|
||||||
|
if (qobject_cast<FolderNode*>(d->m_currentNode)) {
|
||||||
|
bool addFilesEnabled = actions.contains(ProjectNode::AddFile);
|
||||||
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
|
d->m_addExistingFilesAction->setEnabled(addFilesEnabled);
|
||||||
d->m_addNewFileAction->setEnabled(addFilesEnabled);
|
d->m_addNewFileAction->setEnabled(addFilesEnabled);
|
||||||
} else if (FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode)) {
|
d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
|
||||||
const bool removeFileEnabled = fileNode->projectNode()->supportedActions().contains(ProjectNode::RemoveFile);
|
} else if (qobject_cast<FileNode*>(d->m_currentNode)) {
|
||||||
|
bool removeFileEnabled = actions.contains(ProjectNode::RemoveFile);
|
||||||
d->m_removeFileAction->setEnabled(removeFileEnabled);
|
d->m_removeFileAction->setEnabled(removeFileEnabled);
|
||||||
|
d->m_renameFileAction->setEnabled(actions.contains(ProjectNode::Rename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2025,8 +2032,7 @@ void ProjectExplorerPlugin::removeFile()
|
|||||||
FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode);
|
FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode);
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
|
||||||
const QString filePath = d->m_currentNode->path();
|
QString filePath = d->m_currentNode->path();
|
||||||
const QString fileDir = QFileInfo(filePath).dir().absolutePath();
|
|
||||||
RemoveFileDialog removeFileDialog(filePath, core->mainWindow());
|
RemoveFileDialog removeFileDialog(filePath, core->mainWindow());
|
||||||
|
|
||||||
if (removeFileDialog.exec() == QDialog::Accepted) {
|
if (removeFileDialog.exec() == QDialog::Accepted) {
|
||||||
@@ -2072,6 +2078,31 @@ void ProjectExplorerPlugin::renameFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectExplorerPlugin::renameFile(Node *node, const QString &to)
|
||||||
|
{
|
||||||
|
FileNode *fileNode = qobject_cast<FileNode *>(node);
|
||||||
|
if (!fileNode)
|
||||||
|
return;
|
||||||
|
QString orgFilePath = node->path();
|
||||||
|
QString dir = QFileInfo(orgFilePath).absolutePath();
|
||||||
|
QString newFilePath = dir + "/" + to;
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
Core::IVersionControl *vc = core->vcsManager()->findVersionControlForDirectory(dir);
|
||||||
|
bool result = false;
|
||||||
|
if (vc->supportsOperation(Core::IVersionControl::MoveOperation))
|
||||||
|
result = vc->vcsMove(orgFilePath, newFilePath);
|
||||||
|
if (!result) // The moving via vcs failed or the vcs does not support moving, fall back
|
||||||
|
result = QFile::rename(orgFilePath, newFilePath);
|
||||||
|
if (result) {
|
||||||
|
// yeah we moved, tell the filemanager about it
|
||||||
|
Core::ICore::instance()->fileManager()->renamedFile(orgFilePath, newFilePath);
|
||||||
|
// Tell the project plugin about it
|
||||||
|
ProjectNode *projectNode = fileNode->projectNode();
|
||||||
|
projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath);
|
||||||
|
// TODO emit a signal?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectExplorerPlugin::populateOpenWithMenu(QMenu *menu, const QString &fileName)
|
void ProjectExplorerPlugin::populateOpenWithMenu(QMenu *menu, const QString &fileName)
|
||||||
{
|
{
|
||||||
typedef QList<Core::IEditorFactory*> EditorFactoryList;
|
typedef QList<Core::IEditorFactory*> EditorFactoryList;
|
||||||
|
@@ -107,6 +107,9 @@ public:
|
|||||||
|
|
||||||
void startRunControl(RunControl *runControl, const QString &mode);
|
void startRunControl(RunControl *runControl, const QString &mode);
|
||||||
|
|
||||||
|
// internal public for FlatModel
|
||||||
|
void renameFile(Node *node, const QString &to);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void aboutToShowContextMenu(ProjectExplorer::Project *project,
|
void aboutToShowContextMenu(ProjectExplorer::Project *project,
|
||||||
ProjectExplorer::Node *node);
|
ProjectExplorer::Node *node);
|
||||||
@@ -159,7 +162,7 @@ private slots:
|
|||||||
void savePersistentSettings();
|
void savePersistentSettings();
|
||||||
void goToTaskWindow();
|
void goToTaskWindow();
|
||||||
|
|
||||||
void updateContextMenuActions();
|
void updateContextMenuActions(Node *node);
|
||||||
void addNewFile();
|
void addNewFile();
|
||||||
void addExistingFiles();
|
void addExistingFiles();
|
||||||
void openFile();
|
void openFile();
|
||||||
|
@@ -41,7 +41,6 @@ HEADERS += projectexplorer.h \
|
|||||||
buildsettingspropertiespage.h \
|
buildsettingspropertiespage.h \
|
||||||
environmenteditmodel.h \
|
environmenteditmodel.h \
|
||||||
processstep.h \
|
processstep.h \
|
||||||
abstractprocessstep.h \
|
|
||||||
editorconfiguration.h \
|
editorconfiguration.h \
|
||||||
editorsettingspropertiespage.h \
|
editorsettingspropertiespage.h \
|
||||||
runconfiguration.h \
|
runconfiguration.h \
|
||||||
@@ -82,7 +81,8 @@ HEADERS += projectexplorer.h \
|
|||||||
linuxiccparser.h \
|
linuxiccparser.h \
|
||||||
outputformatter.h \
|
outputformatter.h \
|
||||||
runconfigurationmodel.h \
|
runconfigurationmodel.h \
|
||||||
buildconfigurationmodel.h
|
buildconfigurationmodel.h \
|
||||||
|
abstractprocessstep.h
|
||||||
SOURCES += projectexplorer.cpp \
|
SOURCES += projectexplorer.cpp \
|
||||||
projectwindow.cpp \
|
projectwindow.cpp \
|
||||||
buildmanager.cpp \
|
buildmanager.cpp \
|
||||||
|
@@ -60,7 +60,8 @@ typedef QList<ProjectNode *> ProjectNodeList;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// AllProjectNodesVisitor: Retrieve all projects (*.pri/*.pro).
|
// AllProjectNodesVisitor: Retrieve all projects (*.pri/*.pro)
|
||||||
|
// which support adding files
|
||||||
class AllProjectNodesVisitor : public NodesVisitor
|
class AllProjectNodesVisitor : public NodesVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -81,7 +82,7 @@ ProjectNodeList AllProjectNodesVisitor::allProjects()
|
|||||||
|
|
||||||
void AllProjectNodesVisitor::visitProjectNode(ProjectNode *node)
|
void AllProjectNodesVisitor::visitProjectNode(ProjectNode *node)
|
||||||
{
|
{
|
||||||
if (node->supportedActions().contains(ProjectNode::AddFile))
|
if (node->supportedActions(node).contains(ProjectNode::AddFile))
|
||||||
m_projectNodes.push_back(node);
|
m_projectNodes.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "projectnodes.h"
|
#include "projectnodes.h"
|
||||||
|
#include "projectexplorer.h"
|
||||||
|
|
||||||
#include <coreplugin/fileiconprovider.h>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -261,6 +262,27 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags FlatModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return 0;
|
||||||
|
// We claim that everything is editable
|
||||||
|
// That's slightly wrong
|
||||||
|
// We control the only view, and that one does the checks
|
||||||
|
return Qt::ItemIsSelectable|Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FlatModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return false;
|
||||||
|
if (role != Qt::EditRole)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ProjectExplorerPlugin::instance()->renameFile(nodeForIndex(index), value.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int FlatModel::rowCount(const QModelIndex &parent) const
|
int FlatModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
|
@@ -43,7 +43,8 @@ class SessionNode;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class FlatModel : public QAbstractItemModel {
|
class FlatModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FlatModel(SessionNode *rootNode, QObject *parent);
|
FlatModel(SessionNode *rootNode, QObject *parent);
|
||||||
@@ -52,6 +53,8 @@ public:
|
|||||||
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||||
QModelIndex parent(const QModelIndex &index) const;
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
|
@@ -159,7 +159,8 @@ public:
|
|||||||
AddSubProject,
|
AddSubProject,
|
||||||
RemoveSubProject,
|
RemoveSubProject,
|
||||||
AddFile,
|
AddFile,
|
||||||
RemoveFile
|
RemoveFile,
|
||||||
|
Rename
|
||||||
};
|
};
|
||||||
|
|
||||||
// all subFolders that are projects
|
// all subFolders that are projects
|
||||||
@@ -169,7 +170,7 @@ public:
|
|||||||
// TODO find a better name
|
// TODO find a better name
|
||||||
virtual bool hasBuildTargets() const = 0;
|
virtual bool hasBuildTargets() const = 0;
|
||||||
|
|
||||||
virtual QList<ProjectAction> supportedActions() const = 0;
|
virtual QList<ProjectAction> supportedActions(Node *node) const = 0;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
|
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
|
||||||
|
|
||||||
|
@@ -48,6 +48,13 @@ bool QmlProjectFile::save(const QString &)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProjectFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
// Can't happen...
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
|
||||||
QString QmlProjectFile::fileName() const
|
QString QmlProjectFile::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual bool save(const QString &fileName = QString());
|
virtual bool save(const QString &fileName = QString());
|
||||||
virtual QString fileName() const;
|
virtual QString fileName() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
virtual QString defaultPath() const;
|
virtual QString defaultPath() const;
|
||||||
virtual QString suggestedFileName() const;
|
virtual QString suggestedFileName() const;
|
||||||
|
@@ -172,8 +172,9 @@ bool QmlProjectNode::hasBuildTargets() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActions() const
|
QList<ProjectExplorer::ProjectNode::ProjectAction> QmlProjectNode::supportedActions(Node *node) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(node);
|
||||||
QList<ProjectAction> actions;
|
QList<ProjectAction> actions;
|
||||||
actions.append(AddFile);
|
actions.append(AddFile);
|
||||||
return actions;
|
return actions;
|
||||||
|
@@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
virtual bool hasBuildTargets() const;
|
virtual bool hasBuildTargets() const;
|
||||||
|
|
||||||
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions() const;
|
virtual QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
virtual bool addSubProjects(const QStringList &proFilePaths);
|
virtual bool addSubProjects(const QStringList &proFilePaths);
|
||||||
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
virtual bool removeSubProjects(const QStringList &proFilePaths);
|
||||||
|
@@ -172,6 +172,13 @@ bool Qt4PriFile::save(const QString &fileName)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Qt4PriFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
// Can't happen
|
||||||
|
Q_ASSERT(false);
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
}
|
||||||
|
|
||||||
QString Qt4PriFile::fileName() const
|
QString Qt4PriFile::fileName() const
|
||||||
{
|
{
|
||||||
return m_priFile->path();
|
return m_priFile->path();
|
||||||
@@ -537,7 +544,7 @@ void Qt4PriFileNode::update(ProFile *includeFileExact, ProFileReader *readerExac
|
|||||||
contents.updateSubFolders(this, this);
|
contents.updateSubFolders(this, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
|
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions(Node *node) const
|
||||||
{
|
{
|
||||||
QList<ProjectAction> actions;
|
QList<ProjectAction> actions;
|
||||||
|
|
||||||
@@ -558,6 +565,11 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileNode *fileNode = qobject_cast<FileNode *>(node);
|
||||||
|
if (fileNode && fileNode->fileType() != ProjectExplorer::ProjectFileType)
|
||||||
|
actions << Rename;
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,9 +612,6 @@ bool Qt4PriFileNode::renameFile(const FileType fileType, const QString &filePath
|
|||||||
if (newFilePath.isEmpty())
|
if (newFilePath.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!QFile::rename(filePath, newFilePath))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QStringList dummy;
|
QStringList dummy;
|
||||||
changeFiles(fileType, QStringList() << filePath, &dummy, RemoveFromProFile);
|
changeFiles(fileType, QStringList() << filePath, &dummy, RemoveFromProFile);
|
||||||
if (!dummy.isEmpty())
|
if (!dummy.isEmpty())
|
||||||
|
@@ -105,6 +105,7 @@ public:
|
|||||||
Qt4PriFile(Qt4PriFileNode *qt4PriFile);
|
Qt4PriFile(Qt4PriFileNode *qt4PriFile);
|
||||||
virtual bool save(const QString &fileName = QString());
|
virtual bool save(const QString &fileName = QString());
|
||||||
virtual QString fileName() const;
|
virtual QString fileName() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
virtual QString defaultPath() const;
|
virtual QString defaultPath() const;
|
||||||
virtual QString suggestedFileName() const;
|
virtual QString suggestedFileName() const;
|
||||||
@@ -133,7 +134,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// ProjectNode interface
|
// ProjectNode interface
|
||||||
QList<ProjectAction> supportedActions() const;
|
QList<ProjectAction> supportedActions(Node *node) const;
|
||||||
|
|
||||||
bool hasBuildTargets() const { return false; }
|
bool hasBuildTargets() const { return false; }
|
||||||
|
|
||||||
|
@@ -180,6 +180,13 @@ bool Qt4ProjectFile::save(const QString &)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Qt4ProjectFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
// Can't happen
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
|
||||||
QString Qt4ProjectFile::fileName() const
|
QString Qt4ProjectFile::fileName() const
|
||||||
{
|
{
|
||||||
return m_filePath;
|
return m_filePath;
|
||||||
|
@@ -88,6 +88,7 @@ public:
|
|||||||
|
|
||||||
bool save(const QString &fileName = QString());
|
bool save(const QString &fileName = QString());
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
QString defaultPath() const;
|
QString defaultPath() const;
|
||||||
QString suggestedFileName() const;
|
QString suggestedFileName() const;
|
||||||
|
@@ -157,6 +157,12 @@ bool ResourceEditorFile::save(const QString &name /*= QString()*/)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResourceEditorFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
m_parent->m_resourceEditor->setFileName(newName);
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
QString ResourceEditorW::id() const {
|
QString ResourceEditorW::id() const {
|
||||||
return QLatin1String(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
return QLatin1String(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
@@ -66,6 +66,7 @@ public:
|
|||||||
QString defaultPath() const;
|
QString defaultPath() const;
|
||||||
QString suggestedFileName() const;
|
QString suggestedFileName() const;
|
||||||
virtual QString mimeType() const;
|
virtual QString mimeType() const;
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_mimeType;
|
const QString m_mimeType;
|
||||||
|
@@ -52,6 +52,7 @@ bool SubversionControl::supportsOperation(Operation operation) const
|
|||||||
switch (operation) {
|
switch (operation) {
|
||||||
case AddOperation:
|
case AddOperation:
|
||||||
case DeleteOperation:
|
case DeleteOperation:
|
||||||
|
case MoveOperation:
|
||||||
case AnnotateOperation:
|
case AnnotateOperation:
|
||||||
break;
|
break;
|
||||||
case OpenOperation:
|
case OpenOperation:
|
||||||
@@ -81,6 +82,13 @@ bool SubversionControl::vcsDelete(const QString &fileName)
|
|||||||
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SubversionControl::vcsMove(const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
const QFileInfo fromInfo(from);
|
||||||
|
const QFileInfo toInfo(to);
|
||||||
|
return m_plugin->vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
bool SubversionControl::vcsCreateRepository(const QString &)
|
bool SubversionControl::vcsCreateRepository(const QString &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@@ -52,6 +52,7 @@ public:
|
|||||||
virtual bool vcsOpen(const QString &fileName);
|
virtual bool vcsOpen(const QString &fileName);
|
||||||
virtual bool vcsAdd(const QString &fileName);
|
virtual bool vcsAdd(const QString &fileName);
|
||||||
virtual bool vcsDelete(const QString &filename);
|
virtual bool vcsDelete(const QString &filename);
|
||||||
|
virtual bool vcsMove(const QString &from, const QString &to);
|
||||||
virtual bool vcsCreateRepository(const QString &directory);
|
virtual bool vcsCreateRepository(const QString &directory);
|
||||||
|
|
||||||
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
||||||
|
@@ -1210,6 +1210,16 @@ bool SubversionPlugin::vcsDelete(const QString &workingDir, const QString &rawFi
|
|||||||
return !response.error;
|
return !response.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SubversionPlugin::vcsMove(const QString &workingDir, const QString &from, const QString &to)
|
||||||
|
{
|
||||||
|
QStringList args(QLatin1String("move"));
|
||||||
|
args << QDir::toNativeSeparators(from) << QDir::toNativeSeparators(to);
|
||||||
|
qDebug()<<args;
|
||||||
|
const SubversionResponse response = runSvn(workingDir, args, m_settings.timeOutMS(), true);
|
||||||
|
qDebug() << response.stdOut << "\n"<<response.stdErr;
|
||||||
|
return !response.error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Subversion has ".svn" directory in each directory
|
/* Subversion has ".svn" directory in each directory
|
||||||
* it manages. The top level is the first directory
|
* it manages. The top level is the first directory
|
||||||
* under the directory that does not have a ".svn". */
|
* under the directory that does not have a ".svn". */
|
||||||
|
@@ -94,6 +94,7 @@ public:
|
|||||||
bool vcsAdd14(const QString &workingDir, const QString &fileName);
|
bool vcsAdd14(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsAdd15(const QString &workingDir, const QString &fileName);
|
bool vcsAdd15(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsDelete(const QString &workingDir, const QString &fileName);
|
bool vcsDelete(const QString &workingDir, const QString &fileName);
|
||||||
|
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
||||||
bool managesDirectory(const QString &directory) const;
|
bool managesDirectory(const QString &directory) const;
|
||||||
QString findTopLevelForDirectory(const QString &directory) const;
|
QString findTopLevelForDirectory(const QString &directory) const;
|
||||||
|
|
||||||
|
@@ -205,6 +205,14 @@ bool BaseTextDocument::save(const QString &fileName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseTextDocument::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
const QFileInfo fi(newName);
|
||||||
|
m_fileName = QDir::cleanPath(fi.absoluteFilePath());
|
||||||
|
emit titleChanged(fi.fileName());
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
bool BaseTextDocument::isReadOnly() const
|
bool BaseTextDocument::isReadOnly() const
|
||||||
{
|
{
|
||||||
if (m_isBinaryData || m_hasDecodingError)
|
if (m_isBinaryData || m_hasDecodingError)
|
||||||
|
@@ -89,6 +89,7 @@ public:
|
|||||||
void reload(ReloadFlag flag, ChangeType type);
|
void reload(ReloadFlag flag, ChangeType type);
|
||||||
virtual QString mimeType() const;
|
virtual QString mimeType() const;
|
||||||
void setMimeType(const QString &mt);
|
void setMimeType(const QString &mt);
|
||||||
|
virtual void rename(const QString &newName);
|
||||||
|
|
||||||
virtual QString defaultPath() const { return m_defaultPath; }
|
virtual QString defaultPath() const { return m_defaultPath; }
|
||||||
virtual QString suggestedFileName() const { return m_suggestedFileName; }
|
virtual QString suggestedFileName() const { return m_suggestedFileName; }
|
||||||
|
@@ -39,6 +39,13 @@ SubmitEditorFile::SubmitEditorFile(const QString &mimeType, QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubmitEditorFile::rename(const QString &newName)
|
||||||
|
{
|
||||||
|
Q_UNUSED(newName);
|
||||||
|
// We can't be renamed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void SubmitEditorFile::setFileName(const QString name)
|
void SubmitEditorFile::setFileName(const QString name)
|
||||||
{
|
{
|
||||||
m_fileName = name;
|
m_fileName = name;
|
||||||
|
@@ -54,7 +54,7 @@ public:
|
|||||||
bool save(const QString &fileName);
|
bool save(const QString &fileName);
|
||||||
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||||
void reload(ReloadFlag flag, ChangeType type);
|
void reload(ReloadFlag flag, ChangeType type);
|
||||||
|
void rename(const QString &newName);
|
||||||
|
|
||||||
void setFileName(const QString name);
|
void setFileName(const QString name);
|
||||||
void setModified(bool modified = true);
|
void setModified(bool modified = true);
|
||||||
|
Reference in New Issue
Block a user