Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
a8342123
Commit
a8342123
authored
Jan 13, 2009
by
hjk
Browse files
fakevim: refactoring, pimpl FakeVimPlugin
parent
e6f7cb68
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimplugin.cpp
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
)
src/plugins/fakevim/fakevimplugin.h
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
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment