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
f08c67b4
Commit
f08c67b4
authored
Jan 15, 2009
by
hjk
Browse files
fakevim: remove core dependencies from fakevimhandler.cpp. breaks
writing of partial files for now.
parent
032b2bae
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/fakevim/fakevimhandler.cpp
View file @
f08c67b4
...
...
@@ -40,10 +40,6 @@
// Qt Creator. The idea is to keep this file here in a "clean" state that
// allows easy reuse with any QTextEdit or QPlainTextEdit derived class.
#include
<coreplugin/filemanager.h>
#include
<coreplugin/icore.h>
#include
<texteditor/basetexteditor.h>
//#include <indenter.h>
#include
<QtCore/QDebug>
...
...
@@ -1200,18 +1196,11 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
bool
exists
=
file
.
exists
();
if
(
exists
&&
!
forced
&&
!
noArgs
)
{
showRedMessage
(
tr
(
"File '%1' exists (add ! to override)"
).
arg
(
fileName
));
}
else
if
(
m_currentFile
||
file
.
open
(
QIODevice
::
ReadWrite
))
{
if
(
m_currentFile
)
{
m_core
->
fileManager
()
->
blockFileChange
(
m_currentFile
);
m_currentFile
->
save
(
fileName
);
m_core
->
fileManager
()
->
unblockFileChange
(
m_currentFile
);
}
else
{
QTextCursor
tc
=
selectRange
(
beginLine
,
endLine
);
qDebug
()
<<
"ANCHOR: "
<<
tc
.
position
()
<<
tc
.
anchor
()
<<
tc
.
selection
().
toPlainText
();
{
QTextStream
ts
(
&
file
);
ts
<<
tc
.
selection
().
toPlainText
();
}
file
.
close
();
}
}
else
if
(
file
.
open
(
QIODevice
::
ReadWrite
))
{
QTextCursor
tc
=
selectRange
(
beginLine
,
endLine
);
QString
contents
=
tc
.
selection
().
toPlainText
();
emit
q
->
writeFile
(
fileName
,
contents
);
// check by reading back
file
.
open
(
QIODevice
::
ReadOnly
);
QByteArray
ba
=
file
.
readAll
();
showBlackMessage
(
tr
(
"
\"
%1
\"
%2 %3L, %4C written"
)
...
...
@@ -1741,11 +1730,6 @@ void FakeVimHandler::Private::setWidget(QWidget *ob)
{
m_textedit
=
qobject_cast
<
QTextEdit
*>
(
ob
);
m_plaintextedit
=
qobject_cast
<
QPlainTextEdit
*>
(
ob
);
TextEditor
::
BaseTextEditor
*
editor
=
qobject_cast
<
TextEditor
::
BaseTextEditor
*>
(
ob
);
if
(
editor
)
{
m_currentFile
=
editor
->
file
();
m_currentFileName
=
m_currentFile
->
fileName
();
}
}
///////////////////////////////////////////////////////////////////////
...
...
@@ -1834,3 +1818,8 @@ void FakeVimHandler::quit()
{
d
->
quit
();
}
void
FakeVimHandler
::
setCurrentFileName
(
const
QString
&
fileName
)
{
d
->
m_currentFileName
=
fileName
;
}
src/plugins/fakevim/fakevimhandler.h
View file @
f08c67b4
...
...
@@ -58,6 +58,7 @@ public slots:
// FIXME: good idea?
void
addWidget
(
QWidget
*
widget
);
void
removeWidget
(
QWidget
*
widget
);
void
setCurrentFileName
(
const
QString
&
fileName
);
// This executes an "ex" style command taking context
// information from \p widget;
...
...
@@ -72,6 +73,7 @@ signals:
void
quitRequested
(
QWidget
*
);
void
selectionChanged
(
QWidget
*
widget
,
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selection
);
void
writeFile
(
const
QString
&
fileName
,
const
QString
&
contents
);
private:
bool
eventFilter
(
QObject
*
ob
,
QEvent
*
ev
);
...
...
src/plugins/fakevim/fakevimplugin.cpp
View file @
f08c67b4
...
...
@@ -39,7 +39,9 @@
#include
<coreplugin/actionmanager/actionmanager.h>
#include
<coreplugin/coreconstants.h>
#include
<coreplugin/editormanager/editormanager.h>
#include
<coreplugin/filemanager.h>
#include
<coreplugin/icore.h>
#include
<coreplugin/ifile.h>
#include
<coreplugin/messagemanager.h>
#include
<coreplugin/modemanager.h>
#include
<coreplugin/uniqueidmanager.h>
...
...
@@ -117,12 +119,14 @@ private slots:
void
editorAboutToClose
(
Core
::
IEditor
*
);
void
changeSelection
(
QWidget
*
widget
,
const
QList
<
QTextEdit
::
ExtraSelection
>
&
selections
);
void
writeFile
(
const
QString
&
fileName
,
const
QString
&
contents
);
private:
FakeVimPlugin
*
q
;
FakeVimHandler
*
m_handler
;
QAction
*
m_installHandlerAction
;
Core
::
ICore
*
m_core
;
Core
::
IFile
*
m_currentFile
;
};
}
// namespace Internal
...
...
@@ -134,6 +138,7 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
m_handler
=
0
;
m_installHandlerAction
=
0
;
m_core
=
0
;
m_currentFile
=
0
;
}
FakeVimPluginPrivate
::~
FakeVimPluginPrivate
()
...
...
@@ -206,6 +211,12 @@ void FakeVimPluginPrivate::installHandler(QWidget *widget)
this
,
SLOT
(
changeSelection
(
QWidget
*
,
QList
<
QTextEdit
::
ExtraSelection
>
)));
m_handler
->
addWidget
(
widget
);
TextEditor
::
BaseTextEditor
*
editor
=
qobject_cast
<
TextEditor
::
BaseTextEditor
*>
(
widget
);
if
(
editor
)
{
m_currentFile
=
editor
->
file
();
m_handler
->
setCurrentFileName
(
editor
->
file
()
->
fileName
());
}
BaseTextEditor
*
bt
=
qobject_cast
<
BaseTextEditor
*>
(
widget
);
if
(
bt
)
{
...
...
@@ -225,12 +236,30 @@ void FakeVimPluginPrivate::installHandler(QWidget *widget)
}
}
void
FakeVimPluginPrivate
::
writeFile
(
const
QString
&
fileName
,
const
QString
&
contents
)
{
if
(
m_currentFile
&&
fileName
==
m_currentFile
->
fileName
())
{
// handle that as a special case for nicer interation with
// Creator core
m_core
->
fileManager
()
->
blockFileChange
(
m_currentFile
);
m_currentFile
->
save
(
fileName
);
m_core
->
fileManager
()
->
unblockFileChange
(
m_currentFile
);
}
else
{
QFile
file
(
fileName
);
file
.
open
(
QIODevice
::
ReadWrite
);
{
QTextStream
ts
(
&
file
);
ts
<<
contents
;
}
file
.
close
();
}
}
void
FakeVimPluginPrivate
::
removeHandler
(
QWidget
*
widget
)
{
Q_UNUSED
(
widget
);
m_handler
->
removeWidget
(
widget
);
Core
::
EditorManager
::
instance
()
->
hideEditorInfoBar
(
QLatin1String
(
Constants
::
MINI_BUFFER
));
m_currentFile
=
0
;
}
void
FakeVimPluginPrivate
::
editorOpened
(
Core
::
IEditor
*
editor
)
...
...
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