awesome-widgets/sources/awesomewidgets/awnoformatter.cpp

96 lines
2.8 KiB
C++

/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awnoformatter.h"
#include "ui_awnoformatter.h"
#include <KI18n/KLocalizedString>
#include "awdebug.h"
AWNoFormatter::AWNoFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWNoFormatter)
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
if (!filePath.isEmpty())
readConfiguration();
ui->setupUi(this);
translate();
}
AWNoFormatter::~AWNoFormatter()
{
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui;
}
QString AWNoFormatter::convert(const QVariant &_value) const
{
qCDebug(LOG_LIB) << "Convert value" << _value;
return _value.toString();
}
AWNoFormatter *AWNoFormatter::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB) << "File" << _fileName << "with number" << _number;
AWNoFormatter *item
= new AWNoFormatter(static_cast<QWidget *>(parent()), _fileName);
AWAbstractFormatter::copyDefaults(item);
item->setNumber(_number);
return item;
}
int AWNoFormatter::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_typeValue->setText(QString("NoFormat"));
int ret = exec();
if (ret != 1)
return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setApiVersion(AWEFAPI);
setStrType(ui->label_typeValue->text());
writeConfiguration();
return ret;
}
void AWNoFormatter::translate()
{
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_type->setText(i18n("Type"));
}