File indexing completed on 2024-04-21 16:29:34

0001 /* This file is part of Apper
0002  *
0003  * Copyright (C) 2012 Matthias Klumpp <matthias@tenstral.net>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0018  */
0019 
0020 #include "SimplePage.h"
0021 #include "ui_SimplePage.h"
0022 
0023 #include <QGroupBox>
0024 
0025 #include <KTextBrowser>
0026 #include <KDebug>
0027 
0028 SimplePage::SimplePage(QWidget *parent) :
0029     QWidget(parent),
0030     ui(new Ui::SimplePage)
0031 {
0032     ui->setupUi(this);
0033 }
0034 
0035 SimplePage::~SimplePage()
0036 {
0037     delete ui;
0038 }
0039 
0040 void SimplePage::setTitle(const QString& title)
0041 {
0042     setWindowTitle(title);
0043 }
0044 
0045 
0046 void SimplePage::setDescription(const QString &description)
0047 {
0048     ui->descriptionL->setText(description);
0049 }
0050 
0051 void SimplePage::setDetails(const QString &details, bool isHtml)
0052 {
0053     if (!details.isEmpty()) {
0054         KTextBrowser *browser = new KTextBrowser(this);
0055         browser->setFrameShape(QFrame::NoFrame);
0056         browser->setFrameShadow(QFrame::Plain);
0057         browser->setStyleSheet("QTextEdit {\nbackground-color: transparent;\n};");
0058     if (isHtml)
0059         browser->setHtml(details);
0060     else
0061         browser->setText(details);
0062         ui->descriptionLayout->addWidget(browser);
0063         ui->descriptionLayout->insertSpacing(0, 20);
0064     }
0065 }
0066 
0067 void SimplePage::addWidget(QWidget *widget)
0068 {
0069     if (widget) {
0070         ui->descriptionLayout->insertSpacing(0, 20);
0071         ui->descriptionLayout->addWidget(widget);
0072     }
0073 }
0074 
0075 void SimplePage::reset()
0076 {
0077     setTitle("");
0078     setDescription("");
0079     setDetails("");
0080     QList<KTextBrowser*> detailsB = findChildren<KTextBrowser*>();
0081     foreach (KTextBrowser* browser, detailsB) {
0082     browser->setVisible(false);
0083     delete browser;
0084     }
0085 }