forked from qt-creator/qt-creator
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:
@@ -135,13 +135,13 @@ BaseTextMark::BaseTextMark(const QString &fileName, int lineNumber)
|
||||
// which might be set in the derived constructor
|
||||
void BaseTextMark::init()
|
||||
{
|
||||
Internal::TextEditorPlugin::instance()->baseTextMarkRegistry()->add(this);
|
||||
Internal::TextEditorPlugin::baseTextMarkRegistry()->add(this);
|
||||
}
|
||||
|
||||
BaseTextMark::~BaseTextMark()
|
||||
{
|
||||
// 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
|
||||
QTC_CHECK(b);
|
||||
}
|
||||
|
@@ -321,7 +321,7 @@ void Manager::registerMimeTypesFinished()
|
||||
const QPair<RegisterData, QList<MimeType> > &result = m_registeringWatcher.result();
|
||||
m_register = result.first;
|
||||
|
||||
PlainTextEditorFactory *factory = TextEditorPlugin::instance()->editorFactory();
|
||||
PlainTextEditorFactory *factory = TextEditorPlugin::editorFactory();
|
||||
const QSet<QString> &inFactory = factory->mimeTypes().toSet();
|
||||
foreach (const MimeType &mimeType, result.second) {
|
||||
MimeDatabase::addMimeType(mimeType);
|
||||
|
@@ -442,7 +442,7 @@ void TextEditorActionHandler::updateCopyAction()
|
||||
|
||||
void TextEditorActionHandler::gotoAction()
|
||||
{
|
||||
QString locatorString = TextEditorPlugin::instance()->lineNumberFilter()->shortcutString();
|
||||
QString locatorString = TextEditorPlugin::lineNumberFilter()->shortcutString();
|
||||
locatorString += QLatin1Char(' ');
|
||||
const int selectionStart = locatorString.size();
|
||||
locatorString += tr("<line>:<column>");
|
||||
|
@@ -66,7 +66,7 @@ static const char kCurrentDocumentRowCount[] = "CurrentDocument:RowCount";
|
||||
static const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount";
|
||||
static const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize";
|
||||
|
||||
TextEditorPlugin *TextEditorPlugin::m_instance = 0;
|
||||
static TextEditorPlugin *m_instance = 0;
|
||||
|
||||
TextEditorPlugin::TextEditorPlugin()
|
||||
: m_settings(0),
|
||||
@@ -83,11 +83,6 @@ TextEditorPlugin::~TextEditorPlugin()
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
TextEditorPlugin *TextEditorPlugin::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
static const char wizardCategoryC[] = "U.General";
|
||||
|
||||
static inline QString wizardDisplayCategory()
|
||||
@@ -266,6 +261,21 @@ void TextEditorPlugin::extensionsInitialized()
|
||||
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()
|
||||
{
|
||||
Core::IEditor *iface = Core::EditorManager::currentEditor();
|
||||
|
@@ -56,15 +56,13 @@ public:
|
||||
TextEditorPlugin();
|
||||
virtual ~TextEditorPlugin();
|
||||
|
||||
static TextEditorPlugin *instance();
|
||||
|
||||
// ExtensionSystem::PluginInterface
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||
void extensionsInitialized();
|
||||
|
||||
PlainTextEditorFactory *editorFactory() { return m_editorFactory; }
|
||||
LineNumberFilter *lineNumberFilter() { return m_lineNumberFilter; }
|
||||
BaseTextMarkRegistry *baseTextMarkRegistry() { return m_baseTextMarkRegistry; }
|
||||
static PlainTextEditorFactory *editorFactory();
|
||||
static LineNumberFilter *lineNumberFilter();
|
||||
static BaseTextMarkRegistry *baseTextMarkRegistry();
|
||||
|
||||
private slots:
|
||||
void invokeCompletion();
|
||||
@@ -73,7 +71,6 @@ private slots:
|
||||
void updateCurrentSelection(const QString &text);
|
||||
|
||||
private:
|
||||
static TextEditorPlugin *m_instance;
|
||||
TextEditorSettings *m_settings;
|
||||
PlainTextEditorFactory *m_editorFactory;
|
||||
LineNumberFilter *m_lineNumberFilter;
|
||||
|
Reference in New Issue
Block a user