[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/plasmate/editors/text
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-11-06 21:12:15
Message-ID: 1257541935.415243.17604.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1045837 by aseigo:

use KTextEditor for extra crunchy goodness, like setting what the save suffix is


 M  +2 -2      CMakeLists.txt  
 M  +23 -26    texteditor.cpp  


--- trunk/playground/base/plasma/plasmate/editors/text/CMakeLists.txt \
#1045836:1045837 @@ -13,7 +13,7 @@
 include_directories(${KDE4_INCLUDES} ../..)
 
 kde4_add_plugin(plasmate_text_editor ${text_editor_SRCS})
-target_link_libraries(plasmate_text_editor ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS})
+target_link_libraries(plasmate_text_editor ${KDE4_PLASMA_LIBS} \
${KDE4_KTEXTEDITOR_LIBS} ${KDE4_KIO_LIBS})  
 set( testtext_SRCS tests/test_text.cpp
                         texteditor.cpp
@@ -24,5 +24,5 @@
 # )
 
 kde4_add_executable( testtext TEST ${testtext_SRCS})
-target_link_libraries( testtext ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} )
+target_link_libraries( testtext ${KDE4_KDEUI_LIBS} ${KDE4_KTEXTEDITOR_LIBS} \
${KDE4_PLASMA_LIBS} )  
--- trunk/playground/base/plasma/plasmate/editors/text/texteditor.cpp \
#1045836:1045837 @@ -6,46 +6,43 @@
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
 */
-#include <kaction.h>
-#include <kactioncollection.h>
-#include <kconfig.h>
-#include <kedittoolbar.h>
-#include <kfiledialog.h>
-#include <kshortcutsdialog.h>
-#include <klibloader.h>
-#include <kmessagebox.h>
-#include <kstandardaction.h>
-#include <kstatusbar.h>
-#include <kurl.h>
-#include <kparts/part.h>
 
+#include "texteditor.h"
+
 #include <QHBoxLayout>
 
-#include "texteditor.h"
+#include <KService>
+#include <KServiceTypeTrader>
+#include <KTextEditor/ConfigInterface>
+#include <KTextEditor/Document>
+#include <KTextEditor/View>
 
 TextEditor::TextEditor(QWidget *parent)
         : QWidget(parent)
 {
-    QHBoxLayout l;
+    QHBoxLayout *l = new QHBoxLayout(this);
 
-    KLibFactory *factory = KLibLoader::self()->factory("katepart");
-    if (factory) {
-        // now that the Part is loaded, we cast it to a Part to get
-        // our hands on it
-        KParts::ReadWritePart *m_part = static_cast<KParts::ReadWritePart \
*>(factory->create(this, "KatePart")); +    KService::List offers = \
KServiceTypeTrader::self()->query("KTextEditor/Document"); +    foreach (const \
KService::Ptr service, offers) { +        KTextEditor::Document *editorPart = \
service->createInstance<KTextEditor::Document>(this); +        if (editorPart) {
+            editorPart->setHighlightingMode("JavaScript/PlasmaDesktop");
 
-        if (m_part) {
-            // tell the KParts::MainWindow that this is indeed
-            // the main widget
-            l.addWidget(m_part->widget());
-//             setCentralWidget(m_part->widget());
+            KTextEditor::View *view = editorPart->createView(this);
+            view->setContextMenu(view->defaultContextMenu());
 
+            KTextEditor::ConfigInterface *config = \
qobject_cast<KTextEditor::ConfigInterface*>(view); +            if (config) {
+                config->setConfigValue("line-numbers", true);
+                config->setConfigValue("dynamic-word-wrap", true);
+                config->setConfigValue("backup-on-save-prefix", '.');
+            }
+
 //             setupGUI(ToolBar | Keys | StatusBar | Save);
 
             // and integrate the part's GUI with the shell's
 //             createGUI(m_part);
+            l->addWidget(view);
         }
     }
-
-    setLayout(&l);
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic