Commit d9da6dcc authored by hjk's avatar hjk
Browse files

Fixes: snippets: compile fix for dead code

parent 3e6cf4e9
This is dead code for now.
......@@ -50,8 +50,7 @@ const QIcon SnippetsCompletion::m_fileIcon = QIcon(":/snippets/images/file.png")
SnippetsCompletion::SnippetsCompletion(QObject *parent)
: ICompletionCollector(parent)
{
m_core = SnippetsPlugin::core();
m_snippetsWnd = SnippetsPlugin::snippetsWindow();
m_snippetsWindow = SnippetsPlugin::snippetsWindow();
updateCompletions();
}
......@@ -66,9 +65,9 @@ void SnippetsCompletion::updateCompletions()
{
qDeleteAll(m_autoCompletions.values());
m_autoCompletions.clear();
#if 0
int index = 0;
foreach (SnippetSpec *spec, m_snippetsWnd->snippets()) {
foreach (SnippetSpec *spec, m_snippetsWindow->snippets()) {
if (!spec->completionShortcut().isEmpty()) {
TextEditor::CompletionItem *item = new TextEditor::CompletionItem;
item->m_key = spec->name();
......@@ -79,6 +78,7 @@ void SnippetsCompletion::updateCompletions()
++index;
}
}
#endif
}
bool SnippetsCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
......@@ -96,29 +96,36 @@ int SnippetsCompletion::startCompletion(TextEditor::ITextEditable *editor)
return m_startPosition;
}
void SnippetsCompletion::completions(QList<TextEditor::CompletionItem *> *completions)
#if 0
void SnippetsCompletion::completions(const QList<TextEditor::CompletionItem *> &completions)
{
const int length = m_editor->position() - m_startPosition;
if (length >= 2) {
QString key = m_editor->textAt(m_startPosition, length);
foreach (TextEditor::CompletionItem* item, m_autoCompletions.values()) {
if (item->m_key.startsWith(key, Qt::CaseInsensitive)) {
(*completions) << item;
}
if (item->m_key.startsWith(key, Qt::CaseInsensitive))
completions->append(item);
}
}
}
#endif
QString SnippetsCompletion::text(TextEditor::CompletionItem *item) const
{
const SnippetSpec *spec = m_snippetsWnd->snippets().at(item->m_index);
#if 0
const SnippetSpec *spec = m_snippetsWindow->snippets().at(item->m_index);
return spec->name();
#endif
return QString();
}
QString SnippetsCompletion::details(TextEditor::CompletionItem *item) const
{
const SnippetSpec *spec = m_snippetsWnd->snippets().at(item->m_index);
#if 0
const SnippetSpec *spec = m_snippetsWindow->snippets().at(item->m_index);
return spec->description();
#endif
return QString();
}
QIcon SnippetsCompletion::icon(TextEditor::CompletionItem *) const
......@@ -126,18 +133,20 @@ QIcon SnippetsCompletion::icon(TextEditor::CompletionItem *) const
return m_fileIcon;
}
void SnippetsCompletion::complete(TextEditor::CompletionItem *item)
void SnippetsCompletion::complete(const TextEditor::CompletionItem &item)
{
SnippetSpec *spec = m_snippetsWnd->snippets().at(item->m_index);
#if 0
SnippetSpec *spec = m_snippetsWindow->snippets().at(item->m_index);
int length = m_editor->position() - m_startPosition;
m_editor->setCurPos(m_startPosition);
m_editor->remove(length);
m_snippetsWnd->insertSnippet(m_editor, spec);
m_snippetsWindow->insertSnippet(m_editor, spec);
#endif
}
bool SnippetsCompletion::partiallyComplete()
bool SnippetsCompletion::partiallyComplete(const myns::QList<TextEditor::CompletionItem>&)
{
return false;
}
......
......@@ -36,15 +36,11 @@
#include <texteditor/icompletioncollector.h>
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QDir>
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtGui/QIcon>
namespace Core {
class ICore;
}
namespace TextEditor {
class ITextEditable;
class ITextEditor;
......@@ -72,10 +68,12 @@ public:
QString details(TextEditor::CompletionItem *item) const;
QIcon icon(TextEditor::CompletionItem *item) const;
void complete(TextEditor::CompletionItem *item);
bool partiallyComplete();
void complete(const TextEditor::CompletionItem &item);
bool partiallyComplete(const QList<TextEditor::CompletionItem> &);
void cleanup();
void completions(QList<TextEditor::CompletionItem>*);
private slots:
void updateCompletions();
......@@ -83,10 +81,9 @@ private:
static int findStartOfName(const TextEditor::ITextEditor *editor);
TextEditor::ITextEditable *m_editor;
int m_startPosition; // Position of the cursor from which completion started
int m_startPosition; // Position of the cursor from which completion started
SnippetsWindow *m_snippetsWnd;
Core::ICore *m_core;
SnippetsWindow *m_snippetsWindow;
QMultiMap<QString, TextEditor::CompletionItem *> m_autoCompletions;
......
......@@ -36,16 +36,18 @@
#include "snippetsplugin.h"
#include "snippetspec.h"
#include <QtCore/QtPlugin>
#include <QtCore/QDebug>
#include <QtGui/QShortcut>
#include <QtCore/QtPlugin>
#include <QtGui/QApplication>
#include <QtGui/QShortcut>
#include <extensionsystem/pluginmanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/CoreTools>
#include <coreplugin/baseview.h>
#include <coreplugin/icore.h>
#include <coreplugin/iview.h>
#include <texteditor/itexteditable.h>
#include <texteditor/texteditorconstants.h>
......@@ -56,6 +58,7 @@ SnippetsPlugin *SnippetsPlugin::m_instance = 0;
SnippetsPlugin::SnippetsPlugin()
{
m_instance = this;
m_snippetsCompletion = 0;
}
SnippetsPlugin::~SnippetsPlugin()
......@@ -78,17 +81,20 @@ bool SnippetsPlugin::initialize(const QStringList &arguments, QString *)
context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
m_snippetWnd = new SnippetsWindow();
addAutoReleasedObject(new Core::BaseView("Snippets.SnippetsTree",
m_snippetWnd,
QList<int>() << core->uniqueIDManager()->uniqueIdentifier(QLatin1String("Snippets Window"))
<< core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR),
Qt::RightDockWidgetArea));
Core::BaseView *view = new Core::BaseView;
view->setUniqueViewName("Snippets.SnippetsTree");
view->setWidget(m_snippetWnd);
view->setContext(QList<int>()
<< core->uniqueIDManager()->uniqueIdentifier(QLatin1String("Snippets Window"))
<< core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR));
//view->setDefaultPosition(Qt::RightDockWidgetArea));
addAutoReleasedObject(view);
m_snippetsCompletion = new SnippetsCompletion(this);
addObject(m_snippetsCompletion);
foreach (SnippetSpec *snippet, m_snippetWnd->snippets()) {
QShortcut *sc = new QShortcut(m_snippetWnd);
Core::ICommand *cmd = am->registerShortcut(sc, simplifySnippetName(snippet), context);
Core::Command *cmd = am->registerShortcut(sc, simplifySnippetName(snippet), context);
cmd->setCategory(tr("Snippets"));
connect(sc, SIGNAL(activated()), this, SLOT(snippetActivated()));
m_shortcuts.insert(sc, snippet);
......
......@@ -59,8 +59,6 @@ Q_DECLARE_METATYPE(Snippets::Internal::SnippetSpec *)
SnippetsWindow::SnippetsWindow()
{
m_core = SnippetsPlugin::core();
setWindowTitle(tr("Snippets"));
setWindowIcon(QIcon(":/snippets/images/snippets.png"));
setOrientation(Qt::Vertical);
......@@ -79,7 +77,7 @@ SnippetsWindow::SnippetsWindow()
if (!initSnippetsDir())
setDisabled(true);
else {
QDir defaultDir(m_core->resourcePath() + QLatin1String("/snippets"));
QDir defaultDir(Core::ICore::instance()->resourcePath() + QLatin1String("/snippets"));
if (defaultDir.exists())
initSnippets(defaultDir);
initSnippets(m_snippetsDir);
......@@ -110,9 +108,9 @@ void SnippetsWindow::activateSnippet(QTreeWidgetItem *item, int column)
return;
TextEditor::ITextEditable *editor = 0;
if (m_core->editorManager()->currentEditor())
if (Core::ICore::instance()->editorManager()->currentEditor())
editor = qobject_cast<TextEditor::ITextEditable *>(
m_core->editorManager()->currentEditor());
Core::ICore::instance()->editorManager()->currentEditor());
if (editor) {
SnippetSpec* spec = qVariantValue<SnippetSpec*>(item->data(0, Qt::UserRole));
insertSnippet(editor, spec);
......@@ -229,9 +227,9 @@ void SnippetsWindow::showInputWidget(bool canceled, const QString &value)
return;
TextEditor::ITextEditor *te = 0;
if (m_core->editorManager()->currentEditor())
if (Core::ICore::instance()->editorManager()->currentEditor())
te = qobject_cast<TextEditor::ITextEditor*>(
m_core->editorManager()->currentEditor());
Core::ICore::instance()->editorManager()->currentEditor());
int arg = m_requiredArgs.takeFirst();
if (arg != -1)
......
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