Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
fabf76d2
Commit
fabf76d2
authored
Dec 08, 2010
by
Leandro Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Snippets: Remove the snippets manager
Let the collection itself be the singleton.
parent
e699f5d5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
19 additions
and
135 deletions
+19
-135
src/plugins/texteditor/snippets/snippetcollector.cpp
src/plugins/texteditor/snippets/snippetcollector.cpp
+1
-3
src/plugins/texteditor/snippets/snippetscollection.cpp
src/plugins/texteditor/snippets/snippetscollection.cpp
+6
-0
src/plugins/texteditor/snippets/snippetscollection.h
src/plugins/texteditor/snippets/snippetscollection.h
+8
-3
src/plugins/texteditor/snippets/snippetsmanager.cpp
src/plugins/texteditor/snippets/snippetsmanager.cpp
+0
-54
src/plugins/texteditor/snippets/snippetsmanager.h
src/plugins/texteditor/snippets/snippetsmanager.h
+0
-63
src/plugins/texteditor/snippets/snippetssettingspage.cpp
src/plugins/texteditor/snippets/snippetssettingspage.cpp
+4
-10
src/plugins/texteditor/texteditor.pro
src/plugins/texteditor/texteditor.pro
+0
-2
No files found.
src/plugins/texteditor/snippets/snippetcollector.cpp
View file @
fabf76d2
...
...
@@ -28,7 +28,6 @@
**************************************************************************/
#include "snippetcollector.h"
#include "snippetsmanager.h"
#include "snippetscollection.h"
#include <texteditor/texteditorconstants.h>
...
...
@@ -44,8 +43,7 @@ void appendSnippets(ICompletionCollector *collector,
const
QIcon
&
icon
,
int
order
)
{
QSharedPointer
<
SnippetsCollection
>
collection
=
SnippetsManager
::
instance
()
->
snippetsCollection
();
SnippetsCollection
*
collection
=
SnippetsCollection
::
instance
();
const
int
size
=
collection
->
totalActiveSnippets
(
groupId
);
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
const
Snippet
&
snippet
=
collection
->
snippet
(
i
,
groupId
);
...
...
src/plugins/texteditor/snippets/snippetscollection.cpp
View file @
fabf76d2
...
...
@@ -98,6 +98,12 @@ int SnippetsCollection::Hint::index() const
return
m_index
;
}
SnippetsCollection
*
SnippetsCollection
::
instance
()
{
static
SnippetsCollection
collection
;
return
&
collection
;
}
// SnippetsCollection
SnippetsCollection
::
SnippetsCollection
()
:
m_userSnippetsPath
(
Core
::
ICore
::
instance
()
->
userResourcePath
()
+
QLatin1String
(
"/snippets/"
)),
...
...
src/plugins/texteditor/snippets/snippetscollection.h
View file @
fabf76d2
...
...
@@ -54,8 +54,9 @@ class SnippetsCollection : public QObject
{
Q_OBJECT
public:
SnippetsCollection
();
~
SnippetsCollection
();
virtual
~
SnippetsCollection
();
static
SnippetsCollection
*
instance
();
class
Hint
{
...
...
@@ -100,6 +101,9 @@ private slots:
void
identifyGroups
();
private:
SnippetsCollection
();
Q_DISABLE_COPY
(
SnippetsCollection
)
int
groupIndex
(
const
QString
&
groupId
)
const
;
bool
isGroupKnown
(
const
QString
&
groupId
)
const
;
...
...
@@ -123,7 +127,8 @@ private:
static
const
QLatin1String
kModified
;
// Built-in snippets are specified in XMLs distributed in a system's folder. Snippets
// created or modified/removed (if they are built-ins) by the user are stored in another
// created or modified/removed (if they are built-ins) by the user are stored in user's
// folder.
QString
m_userSnippetsPath
;
QString
m_userSnippetsFile
;
QStringList
m_builtInSnippetsFiles
;
...
...
src/plugins/texteditor/snippets/snippetsmanager.cpp
deleted
100644 → 0
View file @
e699f5d5
/**************************************************************************
**
** 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 "snippetsmanager.h"
#include "snippetscollection.h"
using
namespace
TextEditor
;
using
namespace
Internal
;
SnippetsManager
::
SnippetsManager
()
:
m_collection
(
new
SnippetsCollection
)
{
m_collection
->
reload
();
}
SnippetsManager
::~
SnippetsManager
()
{}
SnippetsManager
*
SnippetsManager
::
instance
()
{
static
SnippetsManager
manager
;
return
&
manager
;
}
QSharedPointer
<
SnippetsCollection
>
SnippetsManager
::
snippetsCollection
()
const
{
return
m_collection
;
}
src/plugins/texteditor/snippets/snippetsmanager.h
deleted
100644 → 0
View file @
e699f5d5
/**************************************************************************
**
** 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 SNIPPETSMANAGER_H
#define SNIPPETSMANAGER_H
#include <QtCore/QSharedPointer>
namespace
TextEditor
{
class
ISnippetProvider
;
namespace
Internal
{
class
SnippetsCollection
;
class
SnippetsManager
{
private:
SnippetsManager
();
Q_DISABLE_COPY
(
SnippetsManager
)
public:
~
SnippetsManager
();
static
SnippetsManager
*
instance
();
QSharedPointer
<
SnippetsCollection
>
snippetsCollection
()
const
;
private:
QSharedPointer
<
SnippetsCollection
>
m_collection
;
};
}
// Internal
}
// TextEditor
#endif // SNIPPETSMANAGER_H
src/plugins/texteditor/snippets/snippetssettingspage.cpp
View file @
fabf76d2
...
...
@@ -28,7 +28,6 @@
**************************************************************************/
#include "snippetssettingspage.h"
#include "snippetsmanager.h"
#include "snippeteditor.h"
#include "isnippetprovider.h"
#include "snippet.h"
...
...
@@ -40,7 +39,6 @@
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QSharedPointer>
#include <QtCore/QModelIndex>
#include <QtCore/QAbstractTableModel>
#include <QtCore/QList>
...
...
@@ -85,26 +83,22 @@ private:
void
replaceSnippet
(
const
Snippet
&
snippet
,
const
QModelIndex
&
modelIndex
);
static
bool
isValidTrigger
(
const
QString
&
s
);
QSharedPointer
<
SnippetsCollection
>
m_collection
;
SnippetsCollection
*
m_collection
;
QString
m_activeGroupId
;
};
SnippetsTableModel
::
SnippetsTableModel
(
QObject
*
parent
)
:
QAbstractTableModel
(
parent
),
m_collection
(
Snippets
Manager
::
instance
()
->
snippets
Collection
())
m_collection
(
SnippetsCollection
::
instance
())
{}
int
SnippetsTableModel
::
rowCount
(
const
QModelIndex
&
)
const
{
if
(
m_collection
.
isNull
())
return
0
;
return
m_collection
->
totalActiveSnippets
(
m_activeGroupId
);
}
int
SnippetsTableModel
::
columnCount
(
const
QModelIndex
&
)
const
{
if
(
m_collection
.
isNull
())
return
0
;
return
2
;
}
...
...
@@ -390,7 +384,7 @@ void SnippetsSettingsPagePrivate::apply()
writeSettings
();
if
(
m_snippetsCollectionChanged
)
{
Snippets
Manager
::
instance
()
->
snippets
Collection
()
->
synchronize
();
SnippetsCollection
::
instance
()
->
synchronize
();
m_snippetsCollectionChanged
=
false
;
}
}
...
...
@@ -398,7 +392,7 @@ void SnippetsSettingsPagePrivate::apply()
void
SnippetsSettingsPagePrivate
::
finish
()
{
if
(
m_snippetsCollectionChanged
)
{
Snippets
Manager
::
instance
()
->
snippets
Collection
()
->
reload
();
SnippetsCollection
::
instance
()
->
reload
();
m_snippetsCollectionChanged
=
false
;
}
}
...
...
src/plugins/texteditor/texteditor.pro
View file @
fabf76d2
...
...
@@ -75,7 +75,6 @@ SOURCES += texteditorplugin.cpp \
autocompleter
.
cpp
\
snippets
/
snippetssettingspage
.
cpp
\
snippets
/
snippet
.
cpp
\
snippets
/
snippetsmanager
.
cpp
\
snippets
/
snippeteditor
.
cpp
\
snippets
/
snippetscollection
.
cpp
\
snippets
/
snippetssettings
.
cpp
\
...
...
@@ -158,7 +157,6 @@ HEADERS += texteditorplugin.h \
autocompleter
.
h
\
snippets
/
snippetssettingspage
.
h
\
snippets
/
snippet
.
h
\
snippets
/
snippetsmanager
.
h
\
snippets
/
snippeteditor
.
h
\
snippets
/
snippetscollection
.
h
\
snippets
/
reuse
.
h
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment