|
|
|
@ -99,9 +99,10 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
|
|
|
|
mMastersTable = new QTableView(this);
|
|
|
|
|
mMastersTable->setModel(mMastersProxyModel);
|
|
|
|
|
mMastersTable->setObjectName("MastersTable");
|
|
|
|
|
mMastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
mMastersTable->setSortingEnabled(false);
|
|
|
|
|
mMastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
mMastersTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
mMastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
mMastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
mMastersTable->setAlternatingRowColors(true);
|
|
|
|
|
mMastersTable->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
@ -118,7 +119,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
|
|
|
|
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
|
mPluginsTable->setSortingEnabled(false);
|
|
|
|
|
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
|
|
mPluginsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
|
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
|
mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
|
|
|
mPluginsTable->setAlternatingRowColors(true);
|
|
|
|
|
mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
|
|
|
|
@ -173,6 +174,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
|
|
|
|
connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
|
|
|
|
|
|
|
|
|
|
connect(mPluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
|
|
|
|
connect(mMastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
|
|
|
|
|
|
|
|
|
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
|
|
|
|
|
|
|
|
|
@ -208,15 +210,13 @@ void DataFilesPage::createActions()
|
|
|
|
|
mProfileToolBar->addAction(mDeleteProfileAction);
|
|
|
|
|
|
|
|
|
|
// Context menu actions
|
|
|
|
|
mCheckAction = new QAction(tr("Check selected"), this);
|
|
|
|
|
mCheckAction = new QAction(tr("Check Selection"), this);
|
|
|
|
|
connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check()));
|
|
|
|
|
|
|
|
|
|
mUncheckAction = new QAction(tr("Uncheck selected"), this);
|
|
|
|
|
mUncheckAction = new QAction(tr("Uncheck Selection"), this);
|
|
|
|
|
connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck()));
|
|
|
|
|
|
|
|
|
|
// Context menu for the plugins table
|
|
|
|
|
mContextMenu = new QMenu(this);
|
|
|
|
|
|
|
|
|
|
mContextMenu->addAction(mCheckAction);
|
|
|
|
|
mContextMenu->addAction(mUncheckAction);
|
|
|
|
|
}
|
|
|
|
@ -296,6 +296,9 @@ void DataFilesPage::loadSettings()
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::saveSettings()
|
|
|
|
|
{
|
|
|
|
|
if (mDataFilesModel->rowCount() < 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString profile = mLauncherSettings.value(QString("Profiles/CurrentProfile"));
|
|
|
|
|
|
|
|
|
|
if (profile.isEmpty())
|
|
|
|
@ -406,43 +409,63 @@ void DataFilesPage::deleteProfile()
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::check()
|
|
|
|
|
{
|
|
|
|
|
// Check the current selection
|
|
|
|
|
if (!mPluginsTable->selectionModel()->hasSelection()) {
|
|
|
|
|
if (mPluginsTable->hasFocus())
|
|
|
|
|
setPluginsCheckstates(Qt::Checked);
|
|
|
|
|
|
|
|
|
|
if (mMastersTable->hasFocus())
|
|
|
|
|
setMastersCheckstates(Qt::Checked);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::uncheck()
|
|
|
|
|
{
|
|
|
|
|
if (mPluginsTable->hasFocus())
|
|
|
|
|
setPluginsCheckstates(Qt::Unchecked);
|
|
|
|
|
|
|
|
|
|
if (mMastersTable->hasFocus())
|
|
|
|
|
setMastersCheckstates(Qt::Unchecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::refresh()
|
|
|
|
|
{
|
|
|
|
|
// mDataFilesModel->sort(0);
|
|
|
|
|
|
|
|
|
|
// Refresh the plugins table
|
|
|
|
|
mPluginsTable->scrollToTop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
|
|
|
|
|
{
|
|
|
|
|
if (!mMastersTable->selectionModel()->hasSelection()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes();
|
|
|
|
|
QModelIndexList indexes = mMastersTable->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
|
|
//sort selection ascending because selectedIndexes returns an unsorted list
|
|
|
|
|
//qSort(indexes.begin(), indexes.end(), rowSmallerThan);
|
|
|
|
|
|
|
|
|
|
foreach (const QModelIndex &index, indexes) {
|
|
|
|
|
foreach (const QModelIndex &index, indexes)
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
|
|
|
|
mFilterProxyModel->mapToSource(index));
|
|
|
|
|
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
|
|
|
|
|
|
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mDataFilesModel->setCheckState(sourceIndex, Qt::Checked);
|
|
|
|
|
mDataFilesModel->setCheckState(sourceIndex, state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::uncheck()
|
|
|
|
|
void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
|
|
|
|
{
|
|
|
|
|
// uncheck the current selection
|
|
|
|
|
if (!mPluginsTable->selectionModel()->hasSelection()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
|
|
//sort selection ascending because selectedIndexes returns an unsorted list
|
|
|
|
|
//qSort(indexes.begin(), indexes.end(), rowSmallerThan);
|
|
|
|
|
|
|
|
|
|
foreach (const QModelIndex &index, indexes) {
|
|
|
|
|
foreach (const QModelIndex &index, indexes)
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -452,19 +475,10 @@ void DataFilesPage::uncheck()
|
|
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mDataFilesModel->setCheckState(sourceIndex, Qt::Unchecked);
|
|
|
|
|
mDataFilesModel->setCheckState(sourceIndex, state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::refresh()
|
|
|
|
|
{
|
|
|
|
|
// mDataFilesModel->sort(0);
|
|
|
|
|
|
|
|
|
|
// Refresh the plugins table
|
|
|
|
|
mPluginsTable->scrollToTop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::setCheckState(QModelIndex index)
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid())
|
|
|
|
@ -554,35 +568,69 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
|
|
|
|
|
|
|
|
|
|
void DataFilesPage::showContextMenu(const QPoint &point)
|
|
|
|
|
{
|
|
|
|
|
// Make sure there are plugins in the view
|
|
|
|
|
if (!mPluginsTable->selectionModel()->hasSelection()) {
|
|
|
|
|
QObject *object = QObject::sender();
|
|
|
|
|
|
|
|
|
|
// Not a signal-slot call
|
|
|
|
|
if (!object)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPoint globalPos = mPluginsTable->mapToGlobal(point);
|
|
|
|
|
if (object->objectName() == QLatin1String("PluginsTable")) {
|
|
|
|
|
if (!mPluginsTable->selectionModel()->hasSelection())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes();
|
|
|
|
|
QPoint globalPos = mPluginsTable->mapToGlobal(point);
|
|
|
|
|
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
|
|
// Show the check/uncheck actions depending on the state of the selected items
|
|
|
|
|
mUncheckAction->setEnabled(false);
|
|
|
|
|
mCheckAction->setEnabled(false);
|
|
|
|
|
// Show the check/uncheck actions depending on the state of the selected items
|
|
|
|
|
mUncheckAction->setEnabled(false);
|
|
|
|
|
mCheckAction->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
foreach (const QModelIndex &index, indexes) {
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return;
|
|
|
|
|
foreach (const QModelIndex &index, indexes)
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
|
|
|
|
mFilterProxyModel->mapToSource(index));
|
|
|
|
|
QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(
|
|
|
|
|
mFilterProxyModel->mapToSource(index));
|
|
|
|
|
|
|
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
|
|
|
|
? mUncheckAction->setEnabled(true)
|
|
|
|
|
: mCheckAction->setEnabled(true);
|
|
|
|
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
|
|
|
|
? mUncheckAction->setEnabled(true)
|
|
|
|
|
: mCheckAction->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show menu
|
|
|
|
|
mContextMenu->exec(globalPos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show menu
|
|
|
|
|
mContextMenu->exec(globalPos);
|
|
|
|
|
if (object->objectName() == QLatin1String("MastersTable")) {
|
|
|
|
|
if (!mMastersTable->selectionModel()->hasSelection())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QPoint globalPos = mMastersTable->mapToGlobal(point);
|
|
|
|
|
QModelIndexList indexes = mMastersTable->selectionModel()->selectedIndexes();
|
|
|
|
|
|
|
|
|
|
// Show the check/uncheck actions depending on the state of the selected items
|
|
|
|
|
mUncheckAction->setEnabled(false);
|
|
|
|
|
mCheckAction->setEnabled(false);
|
|
|
|
|
|
|
|
|
|
foreach (const QModelIndex &index, indexes)
|
|
|
|
|
{
|
|
|
|
|
if (!index.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndex sourceIndex = mMastersProxyModel->mapToSource(index);
|
|
|
|
|
|
|
|
|
|
if (!sourceIndex.isValid())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
|
|
|
|
? mUncheckAction->setEnabled(true)
|
|
|
|
|
: mCheckAction->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mContextMenu->exec(globalPos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|