Implemented file/adjuster widgets into new addon creation dialog

This commit is contained in:
graffy76 2013-09-22 23:52:53 -05:00
parent 70ac14b8ba
commit 513f0c4b3e
10 changed files with 152 additions and 28 deletions

View file

@ -306,7 +306,7 @@ void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
if (!sourceIndex.isValid())
return;
bool isChecked = ( state == Qt::Checked );
//bool isChecked = ( state == Qt::Checked );
mContentModel->setData(sourceIndex, state, Qt::CheckStateRole);
}
@ -397,7 +397,7 @@ void DataFilesPage::slotCurrentGameFileIndexChanged(int index)
void DataFilesPage::slotAddonTableItemClicked(const QModelIndex &index)
{
QAbstractItemModel *const model = addonView->model();
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
model->setData(index, Qt::Checked, Qt::CheckStateRole);

View file

@ -43,6 +43,10 @@ boost::filesystem::path CSVDoc::AdjusterWidget::getPath() const
return mResultPath;
}
bool CSVDoc::AdjusterWidget::isValid() const
{
return mValid;
}
void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
{
QString message;
@ -88,4 +92,4 @@ void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
pixmap (QSize (16, 16)));
emit stateChanged (mValid);
}
}

View file

@ -25,6 +25,9 @@ namespace CSVDoc
void setLocalData (const boost::filesystem::path& localData);
QString getText() const;
bool isValid() const;
boost::filesystem::path getPath() const;
///< This function must not be called if there is no valid path.
@ -38,4 +41,4 @@ namespace CSVDoc
};
}
#endif
#endif

View file

@ -9,12 +9,22 @@
#include <QSpacerItem>
#include <QPushButton>
#include <QLabel>
#include <QGroupBox>
#include <components/contentselector/model/esmfile.hpp>
#include <components/contentselector/view/lineedit.hpp>
#include "filewidget.hpp"
#include "adjusterwidget.hpp"
#include <QDebug>
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
ContentSelector(parent)
ContentSelector(parent),
mFileWidget (new FileWidget (this)),
mAdjusterWidget (new AdjusterWidget (this)),
mEnable_1(false),
mEnable_2(false)
{
// Hide the profile elements
profileGroupBox->hide();
@ -22,12 +32,20 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
resize(400, 400);
connect(projectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
mFileWidget->setType(true);
mFileWidget->extensionLabelIsVisible(false);
connect(projectCreateButton, SIGNAL(clicked()), this, SIGNAL(createNewFile()));
connect(projectButtonBox, SIGNAL(accepted()), this, SIGNAL(openFiles()));
connect(projectButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
mAdjusterWidget, SLOT (setName (const QString&, bool)));
connect (mAdjusterWidget, SIGNAL (stateChanged (bool)), this, SLOT (slotAdjusterChanged(bool)));
connect (this, SIGNAL (signalGameFileChanged(int)), this, SLOT (slotGameFileSelected(int)));
connect (this, SIGNAL (signalUpdateCreateButton(bool, int)), this, SLOT (slotEnableCreateButton(bool, int)));
}
void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
@ -40,24 +58,30 @@ void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
openButton->setEnabled(!items.isEmpty());
}
void CSVDoc::FileDialog::updateCreateButton(const QString &name)
void CSVDoc::FileDialog::slotEnableCreateButton(bool enable, int widgetNumber)
{
if (!projectCreateButton->isVisible())
return;
projectCreateButton->setEnabled(!name.isEmpty());
if (widgetNumber == 1)
mEnable_1 = enable;
if (widgetNumber == 2)
mEnable_2 = enable;
qDebug() << "update enabled" << mEnable_1 << mEnable_2 << enable;
projectCreateButton->setEnabled(mEnable_1 && mEnable_2);
}
QString CSVDoc::FileDialog::fileName()
{
return projectNameLineEdit->text();
return mFileWidget->getName();
}
void CSVDoc::FileDialog::openFile()
{
setWindowTitle(tr("Open"));
projectNameLineEdit->hide();
mFileWidget->hide();
adjusterWidgetFrame->hide();
projectCreateButton->hide();
projectGroupBox->setTitle(tr(""));
projectButtonBox->button(QDialogButtonBox::Open)->setEnabled(false);
@ -71,6 +95,9 @@ void CSVDoc::FileDialog::newFile()
{
setWindowTitle(tr("New"));
fileWidgetFrame->layout()->addWidget(mFileWidget);
adjusterWidgetFrame->layout()->addWidget(mAdjusterWidget);
projectButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
projectButtonBox->addButton(projectCreateButton, QDialogButtonBox::ActionRole);
@ -78,3 +105,13 @@ void CSVDoc::FileDialog::newFile()
raise();
activateWindow();
}
void CSVDoc::FileDialog::slotAdjusterChanged(bool value)
{
emit signalUpdateCreateButton(mAdjusterWidget->isValid(), 2);
}
void CSVDoc::FileDialog::slotGameFileSelected(int value)
{
emit signalUpdateCreateButton(value > -1, 1);
}

View file

@ -26,9 +26,19 @@ namespace ContentSelectorView
namespace CSVDoc
{
class FileWidget;
class AdjusterWidget;
class FileDialog : public ContentSelectorView::ContentSelector
{
Q_OBJECT
FileWidget *mFileWidget;
AdjusterWidget *mAdjusterWidget;
bool mEnable_1;
bool mEnable_2;
public:
explicit FileDialog(QWidget *parent = 0);
@ -41,12 +51,17 @@ namespace CSVDoc
void openFiles();
void createNewFile();
void signalUpdateCreateButton (bool, int);
void signalUpdateCreateButtonFlags(int);
public slots:
private slots:
//void updateViews();
void updateOpenButton(const QStringList &items);
void updateCreateButton(const QString &name);
void slotEnableCreateButton(bool enable, int widgetNumber);
void slotAdjusterChanged(bool value);
void slotGameFileSelected(int value);
};
}
#endif // FILEDIALOG_HPP

View file

@ -50,4 +50,9 @@ QString CSVDoc::FileWidget::getName() const
void CSVDoc::FileWidget::textChanged (const QString& text)
{
emit nameChanged (getName(), mAddon);
}
}
void CSVDoc::FileWidget::extensionLabelIsVisible(bool visible)
{
mType->setVisible(visible);
}

