2013-09-08 12:31:20 +00:00
|
|
|
#include "filewidget.hpp"
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
|
|
QString CSVDoc::FileWidget::getExtension() const
|
|
|
|
{
|
|
|
|
return mAddon ? ".omwaddon" : ".omwgame";
|
|
|
|
}
|
|
|
|
|
|
|
|
CSVDoc::FileWidget::FileWidget(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, mAddon(false)
|
|
|
|
{
|
|
|
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
|
|
|
|
|
|
|
mInput = new QLineEdit(this);
|
|
|
|
|
|
|
|
layout->addWidget(mInput, 1);
|
|
|
|
|
|
|
|
mType = new QLabel(this);
|
|
|
|
|
|
|
|
layout->addWidget(mType);
|
|
|
|
|
2022-08-23 02:28:58 +00:00
|
|
|
connect(mInput, &QLineEdit::textChanged, this, &FileWidget::textChanged);
|
2013-09-08 12:31:20 +00:00
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVDoc::FileWidget::setType(bool addon)
|
|
|
|
{
|
|
|
|
mAddon = addon;
|
|
|
|
|
|
|
|
mType->setText(getExtension());
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CSVDoc::FileWidget::getName() const
|
|
|
|
{
|
|
|
|
QString text = mInput->text();
|
|
|
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
return text + getExtension();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVDoc::FileWidget::textChanged(const QString& text)
|
|
|
|
{
|
2013-09-10 14:45:01 +00:00
|
|
|
emit nameChanged(getName(), mAddon);
|
2013-09-23 04:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSVDoc::FileWidget::extensionLabelIsVisible(bool visible)
|
|
|
|
{
|
|
|
|
mType->setVisible(visible);
|
|
|
|
}
|
2015-08-06 10:52:10 +00:00
|
|
|
|
|
|
|
void CSVDoc::FileWidget::setName(const std::string& text)
|
|
|
|
{
|
|
|
|
QString text2 = QString::fromUtf8(text.c_str());
|
|
|
|
|
|
|
|
mInput->setText(text2);
|
|
|
|
textChanged(text2);
|
|
|
|
}
|