2 This file is part of Akonadi.
4 Copyright (c) 2006 Tobias Koenig <tokoe@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 #include "connectionpage.h"
26 #include <QVBoxLayout>
27 #include <QFontDatabase>
29 #include "tracernotificationinterface.h"
31 ConnectionPage::ConnectionPage(const QString
&identifier
, QWidget
*parent
)
32 : QWidget(parent
), mIdentifier(identifier
), mShowAllConnections(false)
34 QVBoxLayout
*layout
= new QVBoxLayout(this);
36 mDataView
= new KTextEdit(this);
37 mDataView
->setReadOnly(true);
38 mDataView
->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont
));
40 layout
->addWidget(mDataView
);
42 org::freedesktop::Akonadi::TracerNotification
*iface
= new org::freedesktop::Akonadi::TracerNotification(QString(), QStringLiteral("/tracing/notifications"), QDBusConnection::sessionBus(), this);
44 connect(iface
, &OrgFreedesktopAkonadiTracerNotificationInterface::connectionDataInput
,
45 this, &ConnectionPage::connectionDataInput
);
46 connect(iface
, &OrgFreedesktopAkonadiTracerNotificationInterface::connectionDataOutput
,
47 this, &ConnectionPage::connectionDataOutput
);
50 void ConnectionPage::connectionDataInput(const QString
&identifier
, const QString
&msg
)
52 QString str
= QStringLiteral("<font color=\"green\">%2</font>").arg(identifier
) + QLatin1Char(' ');
53 if (mShowAllConnections
|| identifier
== mIdentifier
) {
54 str
+= QStringLiteral("<font color=\"red\">%1</font>").arg(msg
.toHtmlEscaped());
55 mDataView
->append(str
);
59 void ConnectionPage::connectionDataOutput(const QString
&identifier
, const QString
&msg
)
61 QString str
= QStringLiteral("<font color=\"green\">%2</font>").arg(identifier
) + QLatin1Char(' ');
62 if (mShowAllConnections
|| identifier
== mIdentifier
) {
63 str
+= msg
.toHtmlEscaped();
64 mDataView
->append(str
);
68 void ConnectionPage::showAllConnections(bool show
)
70 mShowAllConnections
= show
;
73 QString
ConnectionPage::toHtml() const
75 return mDataView
->toHtml();
78 void ConnectionPage::clear()