View file

@ -27,6 +27,8 @@ namespace CSVDoc
QString getName() const;
void extensionLabelIsVisible(bool visible);
private slots:
void textChanged (const QString& text);

View file

@ -40,6 +40,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
gameFileView->setModel(mGameFileProxyModel);
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentGameFileIndexChanged(int)));
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SIGNAL(signalGameFileChanged(int)));
gameFileView->setCurrentIndex(-1);
gameFileView->setCurrentIndex(0);
@ -120,12 +121,14 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
if (proxy)
proxy->setDynamicSortFilter(true);
emit signalGameFileChanged(true);
}
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
{
QAbstractItemModel *const model = addonView->model();
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
model->setData(index, Qt::Checked, Qt::CheckStateRole);

View file

@ -40,6 +40,7 @@ namespace ContentSelectorView
signals:
void profileChanged(int index);
void signalGameFileChanged(int value);
private slots:
void updateViews();

View file

@ -10,6 +10,12 @@
<height>313</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::DefaultContextMenu</enum>
</property>
@ -97,15 +103,44 @@
</item>
<item>
<widget class="QGroupBox" name="projectGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Project</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="ContentSelectorView::LineEdit" name="projectNameLineEdit">
<property name="placeholderText">
<string>Enter project name...</string>
<widget class="QFrame" name="fileWidgetFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
@ -126,9 +161,33 @@
</widget>
</item>
</layout>
<zorder>projectButtonBox</zorder>
<zorder>projectCreateButton</zorder>
<zorder>projectNameLineEdit</zorder>
</widget>
</item>
<item>
<widget class="QFrame" name="adjusterWidgetFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
@ -249,14 +308,9 @@
</widget>
<customwidgets>
<customwidget>
<class>EsxView::ProfilesComboBox</class>
<class>ContentSelectorView::ProfilesComboBox</class>
<extends>QComboBox</extends>
<header location="global">components/contentselector/view/profilescombobox.hpp</header>
</customwidget>
<customwidget>
<class>EsxView::LineEdit</class>
<extends>QLineEdit</extends>
<header location="global">components/contentselector/view/lineedit.hpp</header>
<header>components/contentselector/view/profilescombobox.hpp</header>
</customwidget>
</customwidgets>
<resources/>