[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:06:53 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=a06ad55
The following commit has been merged in the master branch:
commit a06ad559bf71f8189aa96327c51c78dd9ef9e273
Author: Sven Brauch <svenbrauch at googlemail.com>
Date: Wed Jun 19 12:53:03 2013 +0200
Use KatePart to display debug output in the debugger
To get old features back:
- to save the log, just press Ctrl+S
- to set marks, press Ctrl+B; you can jump between them with Alt+PgUp/Dn
- to search, press Ctrl+F
You might need to focus the editor widget.
When a new message arrives, the view jumps to the current cursor position.
---
tools/debugger/CMakeLists.txt | 7 ++-
tools/debugger/debug-message-view.cpp | 86 ++++++++++++++++++-------------
tools/debugger/debug-message-view.h | 11 ++--
tools/debugger/ktpdebugoutput.xml | 96 +++++++++++++++++++++++++++++++++++
4 files changed, 160 insertions(+), 40 deletions(-)
diff --git a/tools/debugger/CMakeLists.txt b/tools/debugger/CMakeLists.txt
index 08d80d9..43d0dad 100644
--- a/tools/debugger/CMakeLists.txt
+++ b/tools/debugger/CMakeLists.txt
@@ -14,6 +14,11 @@ set(ktp-debugger_SRCS
kde4_add_ui_files(ktp-debugger_SRCS main-window.ui)
kde4_add_executable(ktp-debugger ${ktp-debugger_SRCS})
-target_link_libraries(ktp-debugger ${TELEPATHY_QT4_LIBRARIES} ${KDE4_KDEUI_LIBS})
+target_link_libraries(ktp-debugger
+ ${TELEPATHY_QT4_LIBRARIES}
+ ${KDE4_KDEUI_LIBS}
+ ${KDE4_KTEXTEDITOR_LIBS}
+)
install(TARGETS ktp-debugger DESTINATION ${BIN_INSTALL_DIR})
+install(FILES ktpdebugoutput.xml DESTINATION ${DATA_INSTALL_DIR}/katepart/syntax)
diff --git a/tools/debugger/debug-message-view.cpp b/tools/debugger/debug-message-view.cpp
index 6435405..de451dc 100644
--- a/tools/debugger/debug-message-view.cpp
+++ b/tools/debugger/debug-message-view.cpp
@@ -29,27 +29,51 @@
#include <KAction>
#include <KLocalizedString>
#include <KFindDialog>
+#include <KService>
+#include <KTextEditor/View>
#include <kfind.h>
#include <ctime>
#include <QDate>
#include <QPointer>
+#include <QLayout>
DebugMessageView::DebugMessageView(QWidget *parent)
- : QTextEdit(parent),
- m_ready(false)
+ : QWidget(parent)
+ , m_ready(false)
{
- setReadOnly(true);
- setContextMenuPolicy(Qt::ActionsContextMenu);
- KAction* addMark = new KAction(i18n("Add Mark"), this);
- connect(addMark, SIGNAL(triggered(bool)), SLOT(onAddMark()));
- addAction(KStandardAction::find(this, SLOT(openFindDialog()), this));
- addAction(addMark);
- addAction(KStandardAction::copy(this, SLOT(copy()), this));
- addAction(KStandardAction::selectAll(this, SLOT(selectAll()), this));
- addAction(KStandardAction::clear(this, SLOT(clear()), this));
+ KService::Ptr service = KService::serviceByDesktopPath(QString::fromLatin1("katepart.desktop"));
+
+ if (service) {
+ m_editor = qobject_cast<KTextEditor::Document*>(service->createInstance<KParts::ReadWritePart>(this));
+ Q_ASSERT(m_editor && "Failed to instantiate a KatePart");
+ }
+ else {
+ kFatal() << "Could not find kate part";
+ }
+
+ m_editor->setReadWrite(false);
+ KTextEditor::View* view = m_editor->createView(this);
+ setLayout(new QHBoxLayout());
+ layout()->addWidget(view);
+ m_editor->setHighlightingMode(QString::fromLatin1("KTp"));
+}
+
+void DebugMessageView::showEvent(QShowEvent* event)
+{
+ QWidget::showEvent(event);
+ addDelayedMessages();
}
+void DebugMessageView::addDelayedMessages()
+{
+ m_editor->startEditing();
+ Q_FOREACH(const Tp::DebugMessage &msg, m_tmpCache) {
+ appendMessage(msg);
+ }
+ m_editor->endEditing();
+ m_tmpCache.clear();
+}
DebugMessageView::~DebugMessageView()
{
@@ -138,9 +162,11 @@ void DebugMessageView::onFetchMessagesFinished(Tp::PendingOperation* op)
messages.append(m_tmpCache); //append any messages that were received from onNewDebugMessage()
m_tmpCache.clear();
+ m_editor->startEditing();
Q_FOREACH(const Tp::DebugMessage &msg, messages) {
appendMessage(msg);
}
+ m_editor->endEditing();
//TODO limit m_messages size
@@ -185,30 +211,20 @@ static inline QString formatTimestamp(double timestamp)
void DebugMessageView::appendMessage(const Tp::DebugMessage &msg)
{
- QString message = QString(formatTimestamp(msg.timestamp) %
- QLatin1Literal(" - [") % msg.domain % QLatin1Literal("] ") %
- msg.message);
- append(message);
+ if ( isVisible() ) {
+ QString message = QString(formatTimestamp(msg.timestamp) %
+ QLatin1Literal(" - [") % msg.domain % QLatin1Literal("] ") %
+ msg.message);
+ m_editor->setReadWrite(true);
+ m_editor->insertText(m_editor->documentEnd(), message + QString::fromLatin1("
"));
+ m_editor->setReadWrite(false);
+ }
+ else {
+ m_tmpCache.append(msg);
+ }
}
-void DebugMessageView::onAddMark()
-{
- append(QString(QLatin1String("%1 -----------------------------")).arg(QDate::currentDate().toString()));
-}
-void DebugMessageView::openFindDialog()
-{
- QPointer<KFindDialog> dialog(new KFindDialog(this));
- dialog->setPattern(textCursor().selectedText());
- if(dialog->exec()==QDialog::Accepted) {
- QTextDocument::FindFlags flags=0;
- if(dialog->options() & KFind::FindBackwards) flags |= QTextDocument::FindBackward;
- if(dialog->options() & KFind::WholeWordsOnly) flags |= QTextDocument::FindWholeWords;
- if(dialog->options() & KFind::CaseSensitive) flags |= QTextDocument::FindCaseSensitively;
- bool ret = find(dialog->pattern(), flags);
- if(!ret) {
- Q_EMIT statusMessage(i18n("Could not find '%1'", dialog->pattern()));
- }
- }
- delete dialog;
-}
+
+
+
diff --git a/tools/debugger/debug-message-view.h b/tools/debugger/debug-message-view.h
index 38728cd..d28be2f 100644
--- a/tools/debugger/debug-message-view.h
+++ b/tools/debugger/debug-message-view.h
@@ -21,15 +21,18 @@
#include <QTextEdit>
#include <TelepathyQt/Types>
#include <TelepathyQt/PendingOperation>
+#include <kparts/part.h>
+#include <KTextEditor/Document>
-class DebugMessageView : public QTextEdit
+class DebugMessageView : public QWidget
{
- Q_OBJECT
+Q_OBJECT
public:
explicit DebugMessageView(QWidget *parent = 0);
void setService(const QString & service);
virtual ~DebugMessageView();
+ virtual void showEvent(QShowEvent* );
private Q_SLOTS:
void onServiceRegistered(const QString & service);
@@ -39,8 +42,7 @@ private Q_SLOTS:
void onDebugReceiverMonitoringEnabled(Tp::PendingOperation *op);
void onFetchMessagesFinished(Tp::PendingOperation *op);
void onNewDebugMessage(const Tp::DebugMessage &msg);
- void onAddMark();
- void openFindDialog();
+ void addDelayedMessages();
Q_SIGNALS:
void statusMessage(const QString& msg);
@@ -53,6 +55,7 @@ private:
Tp::DebugMessageList m_tmpCache;
QDBusServiceWatcher *m_serviceWatcher;
bool m_ready;
+ KTextEditor::Document* m_editor;
};
#endif // DEBUG_MESSAGES_MODEL_H
diff --git a/tools/debugger/ktpdebugoutput.xml b/tools/debugger/ktpdebugoutput.xml
new file mode 100644
index 0000000..87ff368
--- /dev/null
+++ b/tools/debugger/ktpdebugoutput.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE language SYSTEM "language.dtd">
+<!--
+Kate syntax highlighing for KTp debug output, used in ktp-debugger.
+Copyright 2013 Sven Brauch <svenbrauch at gmail.com>
+-->
+<language name="KTp" version="1.11" kateversion="2.1" section="Other" extensions="*.ktpdebugoutput" mimetype="text/plain">
+
+ <highlighting>
+
+ <list name="tags">
+ <item>presence</item>
+ <item>show</item>
+ <item>c</item>
+ <item>x</item>
+ <item>photo</item>
+ <item>query</item>
+ <item>feature</item>
+ <item>identity</item>
+ <item>status</item>
+ <item>priority</item>
+ <item>iq</item>
+ <item>vCard</item>
+ <item>FN</item>
+ <item>URL</item>
+ <item>PHOTO</item>
+ <item>TYPE</item>
+ <item>BINVAL</item>
+ <item>message</item>
+ <item>body</item>
+ <item>active</item>
+ <item>error</item>
+ <item>N</item>
+ <item>FAMILY</item>
+ <item>pubsub</item>
+ <item>items</item>
+ </list>
+
+ <contexts>
+ <context attribute="Normal" LineEndContext="#stay" name="Normal">
+ <RegExpr attribute="Timestamp" context="#stay" String="\d+/\d+/\d+ \d+:\d+:\d+\.\d+" column="0"/>
+ <RegExpr attribute="URL" context="#stay" String="([a-zA-Z0-9_]+)?(/[a-zA-Z0-9_]+)+(/)?"/>
+ <RegExpr attribute="URL" context="#stay" String="[a-zA-Z]+://[a-zA-Z_0-9\.@:]+(/[^,\.\s]*)?"/>
+ <RegExpr attribute="URL" context="#stay" String="[a-zA-Z0-9\.]+@[a-zA-Z_0-9\.@:]+(/[^,\)\(\s]*)?"/>
+ <RegExpr attribute="Location" context="#stay" String="[a-zA-Z_0-9]+: .*:\d+:"/>
+ <RegExpr attribute="Location" context="#stay" String="[a-zA-Z_]+[a-zA-Z_0-9]*( \(.*:\d+\))?:"/>
+ <Detect2Chars attribute="Symbol" context="HaveStar" char="*" char1=" " />
+ <HlCHex attribute="Hex" context="#stay"/>
+ <IncludeRules context="FindStrings" />
+ <IncludeRules context="FindStringsDQ" />
+ <IncludeRules context="FindServiceNames" />
+ </context>
+
+ <context attribute="Normal" lineEndContext="#stay" name="HaveStar">
+ <keyword attribute="Tag" String="tags" context="#pop"/>
+ <RegExpr attribute="Normal" String="." context="#pop"/>
+ </context>
+
+ <context attribute="Normal" lineEndContext="#stay" name="FindStrings">
+ <DetectChar attribute="String" context="StringSQ" char="'" />
+ </context>
+ <context attribute="String" lineEndContext="Normal" name="StringSQ">
+ <DetectChar attribute="String" context="#pop" char="'" />
+ </context>
+
+ <context attribute="Normal" lineEndContext="#stay" name="FindStringsDQ">
+ <DetectChar attribute="String" context="StringDQ" char=""" />
+ </context>
+ <context attribute="String" lineEndContext="Normal" name="StringDQ">
+ <DetectChar attribute="String" context="#pop" char=""" />
+ </context>
+
+ <context attribute="Normal" lineEndContext="#stay" name="FindServiceNames">
+ <DetectChar attribute="ServiceName" context="ServiceName" char="[" />
+ </context>
+ <context attribute="ServiceName" lineEndContext="Normal" name="ServiceName">
+ <DetectChar attribute="ServiceName" context="#pop" char="]" />
+ </context>
+ </contexts>
+
+ <itemDatas>
+ <itemData name="Normal" defStyleNum="dsNormal"/>
+ <itemData name="Keyword" defStyleNum="dsKeyword"/>
+ <itemData name="String" defStyleNum="dsString" color="#BC0D0D"/>
+ <itemData name="ServiceName" bold="1"/>
+ <itemData name="Tag" bold="1" defStyleNum="dsDataType"/>
+ <itemData name="Location" defStyleNum="dsFunction" italic="1"/>
+ <itemData name="Timestamp" defStyleNum="dsComment" italic="0"/>
+ <itemData name="URL" defStyleNum="dsOthers" italic="1"/>
+ <itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/>
+ </itemDatas>
+
+ </highlighting>
+
+</language>
+
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list