Toggle addon files when activated or clicked on checkbox rather than clicked (Fixes #1980)

openmw-35
scrawl 10 years ago
parent 244db5cbfe
commit e413bebe99

@ -125,13 +125,17 @@ void CSVDoc::FileDialog::buildOpenFileView()
if(!mDialogBuilt) if(!mDialogBuilt)
{ {
connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); connect (mSelector, SIGNAL (signalAddonDataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (slotAddonDataChanged(const QModelIndex&, const QModelIndex&)));
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()));
} }
void CSVDoc::FileDialog::slotUpdateAcceptButton (int) void CSVDoc::FileDialog::slotAddonDataChanged(const QModelIndex &topleft, const QModelIndex &bottomright)
{
slotUpdateAcceptButton(0);
}
void CSVDoc::FileDialog::slotUpdateAcceptButton(int)
{ {
QString name = ""; QString name = "";

@ -70,6 +70,7 @@ namespace CSVDoc
void slotUpdateAcceptButton (int); void slotUpdateAcceptButton (int);
void slotUpdateAcceptButton (const QString &, bool); void slotUpdateAcceptButton (const QString &, bool);
void slotRejected(); void slotRejected();
void slotAddonDataChanged(const QModelIndex& topleft, const QModelIndex& bottomright);
}; };
} }
#endif // FILEDIALOG_HPP #endif // FILEDIALOG_HPP

@ -106,7 +106,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
//game files can always be checked //game files can always be checked
if (file->isGameFile()) if (file->isGameFile())
return Qt::ItemIsEnabled | Qt::ItemIsSelectable; return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
Qt::ItemFlags returnFlags; Qt::ItemFlags returnFlags;
bool allDependenciesFound = true; bool allDependenciesFound = true;
@ -145,7 +145,7 @@ Qt::ItemFlags ContentSelectorModel::ContentModel::flags(const QModelIndex &index
if (gamefileChecked) if (gamefileChecked)
{ {
if (allDependenciesFound) if (allDependenciesFound)
returnFlags = returnFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | mDragDropFlags; returnFlags = returnFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | mDragDropFlags;
else else
returnFlags = Qt::ItemIsSelectable; returnFlags = Qt::ItemIsSelectable;
} }

@ -58,7 +58,8 @@ void ContentSelectorView::ContentSelector::buildAddonView()
ui.addonView->setModel(mAddonProxyModel); ui.addonView->setModel(mAddonProxyModel);
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &))); connect(ui.addonView, SIGNAL(activated(const QModelIndex&)), this, SLOT(slotAddonTableItemActivated(const QModelIndex&)));
connect(mContentModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SIGNAL(signalAddonDataChanged(QModelIndex,QModelIndex)));
} }
void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &fileList) void ContentSelectorView::ContentSelector::setProfileContent(const QStringList &fileList)
@ -181,7 +182,7 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
emit signalCurrentGamefileIndexChanged (index); emit signalCurrentGamefileIndexChanged (index);
} }
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index) void ContentSelectorView::ContentSelector::slotAddonTableItemActivated(const QModelIndex &index)
{ {
QModelIndex sourceIndex = mAddonProxyModel->mapToSource (index); QModelIndex sourceIndex = mAddonProxyModel->mapToSource (index);
@ -194,10 +195,4 @@ void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QMode
checkState = Qt::Checked; checkState = Qt::Checked;
mContentModel->setData(sourceIndex, checkState, Qt::CheckStateRole); mContentModel->setData(sourceIndex, checkState, Qt::CheckStateRole);
if (checkState == Qt::Checked)
emit signalAddonFileSelected (index.row());
else
emit signalAddonFileUnselected (index.row());
} }

@ -55,13 +55,13 @@ namespace ContentSelectorView
signals: signals:
void signalCurrentGamefileIndexChanged (int); void signalCurrentGamefileIndexChanged (int);
void signalAddonFileSelected (int);
void signalAddonFileUnselected (int); void signalAddonDataChanged (const QModelIndex& topleft, const QModelIndex& bottomright);
private slots: private slots:
void slotCurrentGameFileIndexChanged(int index); void slotCurrentGameFileIndexChanged(int index);
void slotAddonTableItemClicked(const QModelIndex &index); void slotAddonTableItemActivated(const QModelIndex& index);
}; };
} }

Loading…
Cancel
Save