projects
/
quassel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enable ccache on Travis
[quassel.git]
/
src
/
uisupport
/
multilineedit.cpp
diff --git
a/src/uisupport/multilineedit.cpp
b/src/uisupport/multilineedit.cpp
index
e29ef20
..
37f1f62
100644
(file)
--- a/
src/uisupport/multilineedit.cpp
+++ b/
src/uisupport/multilineedit.cpp
@@
-41,14
+41,13
@@
MultiLineEdit::MultiLineEdit(QWidget *parent)
_scrollBarsEnabled(true),
_pasteProtectionEnabled(true),
_emacsMode(false),
_scrollBarsEnabled(true),
_pasteProtectionEnabled(true),
_emacsMode(false),
+ _completionSpace(0),
_lastDocumentHeight(-1)
{
_lastDocumentHeight(-1)
{
-#if QT_VERSION >= 0x040500
- document()->setDocumentMargin(0); // new in Qt 4.5 and we really don't want it here
-#endif
+ document()->setDocumentMargin(0);
setAcceptRichText(false);
setAcceptRichText(false);
-#ifdef HAVE_KDE
4
+#ifdef HAVE_KDE
enableFindReplace(false);
#endif
enableFindReplace(false);
#endif
@@
-56,6
+55,9
@@
MultiLineEdit::MultiLineEdit(QWidget *parent)
setLineWrapEnabled(false);
reset();
setLineWrapEnabled(false);
reset();
+ // Prevent QTextHtmlImporter::appendNodeText from eating whitespace
+ document()->setDefaultStyleSheet("span { white-space: pre-wrap; }");
+
connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged()));
_mircColorMap["00"] = "#ffffff";
connect(this, SIGNAL(textChanged()), this, SLOT(on_textChanged()));
_mircColorMap["00"] = "#ffffff";
@@
-206,7
+208,7
@@
void MultiLineEdit::setEmacsMode(bool enable)
void MultiLineEdit::setSpellCheckEnabled(bool enable)
{
void MultiLineEdit::setSpellCheckEnabled(bool enable)
{
-#ifdef HAVE_KDE
4
+#ifdef HAVE_KDE
setCheckSpellingEnabled(enable);
#else
Q_UNUSED(enable)
setCheckSpellingEnabled(enable);
#else
Q_UNUSED(enable)
@@
-296,18
+298,7
@@
bool MultiLineEdit::event(QEvent *e)
void MultiLineEdit::keyPressEvent(QKeyEvent *event)
{
void MultiLineEdit::keyPressEvent(QKeyEvent *event)
{
- // Workaround the fact that Qt < 4.5 doesn't know InsertLineSeparator yet
-#if QT_VERSION >= 0x040500
if (event == QKeySequence::InsertLineSeparator) {
if (event == QKeySequence::InsertLineSeparator) {
-#else
-
-# ifdef Q_OS_MAC
- if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::META) {
-# else
- if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && event->modifiers() & Qt::SHIFT) {
-# endif
-#endif
-
if (_mode == SingleLine) {
event->accept();
on_returnPressed();
if (_mode == SingleLine) {
event->accept();
on_returnPressed();
@@
-470,7
+461,7
@@
void MultiLineEdit::keyPressEvent(QKeyEvent *event)
}
}
}
}
-#ifdef HAVE_KDE
4
+#ifdef HAVE_KDE
KTextEdit::keyPressEvent(event);
#else
QTextEdit::keyPressEvent(event);
KTextEdit::keyPressEvent(event);
#else
QTextEdit::keyPressEvent(event);
@@
-564,22
+555,18
@@
QString MultiLineEdit::convertRichtextToMircCodes()
cursor.clearSelection();
}
cursor.clearSelection();
}
- if (color) {
- color = false;
+
+ if (color)
mircText.append('\x03');
mircText.append('\x03');
- }
- if (underline) {
- underline = false;
+
+ if (underline)
mircText.append('\x1f');
mircText.append('\x1f');
- }
- if (italic) {
- italic = false;
+
+ if (italic)
mircText.append('\x1d');
mircText.append('\x1d');
- }
- if (bold) {
- bold = false;
+
+ if (bold)
mircText.append('\x02');
mircText.append('\x02');
- }
return mircText;
}
return mircText;
}
@@
-684,8
+671,12
@@
void MultiLineEdit::on_returnPressed()
}
}
-void MultiLineEdit::on_returnPressed(
const QString &
text)
+void MultiLineEdit::on_returnPressed(
QString
text)
{
{
+ if (_completionSpace && text.endsWith(" ")) {
+ text.chop(1);
+ }
+
if (!text.isEmpty()) {
foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) {
if (line.isEmpty())
if (!text.isEmpty()) {
foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) {
if (line.isEmpty())
@@
-704,6
+695,8
@@
void MultiLineEdit::on_returnPressed(const QString &text)
void MultiLineEdit::on_textChanged()
{
void MultiLineEdit::on_textChanged()
{
+ _completionSpace = qMax(_completionSpace - 1, 0);
+
QString newText = text();
newText.replace("\r\n", "\n");
newText.replace('\r', '\n');
QString newText = text();
newText.replace("\r\n", "\n");
newText.replace('\r', '\n');
@@
-786,3
+779,12
@@
void MultiLineEdit::showHistoryEntry()
setTextCursor(cursor);
updateScrollBars();
}
setTextCursor(cursor);
updateScrollBars();
}
+
+
+void MultiLineEdit::addCompletionSpace()
+{
+ // Inserting the space emits textChanged, which should not disable removal
+ _completionSpace = 2;
+ insertPlainText(" ");
+}
+