#include <QSqlTableModel>
#include <QSqlRecord>
#include "setupeditdialog.h"
-#include "../widgets/stringlistwidget.h"
+#include "../widgets/fileextensionwidget.h"
#include "../widgets/effileobjectcombobox.h"
#include "../db/dbmediatype.h"
#include "../db/dbplatform.h"
{
mediaTypeComBox = new EFFileObjectComboBox(dbMediaType, this);
platformComBox = new EFFileObjectComboBox(dbPlatform, this);
- supportedFileTypesList = new StringListWidget;
+ supportedFileTypesList = new FileExtensionWidget;
+ supportedFileTypesList->setToolTip(tr("Set the supported file types by entering the file extension(s) (no wildcards or dots!)."));
}
void SetupEditDialog::layout()
{
- QLabel *platformLabel = new QLabel(tr("&Platform"));
+ QLabel *platformLabel = new QLabel(tr("&Platform:"));
platformLabel->setBuddy(platformComBox);
- QLabel *mediaTypeLabel = new QLabel(tr("Media&Type"));
+ QLabel *mediaTypeLabel = new QLabel(tr("Media&Type:"));
mediaTypeLabel->setBuddy(mediaTypeComBox);
+ QLabel *fileTypesLabel = new QLabel(tr("Supported file types:"));
QGridLayout *gridLayout = new QGridLayout;
gridLayout->addWidget(platformLabel, 0, 0);
gridLayout->addWidget(platformComBox, 0, 1);
gridLayout->addWidget(mediaTypeLabel, 1, 0);
gridLayout->addWidget(mediaTypeComBox, 1, 1);
- gridLayout->addWidget(supportedFileTypesList, 2, 0, 2, 2);
+ gridLayout->addWidget(fileTypesLabel, 2, 0, 1, 2);
+ gridLayout->addWidget(supportedFileTypesList, 3, 0, 2, 2);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(gridLayout);
mainLayout->addWidget(buttonBox);
class DbSetup;
class DbMediaType;
class DbPlatform;
-class StringListWidget;
+class FileExtensionWidget;
class MediaType;
class Platform;
DbSetup *dbSetup;
DbPlatform *dbPlatform;
DbMediaType *dbMediaType;
- StringListWidget *supportedFileTypesList;
+ FileExtensionWidget *supportedFileTypesList;
void initWidgets();
void layout();
dialogs/emufrontfileobjectdialog.h \
dialogs/browsefilepathdialog.h \
db/dbconfig.h \
- utils/datfileutil.h
+ utils/datfileutil.h \
+ widgets/fileextensionwidget.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
dialogs/emufrontfileobjectdialog.cpp \
dialogs/browsefilepathdialog.cpp \
db/dbconfig.cpp \
- utils/datfileutil.cpp
+ utils/datfileutil.cpp \
+ widgets/fileextensionwidget.cpp
OTHER_FILES +=
CONFIG += mobility
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront 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 EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include "fileextensionwidget.h"
+
+FileExtensionWidget::FileExtensionWidget(QWidget *parent) :
+ StringListWidget(parent)
+{
+}
+
+bool FileExtensionWidget::confirmInput(const QString &input) const
+{
+ QRegExp rx("^[A-Za-z0-9]*$");
+ return rx.exactMatch(input);
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront 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 EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef FILEEXTENSIONWIDGET_H
+#define FILEEXTENSIONWIDGET_H
+
+#include "stringlistwidget.h"
+
+class FileExtensionWidget : public StringListWidget
+{
+ Q_OBJECT
+public:
+ FileExtensionWidget(QWidget *parent = 0);
+
+protected:
+ virtual bool confirmInput(const QString &) const;
+
+signals:
+
+public slots:
+
+};
+
+#endif // FILEEXTENSIONWIDGET_H
void StringListWidget::addClicked()
{
QString input = QInputDialog::getText(this, tr("Add"), tr("Add new item"));
+ input = input.trimmed();
if (input.isEmpty()) return;
+ if (!confirmInput(input)) {
+ QMessageBox::information(this, tr("Input failed!"), ("Input was not accepted."));
+ return;
+ }
stringList->addItem(input);
stringList->sortItems();
emit stringListUpdated();
}
+bool StringListWidget::confirmInput(const QString &) const
+{
+ return true;
+}
+
void StringListWidget::removeClicked()
{
qDebug() << "StringListWidget::removeClicked";
#include <QWidget>
-//class QStringListModel;
class QListWidget;
class QPushButton;
signals:
void stringListUpdated();
+protected:
+ virtual bool confirmInput(const QString &) const;
+
private slots:
void addClicked();
void removeClicked();