[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kte-collaborative/0.6] common: Finally fix the tab problem by using the replace-tabs key of the Con
From: Sven Brauch <svenbrauch () googlemail ! com>
Date: 2014-08-31 21:16:32
Message-ID: E1XOCUC-0007Tw-1u () scm ! kde ! org
[Download RAW message or body]
Git commit 3e51177c519aa2b1c1d2f246db05f3d304a608b8 by Sven Brauch.
Committed on 31/08/2014 at 21:16.
Pushed by brauch into branch '0.6'.
Finally fix the tab problem by using the replace-tabs key of the ConfigIface
M +0 -8 common/CMakeLists.txt
M +7 -35 common/document.cpp
http://commits.kde.org/kte-collaborative/3e51177c519aa2b1c1d2f246db05f3d304a608b8
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 0efceac..3d81989 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -2,14 +2,6 @@
# The common directory (and library) contais functionality which is common to both \
the KTE plugin and the kioslave. # Since both need the whole connection and browser \
stuff, this is a quite large part of the code base.
-# Check if KTE is new enough to have the BufferInterface
-try_compile( HAVE_BUFFERIFACE ${CMAKE_CURRENT_SOURCE_DIR} \
${CMAKE_CURRENT_SOURCE_DIR}/testbufferinterface.cpp
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${KDE4_INCLUDES}"
- LINK_LIBRARIES ${KDE4_KTEXTEDITOR_LIBS} )
-if(HAVE_BUFFERIFACE)
- add_definitions("-DKTEXTEDITOR_HAS_BUFFER_IFACE")
-endif(HAVE_BUFFERIFACE)
-
include_directories(
${KDE4_INCLUDES}
${LIBQINFINITY_INCLUDES}
diff --git a/common/document.cpp b/common/document.cpp
index 8484b99..5f2881a 100644
--- a/common/document.cpp
+++ b/common/document.cpp
@@ -52,9 +52,7 @@
#include <QFormLayout>
#include <QLabel>
-#ifdef KTEXTEDITOR_HAS_BUFFER_IFACE
-#include <ktexteditor/bufferinterface.h>
-#endif
+#include <KTextEditor/ConfigInterface>
namespace Kobby
{
@@ -65,6 +63,8 @@ Document::Document( KTextEditor::Document* kDocument )
, m_dirty( false )
{
m_kDocument->setParent( 0 );
+ KTextEditor::ConfigInterface* iface = \
qobject_cast<KTextEditor::ConfigInterface*>(m_kDocument); + \
iface->setConfigValue("replace-tabs", false); connect( m_kDocument, \
SIGNAL(textChanged( KTextEditor::Document* )), this, SLOT(textChanged( \
KTextEditor::Document* )) );
connect( m_kDocument, SIGNAL(documentSavedOrUploaded( KTextEditor::Document*,
@@ -215,26 +215,10 @@ void KDocumentTextBuffer::onInsertText( unsigned int offset,
KTextEditor::Cursor startCursor = offsetToCursor_kte( offset );
QString str = codec()->toUnicode( chunk.text() );
ReadWriteTransaction transaction(kDocument());
-#ifdef KTEXTEDITOR_HAS_BUFFER_IFACE
- // The compile-time check just verifies that the interface is present.
- // This does not guarantee that it is supported by the KTE implementation \
used here.
- if ( KTextEditor::BufferInterface* iface = \
qobject_cast<KTextEditor::BufferInterface*>(kDocument()) ) {
- iface->insertTextSilent(startCursor, str);
- }
-#else
- if ( false ) { }
-#endif
- else {
- kDebug() << "Text editor does not support the Buffer interface. Using \
workaround for tabs.";
-#ifdef ENABLE_TAB_HACK
- // If we don't have the buffer iface and the tab hack is enabled, \
replace
- // all tabs by 1 space. That won't break stuff, since it has the same \
length
- str = str.replace("\t", " ");
-#endif
- kDocument()->blockSignals(true);
- kDocument()->insertText( startCursor, str );
- kDocument()->blockSignals(false);
- }
+ kDocument()->blockSignals(true);
+ kDocument()->insertText( startCursor, str );
+ kDocument()->blockSignals(false);
+ Q_ASSERT(!qobject_cast<KTextEditor::ConfigInterface*>(kDocument())->configValue("replace-tabs").toBool());
emit remoteChangedText(KTextEditor::Range(startCursor, \
offsetToCursor_kte(offset+chunk.length())), user, false); checkConsistency();
}
@@ -284,18 +268,6 @@ void KDocumentTextBuffer::onEraseText( unsigned int offset,
void KDocumentTextBuffer::checkConsistency()
{
QString bufferContents = codec()->toUnicode( slice(0, length())->text() );
-#ifndef KTEXTEDITOR_HAS_BUFFER_IFACE
- if ( false ) { }
-#else
- if ( qobject_cast<KTextEditor::BufferInterface*>(kDocument()) ) { }
-#endif
-#ifdef ENABLE_TAB_HACK
- else {
- // In this case, it's allowed that the buffer and the document differ in \
tabs being
- // replaced by spaces.
- bufferContents = bufferContents.replace("\t", " ");
- }
-#endif
QString documentContents = kDocument()->text();
if ( bufferContents != documentContents ) {
KUrl url = kDocument()->url();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic