TextEditor: static-ify plugin class

Change-Id: Id795b711f08c89b6066c5269c482fea5e99dd52f
Reviewed-by: David Schulz <david.schulz@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
hjk
2014-06-24 17:13:26 +02:00
parent cc4943a240
commit ea7c3c74bd
5 changed files with 23 additions and 16 deletions

View File

@@ -135,13 +135,13 @@ BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber)
// which might be set in the derived constructor // which might be set in the derived constructor
void BaseTextMark::init() void BaseTextMark::init()
{ {
Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->add(this); Internal::TextEditorPlugin::baseTextMarkRegistry()->add(this);
} }
BaseTextMark::~BaseTextMark() BaseTextMark::~BaseTextMark()
{ {
// oha we are deleted // oha we are deleted
bool b = Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->remove(this); bool b = Internal::TextEditorPlugin::baseTextMarkRegistry()->remove(this);
// If you get a assertion in this line, init() was never called // If you get a assertion in this line, init() was never called
QTC_CHECK(b); QTC_CHECK(b);
} }

View File

@@ -321,7 +321,7 @@ void Manager::registerMimeTypesFinished()
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result(); const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
m_register = result.first; m_register = result.first;
PlainTextEditorFactory *factory = TextEditorPlugin::instance()->editorFactory(); PlainTextEditorFactory *factory = TextEditorPlugin::editorFactory();
const QSet<QString> &inFactory = factory->mimeTypes().toSet(); const QSet<QString> &inFactory = factory->mimeTypes().toSet();
foreach (const MimeType &mimeType, result.second) { foreach (const MimeType &mimeType, result.second) {
MimeDatabase::addMimeType(mimeType); MimeDatabase::addMimeType(mimeType);

View File

@@ -442,7 +442,7 @@ void TextEditorActionHandler::updateCopyAction()
void TextEditorActionHandler::gotoAction() void TextEditorActionHandler::gotoAction()
{ {
QString locatorString = TextEditorPlugin::instance()->lineNumberFilter()->shortcutString(); QString locatorString = TextEditorPlugin::lineNumberFilter()->shortcutString();
locatorString += QLatin1Char(' '); locatorString += QLatin1Char(' ');
const int selectionStart = locatorString.size(); const int selectionStart = locatorString.size();
locatorString += tr("<line>:<column>"); locatorString += tr("<line>:<column>");

View File

@@ -66,7 +66,7 @@ static const char kCurrentDocumentRowCount[] = "CurrentDocument:RowCount";
static const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount"; static const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount";
static const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize"; static const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize";
TextEditorPlugin *TextEditorPlugin::m_instance = 0; static TextEditorPlugin *m_instance = 0;
TextEditorPlugin::TextEditorPlugin() TextEditorPlugin::TextEditorPlugin()
: m_settings(0), : m_settings(0),
@@ -83,11 +83,6 @@ TextEditorPlugin::~TextEditorPlugin()
m_instance = 0; m_instance = 0;
} }
TextEditorPlugin *TextEditorPlugin::instance()
{
return m_instance;
}
static const char wizardCategoryC[] = "U.General"; static const char wizardCategoryC[] = "U.General";
static inline QString wizardDisplayCategory() static inline QString wizardDisplayCategory()
@@ -266,6 +261,21 @@ void TextEditorPlugin::extensionsInitialized()
this, SLOT(updateCurrentSelection(QString))); this, SLOT(updateCurrentSelection(QString)));
} }
PlainTextEditorFactory *TextEditorPlugin::editorFactory()
{
return m_instance->m_editorFactory;
}
LineNumberFilter *TextEditorPlugin::lineNumberFilter()
{
return m_instance->m_lineNumberFilter;
}
BaseTextMarkRegistry *TextEditorPlugin::baseTextMarkRegistry()
{
return m_instance->m_baseTextMarkRegistry;
}
void TextEditorPlugin::invokeCompletion() void TextEditorPlugin::invokeCompletion()
{ {
Core::IEditor *iface = Core::EditorManager::currentEditor(); Core::IEditor *iface = Core::EditorManager::currentEditor();

View File

@@ -56,15 +56,13 @@ public:
TextEditorPlugin(); TextEditorPlugin();
virtual ~TextEditorPlugin(); virtual ~TextEditorPlugin();
static TextEditorPlugin *instance();
// ExtensionSystem::PluginInterface // ExtensionSystem::PluginInterface
bool initialize(const QStringList &arguments, QString *errorMessage); bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized(); void extensionsInitialized();
PlainTextEditorFactory *editorFactory() { return m_editorFactory; } static PlainTextEditorFactory *editorFactory();
LineNumberFilter *lineNumberFilter() { return m_lineNumberFilter; } static LineNumberFilter *lineNumberFilter();
BaseTextMarkRegistry *baseTextMarkRegistry() { return m_baseTextMarkRegistry; } static BaseTextMarkRegistry *baseTextMarkRegistry();
private slots: private slots:
void invokeCompletion(); void invokeCompletion();
@@ -73,7 +71,6 @@ private slots:
void updateCurrentSelection(const QString &text); void updateCurrentSelection(const QString &text);
private: private:
static TextEditorPlugin *m_instance;
TextEditorSettings *m_settings; TextEditorSettings *m_settings;
PlainTextEditorFactory *m_editorFactory; PlainTextEditorFactory *m_editorFactory;
LineNumberFilter *m_lineNumberFilter; LineNumberFilter *m_lineNumberFilter;