mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-23 09:06:46 +00:00
fixed missing adjuster widget in file dialog open view
This commit is contained in:
parent
ea7a8eb2a4
commit
b51bef0d98
6 changed files with 53 additions and 23 deletions
|
@ -11,7 +11,7 @@
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
||||||
: QWidget (parent), mValid (false)
|
: QWidget (parent), mValid (false), mAction (ContentAction_Undefined)
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout (this);
|
QHBoxLayout *layout = new QHBoxLayout (this);
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
||||||
setLayout (layout);
|
setLayout (layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::AdjusterWidget::setAction (ContentAction action)
|
||||||
|
{
|
||||||
|
mAction = action;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData)
|
void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData)
|
||||||
{
|
{
|
||||||
mLocalData = localData;
|
mLocalData = localData;
|
||||||
|
@ -51,6 +56,12 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
||||||
{
|
{
|
||||||
QString message;
|
QString message;
|
||||||
|
|
||||||
|
if (mAction == ContentAction_Undefined)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("ContentAction_Undefined when AdjusterWidget::setName() called.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
{
|
{
|
||||||
mValid = false;
|
mValid = false;
|
||||||
|
|
|
@ -9,21 +9,32 @@ class QLabel;
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
|
enum ContentAction
|
||||||
|
{
|
||||||
|
ContentAction_New,
|
||||||
|
ContentAction_Edit,
|
||||||
|
ContentAction_Undefined
|
||||||
|
};
|
||||||
|
|
||||||
class AdjusterWidget : public QWidget
|
class AdjusterWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
boost::filesystem::path mLocalData;
|
boost::filesystem::path mLocalData;
|
||||||
QLabel *mMessage;
|
QLabel *mMessage;
|
||||||
QLabel *mIcon;
|
QLabel *mIcon;
|
||||||
bool mValid;
|
bool mValid;
|
||||||
boost::filesystem::path mResultPath;
|
boost::filesystem::path mResultPath;
|
||||||
|
ContentAction mAction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AdjusterWidget (QWidget *parent = 0);
|
AdjusterWidget (QWidget *parent = 0);
|
||||||
|
|
||||||
void setLocalData (const boost::filesystem::path& localData);
|
void setLocalData (const boost::filesystem::path& localData);
|
||||||
|
void setAction (ContentAction action);
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
|
|
|
@ -53,17 +53,19 @@ void CSVDoc::FileDialog::setLocalData (const boost::filesystem::path& localData)
|
||||||
mAdjusterWidget->setLocalData (localData);
|
mAdjusterWidget->setLocalData (localData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::showDialog(DialogType dialogType)
|
void CSVDoc::FileDialog::showDialog (ContentAction action)
|
||||||
{
|
{
|
||||||
mDialogType = dialogType;
|
mAction = action;
|
||||||
|
|
||||||
switch (mDialogType)
|
ui.projectGroupBoxLayout->insertWidget (0, mAdjusterWidget);
|
||||||
|
|
||||||
|
switch (mAction)
|
||||||
{
|
{
|
||||||
case DialogType_New:
|
case ContentAction_New:
|
||||||
buildNewFileView();
|
buildNewFileView();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogType_Open:
|
case ContentAction_Edit:
|
||||||
buildOpenFileView();
|
buildOpenFileView();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -95,7 +97,6 @@ void CSVDoc::FileDialog::buildNewFileView()
|
||||||
mFileWidget->extensionLabelIsVisible(true);
|
mFileWidget->extensionLabelIsVisible(true);
|
||||||
|
|
||||||
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
|
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
|
||||||
ui.projectGroupBoxLayout->insertWidget (1, mAdjusterWidget);
|
|
||||||
|
|
||||||
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
||||||
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
||||||
|
@ -110,12 +111,12 @@ void CSVDoc::FileDialog::buildOpenFileView()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Open"));
|
setWindowTitle(tr("Open"));
|
||||||
ui.projectGroupBox->setTitle (QString(""));
|
ui.projectGroupBox->setTitle (QString(""));
|
||||||
ui.projectGroupBox->layout()->addWidget (mAdjusterWidget);
|
|
||||||
|
|
||||||
mAdjusterWidget->setVisible (false);
|
|
||||||
|
|
||||||
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
|
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
|
||||||
|
|
||||||
|
connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int)));
|
||||||
|
connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int)));
|
||||||
|
|
||||||
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()));
|
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +136,11 @@ void CSVDoc::FileDialog::slotUpdateAcceptButton(const QString &name, bool)
|
||||||
|
|
||||||
if (mDialogType == DialogType_New)
|
if (mDialogType == DialogType_New)
|
||||||
success = success && !(name.isEmpty());
|
success = success && !(name.isEmpty());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ContentSelectorModel::EsmFile *file = mSelector->selectedFiles().back();
|
||||||
|
mAdjusterWidget->setName (file->fileName(), !file->isGameFile());
|
||||||
|
}
|
||||||
|
|
||||||
ui.projectButtonBox->button (QDialogButtonBox::Ok)->setEnabled (success);
|
ui.projectButtonBox->button (QDialogButtonBox::Ok)->setEnabled (success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
#include "adjusterwidget.hpp"
|
||||||
|
|
||||||
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
#ifndef CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||||
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
#define CS_QT_BOOST_FILESYSTEM_PATH_DECLARED
|
||||||
|
@ -24,32 +25,23 @@ namespace ContentSelectorView
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
class FileWidget;
|
class FileWidget;
|
||||||
class AdjusterWidget;
|
|
||||||
|
|
||||||
class FileDialog : public QDialog
|
class FileDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum DialogType
|
|
||||||
{
|
|
||||||
DialogType_New,
|
|
||||||
DialogType_Open
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector *mSelector;
|
ContentSelectorView::ContentSelector *mSelector;
|
||||||
Ui::FileDialog ui;
|
Ui::FileDialog ui;
|
||||||
DialogType mDialogType;
|
ContentAction mAction;
|
||||||
FileWidget *mFileWidget;
|
FileWidget *mFileWidget;
|
||||||
AdjusterWidget *mAdjusterWidget;
|
AdjusterWidget *mAdjusterWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit FileDialog(QWidget *parent = 0);
|
explicit FileDialog(QWidget *parent = 0);
|
||||||
void showDialog (DialogType dialogType);
|
void showDialog (ContentAction action);
|
||||||
|
|
||||||
void addFiles (const QString &path);
|
void addFiles (const QString &path);
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,16 @@ void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QMode
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = ui.addonView->model();
|
QAbstractItemModel *const model = ui.addonView->model();
|
||||||
|
|
||||||
|
Qt::CheckState checkState = Qt::Unchecked;
|
||||||
|
|
||||||
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
||||||
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
checkState = Qt::Checked;
|
||||||
|
|
||||||
|
model->setData(index, checkState, Qt::CheckStateRole);
|
||||||
|
|
||||||
|
if (checkState == Qt::Checked)
|
||||||
|
emit signalAddonFileSelected (index.row());
|
||||||
else
|
else
|
||||||
model->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
emit signalAddonFileUnselected (index.row());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace ContentSelectorView
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalCurrentGamefileIndexChanged (int);
|
void signalCurrentGamefileIndexChanged (int);
|
||||||
|
void signalAddonFileSelected (int);
|
||||||
|
void signalAddonFileUnselected (int);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue