forked from mirror/openmw-tes3mp
Implementing ContentSelector class in DataFilesPage
Moved AdjusterWidget / FileWidget to ContentSelectorView
This commit is contained in:
parent
24b167b755
commit
00c78a4aa1
18 changed files with 316 additions and 359 deletions
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "utils/textinputdialog.hpp"
|
#include "utils/textinputdialog.hpp"
|
||||||
#include "components/contentselector/view/contentselector.hpp"
|
#include "components/contentselector/view/contentselector.hpp"
|
||||||
#include "components/contentselector/model/contentmodel.hpp"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -28,176 +27,59 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
, mLauncherSettings(launcherSettings)
|
, mLauncherSettings(launcherSettings)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
unsigned char flags;
|
||||||
/*
|
|
||||||
// QMetaObject::connectSlotsByName(this);
|
|
||||||
|
|
||||||
projectGroupBox->hide();
|
flags = ContentSelectorView::Flag_Content | ContentSelectorView::Flag_Profile;
|
||||||
|
|
||||||
// Create a dialog for the new profile name input
|
ContentSelectorView::ContentSelector::configure(this, flags);
|
||||||
mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
|
|
||||||
|
|
||||||
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buildContentModel();
|
|
||||||
buildGameFileView();
|
|
||||||
buildAddonView();
|
|
||||||
buildProfilesView();
|
|
||||||
|
|
||||||
|
|
||||||
createActions();
|
|
||||||
setupDataFiles();
|
setupDataFiles();
|
||||||
|
|
||||||
|
ContentSelectorView::ContentSelector &cSelector =
|
||||||
|
ContentSelectorView::ContentSelector::instance();
|
||||||
|
|
||||||
updateViews();*/
|
connect (&cSelector, SIGNAL (signalProfileRenamed (QString, QString)),
|
||||||
}
|
this, SLOT (slotProfileRenamed (QString, QString)));
|
||||||
|
|
||||||
void DataFilesPage::buildContentModel()
|
connect (&cSelector, SIGNAL (signalProfileChanged (QString, QString)),
|
||||||
{
|
this, SLOT (slotProfileChanged (QString, QString)));
|
||||||
mContentModel = new ContentSelectorModel::ContentModel();
|
|
||||||
connect(mContentModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::buildGameFileView()
|
connect (&cSelector, SIGNAL (signalProfileDeleted (QString)),
|
||||||
{
|
this, SLOT (slotProfileDeleted (QString)));
|
||||||
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
|
||||||
mGameFileProxyModel->setFilterRegExp(QString::number((int)ContentSelectorModel::ContentType_GameFile));
|
|
||||||
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
|
||||||
mGameFileProxyModel->setSourceModel (mContentModel);
|
|
||||||
|
|
||||||
gameFileView->setPlaceholderText(QString("Select a game file..."));
|
connect (&cSelector, SIGNAL (signalProfileAdded ()),
|
||||||
gameFileView->setModel(mGameFileProxyModel);
|
this, SLOT (slotProfileAdded ()));
|
||||||
|
|
||||||
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentGameFileIndexChanged(int)));
|
|
||||||
|
|
||||||
gameFileView->setCurrentIndex(-1);
|
|
||||||
gameFileView->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::buildAddonView()
|
|
||||||
{
|
|
||||||
mAddonProxyModel = new QSortFilterProxyModel(this);
|
|
||||||
mAddonProxyModel->setFilterRegExp (QString::number((int)ContentSelectorModel::ContentType_Addon));
|
|
||||||
mAddonProxyModel->setFilterRole (Qt::UserRole);
|
|
||||||
mAddonProxyModel->setDynamicSortFilter (true);
|
|
||||||
mAddonProxyModel->setSourceModel (mContentModel);
|
|
||||||
|
|
||||||
addonView->setModel(mAddonProxyModel);
|
|
||||||
|
|
||||||
connect(addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::buildProfilesView()
|
|
||||||
{
|
|
||||||
profilesComboBox->setPlaceholderText(QString("Select a profile..."));
|
|
||||||
connect(profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::updateViews()
|
|
||||||
{
|
|
||||||
// Ensure the columns are hidden because sort() re-enables them
|
|
||||||
addonView->setColumnHidden(1, true);
|
|
||||||
addonView->setColumnHidden(2, true);
|
|
||||||
addonView->setColumnHidden(3, true);
|
|
||||||
addonView->setColumnHidden(4, true);
|
|
||||||
addonView->setColumnHidden(5, true);
|
|
||||||
addonView->setColumnHidden(6, true);
|
|
||||||
addonView->setColumnHidden(7, true);
|
|
||||||
addonView->setColumnHidden(8, true);
|
|
||||||
addonView->resizeColumnsToContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
|
||||||
{
|
|
||||||
// mContentModel->addFiles(path);
|
|
||||||
//mContentModel->sort(3); // Sort by date accessed
|
|
||||||
// ui.gameFileView->setCurrentIndex(-1);
|
|
||||||
// mContentModel->uncheckAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::createActions()
|
|
||||||
{
|
|
||||||
// Add the actions to the toolbuttons
|
|
||||||
newProfileButton->setDefaultAction(newProfileAction);
|
|
||||||
deleteProfileButton->setDefaultAction(deleteProfileAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles()
|
|
||||||
{
|
|
||||||
// Set the encoding to the one found in openmw.cfg or the default
|
|
||||||
//mContentSelector.setEncoding(mGameSettings.value(QString("encoding"), QString("win1252")));
|
|
||||||
|
|
||||||
QStringList paths = mGameSettings.getDataDirs();
|
|
||||||
|
|
||||||
foreach (const QString &path, paths) {
|
|
||||||
//mContentSelector.
|
|
||||||
mContentModel->addFiles(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString dataLocal = mGameSettings.getDataLocal();
|
|
||||||
if (!dataLocal.isEmpty())
|
|
||||||
//mContentSelector.
|
|
||||||
mContentModel->addFiles(dataLocal);
|
|
||||||
|
|
||||||
// Sort by date accessed for now
|
|
||||||
//mContentSelector->sort(3);
|
|
||||||
|
|
||||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
|
||||||
|
|
||||||
if (!profiles.isEmpty())
|
|
||||||
profilesComboBox->addItems(profiles);
|
|
||||||
|
|
||||||
// Add the current profile if empty
|
|
||||||
if (profilesComboBox->findText(profile) == -1 && !profile.isEmpty())
|
|
||||||
profilesComboBox->addItem(profile);
|
|
||||||
|
|
||||||
if (profilesComboBox->findText(QString("Default")) == -1)
|
|
||||||
profilesComboBox->addItem(QString("Default"));
|
|
||||||
|
|
||||||
if (profile.isEmpty() || profile == QLatin1String("Default")) {
|
|
||||||
deleteProfileAction->setEnabled(false);
|
|
||||||
profilesComboBox->setEditEnabled(false);
|
|
||||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(QString("Default")));
|
|
||||||
} else {
|
|
||||||
profilesComboBox->setEditEnabled(true);
|
|
||||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
|
||||||
}
|
|
||||||
|
|
||||||
// We do this here to prevent deletion of profiles when initializing the combobox
|
|
||||||
connect(profilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString)));
|
|
||||||
connect(profilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString)));
|
|
||||||
|
|
||||||
loadSettings();
|
|
||||||
|
|
||||||
gameFileView->setCurrentIndex(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::loadSettings()
|
void DataFilesPage::loadSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
if (profile.isEmpty())
|
if (profile.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// mContentSelector.
|
QStringList files = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly);
|
||||||
mContentModel->uncheckAll();
|
|
||||||
|
|
||||||
QStringList gameFiles = mLauncherSettings.values(QString("Profiles/") + profile + QString("/master"), Qt::MatchExactly);
|
|
||||||
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly);
|
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profile + QString("/plugin"), Qt::MatchExactly);
|
||||||
|
|
||||||
|
foreach (const QString &file, addons)
|
||||||
|
files.append(file);
|
||||||
|
|
||||||
|
//ContentSelectorView::ContentSelector::instance().setCheckStates(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::saveSettings()
|
void DataFilesPage::saveSettings()
|
||||||
{
|
{
|
||||||
if (mContentModel->rowCount() < 1)
|
ContentSelectorModel::ContentFileList items =
|
||||||
return;
|
ContentSelectorView::ContentSelector::instance().selectedFiles();
|
||||||
|
|
||||||
|
if (items.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
if (profile.isEmpty()) {
|
if (profile.isEmpty()) {
|
||||||
profile = profilesComboBox->currentText();
|
profile = ContentSelectorView::ContentSelector::instance().getProfileText();
|
||||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
|
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +89,6 @@ void DataFilesPage::saveSettings()
|
||||||
mGameSettings.remove(QString("master"));
|
mGameSettings.remove(QString("master"));
|
||||||
mGameSettings.remove(QString("plugin"));
|
mGameSettings.remove(QString("plugin"));
|
||||||
|
|
||||||
ContentSelectorModel::ContentFileList items = mContentModel->checkedItems();
|
|
||||||
|
|
||||||
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
||||||
|
|
||||||
if (item->gameFiles().size() == 0) {
|
if (item->gameFiles().size() == 0) {
|
||||||
|
@ -223,109 +103,18 @@ void DataFilesPage::saveSettings()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::updateOkButton(const QString &text)
|
void DataFilesPage::slotProfileDeleted (const QString &item)
|
||||||
{
|
{
|
||||||
// We do this here because we need the profiles combobox text
|
mLauncherSettings.remove(QString("Profiles/") + item + QString("/master"));
|
||||||
if (text.isEmpty()) {
|
mLauncherSettings.remove(QString("Profiles/") + item + QString("/plugin"));
|
||||||
mNewProfileDialog->setOkButtonEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(profilesComboBox->findText(text) == -1)
|
|
||||||
? mNewProfileDialog->setOkButtonEnabled(true)
|
|
||||||
: mNewProfileDialog->setOkButtonEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setProfilesComboBoxIndex(int index)
|
void DataFilesPage::slotProfileChanged(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
profilesComboBox->setCurrentIndex(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAbstractItemModel* DataFilesPage::profilesComboBoxModel()
|
|
||||||
{
|
|
||||||
return profilesComboBox->model();
|
|
||||||
}
|
|
||||||
|
|
||||||
int DataFilesPage::profilesComboBoxIndex()
|
|
||||||
{
|
|
||||||
return profilesComboBox->currentIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::on_newProfileAction_triggered()
|
|
||||||
{
|
|
||||||
if (mNewProfileDialog->exec() == QDialog::Accepted) {
|
|
||||||
QString profile = mNewProfileDialog->lineEdit()->text();
|
|
||||||
profilesComboBox->addItem(profile);
|
|
||||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::on_deleteProfileAction_triggered()
|
|
||||||
{
|
|
||||||
QString profile = profilesComboBox->currentText();
|
|
||||||
|
|
||||||
if (profile.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QMessageBox msgBox(this);
|
|
||||||
msgBox.setWindowTitle(tr("Delete Profile"));
|
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
|
||||||
msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile));
|
|
||||||
|
|
||||||
QAbstractButton *deleteButton =
|
|
||||||
msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
|
||||||
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
if (msgBox.clickedButton() == deleteButton) {
|
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/master"));
|
|
||||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
|
|
||||||
|
|
||||||
// Remove the profile from the combobox
|
|
||||||
profilesComboBox->removeItem(profilesComboBox->findText(profile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
|
||||||
{
|
|
||||||
if (!addonView->selectionModel()->hasSelection()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndexList indexes = addonView->selectionModel()->selectedIndexes();
|
|
||||||
|
|
||||||
foreach (const QModelIndex &index, indexes)
|
|
||||||
{
|
|
||||||
if (!index.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QModelIndex sourceIndex = mAddonProxyModel->mapToSource(index);
|
|
||||||
|
|
||||||
if (!sourceIndex.isValid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
//bool isChecked = ( state == Qt::Checked );
|
|
||||||
|
|
||||||
mContentModel->setData(sourceIndex, state, Qt::CheckStateRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::profileChanged(const QString &previous, const QString ¤t)
|
|
||||||
{
|
|
||||||
// Prevent the deletion of the default profile
|
|
||||||
if (current == QLatin1String("Default")) {
|
|
||||||
deleteProfileAction->setEnabled(false);
|
|
||||||
profilesComboBox->setEditEnabled(false);
|
|
||||||
} else {
|
|
||||||
deleteProfileAction->setEnabled(true);
|
|
||||||
profilesComboBox->setEditEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previous.isEmpty())
|
if (previous.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (profilesComboBox->findText(previous) == -1)
|
if (ContentSelectorView::ContentSelector::instance().getProfileIndex (previous) == -1)
|
||||||
return; // Profile was deleted
|
return; // Profile was deleted
|
||||||
|
|
||||||
// Store the previous profile
|
// Store the previous profile
|
||||||
|
@ -336,7 +125,7 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::profileRenamed(const QString &previous, const QString ¤t)
|
void DataFilesPage::slotProfileRenamed(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
if (previous.isEmpty())
|
if (previous.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -350,56 +139,55 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
|
||||||
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
|
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
|
||||||
|
|
||||||
// Remove the profile from the combobox
|
// Remove the profile from the combobox
|
||||||
profilesComboBox->removeItem(profilesComboBox->findText(previous));
|
ContentSelectorView::ContentSelector::instance().removeProfile (previous);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
////////////////////////////
|
|
||||||
|
|
||||||
QStringList DataFilesPage::checkedItemsPaths()
|
void DataFilesPage::slotProfileAdded()
|
||||||
{
|
{
|
||||||
QStringList itemPaths;
|
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||||
|
|
||||||
foreach( const ContentSelectorModel::EsmFile *file, mContentModel->checkedItems())
|
// connect(mNewDialog->lineEdit(), SIGNAL(textChanged(QString)),
|
||||||
itemPaths << file->path();
|
// this, SLOT(updateOkButton(QString)));
|
||||||
|
|
||||||
return itemPaths;
|
if (newDialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
QString profile = newDialog.lineEdit()->text();
|
||||||
|
|
||||||
|
ContentSelectorView::ContentSelector
|
||||||
|
::instance().addProfile(profile, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotCurrentProfileIndexChanged(int index)
|
void DataFilesPage::setProfilesComboBoxIndex(int index)
|
||||||
{
|
{
|
||||||
emit profileChanged(index);
|
ContentSelectorView::ContentSelector::instance().setProfileIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::slotCurrentGameFileIndexChanged(int index)
|
void DataFilesPage::setupDataFiles()
|
||||||
{
|
{
|
||||||
static int oldIndex = -1;
|
ContentSelectorView::ContentSelector &cSelector =
|
||||||
|
ContentSelectorView::ContentSelector::instance();
|
||||||
|
|
||||||
QAbstractItemModel *const model = gameFileView->model();
|
QStringList paths = mGameSettings.getDataDirs();
|
||||||
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
|
||||||
|
|
||||||
if (proxy)
|
foreach (const QString &path, paths)
|
||||||
proxy->setDynamicSortFilter(false);
|
cSelector.addFiles(path);
|
||||||
|
|
||||||
if (oldIndex > -1)
|
QString dataLocal = mGameSettings.getDataLocal();
|
||||||
model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1);
|
|
||||||
|
|
||||||
oldIndex = index;
|
if (!dataLocal.isEmpty())
|
||||||
|
cSelector.addFiles(dataLocal);
|
||||||
|
|
||||||
model->setData(model->index(index, 0), true, Qt::UserRole + 1);
|
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||||
|
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
proxy->setDynamicSortFilter(true);
|
foreach (const QString &item, profiles)
|
||||||
}
|
cSelector.addProfile (item);
|
||||||
|
|
||||||
void DataFilesPage::slotAddonTableItemClicked(const QModelIndex &index)
|
cSelector.addProfile (profile, true);
|
||||||
{
|
|
||||||
QAbstractItemModel *const model = addonView->model();
|
loadSettings();
|
||||||
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
|
||||||
|
|
||||||
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
|
||||||
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
|
||||||
else
|
|
||||||
model->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "ui_datafilespage.h"
|
|
||||||
#include "components/contentselector/view/contentselector.hpp"
|
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
@ -19,7 +16,7 @@ class LauncherSettings;
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
|
||||||
class DataFilesPage : public QWidget, private Ui::DataFilesPage
|
class DataFilesPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -36,58 +33,33 @@ signals:
|
||||||
void profileChanged(int index);
|
void profileChanged(int index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProfilesComboBoxIndex(int index);
|
//void showContextMenu(const QPoint &point);
|
||||||
|
|
||||||
//void showContextMenu(const QPoint &point);
|
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
|
||||||
void profileRenamed(const QString &previous, const QString ¤t);
|
|
||||||
void updateOkButton(const QString &text);
|
|
||||||
void updateViews();
|
|
||||||
// Action slots
|
|
||||||
void on_newProfileAction_triggered();
|
|
||||||
void on_deleteProfileAction_triggered();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void slotProfileAdded();
|
||||||
|
void slotProfileChanged(const QString &previous, const QString ¤t);
|
||||||
|
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
||||||
|
void slotProfileDeleted(const QString &item);
|
||||||
|
void setProfilesComboBoxIndex(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QMenu *mContextMenu;
|
QMenu *mContextMenu;
|
||||||
//ContentSelectorView::ContentSelector mContentSelector;
|
|
||||||
ContentSelectorModel::ContentModel *mContentModel;
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
GameSettings &mGameSettings;
|
GameSettings &mGameSettings;
|
||||||
LauncherSettings &mLauncherSettings;
|
LauncherSettings &mLauncherSettings;
|
||||||
|
|
||||||
TextInputDialog *mNewProfileDialog;
|
|
||||||
QSortFilterProxyModel *mGameFileProxyModel;
|
|
||||||
QSortFilterProxyModel *mAddonProxyModel;
|
|
||||||
|
|
||||||
void setPluginsCheckstates(Qt::CheckState state);
|
void setPluginsCheckstates(Qt::CheckState state);
|
||||||
|
|
||||||
void createActions();
|
|
||||||
void setupDataFiles();
|
void setupDataFiles();
|
||||||
void setupConfig();
|
void setupConfig();
|
||||||
void readConfig();
|
void readConfig();
|
||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
//////////////////////////////////////
|
|
||||||
void buildContentModel();
|
|
||||||
void buildGameFileView();
|
|
||||||
void buildAddonView();
|
|
||||||
void buildProfilesView();
|
|
||||||
|
|
||||||
//void addFiles(const QString &path);
|
|
||||||
|
|
||||||
QStringList checkedItemsPaths();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void slotCurrentProfileIndexChanged(int index);
|
|
||||||
void slotCurrentGameFileIndexChanged(int index);
|
|
||||||
void slotAddonTableItemClicked(const QModelIndex &index);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -106,10 +106,10 @@ void MainDialog::createPages()
|
||||||
mPlayPage = new PlayPage(this);
|
mPlayPage = new PlayPage(this);
|
||||||
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
||||||
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
|
||||||
|
/// reimplement datafilespage functions to provide access
|
||||||
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
// Set the combobox of the play page to imitate the combobox on the datafilespage
|
||||||
mPlayPage->setProfilesComboBoxModel(mDataFilesPage->profilesComboBoxModel());
|
// mPlayPage->setProfilesComboBoxModel(mDataFilesPage->profilesComboBoxModel());
|
||||||
mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->profilesComboBoxIndex());
|
// mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->profilesComboBoxIndex());
|
||||||
|
|
||||||
// Add the pages to the stacked widget
|
// Add the pages to the stacked widget
|
||||||
pagesWidget->addWidget(mPlayPage);
|
pagesWidget->addWidget(mPlayPage);
|
||||||
|
|
|
@ -43,8 +43,7 @@ opencs_units_noqt (model/tools
|
||||||
|
|
||||||
|
|
||||||
opencs_units (view/doc
|
opencs_units (view/doc
|
||||||
viewmanager view operations operation subview startup filedialog newgame filewidget
|
viewmanager view operations operation subview startup filedialog newgame
|
||||||
adjusterwidget
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ void CS::Editor::openFiles()
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path> files;
|
std::vector<boost::filesystem::path> files;
|
||||||
|
|
||||||
foreach (const QString &path, mFileDialog.selectedFilepaths()) {
|
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
||||||
files.push_back(path.toStdString());
|
files.push_back(path.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ void CS::Editor::createNewFile()
|
||||||
{
|
{
|
||||||
std::vector<boost::filesystem::path> files;
|
std::vector<boost::filesystem::path> files;
|
||||||
|
|
||||||
foreach (const QString &path, mFileDialog.selectedFilepaths()) {
|
foreach (const QString &path, mFileDialog.selectedFilePaths()) {
|
||||||
files.push_back(path.toStdString());
|
files.push_back(path.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,16 @@ QString CSVDoc::FileDialog::filename()
|
||||||
return ContentSelectorView::ContentSelector::instance().filename();
|
return ContentSelectorView::ContentSelector::instance().filename();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CSVDoc::FileDialog::selectedFilepaths()
|
QStringList CSVDoc::FileDialog::selectedFilePaths()
|
||||||
{
|
{
|
||||||
return ContentSelectorView::ContentSelector::instance().selectedFiles();
|
QStringList filePaths;
|
||||||
|
|
||||||
|
foreach (ContentSelectorModel::EsmFile *file, ContentSelectorView::ContentSelector::
|
||||||
|
instance().selectedFiles() )
|
||||||
|
{
|
||||||
|
filePaths.append(file->fileName());
|
||||||
|
}
|
||||||
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::showDialog()
|
void CSVDoc::FileDialog::showDialog()
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace CSVDoc
|
||||||
void addFiles (const QString &path);
|
void addFiles (const QString &path);
|
||||||
|
|
||||||
QString filename();
|
QString filename();
|
||||||
QStringList selectedFilepaths();
|
QStringList selectedFilePaths();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "filewidget.hpp"
|
#include "components/contentselector/view/filewidget.hpp"
|
||||||
#include "adjusterwidget.hpp"
|
#include "components/contentselector/view/adjusterwidget.hpp"
|
||||||
|
|
||||||
CSVDoc::NewGameDialogue::NewGameDialogue()
|
CSVDoc::NewGameDialogue::NewGameDialogue()
|
||||||
{
|
{
|
||||||
|
|
|
@ -84,6 +84,7 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||||
model/naturalsort model/contentmodel
|
model/naturalsort model/contentmodel
|
||||||
view/profilescombobox view/comboboxlineedit
|
view/profilescombobox view/comboboxlineedit
|
||||||
view/lineedit view/contentselector
|
view/lineedit view/contentselector
|
||||||
|
view/filewidget view/adjusterwidget
|
||||||
)
|
)
|
||||||
|
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "contentselector.hpp"
|
#include "contentselector.hpp"
|
||||||
|
|
||||||
#include "../model/contentmodel.hpp"
|
|
||||||
#include "../model/esmfile.hpp"
|
#include "../model/esmfile.hpp"
|
||||||
|
#include "lineedit.hpp"
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "../../../apps/opencs/view/doc/filewidget.hpp"
|
#include "filewidget.hpp"
|
||||||
#include "../../../apps/opencs/view/doc/adjusterwidget.hpp"
|
#include "adjusterwidget.hpp"
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
||||||
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
||||||
|
@ -25,6 +26,7 @@ void ContentSelectorView::ContentSelector::configure(QWidget *subject, unsigned
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector& ContentSelectorView::ContentSelector::instance()
|
ContentSelectorView::ContentSelector& ContentSelectorView::ContentSelector::instance()
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(mInstance);
|
assert(mInstance);
|
||||||
return *mInstance;
|
return *mInstance;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +35,7 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned
|
||||||
QWidget(parent), mFlags (flags),
|
QWidget(parent), mFlags (flags),
|
||||||
mAdjusterWidget (0), mFileWidget (0)
|
mAdjusterWidget (0), mFileWidget (0)
|
||||||
{
|
{
|
||||||
|
|
||||||
ui.setupUi (this);
|
ui.setupUi (this);
|
||||||
|
|
||||||
parent->setLayout(new QGridLayout());
|
parent->setLayout(new QGridLayout());
|
||||||
|
@ -41,15 +44,23 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned
|
||||||
buildContentModel();
|
buildContentModel();
|
||||||
buildGameFileView();
|
buildGameFileView();
|
||||||
buildAddonView();
|
buildAddonView();
|
||||||
buildProfilesView();
|
|
||||||
buildNewAddonView();
|
buildNewAddonView();
|
||||||
buildLoadAddonView();
|
buildLoadAddonView();
|
||||||
|
buildProfilesView();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//mContentModel->sort(3); // Sort by date accessed
|
//mContentModel->sort(3); // Sort by date accessed
|
||||||
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
QString ContentSelectorView::ContentSelector::getNewProfileName()
|
||||||
|
{
|
||||||
|
// Create a dialog for the new profile name input
|
||||||
|
//mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
|
||||||
|
|
||||||
|
//connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
bool ContentSelectorView::ContentSelector::isFlagged(SelectorFlags flag) const
|
bool ContentSelectorView::ContentSelector::isFlagged(SelectorFlags flag) const
|
||||||
{
|
{
|
||||||
|
@ -123,8 +134,17 @@ void ContentSelectorView::ContentSelector::buildProfilesView()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.profilesComboBox->setPlaceholderText(QString("Select a profile..."));
|
// Add the actions to the toolbuttons
|
||||||
connect(ui.profilesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
||||||
|
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
||||||
|
|
||||||
|
ui.profilesComboBox->addItem ("Default");
|
||||||
|
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
||||||
|
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString,QString)), this, SIGNAL(signalProfileRenamed(QString,QString)));
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (profileChanged(QString,QString)), this, SIGNAL(signalProfileChanged(QString,QString)));
|
||||||
|
connect (ui.profilesComboBox, SIGNAL (signalProfileTextChanged(QString)), this, SLOT (slotProfileTextChanged (QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
||||||
|
@ -136,7 +156,6 @@ void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.projectCreateButton->setVisible (false);
|
ui.projectCreateButton->setVisible (false);
|
||||||
// ui.projectButtonBox->setStandardButtons(QDialogButtonBox::Open | QDialogButtonBox::Cancel);
|
|
||||||
ui.projectGroupBox->setTitle ("");
|
ui.projectGroupBox->setTitle ("");
|
||||||
|
|
||||||
connect(ui.projectButtonBox, SIGNAL(accepted()), this, SIGNAL(accepted()));
|
connect(ui.projectButtonBox, SIGNAL(accepted()), this, SIGNAL(accepted()));
|
||||||
|
@ -172,6 +191,17 @@ void ContentSelectorView::ContentSelector::buildNewAddonView()
|
||||||
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &list)
|
||||||
|
{
|
||||||
|
if (list.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mContentModel->uncheckAll();
|
||||||
|
|
||||||
|
foreach (const QString &file, list)
|
||||||
|
mContentModel->setCheckState(file, Qt::Checked);
|
||||||
|
}
|
||||||
|
|
||||||
QString ContentSelectorView::ContentSelector::filename() const
|
QString ContentSelectorView::ContentSelector::filename() const
|
||||||
{
|
{
|
||||||
QString filepath = "";
|
QString filepath = "";
|
||||||
|
@ -182,7 +212,7 @@ QString ContentSelectorView::ContentSelector::filename() const
|
||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ContentSelectorView::ContentSelector::selectedFiles() const
|
QStringList ContentSelectorView::ContentSelector::selectedFilePaths() const
|
||||||
{
|
{
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
|
|
||||||
|
@ -195,6 +225,15 @@ QStringList ContentSelectorView::ContentSelector::selectedFiles() const
|
||||||
return filePaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentSelectorModel::ContentFileList
|
||||||
|
ContentSelectorView::ContentSelector::selectedFiles() const
|
||||||
|
{
|
||||||
|
if (mContentModel)
|
||||||
|
return mContentModel->checkedItems();
|
||||||
|
|
||||||
|
return ContentSelectorModel::ContentFileList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +248,55 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::removeProfile(const QString &item)
|
||||||
|
{
|
||||||
|
int idx = ui.profilesComboBox->findText(item);
|
||||||
|
|
||||||
|
if (idx != -1)
|
||||||
|
ui.profilesComboBox->removeItem(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ContentSelectorView::ContentSelector::getProfileIndex ( const QString &item) const
|
||||||
|
{
|
||||||
|
return ui.profilesComboBox->findText (item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::setProfileIndex(int index)
|
||||||
|
{
|
||||||
|
if (index >=0 && index < ui.profilesComboBox->count())
|
||||||
|
ui.profilesComboBox->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::addProfile (const QString &item, bool setAsCurrent)
|
||||||
|
{
|
||||||
|
if (item.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ui.profilesComboBox->findText(item) == -1)
|
||||||
|
ui.profilesComboBox->addItem(item);
|
||||||
|
|
||||||
|
if (setAsCurrent)
|
||||||
|
ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(item));
|
||||||
|
|
||||||
|
enableProfilesComboBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ContentSelectorView::ContentSelector::getProfileText() const
|
||||||
|
{
|
||||||
|
return ui.profilesComboBox->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::enableProfilesComboBox()
|
||||||
|
{
|
||||||
|
if (!ui.profilesComboBox->isEnabled())
|
||||||
|
ui.profilesComboBox->setEnabled(true);
|
||||||
|
|
||||||
|
if (!ui.deleteProfileAction->isEnabled())
|
||||||
|
ui.deleteProfileAction->setEnabled(true);
|
||||||
|
|
||||||
|
ui.projectButtonBox->button(QDialogButtonBox::Open)->setEnabled (true);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList ContentSelectorView::ContentSelector::checkedItemsPaths()
|
QStringList ContentSelectorView::ContentSelector::checkedItemsPaths()
|
||||||
{
|
{
|
||||||
QStringList itemPaths;
|
QStringList itemPaths;
|
||||||
|
@ -221,6 +309,12 @@ QStringList ContentSelectorView::ContentSelector::checkedItemsPaths()
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
||||||
{
|
{
|
||||||
|
//don't allow deleting "Default" profile
|
||||||
|
bool success = (ui.profilesComboBox->itemText(index) == "Default");
|
||||||
|
|
||||||
|
ui.deleteProfileAction->setEnabled(success);
|
||||||
|
ui.profilesComboBox->setEditEnabled(success);
|
||||||
|
|
||||||
emit signalProfileChanged(index);
|
emit signalProfileChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +341,14 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||||
slotUpdateCreateButton(true);
|
slotUpdateCreateButton(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::slotProfileTextChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QPushButton *opnBtn = ui.projectButtonBox->button(QDialogButtonBox::Open);
|
||||||
|
|
||||||
|
if (opnBtn->isEnabled())
|
||||||
|
opnBtn->setEnabled (false);
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = ui.addonView->model();
|
QAbstractItemModel *const model = ui.addonView->model();
|
||||||
|
@ -257,16 +359,6 @@ void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QMode
|
||||||
model->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
model->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotUpdateOpenButton(const QStringList &items)
|
|
||||||
{
|
|
||||||
QPushButton *openButton = ui.projectButtonBox->button(QDialogButtonBox::Open);
|
|
||||||
|
|
||||||
if (!openButton)
|
|
||||||
return;
|
|
||||||
|
|
||||||
openButton->setEnabled(!items.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
||||||
{
|
{
|
||||||
//enable only if a game file is selected and the adjuster widget is non-empty
|
//enable only if a game file is selected and the adjuster widget is non-empty
|
||||||
|
@ -278,3 +370,44 @@ void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
||||||
|
|
||||||
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::on_newProfileAction_triggered()
|
||||||
|
{
|
||||||
|
emit signalProfileAdded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
||||||
|
{
|
||||||
|
QString profile = ui.profilesComboBox->currentText();
|
||||||
|
|
||||||
|
if (profile.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QMessageBox msgBox(this);
|
||||||
|
msgBox.setWindowTitle(tr("Delete Profile"));
|
||||||
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||||
|
msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile));
|
||||||
|
|
||||||
|
QAbstractButton *deleteButton =
|
||||||
|
msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||||
|
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
if (msgBox.clickedButton() != deleteButton)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Remove the profile from the combobox
|
||||||
|
ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile));
|
||||||
|
|
||||||
|
//signal for removal from model
|
||||||
|
emit signalProfileDeleted (profile);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void ContentSelectorView::ContentSelector::slotUpdateOkButton(const QString &text)
|
||||||
|
{
|
||||||
|
bool success = (ui.profilesComboBox->findText(text) == -1);
|
||||||
|
|
||||||
|
mNewDialog->setOkButtonEnabled(success);
|
||||||
|
}*/
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
#include "ui_datafilespage.h"
|
#include "ui_datafilespage.h"
|
||||||
|
#include "../model/contentmodel.hpp"
|
||||||
namespace ContentSelectorModel { class ContentModel; }
|
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
|
class TextInputDialog;
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,8 @@ namespace ContentSelectorView
|
||||||
CSVDoc::FileWidget *mFileWidget;
|
CSVDoc::FileWidget *mFileWidget;
|
||||||
CSVDoc::AdjusterWidget *mAdjusterWidget;
|
CSVDoc::AdjusterWidget *mAdjusterWidget;
|
||||||
|
|
||||||
|
TextInputDialog *mNewDialog;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ContentSelectorModel::ContentModel *mContentModel;
|
ContentSelectorModel::ContentModel *mContentModel;
|
||||||
|
@ -43,19 +45,28 @@ namespace ContentSelectorView
|
||||||
QSortFilterProxyModel *mAddonProxyModel;
|
QSortFilterProxyModel *mAddonProxyModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit ContentSelector(QWidget *parent = 0, unsigned char flags = Flag_Content);
|
||||||
|
|
||||||
static void configure(QWidget *subject, unsigned char flags = Flag_Content);
|
static void configure(QWidget *subject, unsigned char flags = Flag_Content);
|
||||||
static ContentSelector &instance();
|
static ContentSelector &instance();
|
||||||
static void addFiles(const QString &path);
|
static void addFiles(const QString &path);
|
||||||
|
|
||||||
void setCheckState(QModelIndex index, QSortFilterProxyModel *model);
|
void setCheckStates (const QStringList &list);
|
||||||
QStringList checkedItemsPaths();
|
QStringList checkedItemsPaths();
|
||||||
|
ContentSelectorModel::ContentFileList *CheckedItems();
|
||||||
|
|
||||||
QString filename() const;
|
QString filename() const;
|
||||||
QStringList selectedFiles() const;
|
ContentSelectorModel::ContentFileList selectedFiles() const;
|
||||||
|
QStringList selectedFilePaths() const;
|
||||||
|
|
||||||
|
void addProfile (const QString &item, bool setAsCurrent = false);
|
||||||
|
void removeProfile (const QString &item);
|
||||||
|
int getProfileIndex (const QString &item) const;
|
||||||
|
void setProfileIndex (int index);
|
||||||
|
QString getProfileText() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
explicit ContentSelector(QWidget *parent = 0, unsigned char flags = Flag_Content);
|
|
||||||
Ui::DataFilesPage ui;
|
Ui::DataFilesPage ui;
|
||||||
|
|
||||||
void buildContentModel();
|
void buildContentModel();
|
||||||
|
@ -66,6 +77,8 @@ namespace ContentSelectorView
|
||||||
void buildLoadAddonView();
|
void buildLoadAddonView();
|
||||||
|
|
||||||
bool isFlagged(SelectorFlags flag) const;
|
bool isFlagged(SelectorFlags flag) const;
|
||||||
|
QString getNewProfileName();
|
||||||
|
void enableProfilesComboBox();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void accepted();
|
void accepted();
|
||||||
|
@ -76,14 +89,24 @@ namespace ContentSelectorView
|
||||||
|
|
||||||
void signalCreateButtonClicked();
|
void signalCreateButtonClicked();
|
||||||
|
|
||||||
|
void signalProfileRenamed(QString,QString);
|
||||||
|
void signalProfileChanged(QString,QString);
|
||||||
|
void signalProfileDeleted(QString);
|
||||||
|
void signalProfileAdded();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void slotProfileTextChanged (const QString &text);
|
||||||
void slotCurrentProfileIndexChanged(int index);
|
void slotCurrentProfileIndexChanged(int index);
|
||||||
void slotCurrentGameFileIndexChanged(int index);
|
void slotCurrentGameFileIndexChanged(int index);
|
||||||
void slotAddonTableItemClicked(const QModelIndex &index);
|
void slotAddonTableItemClicked(const QModelIndex &index);
|
||||||
|
|
||||||
void slotUpdateCreateButton (bool);
|
void slotUpdateCreateButton (bool);
|
||||||
void slotUpdateOpenButton(const QStringList &items);
|
// void slotUpdateOpenButton(const QStringList &items);
|
||||||
|
|
||||||
|
// Action slots
|
||||||
|
void on_newProfileAction_triggered();
|
||||||
|
void on_deleteProfileAction_triggered();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ void ContentSelectorView::ProfilesComboBox::setEditEnabled(bool editable)
|
||||||
|
|
||||||
connect(lineEdit(), SIGNAL(textChanged(QString)), this,
|
connect(lineEdit(), SIGNAL(textChanged(QString)), this,
|
||||||
SLOT(slotTextChanged(QString)));
|
SLOT(slotTextChanged(QString)));
|
||||||
|
|
||||||
|
connect (lineEdit(), SIGNAL(textChanged(QString)), this,
|
||||||
|
SIGNAL (signalProfileTextChanged (QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ProfilesComboBox::slotTextChanged(const QString &text)
|
void ContentSelectorView::ProfilesComboBox::slotTextChanged(const QString &text)
|
||||||
|
|
|
@ -17,10 +17,12 @@ namespace ContentSelectorView
|
||||||
void setPlaceholderText (const QString &text);
|
void setPlaceholderText (const QString &text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void signalProfileTextChanged (const QString &item);
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
void profileChanged(const QString &previous, const QString ¤t);
|
||||||
void profileRenamed(const QString &oldName, const QString &newName);
|
void profileRenamed(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void slotEditingFinished();
|
void slotEditingFinished();
|
||||||
void slotIndexChanged(int index);
|
void slotIndexChanged(int index);
|
||||||
void slotTextChanged(const QString &text);
|
void slotTextChanged(const QString &text);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>518</width>
|
<width>518</width>
|
||||||
<height>313</height>
|
<height>424</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -26,6 +26,9 @@
|
||||||
<string>Content</string>
|
<string>Content</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="filterLayout">
|
<layout class="QHBoxLayout" name="filterLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -116,6 +119,18 @@
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="fileWidgetFrame">
|
<widget class="QFrame" name="fileWidgetFrame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -143,18 +158,17 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="projectButtonBox">
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Open</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="projectCreateButton">
|
<widget class="QPushButton" name="projectCreateButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Create</string>
|
<string>Create</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -209,7 +223,7 @@
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>9</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -220,7 +234,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="ContentSelectorView::ProfilesComboBox" name="profilesComboBox">
|
<widget class="ContentSelectorView::ProfilesComboBox" name="profilesComboBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
@ -228,6 +242,11 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Default</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -262,6 +281,13 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="projectButtonBox">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Open</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<action name="newProfileAction">
|
<action name="newProfileAction">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
|
@ -280,6 +306,9 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="deleteProfileAction">
|
<action name="deleteProfileAction">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-delete">
|
<iconset theme="edit-delete">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
|
|
Loading…
Reference in a new issue