summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk121@nokiamail.com>2014-02-24 16:55:13 +0100
committerhjk <hjk121@nokiamail.com>2014-02-25 15:14:37 +0100
commitccd99638ee328f92f4cc985e41c6d541b5cd1071 (patch)
tree333595c57a595e78570d76c1f6cd413a5c4871a9
parent7b3927381736d64a96f6db549eefd5da9d87c09d (diff)
downloadqt-creator-ccd99638ee328f92f4cc985e41c6d541b5cd1071.tar.gz
VcsBase: Re-organize BaseVcsEditorFactory interface
Less code now. Change-Id: I5abdd0bb56ecb940bb606111461b521a54ecaf21 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.cpp21
-rw-r--r--src/plugins/vcsbase/basevcseditorfactory.h45
2 files changed, 25 insertions, 41 deletions
diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp
index ea2fdf5b39..9045388836 100644
--- a/src/plugins/vcsbase/basevcseditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcseditorfactory.cpp
@@ -51,21 +51,20 @@ namespace Internal {
class BaseVcsEditorFactoryPrivate
{
public:
- BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t);
-
const VcsBaseEditorParameters *m_type;
+ QObject *m_describeReceiver;
+ const char *m_describeSlot;
};
-BaseVcsEditorFactoryPrivate::BaseVcsEditorFactoryPrivate(const VcsBaseEditorParameters *t) :
- m_type(t)
-{
-}
-
} // namespace Internal
-BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t)
- : d(new Internal::BaseVcsEditorFactoryPrivate(t))
+BaseVcsEditorFactory::BaseVcsEditorFactory(const VcsBaseEditorParameters *t,
+ QObject *describeReceiver, const char *describeSlot)
+ : d(new Internal::BaseVcsEditorFactoryPrivate)
{
+ d->m_type = t;
+ d->m_describeReceiver = describeReceiver;
+ d->m_describeSlot = describeSlot;
setId(t->id);
setDisplayName(QCoreApplication::translate("VCS", t->displayName));
addMimeType(t->mimeType);
@@ -81,6 +80,10 @@ Core::IEditor *BaseVcsEditorFactory::createEditor()
{
VcsBaseEditorWidget *vcsEditor = createVcsBaseEditor(d->m_type);
+ vcsEditor->init();
+ if (d->m_describeReceiver)
+ connect(vcsEditor, SIGNAL(describeRequested(QString,QString)), d->m_describeReceiver, d->m_describeSlot);
+
vcsEditor->baseTextDocument()->setMimeType(mimeTypes().front());
TextEditor::TextEditorSettings::initializeEditor(vcsEditor);
diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h
index 7bc9e30eff..e25465acdd 100644
--- a/src/plugins/vcsbase/basevcseditorfactory.h
+++ b/src/plugins/vcsbase/basevcseditorfactory.h
@@ -43,16 +43,16 @@ class VCSBASE_EXPORT BaseVcsEditorFactory : public Core::IEditorFactory
Q_OBJECT
public:
- explicit BaseVcsEditorFactory(const VcsBaseEditorParameters *type);
+ explicit BaseVcsEditorFactory(const VcsBaseEditorParameters *type,
+ QObject *describeReceiver,
+ const char *describeSlot);
~BaseVcsEditorFactory();
Core::IEditor *createEditor();
private:
- // Implement to create and initialize (call init()) a
- // VcsBaseEditor subclass
- virtual VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type,
- QWidget *parent = 0) = 0;
+ // Implement to create and initialize (call init()) a VcsBaseEditor subclass.
+ virtual VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type) = 0;
Internal::BaseVcsEditorFactoryPrivate *const d;
};
@@ -64,37 +64,18 @@ class VcsEditorFactory : public BaseVcsEditorFactory
public:
explicit VcsEditorFactory(const VcsBaseEditorParameters *type,
QObject *describeReceiver = 0,
- const char *describeSlot = 0);
+ const char *describeSlot = 0)
+ : BaseVcsEditorFactory(type, describeReceiver, describeSlot)
+ {
+ }
private:
- VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type,
- QWidget *parent = 0);
- QObject *m_describeReceiver;
- const char *m_describeSlot;
+ VcsBaseEditorWidget *createVcsBaseEditor(const VcsBaseEditorParameters *type)
+ {
+ return new Editor(type, 0);
+ }
};
-template <class Editor>
-VcsEditorFactory<Editor>::VcsEditorFactory(const VcsBaseEditorParameters *type,
- QObject *describeReceiver,
- const char *describeSlot) :
- BaseVcsEditorFactory(type),
- m_describeReceiver(describeReceiver),
- m_describeSlot(describeSlot)
-{
-}
-
-template <class Editor>
-VcsBaseEditorWidget *VcsEditorFactory<Editor>::createVcsBaseEditor(const VcsBaseEditorParameters *type,
- QWidget *parent)
-{
- VcsBaseEditorWidget *rc = new Editor(type, parent);
- rc->init();
- if (m_describeReceiver)
- connect(rc, SIGNAL(describeRequested(QString,QString)), m_describeReceiver, m_describeSlot);
- return rc;
-
-}
-
} // namespace VcsBase
#endif // BASEVCSEDITORFACTORY_H