Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
a8342123
Commit
a8342123
authored
16 years ago
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
fakevim: refactoring, pimpl FakeVimPlugin
parent
e6f7cb68
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/fakevim/fakevimplugin.cpp
+88
-21
88 additions, 21 deletions
src/plugins/fakevim/fakevimplugin.cpp
src/plugins/fakevim/fakevimplugin.h
+5
-38
5 additions, 38 deletions
src/plugins/fakevim/fakevimplugin.h
with
93 additions
and
59 deletions
src/plugins/fakevim/fakevimplugin.cpp
+
88
−
21
View file @
a8342123
...
...
@@ -57,13 +57,14 @@
#include
<utils/qtcassert.h>
#include
<QtCore/QDebug>
#include
<QtCore/
qp
lugin
.h
>
#include
<QtCore/
QtP
lugin>
#include
<QtCore/QObject>
#include
<QtCore/QPoint>
#include
<QtCore/QSettings>
#include
<QtGui/QMessageBox>
#include
<QtGui/QPlainTextEdit>
#include
<QtGui/QTextEdit>
#include
<QtGui/QTextBlock>
#include
<QtGui/QTextCursor>
...
...
@@ -87,26 +88,65 @@ const char * const INSTALL_KEY = "Alt+V,Alt+V";
///////////////////////////////////////////////////////////////////////
//
// FakeVimPlugin
// FakeVimPlugin
Private
//
///////////////////////////////////////////////////////////////////////
FakeVimPlugin
::
FakeVimPlugin
()
namespace
FakeVim
{
namespace
Internal
{
class
FakeVimPluginPrivate
:
public
QObject
{
m_core
=
0
;
Q_OBJECT
public:
FakeVimPluginPrivate
(
FakeVimPlugin
*
);
~
FakeVimPluginPrivate
();
friend
class
FakeVimPlugin
;
bool
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
);
void
shutdown
();
private
slots
:
void
installHandler
();
void
installHandler
(
QWidget
*
widget
);
void
removeHandler
(
QWidget
*
widget
);
void
showCommandBuffer
(
const
QString
&
contents
);
void
showExtraInformation
(
const
QString
&
msg
);
void
editorOpened
(
Core
::
IEditor
*
);
void
editorAboutToClose
(
Core
::
IEditor
*
);
void
changeSelection
(
QWidget
*
widget
,
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selections
);
private:
FakeVimPlugin
*
q
;
FakeVimHandler
*
m_handler
;
QAction
*
m_installHandlerAction
;
Core
::
ICore
*
m_core
;
};
}
// namespace Internal
}
// namespace FakeVim
FakeVimPluginPrivate
::
FakeVimPluginPrivate
(
FakeVimPlugin
*
plugin
)
{
q
=
plugin
;
m_handler
=
0
;
m_installHandlerAction
=
0
;
m_core
=
0
;
}
FakeVimPlugin
::~
FakeVimPlugin
()
{}
FakeVimPluginPrivate
::~
FakeVimPluginPrivate
()
{
}
void
FakeVimPlugin
::
shutdown
()
void
FakeVimPlugin
Private
::
shutdown
()
{
delete
m_handler
;
m_handler
=
0
;
}
bool
FakeVimPlugin
::
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
)
bool
FakeVimPlugin
Private
::
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
)
{
Q_UNUSED
(
arguments
);
Q_UNUSED
(
error_message
);
...
...
@@ -147,17 +187,13 @@ bool FakeVimPlugin::initialize(const QStringList &arguments, QString *error_mess
return
true
;
}
void
FakeVimPlugin
::
extensionsInitialized
()
{
}
void
FakeVimPlugin
::
installHandler
()
void
FakeVimPluginPrivate
::
installHandler
()
{
if
(
Core
::
IEditor
*
editor
=
m_core
->
editorManager
()
->
currentEditor
())
installHandler
(
editor
->
widget
());
}
void
FakeVimPlugin
::
installHandler
(
QWidget
*
widget
)
void
FakeVimPlugin
Private
::
installHandler
(
QWidget
*
widget
)
{
connect
(
m_handler
,
SIGNAL
(
extraInformationChanged
(
QString
)),
this
,
SLOT
(
showExtraInformation
(
QString
)));
...
...
@@ -189,7 +225,7 @@ void FakeVimPlugin::installHandler(QWidget *widget)
}
}
void
FakeVimPlugin
::
removeHandler
(
QWidget
*
widget
)
void
FakeVimPlugin
Private
::
removeHandler
(
QWidget
*
widget
)
{
Q_UNUSED
(
widget
);
m_handler
->
removeWidget
(
widget
);
...
...
@@ -197,38 +233,69 @@ void FakeVimPlugin::removeHandler(QWidget *widget)
QLatin1String
(
Constants
::
MINI_BUFFER
));
}
void
FakeVimPlugin
::
editorOpened
(
Core
::
IEditor
*
editor
)
void
FakeVimPlugin
Private
::
editorOpened
(
Core
::
IEditor
*
editor
)
{
Q_UNUSED
(
editor
);
//qDebug() << "OPENING: " << editor << editor->widget();
//installHandler(editor->widget());
}
void
FakeVimPlugin
::
editorAboutToClose
(
Core
::
IEditor
*
editor
)
void
FakeVimPlugin
Private
::
editorAboutToClose
(
Core
::
IEditor
*
editor
)
{
//qDebug() << "CLOSING: " << editor << editor->widget();
removeHandler
(
editor
->
widget
());
}
void
FakeVimPlugin
::
showCommandBuffer
(
const
QString
&
contents
)
void
FakeVimPlugin
Private
::
showCommandBuffer
(
const
QString
&
contents
)
{
Core
::
EditorManager
::
instance
()
->
showEditorInfoBar
(
QLatin1String
(
Constants
::
MINI_BUFFER
),
contents
,
tr
(
"Quit FakeVim"
),
m_handler
,
SLOT
(
quit
()));
}
void
FakeVimPlugin
::
showExtraInformation
(
const
QString
&
text
)
void
FakeVimPlugin
Private
::
showExtraInformation
(
const
QString
&
text
)
{
QMessageBox
::
information
(
0
,
tr
(
"FakeVim Information"
),
text
);
}
void
FakeVimPlugin
::
changeSelection
(
QWidget
*
widget
,
void
FakeVimPlugin
Private
::
changeSelection
(
QWidget
*
widget
,
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selection
)
{
if
(
BaseTextEditor
*
bt
=
qobject_cast
<
BaseTextEditor
*>
(
widget
))
bt
->
setExtraSelections
(
BaseTextEditor
::
FakeVimSelection
,
selection
);
}
//#include "fakevimplugin.moc"
///////////////////////////////////////////////////////////////////////
//
// FakeVimPlugin
//
///////////////////////////////////////////////////////////////////////
FakeVimPlugin
::
FakeVimPlugin
()
:
d
(
new
FakeVimPluginPrivate
(
this
))
{}
FakeVimPlugin
::~
FakeVimPlugin
()
{
delete
d
;
}
bool
FakeVimPlugin
::
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
)
{
return
d
->
initialize
(
arguments
,
error_message
);
}
void
FakeVimPlugin
::
shutdown
()
{
d
->
shutdown
();
}
void
FakeVimPlugin
::
extensionsInitialized
()
{
}
#include
"fakevimplugin.moc"
Q_EXPORT_PLUGIN
(
FakeVimPlugin
)
This diff is collapsed.
Click to expand it.
src/plugins/fakevim/fakevimplugin.h
+
5
−
38
View file @
a8342123
...
...
@@ -36,35 +36,13 @@
#include
<extensionsystem/iplugin.h>
#include
<QtCore/QObject>
#include
<QtCore/QList>
#include
<QtGui/QTextEdit>
QT_BEGIN_NAMESPACE
class
QAction
;
QT_END_NAMESPACE
namespace
Core
{
class
ICore
;
class
IEditor
;
}
// namespace Core
namespace
TextEditor
{
class
ITextEditor
;
}
// namespace TextEditor
namespace
FakeVim
{
namespace
Internal
{
class
FakeVimHandler
;
class
FakeVimPluginPrivate
;
class
FakeVimPlugin
:
public
ExtensionSystem
::
IPlugin
{
Q_OBJECT
...
...
@@ -74,25 +52,14 @@ public:
~
FakeVimPlugin
();
private:
// implementation of ExtensionSystem::IPlugin
bool
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
);
void
shutdown
();
void
extensionsInitialized
();
private
slots
:
void
installHandler
();
void
installHandler
(
QWidget
*
widget
);
void
removeHandler
(
QWidget
*
widget
);
void
showCommandBuffer
(
const
QString
&
contents
);
void
showExtraInformation
(
const
QString
&
msg
);
void
editorOpened
(
Core
::
IEditor
*
);
void
editorAboutToClose
(
Core
::
IEditor
*
);
void
changeSelection
(
QWidget
*
widget
,
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selections
);
private:
FakeVimHandler
*
m_handler
;
QAction
*
m_installHandlerAction
;
Core
::
ICore
*
m_core
;
friend
class
FakeVimPluginPrivate
;
FakeVimPluginPrivate
*
d
;
};
}
// namespace Internal
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment