|
|
|
@ -5,7 +5,6 @@
|
|
|
|
|
|
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
@ -14,6 +13,9 @@
|
|
|
|
|
|
|
|
|
|
#include "filewidget.hpp"
|
|
|
|
|
#include "adjusterwidget.hpp"
|
|
|
|
|
#include "textinputdialog.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
|
|
|
|
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
|
|
|
@ -33,7 +35,8 @@ ContentSelectorView::ContentSelector& ContentSelectorView::ContentSelector::inst
|
|
|
|
|
|
|
|
|
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned char flags) :
|
|
|
|
|
QWidget(parent), mFlags (flags),
|
|
|
|
|
mAdjusterWidget (0), mFileWidget (0)
|
|
|
|
|
mAdjusterWidget (0), mFileWidget (0),
|
|
|
|
|
mIgnoreProfileSignal (false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
ui.setupUi (this);
|
|
|
|
@ -53,14 +56,6 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
@ -94,6 +89,8 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.gameFileView->setVisible (true);
|
|
|
|
|
|
|
|
|
|
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
|
|
|
|
mGameFileProxyModel->setFilterRegExp(QString::number((int)ContentSelectorModel::ContentType_GameFile));
|
|
|
|
|
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
|
|
|
@ -102,7 +99,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
|
|
|
|
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
|
|
|
|
ui.gameFileView->setModel(mGameFileProxyModel);
|
|
|
|
|
|
|
|
|
|
connect(ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
|
|
|
|
connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
|
|
|
|
|
|
|
|
|
ui.gameFileView->setCurrentIndex(-1);
|
|
|
|
|
}
|
|
|
|
@ -115,6 +112,8 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.addonView->setVisible (true);
|
|
|
|
|
|
|
|
|
|
mAddonProxyModel = new QSortFilterProxyModel(this);
|
|
|
|
|
mAddonProxyModel->setFilterRegExp (QString::number((int)ContentSelectorModel::ContentType_Addon));
|
|
|
|
|
mAddonProxyModel->setFilterRole (Qt::UserRole);
|
|
|
|
@ -129,31 +128,48 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
|
|
|
|
void ContentSelectorView::ContentSelector::buildProfilesView()
|
|
|
|
|
{
|
|
|
|
|
if (!isFlagged (Flag_Profile))
|
|
|
|
|
{
|
|
|
|
|
ui.profileGroupBox->setVisible(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.profileGroupBox->setVisible (true);
|
|
|
|
|
|
|
|
|
|
// Add the actions to the toolbuttons
|
|
|
|
|
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
|
|
|
|
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
|
|
|
|
|
|
|
|
|
//enable ui elements
|
|
|
|
|
ui.profilesComboBox->addItem ("Default");
|
|
|
|
|
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
|
|
|
|
|
|
|
|
|
if (!ui.profilesComboBox->isEnabled())
|
|
|
|
|
ui.profilesComboBox->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
if (!ui.deleteProfileAction->isEnabled())
|
|
|
|
|
ui.deleteProfileAction->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
//establish connections
|
|
|
|
|
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 (signalProfileChanged(QString,QString)), this, SIGNAL(signalProfileChangedByUser(QString,QString)));
|
|
|
|
|
connect (ui.profilesComboBox, SIGNAL (signalProfileTextChanged(QString)), this, SLOT (slotProfileTextChanged (QString)));
|
|
|
|
|
|
|
|
|
|
ui.profileGroupBox->setVisible (true);
|
|
|
|
|
ui.projectButtonBox->setVisible (false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
|
|
|
|
{
|
|
|
|
|
if (!isFlagged (Flag_LoadAddon))
|
|
|
|
|
{
|
|
|
|
|
ui.projectGroupBox->setVisible (false);
|
|
|
|
|
if (!isFlagged (Flag_NewAddon))
|
|
|
|
|
ui.projectGroupBox->setVisible (false);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.projectGroupBox->setVisible (true);
|
|
|
|
|
ui.projectCreateButton->setVisible (false);
|
|
|
|
|
ui.projectGroupBox->setTitle ("");
|
|
|
|
|
|
|
|
|
@ -165,10 +181,14 @@ void ContentSelectorView::ContentSelector::buildNewAddonView()
|
|
|
|
|
{
|
|
|
|
|
if (!isFlagged (Flag_NewAddon))
|
|
|
|
|
{
|
|
|
|
|
ui.profileGroupBox->setVisible (false);
|
|
|
|
|
if (!isFlagged (Flag_LoadAddon))
|
|
|
|
|
ui.projectGroupBox->setVisible (false);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.projectGroupBox->setVisible (true);
|
|
|
|
|
|
|
|
|
|
mFileWidget = new CSVDoc::FileWidget (this);
|
|
|
|
|
mAdjusterWidget = new CSVDoc::AdjusterWidget (this);
|
|
|
|
|
|
|
|
|
@ -190,18 +210,36 @@ void ContentSelectorView::ContentSelector::buildNewAddonView()
|
|
|
|
|
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
|
|
|
|
{
|
|
|
|
|
int index = -1;
|
|
|
|
|
|
|
|
|
|
if (!filename.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
index = ui.gameFileView->findText(filename);
|
|
|
|
|
|
|
|
|
|
//verify that the current index is also checked in the model
|
|
|
|
|
mContentModel->setCheckState(filename, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.gameFileView->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::clearCheckStates()
|
|
|
|
|
{
|
|
|
|
|
mContentModel->uncheckAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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::projectFilename() const
|
|
|
|
|
{
|
|
|
|
|
QString filepath = "";
|
|
|
|
|
|
|
|
|
@ -211,26 +249,13 @@ QString ContentSelectorView::ContentSelector::filename() const
|
|
|
|
|
return filepath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ContentSelectorView::ContentSelector::selectedFilePaths() const
|
|
|
|
|
{
|
|
|
|
|
QStringList filePaths;
|
|
|
|
|
|
|
|
|
|
if (mContentModel)
|
|
|
|
|
{
|
|
|
|
|
foreach (ContentSelectorModel::EsmFile *file, mContentModel->checkedItems())
|
|
|
|
|
filePaths.append(file->path());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return filePaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ContentSelectorModel::ContentFileList
|
|
|
|
|
ContentSelectorView::ContentSelector::selectedFiles() const
|
|
|
|
|
{
|
|
|
|
|
if (mContentModel)
|
|
|
|
|
return mContentModel->checkedItems();
|
|
|
|
|
if (!mContentModel)
|
|
|
|
|
return ContentSelectorModel::ContentFileList();
|
|
|
|
|
|
|
|
|
|
return ContentSelectorModel::ContentFileList();
|
|
|
|
|
return mContentModel->checkedItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -243,78 +268,58 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
mInstance->mContentModel->addFiles(path);
|
|
|
|
|
mInstance->ui.gameFileView->setCurrentIndex(-1);
|
|
|
|
|
mInstance->mContentModel->uncheckAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
QString previous = ui.profilesComboBox->currentText();
|
|
|
|
|
|
|
|
|
|
if (ui.profilesComboBox->findText(item) == -1)
|
|
|
|
|
ui.profilesComboBox->addItem(item);
|
|
|
|
|
|
|
|
|
|
if (setAsCurrent)
|
|
|
|
|
ui.profilesComboBox->setCurrentIndex(ui.profilesComboBox->findText(item));
|
|
|
|
|
|
|
|
|
|
enableProfilesComboBox();
|
|
|
|
|
setProfile (ui.profilesComboBox->findText(item));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ContentSelectorView::ContentSelector::getProfileText() const
|
|
|
|
|
void ContentSelectorView::ContentSelector::setProfile(int index)
|
|
|
|
|
{
|
|
|
|
|
return ui.profilesComboBox->currentText();
|
|
|
|
|
//programmatic change requires second call to non-signalized "slot" since no signal responses
|
|
|
|
|
//occur for programmatic changes to the profilesComboBox.
|
|
|
|
|
if (index >= -1 && index < ui.profilesComboBox->count())
|
|
|
|
|
{
|
|
|
|
|
QString previous = ui.profilesComboBox->itemText(ui.profilesComboBox->currentIndex());
|
|
|
|
|
QString current = ui.profilesComboBox->itemText(index);
|
|
|
|
|
|
|
|
|
|
ui.profilesComboBox->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::enableProfilesComboBox()
|
|
|
|
|
QString ContentSelectorView::ContentSelector::getProfileText() const
|
|
|
|
|
{
|
|
|
|
|
if (!ui.profilesComboBox->isEnabled())
|
|
|
|
|
ui.profilesComboBox->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
if (!ui.deleteProfileAction->isEnabled())
|
|
|
|
|
ui.deleteProfileAction->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
ui.projectButtonBox->button(QDialogButtonBox::Open)->setEnabled (true);
|
|
|
|
|
return ui.profilesComboBox->currentText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ContentSelectorView::ContentSelector::checkedItemsPaths()
|
|
|
|
|
QAbstractItemModel *ContentSelectorView::ContentSelector::profilesModel() const
|
|
|
|
|
{
|
|
|
|
|
QStringList itemPaths;
|
|
|
|
|
|
|
|
|
|
foreach( const ContentSelectorModel::EsmFile *file, mContentModel->checkedItems())
|
|
|
|
|
itemPaths << file->path();
|
|
|
|
|
|
|
|
|
|
return itemPaths;
|
|
|
|
|
return ui.profilesComboBox->model();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
|
|
|
|
{
|
|
|
|
|
//don't allow deleting "Default" profile
|
|
|
|
|
bool success = (ui.profilesComboBox->itemText(index) == "Default");
|
|
|
|
|
bool success = (ui.profilesComboBox->itemText(index) != "Default");
|
|
|
|
|
|
|
|
|
|
ui.deleteProfileAction->setEnabled(success);
|
|
|
|
|
ui.profilesComboBox->setEditEnabled(success);
|
|
|
|
|
|
|
|
|
|
emit signalProfileChanged(index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
|
|
|
@ -370,10 +375,12 @@ void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
|
|
|
|
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::on_newProfileAction_triggered()
|
|
|
|
|
{
|
|
|
|
|
emit signalProfileAdded();
|
|
|
|
|
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
|
|
|
|
|
|
|
|
|
if (newDialog.exec() == QDialog::Accepted)
|
|
|
|
|
emit signalAddNewProfile(newDialog.getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
|
|
|
@ -402,11 +409,6 @@ void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
|
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
}*/
|
|
|
|
|
slotCurrentProfileIndexChanged(ui.profilesComboBox->currentIndex());
|
|
|
|
|
}
|
|
|
|
|