forked from qt-creator/qt-creator
Refactor source property
Get rid of source property out of DiffEditorWidget, attach dynamic property when it's needed instead. Change-Id: I6641a7b55c42b4eceba78c2e28f5140b40fe0fa5 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -888,16 +888,6 @@ QTextCodec *DiffEditorWidget::codec() const
|
|||||||
return const_cast<QTextCodec *>(m_leftEditor->codec());
|
return const_cast<QTextCodec *>(m_leftEditor->codec());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DiffEditorWidget::source() const
|
|
||||||
{
|
|
||||||
return m_source;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiffEditorWidget::setSource(const QString &source)
|
|
||||||
{
|
|
||||||
m_source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseTextEditorWidget *DiffEditorWidget::leftEditor() const
|
BaseTextEditorWidget *DiffEditorWidget::leftEditor() const
|
||||||
{
|
{
|
||||||
return m_leftEditor;
|
return m_leftEditor;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ struct FileData;
|
|||||||
|
|
||||||
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
|
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_PROPERTY(QString source READ source WRITE setSource)
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
struct DiffFileInfo {
|
struct DiffFileInfo {
|
||||||
@@ -84,9 +83,6 @@ public:
|
|||||||
void setDiff(const QList<DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
|
void setDiff(const QList<DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
|
||||||
QTextCodec *codec() const;
|
QTextCodec *codec() const;
|
||||||
|
|
||||||
QString source() const;
|
|
||||||
void setSource(const QString &source);
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
void testAssemblyRows();
|
void testAssemblyRows();
|
||||||
#endif // WITH_TESTS
|
#endif // WITH_TESTS
|
||||||
|
|||||||
@@ -1045,7 +1045,7 @@ DiffEditor::DiffEditor *GitClient::createDiffEditor(const char *registerDynamicP
|
|||||||
Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait.toUtf8()));
|
Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait.toUtf8()));
|
||||||
QTC_ASSERT(diffEditor, return 0);
|
QTC_ASSERT(diffEditor, return 0);
|
||||||
diffEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
|
diffEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
|
||||||
diffEditor->editorWidget()->setSource(source);
|
VcsBasePlugin::setSource(diffEditor, source);
|
||||||
|
|
||||||
Core::EditorManager::activateEditor(diffEditor);
|
Core::EditorManager::activateEditor(diffEditor);
|
||||||
return diffEditor;
|
return diffEditor;
|
||||||
|
|||||||
@@ -562,7 +562,6 @@ public:
|
|||||||
|
|
||||||
const VcsBaseEditorParameters *m_parameters;
|
const VcsBaseEditorParameters *m_parameters;
|
||||||
|
|
||||||
QString m_source;
|
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
|
|
||||||
QRegExp m_diffFilePattern;
|
QRegExp m_diffFilePattern;
|
||||||
@@ -738,12 +737,12 @@ void VcsBaseEditorWidget::setForceReadOnly(bool b)
|
|||||||
|
|
||||||
QString VcsBaseEditorWidget::source() const
|
QString VcsBaseEditorWidget::source() const
|
||||||
{
|
{
|
||||||
return d->m_source;
|
return VcsBasePlugin::source(editor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBaseEditorWidget::setSource(const QString &source)
|
void VcsBaseEditorWidget::setSource(const QString &source)
|
||||||
{
|
{
|
||||||
d->m_source = source;
|
VcsBasePlugin::setSource(editor(), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
|
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
|
||||||
|
|||||||
@@ -241,8 +241,7 @@ void StateListener::slotStateChanged()
|
|||||||
const QList<Core::IEditor *> editors =
|
const QList<Core::IEditor *> editors =
|
||||||
Core::EditorManager::documentModel()->editorsForDocument(currentDocument);
|
Core::EditorManager::documentModel()->editorsForDocument(currentDocument);
|
||||||
if (!editors.isEmpty()) {
|
if (!editors.isEmpty()) {
|
||||||
if (QWidget *editorWidget = editors.first()->widget())
|
state.currentFile = VcsBasePlugin::source(editors.first());
|
||||||
state.currentFile = editorWidget->property("source").toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -749,6 +748,18 @@ bool VcsBasePlugin::isSshPromptConfigured()
|
|||||||
return !sshPrompt().isEmpty();
|
return !sshPrompt().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char SOURCE_PROPERTY[] = "qtcreator_source";
|
||||||
|
|
||||||
|
void VcsBasePlugin::setSource(Core::IEditor *editor, const QString &source)
|
||||||
|
{
|
||||||
|
editor->setProperty(SOURCE_PROPERTY, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VcsBasePlugin::source(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
return editor->property(SOURCE_PROPERTY).toString();
|
||||||
|
}
|
||||||
|
|
||||||
void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
|
void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
|
||||||
bool forceCLocale,
|
bool forceCLocale,
|
||||||
const QString &sshPromptBinary)
|
const QString &sshPromptBinary)
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace Utils { struct SynchronousProcessResponse; }
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
class IVersionControl;
|
class IVersionControl;
|
||||||
class Id;
|
class Id;
|
||||||
|
class IEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
@@ -155,6 +156,11 @@ public:
|
|||||||
// Returns whether an SSH prompt is configured.
|
// Returns whether an SSH prompt is configured.
|
||||||
static bool isSshPromptConfigured();
|
static bool isSshPromptConfigured();
|
||||||
|
|
||||||
|
// Sets the source of editor contents, can be directory or file.
|
||||||
|
static void setSource(Core::IEditor *editor, const QString &source);
|
||||||
|
// Returns the source of editor contents.
|
||||||
|
static QString source(Core::IEditor *editor);
|
||||||
|
|
||||||
// Convenience to synchronously run VCS commands
|
// Convenience to synchronously run VCS commands
|
||||||
enum RunVcsFlags {
|
enum RunVcsFlags {
|
||||||
ShowStdOutInLogWindow = 0x1, // Append standard output to VCS output window.
|
ShowStdOutInLogWindow = 0x1, // Append standard output to VCS output window.
|
||||||
|
|||||||
Reference in New Issue
Block a user