Commit 0d130284 authored by jkobus's avatar jkobus Committed by Jarek Kobus
Browse files

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's avatarOrgad Shaneh <orgads@gmail.com>
parent cc1e8464
......@@ -888,16 +888,6 @@ QTextCodec *DiffEditorWidget::codec() const
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
{
return m_leftEditor;
......
......@@ -58,7 +58,6 @@ struct FileData;
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
{
Q_PROPERTY(QString source READ source WRITE setSource)
Q_OBJECT
public:
struct DiffFileInfo {
......@@ -84,9 +83,6 @@ public:
void setDiff(const QList<DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
QTextCodec *codec() const;
QString source() const;
void setSource(const QString &source);
#ifdef WITH_TESTS
void testAssemblyRows();
#endif // WITH_TESTS
......
......@@ -1045,7 +1045,7 @@ DiffEditor::DiffEditor *GitClient::createDiffEditor(const char *registerDynamicP
Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait.toUtf8()));
QTC_ASSERT(diffEditor, return 0);
diffEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
diffEditor->editorWidget()->setSource(source);
VcsBasePlugin::setSource(diffEditor, source);
Core::EditorManager::activateEditor(diffEditor);
return diffEditor;
......
......@@ -562,7 +562,6 @@ public:
const VcsBaseEditorParameters *m_parameters;
QString m_source;
QString m_workingDirectory;
QRegExp m_diffFilePattern;
......@@ -738,12 +737,12 @@ void VcsBaseEditorWidget::setForceReadOnly(bool b)
QString VcsBaseEditorWidget::source() const
{
return d->m_source;
return VcsBasePlugin::source(editor());
}
void VcsBaseEditorWidget::setSource(const QString &source)
{
d->m_source = source;
VcsBasePlugin::setSource(editor(), source);
}
QString VcsBaseEditorWidget::annotateRevisionTextFormat() const
......
......@@ -241,8 +241,7 @@ void StateListener::slotStateChanged()
const QList<Core::IEditor *> editors =
Core::EditorManager::documentModel()->editorsForDocument(currentDocument);
if (!editors.isEmpty()) {
if (QWidget *editorWidget = editors.first()->widget())
state.currentFile = editorWidget->property("source").toString();
state.currentFile = VcsBasePlugin::source(editors.first());
}
}
}
......@@ -749,6 +748,18 @@ bool VcsBasePlugin::isSshPromptConfigured()
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,
bool forceCLocale,
const QString &sshPromptBinary)
......
......@@ -48,6 +48,7 @@ namespace Utils { struct SynchronousProcessResponse; }
namespace Core {
class IVersionControl;
class Id;
class IEditor;
}
namespace VcsBase {
......@@ -155,6 +156,11 @@ public:
// Returns whether an SSH prompt is configured.
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
enum RunVcsFlags {
ShowStdOutInLogWindow = 0x1, // Append standard output to VCS output window.
......
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