summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2010-10-08 10:04:41 +0200
committerLeandro Melo <leandro.melo@nokia.com>2010-10-08 10:14:57 +0200
commit818c8acea95b3c1b875058cf1db70f4e8dbc046a (patch)
treefb5a95e2cb3bf1295f063329e78a34b5aa02f4cf
parentb53ba61248ac398c98cf5849d050f99de92ff6a9 (diff)
downloadqt-creator-818c8acea95b3c1b875058cf1db70f4e8dbc046a.tar.gz
Remove old snippets plugin.
Reviewed-by: con
-rw-r--r--src/plugins/plugins.pro6
-rw-r--r--src/plugins/snippets/QMLSNIPPETS.TXT96
-rw-r--r--src/plugins/snippets/README1
-rw-r--r--src/plugins/snippets/Snippets.pluginspec20
-rw-r--r--src/plugins/snippets/images/dir.pngbin862 -> 0 bytes
-rw-r--r--src/plugins/snippets/images/diropen.pngbin931 -> 0 bytes
-rw-r--r--src/plugins/snippets/images/file.pngbin452 -> 0 bytes
-rw-r--r--src/plugins/snippets/images/snippets.pngbin908 -> 0 bytes
-rw-r--r--src/plugins/snippets/inputwidget.cpp131
-rw-r--r--src/plugins/snippets/inputwidget.h67
-rw-r--r--src/plugins/snippets/snippets.pro24
-rw-r--r--src/plugins/snippets/snippets.qrc8
-rw-r--r--src/plugins/snippets/snippetscompletion.cpp164
-rw-r--r--src/plugins/snippets/snippetscompletion.h93
-rw-r--r--src/plugins/snippets/snippetspec.cpp97
-rw-r--r--src/plugins/snippets/snippetspec.h65
-rw-r--r--src/plugins/snippets/snippetsplugin.cpp122
-rw-r--r--src/plugins/snippets/snippetsplugin.h80
-rw-r--r--src/plugins/snippets/snippetswindow.cpp429
-rw-r--r--src/plugins/snippets/snippetswindow.h120
20 files changed, 0 insertions, 1523 deletions
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 6cbc707d37..67490abf3b 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -19,7 +19,6 @@ SUBDIRS = plugin_coreplugin \
plugin_cvs \
plugin_cpptools \
plugin_qt4projectmanager \
-# plugin_snippets \ # buggy and annoying
plugin_locator \
plugin_debugger \
# plugin_qtestlib \ # this seems to be dead
@@ -145,11 +144,6 @@ plugin_bookmarks.depends = plugin_projectexplorer
plugin_bookmarks.depends += plugin_coreplugin
plugin_bookmarks.depends += plugin_texteditor
-plugin_snippets.subdir = snippets
-plugin_snippets.depends = plugin_projectexplorer
-plugin_snippets.depends += plugin_coreplugin
-plugin_snippets.depends += plugin_texteditor
-
plugin_debugger.subdir = debugger
plugin_debugger.depends = plugin_projectexplorer
plugin_debugger.depends += plugin_coreplugin
diff --git a/src/plugins/snippets/QMLSNIPPETS.TXT b/src/plugins/snippets/QMLSNIPPETS.TXT
deleted file mode 100644
index cd50273ed4..0000000000
--- a/src/plugins/snippets/QMLSNIPPETS.TXT
+++ /dev/null
@@ -1,96 +0,0 @@
-property <name> <name> : <name>
-if you delete the last name as you tab through it should also delete the : colon as that is not needed.
-
-----------------
-Item {
- id: <name>
-
- }
-If you delete the name maybe the 'id:' should be deleted as well.
-
-This is fine for most other QML elements such as Rectangle and MouseArea
-
-----------------
-
-BorderImage {
- id: <name>
- width: <name>; height: <name>
- border.left: <name>; border.top: <name>
- border.right: <name>; border.bottom: <name>
- source: "<name>"
-}
-
--------------------
-
-Image {
- id: <name>
- source: "<name>"
-}
-
-----------------
-
-Text {
- id: <name>
- text: "<name>"
-}
-
-----------------
-
-states: [
- State {
- name: "<name>"
- PropertyChanges {
- target: <name>
- <- cursor should end up here at the end?
- }
- }
-]
-
-------------------
-State {
- name: "<name>"
- PropertyChanges {
- target: <name>
- <- cursor should end up here at the end?
- }
-}
-
-
---------------------
-transitions: [
- Transition {
- from: "<name>"
- to: "<name>"
- <- cursor should end up here at the end?
- }
-]
-
------------------------
-
-Transition {
- from: "<name>"
- to: "<name>"
- <- cursor should end up here at the end?
-}
-
------------------------
-
-PropertyChanges {
- target: <name>
- <- cursor should end up here at the end?
- }
-
-NumberAnimation { matchTargets: "<name>"; matchProperties: "<name>"; duration: <int> }
-NumberAnimation { target: "<name>"; property: "<name>"; value: <name>; duration: <int> }
-PropertyAction { matchTargets: "<name>"; matchProperties: "<name>"; duration: <int> }
-PropertyAction { target: "<name>"; property: "<name>"; value: <name>; duration: <int> }
-PauseAnimation { duration: <name>}
-ColorAnimation { from: <name>; to: <name>; duration: <int> }
-effect: Colorize { color: "<name>" }
-effect: Blur { blurRadius: "<int>" }
-effect: DropShadow {
- blurRadius: <int>
- offset.x: <int>
- offset.y: <int>
- }
-
diff --git a/src/plugins/snippets/README b/src/plugins/snippets/README
deleted file mode 100644
index 0631c716c2..0000000000
--- a/src/plugins/snippets/README
+++ /dev/null
@@ -1 +0,0 @@
-This is dead code for now.
diff --git a/src/plugins/snippets/Snippets.pluginspec b/src/plugins/snippets/Snippets.pluginspec
deleted file mode 100644
index 83d38cc0c0..0000000000
--- a/src/plugins/snippets/Snippets.pluginspec
+++ /dev/null
@@ -1,20 +0,0 @@
-<plugin name="Snippets" version="2.1.81" compatVersion="2.1.81">
- <vendor>Nokia Corporation</vendor>
- <copyright>(C) 2010 Nokia Corporation</copyright>
- <license>
-Commercial Usage
-
-Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
-
-GNU Lesser General Public License Usage
-
-Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
- </license>
- <description>Code snippet plugin.</description>
- <url>http://qt.nokia.com</url>
- <dependencyList>
- <dependency name="Core" version="2.1.81"/>
- <dependency name="TextEditor" version="2.1.81"/>
- <dependency name="ProjectExplorer" version="2.1.81"/>
- </dependencyList>
-</plugin>
diff --git a/src/plugins/snippets/images/dir.png b/src/plugins/snippets/images/dir.png
deleted file mode 100644
index 57cec6bcd3..0000000000
--- a/src/plugins/snippets/images/dir.png
+++ /dev/null
Binary files differ
diff --git a/src/plugins/snippets/images/diropen.png b/src/plugins/snippets/images/diropen.png
deleted file mode 100644
index 48fcb9b703..0000000000
--- a/src/plugins/snippets/images/diropen.png
+++ /dev/null
Binary files differ
diff --git a/src/plugins/snippets/images/file.png b/src/plugins/snippets/images/file.png
deleted file mode 100644
index 4a24ce3c2f..0000000000
--- a/src/plugins/snippets/images/file.png
+++ /dev/null
Binary files differ
diff --git a/src/plugins/snippets/images/snippets.png b/src/plugins/snippets/images/snippets.png
deleted file mode 100644
index b799041d61..0000000000
--- a/src/plugins/snippets/images/snippets.png
+++ /dev/null
Binary files differ
diff --git a/src/plugins/snippets/inputwidget.cpp b/src/plugins/snippets/inputwidget.cpp
deleted file mode 100644
index 2453a88efd..0000000000
--- a/src/plugins/snippets/inputwidget.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include <QtCore/QDebug>
-#include <QtGui/QApplication>
-#include <QtGui/QLabel>
-#include <QtGui/QLineEdit>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QBitmap>
-#include <QtGui/QPainter>
-#include <QtGui/QResizeEvent>
-
-#include "inputwidget.h"
-
-using namespace Snippets::Internal;
-
-InputWidget::InputWidget(const QString &text, const QString &value)
- : QFrame(0, Qt::Popup)
-{
- setAttribute(Qt::WA_DeleteOnClose);
-
- m_label = new QLabel();
- m_label->setTextFormat(Qt::RichText);
- m_label->setText(text);
-
- m_lineEdit = new QLineEdit();
- m_lineEdit->setText(value);
- m_lineEdit->setSelection(0, value.length());
-
- qApp->installEventFilter(this);
-
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(m_label);
- layout->addWidget(m_lineEdit);
- layout->setMargin(3);
-
- setLayout(layout);
- ensurePolished();
-
- setAutoFillBackground(false);
-}
-
-void InputWidget::resizeEvent(QResizeEvent *event)
-{
- int height = event->size().height();
- int width = event->size().width();
- qDebug() << event->size();
-
- QPalette pal = palette();
- QLinearGradient bg(0,0,0,height);
- bg.setColorAt(0, QColor(195,195,255));
- bg.setColorAt(1, QColor(230,230,255));
- pal.setBrush(QPalette::Background, QBrush(bg));
- setPalette(pal);
-
- QBitmap bm(width, height);
- bm.fill(Qt::color0);
- QPainter p(&bm);
- p.setBrush(QBrush(Qt::color1, Qt::SolidPattern));
- p.setPen(Qt::color1);
- int rw = (25 * height) / width;
- p.drawRoundRect(0,0,width,height, rw, 25);
- setMask(bm);
-}
-
-void InputWidget::showInputWidget(const QPoint &position)
-{
- move(position);
- show();
- m_lineEdit->setFocus();
-}
-
-bool InputWidget::eventFilter(QObject *o, QEvent *e)
-{
- if (o != m_lineEdit) {
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonDblClick:
- closeInputWidget(true);
- default:
- break;
- }
- } else if (e->type() == QEvent::KeyPress) {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
- switch (ke->key()) {
- case Qt::Key_Escape:
- qDebug() << "Escape";
- closeInputWidget(true);
- break;
- case Qt::Key_Enter:
- case Qt::Key_Return:
- qDebug() << "Enter";
- closeInputWidget(false);
- return true;
- }
- }
-
- return false;
-}
-
-void InputWidget::closeInputWidget(bool cancel)
-{
- emit finished(cancel, m_lineEdit->text());
- close();
-}
diff --git a/src/plugins/snippets/inputwidget.h b/src/plugins/snippets/inputwidget.h
deleted file mode 100644
index fbfeb6db29..0000000000
--- a/src/plugins/snippets/inputwidget.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef INPUTWIDGET_H
-#define INPUTWIDGET_H
-
-#include <QtGui/QFrame>
-
-QT_BEGIN_NAMESPACE
-class QLabel;
-class QLineEdit;
-QT_END_NAMESPACE
-
-namespace Snippets {
-namespace Internal {
-
-class InputWidget : public QFrame
-{
- Q_OBJECT
-
-public:
- InputWidget(const QString &text, const QString &value);
- void showInputWidget(const QPoint &position);
-
-signals:
- void finished(bool canceled, const QString &value);
-
-protected:
- bool eventFilter(QObject *, QEvent *);
- void resizeEvent(QResizeEvent *event);
-
-private:
- void closeInputWidget(bool cancel);
- QLabel *m_label;
- QLineEdit *m_lineEdit;
-};
-
-} // namespace Internal
-} // namespace Snippets
-
-#endif // INPUTWIDGET_H
diff --git a/src/plugins/snippets/snippets.pro b/src/plugins/snippets/snippets.pro
deleted file mode 100644
index 8c6eb285cd..0000000000
--- a/src/plugins/snippets/snippets.pro
+++ /dev/null
@@ -1,24 +0,0 @@
-TEMPLATE = lib
-TARGET = Snippets
-QT += xml
-
-include(../../qtcreatorplugin.pri)
-include(../../plugins/projectexplorer/projectexplorer.pri)
-include(../../plugins/coreplugin/coreplugin.pri)
-include(../../plugins/texteditor/texteditor.pri)
-
-INCLUDEPATH += ../projectexplorer
-
-HEADERS += snippetsplugin.h \
- snippetswindow.h \
- snippetspec.h \
- snippetscompletion.h \
- inputwidget.h
-
-SOURCES += snippetsplugin.cpp \
- snippetswindow.cpp \
- snippetspec.cpp \
- snippetscompletion.cpp \
- inputwidget.cpp
-
-RESOURCES += snippets.qrc
diff --git a/src/plugins/snippets/snippets.qrc b/src/plugins/snippets/snippets.qrc
deleted file mode 100644
index b36585dcc5..0000000000
--- a/src/plugins/snippets/snippets.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<RCC>
- <qresource prefix="/snippets" >
- <file>images/file.png</file>
- <file>images/dir.png</file>
- <file>images/diropen.png</file>
- <file>images/snippets.png</file>
- </qresource>
-</RCC>
diff --git a/src/plugins/snippets/snippetscompletion.cpp b/src/plugins/snippets/snippetscompletion.cpp
deleted file mode 100644
index 974c849df8..0000000000
--- a/src/plugins/snippets/snippetscompletion.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "snippetscompletion.h"
-#include "snippetswindow.h"
-#include "snippetspec.h"
-#include "snippetsplugin.h"
-
-#include <texteditor/itexteditable.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QMap>
-#include <QtGui/QAction>
-#include <QtGui/QKeyEvent>
-
-using namespace Snippets::Internal;
-
-const QIcon SnippetsCompletion::m_fileIcon = QIcon(":/snippets/images/file.png");
-
-SnippetsCompletion::SnippetsCompletion(QObject *parent)
- : ICompletionCollector(parent)
-{
- m_snippetsWindow = SnippetsPlugin::snippetsWindow();
-
- updateCompletions();
-}
-
-SnippetsCompletion::~SnippetsCompletion()
-{
- qDeleteAll(m_autoCompletions.values());
- m_autoCompletions.clear();
-}
-
-void SnippetsCompletion::updateCompletions()
-{
- qDeleteAll(m_autoCompletions.values());
- m_autoCompletions.clear();
-#if 0
- int index = 0;
- foreach (SnippetSpec *spec, m_snippetsWindow->snippets()) {
- if (!spec->completionShortcut().isEmpty()) {
- TextEditor::CompletionItem *item = new TextEditor::CompletionItem;
- item->m_key = spec->name();
- item->m_collector = this;
- item->m_index = index;
- item->m_relevance = 0;
- m_autoCompletions.insert(spec->completionShortcut(), item);
- ++index;
- }
- }
-#endif
-}
-
-bool SnippetsCompletion::triggersCompletion(TextEditor::ITextEditable *editor)
-{
- QString currentWord = editor->textAt(editor->position() - 3, 3);
- currentWord = currentWord.trimmed();
- return currentWord.length() == 2 && m_autoCompletions.contains(currentWord) &&
- !editor->characterAt(editor->position() - 1).isSpace();
-}
-
-int SnippetsCompletion::startCompletion(TextEditor::ITextEditable *editor)
-{
- m_editor = editor;
- m_startPosition = findStartOfName(m_editor);
- return m_startPosition;
-}
-
-#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->append(item);
- }
- }
-}
-#endif
-
-QString SnippetsCompletion::text(TextEditor::CompletionItem *item) const
-{
-#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
-{
-#if 0
- const SnippetSpec *spec = m_snippetsWindow->snippets().at(item->m_index);
- return spec->description();
-#endif
- return QString();
-}
-
-QIcon SnippetsCompletion::icon(TextEditor::CompletionItem *) const
-{
- return m_fileIcon;
-}
-
-void SnippetsCompletion::complete(const TextEditor::CompletionItem &item)
-{
-#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_snippetsWindow->insertSnippet(m_editor, spec);
-#endif
-}
-
-bool SnippetsCompletion::partiallyComplete(const myns::QList<TextEditor::CompletionItem>&)
-{
- return false;
-}
-
-void SnippetsCompletion::cleanup()
-{
-}
-
-int SnippetsCompletion::findStartOfName(const TextEditor::ITextEditor *editor)
-{
- int pos = editor->position() - 1;
- QChar chr = editor->characterAt(pos);
-
- // Skip to the start of a name
- while (!chr.isSpace() && !chr.isNull())
- chr = editor->characterAt(--pos);
-
- return pos + 1;
-}
diff --git a/src/plugins/snippets/snippetscompletion.h b/src/plugins/snippets/snippetscompletion.h
deleted file mode 100644
index 89a57eb03c..0000000000
--- a/src/plugins/snippets/snippetscompletion.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef SNIPPETSCOMPLETION_H
-#define SNIPPETSCOMPLETION_H
-
-#include <texteditor/icompletioncollector.h>
-
-#include <QtCore/QDir>
-#include <QtCore/QMap>
-#include <QtCore/QObject>
-#include <QtGui/QIcon>
-
-namespace TextEditor {
-class ITextEditable;
-class ITextEditor;
-}
-
-namespace Snippets {
-namespace Internal {
-
-class SnippetsWindow;
-class SnippetSpec;
-
-class SnippetsCompletion : public TextEditor::ICompletionCollector
-{
- Q_OBJECT
-public:
- SnippetsCompletion(QObject *parent);
- ~SnippetsCompletion();
-
- // ICompletionCollector
- bool triggersCompletion(TextEditor::ITextEditable *editor);
- int startCompletion(TextEditor::ITextEditable *editor);
- void completions(QList<TextEditor::CompletionItem *> *completions);
-
- QString text(TextEditor::CompletionItem *item) const;
- QString details(TextEditor::CompletionItem *item) const;
- QIcon icon(TextEditor::CompletionItem *item) const;
-
- void complete(const TextEditor::CompletionItem &item);
- bool partiallyComplete(const QList<TextEditor::CompletionItem> &);
- void cleanup();
-
- void completions(QList<TextEditor::CompletionItem>*);
-
-private slots:
- void updateCompletions();
-
-private:
- static int findStartOfName(const TextEditor::ITextEditor *editor);
-
- TextEditor::ITextEditable *m_editor;
- int m_startPosition; // Position of the cursor from which completion started
-
- SnippetsWindow *m_snippetsWindow;
-
- QMultiMap<QString, TextEditor::CompletionItem *> m_autoCompletions;
-
- static const QIcon m_fileIcon;
-};
-
-} // namespace Internal
-} // namespace Snippets
-
-#endif // SNIPPETSCOMPLETION_H
-
diff --git a/src/plugins/snippets/snippetspec.cpp b/src/plugins/snippets/snippetspec.cpp
deleted file mode 100644
index f0086088af..0000000000
--- a/src/plugins/snippets/snippetspec.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "snippetspec.h"
-#include "persistentsettings.h"
-
-using namespace Snippets::Internal;
-using ProjectExplorer::PersistentSettingsReader;
-
-bool SnippetSpec::load(const QString &fileName)
-{
- PersistentSettingsReader reader;
- if (!reader.load(fileName))
- return false;
-
- m_contents = reader.restoreValue(QLatin1String("Contents")).toString();
- m_name = reader.restoreValue(QLatin1String("Name")).toString();
- m_description = reader.restoreValue(QLatin1String("Description")).toString();
- m_category = reader.restoreValue(QLatin1String("Category")).toString();
- m_completionShortcut = reader.restoreValue(QLatin1String("Shortcut")).toString();
-
- QMap<QString, QVariant> temp = reader.restoreValue(QLatin1String("Arguments")).toMap();
- QMap<QString, QVariant>::const_iterator it, end;
- end = temp.constEnd();
- for (it = temp.constBegin(); it != end; ++it) {
- m_argumentDescription.insert( it.key().toInt(), it.value().toString());
- }
-
- temp = reader.restoreValue(QLatin1String("ArgumentDefaults")).toMap();
- end = temp.constEnd();
- for (it = temp.constBegin(); it != end; ++it) {
- m_argumentDefault.insert(it.key().toInt(), it.value().toString());
- }
-
- return true;
-}
-
-QString SnippetSpec::contents() const
-{
- return m_contents;
-}
-
-QString SnippetSpec::name() const
-{
- return m_name;
-}
-
-QString SnippetSpec::description() const
-{
- return m_description;
-}
-
-QString SnippetSpec::category() const
-{
- return m_category;
-}
-
-QString SnippetSpec::completionShortcut() const
-{
- return m_completionShortcut;
-}
-
-QString SnippetSpec::argumentDescription(int id) const
-{
- return m_argumentDescription.value(id);
-}
-
-QString SnippetSpec::argumentDefault(int id) const
-{
- return m_argumentDefault.value(id);
-}
diff --git a/src/plugins/snippets/snippetspec.h b/src/plugins/snippets/snippetspec.h
deleted file mode 100644
index 2f07e6f6fa..0000000000
--- a/src/plugins/snippets/snippetspec.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef SNIPPETSPEC_H
-#define SNIPPETSPEC_H
-
-#include <QtCore/QMap>
-#include <QtCore/QString>
-
-namespace Snippets {
-namespace Internal {
-
-class SnippetSpec
-{
-public:
- bool load(const QString &fileName);
-
- QString contents() const;
- QString name() const;
- QString description() const;
- QString category() const;
- QString completionShortcut() const;
- QString argumentDescription(int id) const;
- QString argumentDefault(int id) const;
-
-private:
- QString m_contents;
- QString m_name;
- QString m_description;
- QString m_category;
- QString m_completionShortcut;
- QMap<int, QString> m_argumentDescription;
- QMap<int, QString> m_argumentDefault;
-};
-
-} //namespace Internal
-} //namespace Snippets
-
-#endif // SNIPPETSPEC_H
diff --git a/src/plugins/snippets/snippetsplugin.cpp b/src/plugins/snippets/snippetsplugin.cpp
deleted file mode 100644
index 50e22565d0..0000000000
--- a/src/plugins/snippets/snippetsplugin.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "snippetswindow.h"
-#include "snippetscompletion.h"
-#include "snippetsplugin.h"
-#include "snippetspec.h"
-
-#include <QtCore/QDebug>
-#include <QtCore/QtPlugin>
-#include <QtGui/QApplication>
-#include <QtGui/QShortcut>
-
-#include <extensionsystem/pluginmanager.h>
-#include <coreplugin/uniqueidmanager.h>
-#include <coreplugin/actionmanager/actionmanager.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <coreplugin/baseview.h>
-#include <coreplugin/icore.h>
-#include <coreplugin/iview.h>
-#include <texteditor/itexteditable.h>
-#include <texteditor/texteditorconstants.h>
-
-using namespace Snippets::Internal;
-
-SnippetsPlugin *SnippetsPlugin::m_instance = 0;
-
-SnippetsPlugin::SnippetsPlugin()
-{
- m_instance = this;
- m_snippetsCompletion = 0;
-}
-
-SnippetsPlugin::~SnippetsPlugin()
-{
- removeObject(m_snippetsCompletion);
- delete m_snippetsCompletion;
-}
-
-void SnippetsPlugin::extensionsInitialized()
-{
-}
-
-bool SnippetsPlugin::initialize(const QStringList &arguments, QString *)
-{
- Q_UNUSED(arguments)
- Core::ICore *core = Core::ICore::instance();
- Core::ActionManager *am = core->actionManager();
-
- QList<int> context;
- context << core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
-
- m_snippetWnd = new SnippetsWindow();
- Core::BaseView *view = new Core::BaseView;
- view->setUniqueViewName("Snippets");
- 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::Command *cmd = am->registerShortcut(sc, simplifySnippetName(snippet), context);
- cmd->setCategory(tr("Snippets"));
- connect(sc, SIGNAL(activated()), this, SLOT(snippetActivated()));
- m_shortcuts.insert(sc, snippet);
- }
-
- return true;
-}
-
-QString SnippetsPlugin::simplifySnippetName(SnippetSpec *snippet) const
-{
- return QLatin1String("Snippets.")
- + snippet->category().simplified().replace(QLatin1String(" "), QLatin1String(""))
- + QLatin1Char('.')
- + snippet->name().simplified().replace(QLatin1String(" "), QLatin1String(""));
-}
-
-void SnippetsPlugin::snippetActivated()
-{
- Core::ICore *core = Core::ICore::instance();
- SnippetSpec *snippet = m_shortcuts.value(sender());
- if (snippet && core->editorManager()->currentEditor()) {
- TextEditor::ITextEditable *te =
- qobject_cast<TextEditor::ITextEditable *>(
- core->editorManager()->currentEditor());
- m_snippetWnd->insertSnippet(te, snippet);
- }
-}
-
-Q_EXPORT_PLUGIN(SnippetsPlugin)
diff --git a/src/plugins/snippets/snippetsplugin.h b/src/plugins/snippets/snippetsplugin.h
deleted file mode 100644
index b28e09ddfc..0000000000
--- a/src/plugins/snippets/snippetsplugin.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef SNIPPETS_H
-#define SNIPPETS_H
-
-#include <QtCore/QMap>
-#include <QtCore/QObject>
-#include <QtGui/QShortcut>
-
-#include <extensionsystem/iplugin.h>
-
-namespace Snippets {
-namespace Internal {
-
-class SnippetsWindow;
-class SnippetSpec;
-class SnippetsCompletion;
-
-class SnippetsPlugin : public ExtensionSystem::IPlugin
-{
- Q_OBJECT
-
-public:
- SnippetsPlugin();
- virtual ~SnippetsPlugin();
-
- static SnippetsPlugin *instance() { return m_instance; }
- static SnippetsWindow *snippetsWindow() { return m_instance->m_snippetWnd; }
-
- bool initialize(const QStringList &arguments, QString *errorMessage);
- void extensionsInitialized();
-
-private slots:
- void snippetActivated();
-
-private:
- static SnippetsPlugin *m_instance;
-
- QString simplifySnippetName(SnippetSpec *snippet) const;
- SnippetsCompletion *m_snippetsCompletion;
- SnippetsWindow *m_snippetWnd;
-
- int m_textContext;
- int m_snippetsMode;
- QShortcut *m_exitShortcut;
- QShortcut *m_modeShortcut;
- QMap<QObject*, SnippetSpec*> m_shortcuts;
-};
-
-} // namespace Internal
-} // namespace Snippets
-
-#endif // SNIPPETS_H
diff --git a/src/plugins/snippets/snippetswindow.cpp b/src/plugins/snippets/snippetswindow.cpp
deleted file mode 100644
index 59f31fcb1e..0000000000
--- a/src/plugins/snippets/snippetswindow.cpp
+++ /dev/null
@@ -1,429 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "snippetswindow.h"
-#include "snippetspec.h"
-#include "inputwidget.h"
-#include "snippetsplugin.h"
-
-#include <coreplugin/icore.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <texteditor/itexteditable.h>
-#include <texteditor/itexteditor.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtGui/QDragEnterEvent>
-#include <QtGui/QApplication>
-#include <QtGui/QLabel>
-#include <QtCore/QMimeData>
-#include <QtGui/QHeaderView>
-
-using namespace Snippets::Internal;
-
-const QIcon SnippetsWindow::m_fileIcon = QIcon(":/snippets/images/file.png");
-const QIcon SnippetsWindow::m_dirIcon = QIcon(":/snippets/images/dir.png");
-const QIcon SnippetsWindow::m_dirOpenIcon = QIcon(":/snippets/images/diropen.png");
-
-Q_DECLARE_METATYPE(Snippets::Internal::SnippetSpec *)
-
-SnippetsWindow::SnippetsWindow()
-{
- setWindowTitle(tr("Snippets"));
- setWindowIcon(QIcon(":/snippets/images/snippets.png"));
- setOrientation(Qt::Vertical);
-
- m_snippetsTree = new SnippetsTree(this);
- addWidget(m_snippetsTree);
-
- m_descLabel = new QLabel(this);
- m_descLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft);
- m_descLabel->setFrameShape(QFrame::Panel);
- m_descLabel->setFrameShadow(QFrame::Raised);
- m_descLabel->setWordWrap(true);
- addWidget(m_descLabel);
-
- m_snippetsDir = QDir::home();
- if (!initSnippetsDir())
- setDisabled(true);
- else {
- QDir defaultDir(Core::ICore::instance()->resourcePath() + QLatin1String("/snippets"));
- if (defaultDir.exists())
- initSnippets(defaultDir);
- initSnippets(m_snippetsDir);
- }
-
- connect(m_snippetsTree, SIGNAL(itemCollapsed(QTreeWidgetItem *)),
- this, SLOT(setClosedIcon(QTreeWidgetItem *)));
-
- connect(m_snippetsTree, SIGNAL(itemExpanded(QTreeWidgetItem *)),
- this, SLOT(setOpenIcon(QTreeWidgetItem *)));
-
- connect(m_snippetsTree, SIGNAL(itemActivated(QTreeWidgetItem *, int)),
- this, SLOT(activateSnippet(QTreeWidgetItem *, int)));
-
- connect(m_snippetsTree, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
- this, SLOT(updateDescription(QTreeWidgetItem *)));
-}
-
-SnippetsWindow::~SnippetsWindow()
-{
- qDeleteAll(m_snippets);
-}
-
-
-void SnippetsWindow::activateSnippet(QTreeWidgetItem *item, int column)
-{
- if (!item->parent())
- return;
-
- TextEditor::ITextEditable *editor = 0;
- if (Core::ICore::instance()->editorManager()->currentEditor())
- editor = qobject_cast<TextEditor::ITextEditable *>(
- Core::ICore::instance()->editorManager()->currentEditor());
- if (editor) {
- SnippetSpec* spec = qVariantValue<SnippetSpec*>(item->data(0, Qt::UserRole));
- insertSnippet(editor, spec);
- }
-
- Q_UNUSED(column)
-}
-
-const QList<SnippetSpec *> &SnippetsWindow::snippets() const
-{
- return m_snippets;
-}
-
-void SnippetsWindow::initSnippets(const QDir &dir)
-{
- QString name;
- QString category;
-
- QMap<QString, QTreeWidgetItem *> categories;
- for (int i = 0; i < m_snippetsTree->topLevelItemCount(); ++i) {
- categories.insert(m_snippetsTree->topLevelItem(i)->text(0),
- m_snippetsTree->topLevelItem(i));
- }
-
- foreach (const QString &snippet, dir.entryList(QStringList("*.snp"))) {
- SnippetSpec *spec = new SnippetSpec();
- if (spec->load(dir.filePath(snippet))) {
- if (!categories.contains(spec->category())) {
- QTreeWidgetItem *citem = new QTreeWidgetItem(m_snippetsTree);
- citem->setText(0, spec->category());
- citem->setIcon(0, m_dirIcon);
- categories.insert(spec->category(), citem);
- }
-
- QTreeWidgetItem *item = new QTreeWidgetItem(
- categories.value(spec->category()));
- item->setText(0, spec->name());
- item->setIcon(0, m_fileIcon);
- QVariant v;
- qVariantSetValue<SnippetSpec *>(v, spec);
- item->setData(0, Qt::UserRole, v);
-
- m_snippets.append(spec);
- }
- }
-}
-
-QString SnippetsWindow::createUniqueFileName()
-{
- int fileNumber = 0;
- QString baseName = "snippet";
- while (m_snippetsDir.exists(baseName + QString::number(fileNumber) + ".snp")) {
- ++fileNumber;
- }
- return baseName + QString::number(fileNumber) + ".snp";
-}
-
-void SnippetsWindow::writeSnippet(const QMimeData *)
-{
-}
-
-bool SnippetsWindow::initSnippetsDir()
-{
- if (!m_snippetsDir.exists(".qworkbench"))
- m_snippetsDir.mkdir(".qworkbench");
- if (!m_snippetsDir.cd(".qworkbench"))
- return false;
-
- if (!m_snippetsDir.exists("snippets"))
- m_snippetsDir.mkdir("snippets");
- return m_snippetsDir.cd("snippets");
-}
-
-void SnippetsWindow::getArguments()
-{
- QString contents = m_currentSnippet->contents();
- int index = 0;
- bool pc = false;
- QString nrstr;
-
- QSet<int> requiredArgs;
- m_requiredArgs.clear();
- m_args.clear();
-
- while (index < contents.length()) {
- QChar c = contents.at(index);
- if (c == QLatin1Char('%')) {
- pc = !pc;
- } else if (pc) {
- if (c.isNumber()) {
- nrstr += c;
- } else {
- pc = false;
- }
- }
-
- if (!pc && !nrstr.isEmpty()) {
- requiredArgs << nrstr.toInt();
- nrstr.clear();
- }
-
- ++index;
- }
-
- m_requiredArgs = requiredArgs.toList();
- m_requiredArgs.prepend(-1);
-
- showInputWidget(false, QString());
-}
-
-void SnippetsWindow::showInputWidget(bool canceled, const QString &value)
-{
- if (canceled)
- return;
-
- TextEditor::ITextEditor *te = 0;
- if (Core::ICore::instance()->editorManager()->currentEditor())
- te = qobject_cast<TextEditor::ITextEditor*>(
- Core::ICore::instance()->editorManager()->currentEditor());
-
- int arg = m_requiredArgs.takeFirst();
- if (arg != -1)
- m_args << value;
-
- if (!te || m_requiredArgs.isEmpty()) {
- qDebug("replaceAndInsert");
- replaceAndInsert();
- } else {
- QString desc = m_currentSnippet->argumentDescription(m_requiredArgs.first());
- QString def = m_currentSnippet->argumentDefault(m_requiredArgs.first());
- foreach (const QString &arg, m_args) {
- desc = desc.arg(arg);
- def = def.arg(arg);
- }
-
- InputWidget *iw = new InputWidget(desc, def);
- connect(iw, SIGNAL(finished(bool, const QString &)),
- this, SLOT(showInputWidget(bool, const QString &)));
- iw->showInputWidget(te->cursorRect().bottomRight());
- }
-}
-
-void SnippetsWindow::replaceAndInsert()
-{
- QString result;
- QString keyWord;
- int setAnchor = -1;
- int setCursor = -1;
- int selLength = 0;
-
- //clean up selection
- int startPos = m_currentEditor->position(TextEditor::ITextEditable::Anchor);
- int endPos = m_currentEditor->position();
-
- if (startPos < 0) {
- startPos = endPos;
- } else {
- if (startPos > endPos) {
- int tmp = startPos;
- startPos = endPos;
- endPos = tmp;
- }
- selLength = endPos - startPos;
- }
-
- //parse the contents
- m_currentEditor->setCurPos(startPos);
- QString editorIndent = getCurrentIndent(m_currentEditor);
- QString content = m_currentSnippet->contents();
- foreach (const QString &arg, m_args) {
- content = content.arg(arg);
- }
-
- int startOfKey = -1;
- for (int i = 0; i<content.length(); ++i) {
- //handle windows,mac and linux new lines...
- if (content.at(i) == QLatin1Char('\n')) {
- if ((i <= 0) || content.at(i-1) != QLatin1Char('\r'))
- result += QLatin1Char('\n') + editorIndent;
- continue;
- } else if (content.at(i) == QLatin1Char('\r')) {
- result += QLatin1Char('\n') + editorIndent;
- continue;
- }
-
- if (content.at(i) == QChar('$')) {
- if (startOfKey != -1) {
- m_currentEditor->insert(result);
- if (keyWord == QLatin1String("selection")) {
- const QString &indent = indentOfString(content, i);
- int selStartPos = m_currentEditor->position();
- m_currentEditor->setCurPos(selStartPos + selLength);
- insertIdents(m_currentEditor, indent, selStartPos, m_currentEditor->position());
- } else if (keyWord == QLatin1String("anchor")) {
- setAnchor = m_currentEditor->position();
- } else if (keyWord == QLatin1String("cursor")) {
- setCursor = m_currentEditor->position();
- }
- result.clear();
- keyWord.clear();
- startOfKey = -1;
- } else {
- startOfKey = i;
- }
- } else {
- if (startOfKey != -1)
- keyWord += content.at(i).toLower();
- else
- result += content.at(i);
- }
- }
-
- m_currentEditor->insert(result);
-
- if (setAnchor != -1) {
- m_currentEditor->setCurPos(setAnchor);
- m_currentEditor->select(setCursor);
- } else if (setCursor != -1) {
- m_currentEditor->setCurPos(setCursor);
- }
-}
-
-void SnippetsWindow::insertSnippet(TextEditor::ITextEditable *editor, SnippetSpec *snippet)
-{
- m_currentEditor = editor;
- m_currentSnippet = snippet;
- getArguments();
-}
-
-QString SnippetsWindow::getCurrentIndent(TextEditor::ITextEditor *editor)
-{
- const int startPos = editor->position(TextEditor::ITextEditor::StartOfLine);
- const int endPos = editor->position(TextEditor::ITextEditor::EndOfLine);
- if (startPos < endPos)
- return indentOfString(editor->textAt(startPos, endPos - startPos));
- return QString();
-}
-
-void SnippetsWindow::insertIdents(TextEditor::ITextEditable *editor,
- const QString &indent, int fromPos, int toPos)
-{
- int offset = 0;
- const int startPos = editor->position();
- editor->setCurPos(toPos);
- int currentLinePos = editor->position(TextEditor::ITextEditor::StartOfLine);
- while (currentLinePos > fromPos) {
- editor->setCurPos(currentLinePos);
- editor->insert(indent);
- offset += indent.length();
- editor->setCurPos(currentLinePos-1);
- currentLinePos = editor->position(TextEditor::ITextEditor::StartOfLine);
- }
- editor->setCurPos(startPos + offset);
-}
-
-QString SnippetsWindow::indentOfString(const QString &str, int at)
-{
- QString result;
- int startAt = at;
- if (startAt < 0)
- startAt = str.length() - 1;
-
- // find start position
- while (startAt >= 0 && str.at(startAt) != QChar('\n')
- && str.at(startAt) != QChar('\r')) --startAt;
-
- for (int i = (startAt + 1); i < str.length(); ++i) {
- if (str.at(i) == QChar(' ') || str.at(i) == QChar('\t'))
- result += str.at(i);
- else
- break;
- }
-
- return result;
-}
-
-void SnippetsWindow::setOpenIcon(QTreeWidgetItem *item)
-{
- item->setIcon(0, m_dirOpenIcon);
-}
-
-void SnippetsWindow::setClosedIcon(QTreeWidgetItem *item)
-{
- item->setIcon(0, m_dirIcon);
-}
-
-void SnippetsWindow::updateDescription(QTreeWidgetItem *item)
-{
- const SnippetSpec* spec = qVariantValue<SnippetSpec*>(item->data(0, Qt::UserRole));
- if (spec) {
- m_descLabel->setText(QLatin1String("<b>") + spec->name() + QLatin1String("</b><br>")
- + spec->description());
- } else {
- m_descLabel->setText(QLatin1String("<b>") + item->text(0) + QLatin1String("</b><br>"));
- }
-}
-
-SnippetsTree::SnippetsTree(QWidget *parent)
- : QTreeWidget(parent)
-{
- setColumnCount(1);
- header()->setVisible(false);
- setAlternatingRowColors(true);
- setAcceptDrops(true);
-}
-
-void SnippetsTree::dropEvent(QDropEvent *)
-{
- //writeSnippet(event->mimeData());
-}
-
-void SnippetsTree::dragEnterEvent(QDragEnterEvent *event)
-{
- if (event->mimeData()->hasText())
- event->acceptProposedAction();
-}
-
-void SnippetsTree::dragMoveEvent(QDragMoveEvent *)
-{
-}
diff --git a/src/plugins/snippets/snippetswindow.h b/src/plugins/snippets/snippetswindow.h
deleted file mode 100644
index d974822bdb..0000000000
--- a/src/plugins/snippets/snippetswindow.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef SNIPPETSWINDOW_H
-#define SNIPPETSWINDOW_H
-
-#include <QtCore/QDir>
-#include <QtGui/QTreeWidget>
-#include <QtGui/QSplitter>
-#include <QtGui/QIcon>
-
-QT_BEGIN_NAMESPACE
-class QDir;
-class QLabel;
-QT_END_NAMESPACE
-
-namespace TextEditor {
-class ITextEditable;
-class ITextEditor;
-}
-
-namespace Snippets {
-namespace Internal {
-
-class SnippetSpec;
-class SnippetsTree;
-class InputWidget;
-
-class SnippetsWindow : public QSplitter
-{
- Q_OBJECT
-
-public:
- SnippetsWindow();
- ~SnippetsWindow();
- const QList<SnippetSpec *> &snippets() const;
- void insertSnippet(TextEditor::ITextEditable *editor, SnippetSpec *snippet);
-
-private slots:
- void updateDescription(QTreeWidgetItem *item);
- void activateSnippet(QTreeWidgetItem *item, int column);
- void setOpenIcon(QTreeWidgetItem *item);
- void setClosedIcon(QTreeWidgetItem *item);
-
- void showInputWidget(bool canceled, const QString &value);
-
-private:
- void getArguments();
- void replaceAndInsert();
- QString indentOfString(const QString &str, int at = -1);
- void insertIdents(TextEditor::ITextEditable *editor,
- const QString &indent, int fromPos, int toPos);
- QString getCurrentIndent(TextEditor::ITextEditor *editor);
-
- QList<SnippetSpec *> m_snippets;
- QString createUniqueFileName();
- void writeSnippet(const QMimeData *mData);
- bool initSnippetsDir();
- void initSnippets(const QDir &dir);
-
- QList<int> m_requiredArgs;
- QStringList m_args;
- SnippetSpec *m_currentSnippet;
- TextEditor::ITextEditable *m_currentEditor;
-
- QDir m_snippetsDir;
-
- SnippetsTree *m_snippetsTree;
-
- QLabel *m_descLabel;
-
- static const QIcon m_fileIcon;
- static const QIcon m_dirIcon;
- static const QIcon m_dirOpenIcon;
-};
-
-class SnippetsTree : public QTreeWidget
-{
- Q_OBJECT
-
-public:
- SnippetsTree(QWidget *parent);
-
-protected:
- void dragMoveEvent(QDragMoveEvent * event);
- void dragEnterEvent(QDragEnterEvent *event);
- void dropEvent(QDropEvent *event);
-};
-
-} // namespace Internal
-} // namespace Snippets
-
-#endif // SNIPPETSWINDOW_H
-