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.cpp87
1 files changed, 65 insertions, 22 deletions
diff --git a/pwmanager/pwmanager/commentbox.cpp b/pwmanager/pwmanager/commentbox.cpp
index 280b139..4a76f36 100644
--- a/pwmanager/pwmanager/commentbox.cpp
+++ b/pwmanager/pwmanager/commentbox.cpp
@@ -31,14 +31,15 @@
#include <qmultilineedit.h>
#endif
+
+
+#ifndef PWM_EMBEDDED
CommentBox::CommentBox(QWidget *_parentWidget)
{
PWM_ASSERT(_parentWidget);
parentWidget = _parentWidget;
textDta = 0;
-#ifndef PWM_EMBEDDED
htmlDta = 0;
-#endif
mode = mode_notSet;
}
@@ -53,6 +54,7 @@ void CommentBox::clear()
clearText();
clearHtml();
mode = mode_notSet;
+ this->hide();
}
void CommentBox::clearText()
@@ -62,9 +64,7 @@ void CommentBox::clearText()
void CommentBox::clearHtml()
{
-#ifndef PWM_EMBEDDED
delete_ifnot_null(htmlDta);
-#endif
}
void CommentBox::setText(const QString &text)
@@ -91,7 +91,6 @@ bool CommentBox::getText(QString *text)
void CommentBox::setHtml(QString code)
{
-#ifndef PWM_EMBEDDED
switchTo(mode_html);
PWM_ASSERT(htmlDta);
if (!HtmlGen::replaceSSDummy(&code))
@@ -100,7 +99,6 @@ void CommentBox::setHtml(QString code)
htmlDta->write(code);
htmlDta->end();
htmlDta->show();
-#endif
}
void CommentBox::setContent(const QString &dta)
@@ -110,12 +108,10 @@ void CommentBox::setContent(const QString &dta)
clear();
return;
}
-#ifndef PWM_EMBEDDED
if (HtmlGen::isHtml(dta)) {
setHtml(dta);
return;
}
-#endif
// we assume it's plain text
setText(dta);
}
@@ -140,21 +136,15 @@ void CommentBox::switchTo(commentBoxMode newMode)
// setup new mode
switch (newMode) {
case mode_text:
-#ifndef PWM_EMBEDDED
textDta = new QTextEdit(parentWidget);
textDta->setTextFormat(Qt::PlainText);
-#else
- textDta = new QMultiLineEdit(parentWidget);
-#endif
textDta->setReadOnly(true);
textDta->show();
break;
case mode_html:
-#ifndef PWM_EMBEDDED
htmlDta = new KHTMLPart(parentWidget, 0,
parentWidget);
htmlDta->show();
-#endif
break;
default:
BUG();
@@ -172,14 +162,13 @@ void CommentBox::show()
textDta->show();
break;
case mode_html:
-#ifndef PWM_EMBEDDED
PWM_ASSERT(htmlDta);
htmlDta->show();
-#endif
break;
default:
break;
}
+
}
void CommentBox::hide()
@@ -190,10 +179,8 @@ void CommentBox::hide()
textDta->hide();
break;
case mode_html:
-#ifndef PWM_EMBEDDED
PWM_ASSERT(htmlDta);
htmlDta->hide();
-#endif
break;
default:
break;
@@ -208,14 +195,13 @@ void CommentBox::resize(const QSize &size)
textDta->resize(size);
break;
case mode_html:
-#ifndef PWM_EMBEDDED
PWM_ASSERT(htmlDta);
htmlDta->view()->resize(size);
-#endif
break;
default:
break;
}
+
}
QSize CommentBox::size()
@@ -226,13 +212,70 @@ QSize CommentBox::size()
return textDta->size();
break;
case mode_html:
-#ifndef PWM_EMBEDDED
PWM_ASSERT(htmlDta);
return htmlDta->view()->size();
-#endif
break;
default:
break;
}
+
return QSize();
}
+
+
+////////////////////////////////////////////////////////////////////////
+
+#else
+
+CommentBox::CommentBox(QWidget *_parentWidget)
+ : QMultiLineEdit(_parentWidget)
+
+{
+ this->setReadOnly(true);
+}
+
+CommentBox::~CommentBox()
+{
+}
+
+void CommentBox::clear()
+{
+ this->hide();
+}
+
+
+void CommentBox::setText(const QString &text)
+{
+ QMultiLineEdit::setText(i18n("Comment") + ": " + text);
+ if (!this->isVisible())
+ this->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
+
+
+
+
+
+
+
+
+