diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2018-12-24 21:05:29 -0600 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2018-12-24 22:37:52 -0600 |
| commit | d021011cfa1f9276dc9c3dd7c2fcd395e3a78260 (patch) | |
| tree | 54e3be7a1f21841e64a4ab8dd49f094a09bc4192 /src/mainwindow.cpp | |
| parent | 5f06da756e6d03dde85da6ddad5d8177f7410860 (diff) | |
Allow "endorse", "unendorse", and "won't endorse" for multiple mods
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index de12cf05..47fe4308 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2607,16 +2607,49 @@ void MainWindow::endorseMod(ModInfo::Ptr mod) void MainWindow::endorse_clicked()
{
- endorseMod(ModInfo::getByIndex(m_ContextRow));
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ if (selection->hasSelection() && selection->selectedRows().count() > 1) {
+ if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->loggedIn()) {
+ MessageDialog::showMessage(tr("Endorsing multiple mods will take a while. Please wait..."), this);
+ for (QModelIndex idx : selection->selectedRows()) {
+ ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->endorse(true);
+ }
+ }
+ else {
+ QString username, password;
+ if (m_OrganizerCore.settings().getNexusLogin(username, password)) {
+ MessageDialog::showMessage(tr("Endorsing multiple mods will take a while. Please wait..."), this);
+ for (QModelIndex idx : selection->selectedRows()) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt());
+ m_OrganizerCore.doAfterLogin(boost::bind(&MainWindow::endorseMod, this, modInfo));
+ }
+ NexusInterface::instance(&m_PluginContainer)->getAccessManager()->login(username, password);
+ } else {
+ MessageDialog::showMessage(tr("You need to be logged in with Nexus to endorse"), this);
+ return;
+ }
+ }
+ }
+ else {
+ endorseMod(ModInfo::getByIndex(m_ContextRow));
+ }
}
void MainWindow::dontendorse_clicked()
{
- ModInfo::getByIndex(m_ContextRow)->setNeverEndorse();
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ if (selection->hasSelection() && selection->selectedRows().count() > 1) {
+ for (QModelIndex idx : selection->selectedRows()) {
+ ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->setNeverEndorse();
+ }
+ }
+ else {
+ ModInfo::getByIndex(m_ContextRow)->setNeverEndorse();
+ }
}
-void MainWindow::unendorse_clicked()
+void MainWindow::unendorseMod(ModInfo::Ptr mod)
{
QString username, password;
if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->loggedIn()) {
@@ -2631,6 +2664,37 @@ void MainWindow::unendorse_clicked() }
}
+
+void MainWindow::unendorse_clicked()
+{
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ if (selection->hasSelection() && selection->selectedRows().count() > 1) {
+ if (NexusInterface::instance(&m_PluginContainer)->getAccessManager()->loggedIn()) {
+ MessageDialog::showMessage(tr("Unendorsing multiple mods will take a while. Please wait..."), this);
+ for (QModelIndex idx : selection->selectedRows()) {
+ ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt())->endorse(false);
+ }
+ }
+ else {
+ QString username, password;
+ if (m_OrganizerCore.settings().getNexusLogin(username, password)) {
+ MessageDialog::showMessage(tr("Unendorsing multiple mods will take a while. Please wait..."), this);
+ for (QModelIndex idx : selection->selectedRows()) {
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt());
+ m_OrganizerCore.doAfterLogin(boost::bind(&MainWindow::unendorseMod, this, modInfo));
+ }
+ NexusInterface::instance(&m_PluginContainer)->getAccessManager()->login(username, password);
+ } else {
+ MessageDialog::showMessage(tr("You need to be logged in with Nexus to endorse"), this);
+ return;
+ }
+ }
+ }
+ else {
+ unendorseMod(ModInfo::getByIndex(m_ContextRow));
+ }
+}
+
void MainWindow::loginFailed(const QString &error)
{
qDebug("login failed: %s", qPrintable(error));
|
