[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdesdk/cervisia
From: Christian Loose <christian.loose () hamburg ! de>
Date: 2007-11-25 16:48:38
Message-ID: 1196009318.254122.29390.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 741410 by cloose:
port to Qt4:
- Q3TextEdit -> QTextEdit
- use QTextCursor::insertHTML() to append text
M +28 -19 protocolview.cpp
M +6 -8 protocolview.h
--- trunk/KDE/kdesdk/cervisia/protocolview.cpp #741409:741410
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2002 Bernd Gehrmann
* bernd@physik.hu-berlin.de
- * Copyright (c) 2003-2004 Christian Loose <christian.loose@kdemail.net>
+ * Copyright (c) 2003-2007 Christian Loose <christian.loose@kdemail.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,9 +21,10 @@
#include "protocolview.h"
#include "protocolviewadaptor.h"
-#include <qdir.h>
-#include <q3popupmenu.h>
-#include <qtextdocument.h>
+
+#include <QAction>
+#include <QMenu>
+
#include <klocale.h>
#include <kmessagebox.h>
@@ -32,8 +33,8 @@
#include "cvsjobinterface.h"
-ProtocolView::ProtocolView(const QString& appId, QWidget *parent, const char *name)
- : Q3TextEdit(parent, name)
+ProtocolView::ProtocolView(const QString& appId, QWidget *parent)
+ : QTextEdit(parent)
, job(0)
, m_isUpdateJob(false)
{
@@ -84,16 +85,17 @@
}
-Q3PopupMenu* ProtocolView::createPopupMenu(const QPoint &pos)
+void ProtocolView::contextMenuEvent(QContextMenuEvent* event)
{
- Q3PopupMenu* menu = Q3TextEdit::createPopupMenu(pos);
+ QMenu *menu = QTextEdit::createStandardContextMenu();
- int id = menu->insertItem(i18n("Clear"), this, SLOT( clear() ), 0, -1, 0);
+ QAction* clearAction = menu->addAction(i18n("Clear"), this, SLOT( clear() ));
- if( length() == 0 )
- menu->setItemEnabled(id, false);
+ if( toPlainText().length() == 0 )
+ clearAction->setEnabled(false);
- return menu;
+ menu->exec(event->globalPos());
+ delete menu;
}
@@ -151,10 +153,10 @@
{
QString line = buf.left(pos);
if (!line.isEmpty())
- {
+ {
appendLine(line);
- emit receivedLine(line);
- }
+ emit receivedLine(line);
+ }
buf = buf.right(buf.length()-pos-1);
}
}
@@ -170,7 +172,7 @@
// just add it to the text edit.
if( !m_isUpdateJob )
{
- append(escapedLine);
+ appendHtml(escapedLine);
return;
}
@@ -184,18 +186,25 @@
else if (line.startsWith("P ") || line.startsWith("U "))
color = remoteChangeColor;
- append(color.isValid()
+ appendHtml(color.isValid()
? QString("<font color=\"%1\"><b>%2</b></font>").arg(color.name())
.arg(escapedLine)
: escapedLine);
}
+void ProtocolView::appendHtml(const QString& html)
+{
+ QTextCursor cursor(textCursor());
+ cursor.insertHtml(html);
+ cursor.insertBlock();
+ ensureCursorVisible();
+}
+
+
#include "protocolview.moc"
// Local Variables:
// c-basic-offset: 4
// End:
-
-
--- trunk/KDE/kdesdk/cervisia/protocolview.h #741409:741410
@@ -1,7 +1,7 @@
/*
* Copyright (C) 1999-2002 Bernd Gehrmann
* bernd@mail.berlios.de
- * Copyright (c) 2003-2004 Christian Loose <christian.loose@kdemail.net>
+ * Copyright (c) 2003-2007 Christian Loose <christian.loose@kdemail.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,28 +22,25 @@
#ifndef PROTOCOLVIEW_H
#define PROTOCOLVIEW_H
-#include <q3textedit.h>
-//Added by qt3to4:
-#include <Q3PopupMenu>
+#include <QTextEdit>
#include <kdemacros.h>
class QPoint;
-class Q3PopupMenu;
class OrgKdeCervisiaCvsserviceCvsjobInterface;
-class ProtocolView : public Q3TextEdit
+class ProtocolView : public QTextEdit
{
Q_OBJECT
public:
- explicit ProtocolView(const QString& appId, QWidget *parent=0, const char *name=0);
+ explicit ProtocolView(const QString& appId, QWidget *parent=0);
~ProtocolView();
bool startJob(bool isUpdateJob = false);
protected:
- virtual Q3PopupMenu* createPopupMenu(const QPoint &pos);
+ void contextMenuEvent(QContextMenuEvent* event);
public Q_SLOTS:
void slotReceivedOutput(QString buffer);
@@ -60,6 +57,7 @@
private:
void processOutput();
void appendLine(const QString &line);
+ void appendHtml(const QString& html);
QString buf;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic