summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/commentbox.cpp
Side-by-side diff
Diffstat (limited to 'pwmanager/pwmanager/commentbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/commentbox.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index 5416856..a60440d 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -1,283 +1,283 @@
/***************************************************************************
* *
* copyright (C) 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "commentbox.h"
#include "pwmexception.h"
#include "htmlgen.h"
#include <klocale.h>
#ifndef PWM_EMBEDDED
#include <khtml_part.h>
#include <khtmlview.h>
-#include <qtextedit.h>
+#include <q3textedit.h>
#else
-#include <qmultilineedit.h>
+#include <q3multilineedit.h>
#endif
#ifndef PWM_EMBEDDED
CommentBox::CommentBox(QWidget *_parentWidget)
{
PWM_ASSERT(_parentWidget);
parentWidget = _parentWidget;
textDta = 0;
htmlDta = 0;
mode = mode_notSet;
setFont( prefs->mViewFont );
}
CommentBox::~CommentBox()
{
clearText();
clearHtml();
}
void CommentBox::clear()
{
clearText();
clearHtml();
mode = mode_notSet;
this->hide();
}
void CommentBox::clearText()
{
delete_ifnot_null(textDta);
}
void CommentBox::clearHtml()
{
delete_ifnot_null(htmlDta);
}
void CommentBox::setText(const QString &text)
{
switchTo(mode_text);
PWM_ASSERT(textDta);
textDta->setText( text);
if (!textDta->isVisible())
textDta->show();
}
bool CommentBox::getText(QString *text)
{
if (mode != mode_text)
return false;
PWM_ASSERT(text);
if (!textDta) {
*text = "";
return true;
}
*text = textDta->text();
return true;
}
void CommentBox::setHtml(QString code)
{
switchTo(mode_html);
PWM_ASSERT(htmlDta);
if (!HtmlGen::replaceSSDummy(&code))
printWarn("CommentBox::setHtml(): replaceSSDummy() failed!");
htmlDta->begin();
htmlDta->write(code);
htmlDta->end();
htmlDta->show();
}
void CommentBox::setContent(const QString &dta)
{
// if there's no data, hide the comment-box
if (dta.isEmpty()) {
clear();
return;
}
if (HtmlGen::isHtml(dta)) {
setHtml(dta);
return;
}
// we assume it's plain text
setText(dta);
}
void CommentBox::switchTo(commentBoxMode newMode)
{
if (newMode == mode)
return;
// cleanup old mode
switch (mode) {
case mode_text:
clearText();
break;
case mode_html:
clearHtml();
break;
default:
break;
}
// setup new mode
switch (newMode) {
case mode_text:
- textDta = new QTextEdit(parentWidget);
+ textDta = new Q3TextEdit(parentWidget);
textDta->setTextFormat(Qt::PlainText);
textDta->setReadOnly(true);
textDta->show();
break;
case mode_html:
htmlDta = new KHTMLPart(parentWidget, 0,
parentWidget);
htmlDta->show();
break;
default:
BUG();
break;
}
mode = newMode;
}
void CommentBox::show()
{
switch (mode) {
case mode_text:
PWM_ASSERT(textDta);
textDta->show();
break;
case mode_html:
PWM_ASSERT(htmlDta);
htmlDta->show();
break;
default:
break;
}
}
void CommentBox::hide()
{
switch (mode) {
case mode_text:
PWM_ASSERT(textDta);
textDta->hide();
break;
case mode_html:
PWM_ASSERT(htmlDta);
htmlDta->hide();
break;
default:
break;
}
}
void CommentBox::resize(const QSize &size)
{
switch (mode) {
case mode_text:
PWM_ASSERT(textDta);
textDta->resize(size);
break;
case mode_html:
PWM_ASSERT(htmlDta);
htmlDta->view()->resize(size);
break;
default:
break;
}
}
QSize CommentBox::size()
{
switch (mode) {
case mode_text:
PWM_ASSERT(textDta);
return textDta->size();
break;
case mode_html:
PWM_ASSERT(htmlDta);
return htmlDta->view()->size();
break;
default:
break;
}
return QSize();
}
////////////////////////////////////////////////////////////////////////
#else
CommentBox::CommentBox(QWidget *_parentWidget)
- : QTextBrowser(_parentWidget)
+ : Q3TextBrowser(_parentWidget)
{
//this->setReadOnly(true);
- setFocusPolicy( QWidget::ClickFocus );
+ setFocusPolicy( Qt::ClickFocus );
}
CommentBox::~CommentBox()
{
}
void CommentBox::clear()
{
this->hide();
}
void CommentBox::setText(const QString &text)
{
- QTextBrowser::setText( text);
+ Q3TextBrowser::setText( text);
if (!isVisible())
show();
}
bool CommentBox::getText(QString *text)
{
*text = this->text();
return true;
}
void CommentBox::setContent(const QString &dta)
{
// if there's no data, hide the comment-box
if (dta.isEmpty()) {
clear();
return;
}
// we assume it's plain text
setText(dta);
}
#endif