added FileWidget; fixed OpenCS configuration
parent
ecedb60169
commit
25b7cd33ea
@ -0,0 +1,54 @@
|
||||
|
||||
#include "filewidget.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegExp>
|
||||
|
||||
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);
|
||||
mInput->setValidator (new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$")));
|
||||
|
||||
layout->addWidget (mInput, 1);
|
||||
|
||||
mType = new QLabel (this);
|
||||
|
||||
layout ->addWidget (mType);
|
||||
|
||||
connect (mInput, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
||||
|
||||
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)
|
||||
{
|
||||
emit stateChanged (!text.isEmpty());
|
||||
emit nameChanged (getName());
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#ifndef CSV_DOC_FILEWIDGET_H
|
||||
#define CSV_DOC_FILEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QString;
|
||||
class QLineEdit;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class FileWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
bool mAddon;
|
||||
QLineEdit *mInput;
|
||||
QLabel *mType;
|
||||
|
||||
QString getExtension() const;
|
||||
|
||||
public:
|
||||
|
||||
FileWidget (QWidget *parent = 0);
|
||||
|
||||
void setType (bool addon);
|
||||
|
||||
QString getName() const;
|
||||
|
||||
private slots:
|
||||
|
||||
void textChanged (const QString& text);
|
||||
|
||||
signals:
|
||||
|
||||
void stateChanged (bool valid);
|
||||
|
||||
void nameChanged (const QString& file);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue