diff options
| author | Al <gabriel.cortesi@outlook.com> | 2019-01-11 00:23:39 +0100 |
|---|---|---|
| committer | Al <gabriel.cortesi@outlook.com> | 2019-01-11 00:23:39 +0100 |
| commit | 183069a85db598c577ee34fab046f812009c1f18 (patch) | |
| tree | d3ca880594d49e8f68f6a836878ed9400a1fc85b | |
| parent | ff49e2a43c44cb3e9688647b4c7c45c9bdbce227 (diff) | |
Make Visit on Nexus and Open web page do the other as well for multiple items.
| -rw-r--r-- | src/mainwindow.cpp | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e9d86810..c6dc145d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2974,13 +2974,22 @@ void MainWindow::visitOnNexus_clicked() return;
}
}
-
+ int row_idx;
+ ModInfo::Ptr info;
+ QString gameName;
+ QString webUrl;
for (QModelIndex idx : selection->selectedRows()) {
- int modID = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(idx.data(Qt::UserRole + 1).toInt(), 0), Qt::UserRole).toInt();
- QString gameName = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(idx.data(Qt::UserRole + 1).toInt(), 0), Qt::UserRole + 4).toString();
+ row_idx = idx.data(Qt::UserRole + 1).toInt();
+ info = ModInfo::getByIndex(row_idx);
+ int modID = info->getNexusID();
+ webUrl = info->getURL();
+ gameName = info->getGameName();
if (modID > 0) {
linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName));
}
+ else if (webUrl != "") {
+ linkClicked(webUrl);
+ }
}
}
else {
@@ -2996,11 +3005,43 @@ void MainWindow::visitOnNexus_clicked() void MainWindow::visitWebPage_clicked()
{
- ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow);
- if (info->getURL() != "") {
- linkClicked(info->getURL());
- } else {
- MessageDialog::showMessage(tr("Web page for this mod is unknown"), this);
+
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ if (selection->hasSelection() && selection->selectedRows().count() > 1) {
+ int count = selection->selectedRows().count();
+ if (count > 10) {
+ if (QMessageBox::question(this, tr("Opening Web Pages"),
+ tr("You are trying to open %1 Web Pages. Are you sure you want to do this?").arg(count),
+ QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
+ return;
+ }
+ }
+ int row_idx;
+ ModInfo::Ptr info;
+ QString gameName;
+ QString webUrl;
+ for (QModelIndex idx : selection->selectedRows()) {
+ row_idx = idx.data(Qt::UserRole + 1).toInt();
+ info = ModInfo::getByIndex(row_idx);
+ int modID = info->getNexusID();
+ webUrl = info->getURL();
+ gameName = info->getGameName();
+ if (modID > 0) {
+ linkClicked(NexusInterface::instance(&m_PluginContainer)->getModURL(modID, gameName));
+ }
+ else if (webUrl != "") {
+ linkClicked(webUrl);
+ }
+ }
+ }
+ else {
+ ModInfo::Ptr info = ModInfo::getByIndex(m_ContextRow);
+ if (info->getURL() != "") {
+ linkClicked(info->getURL());
+ }
+ else {
+ MessageDialog::showMessage(tr("Web page for this mod is unknown"), this);
+ }
}
}
|
