From cc5f0c8555fbbcc4b6d0dc29a42b8c7869df1859 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 27 Dec 2020 23:23:56 +0100 Subject: Drag and drop from download view to install + Expand and scroll to mod on install. --- src/mainwindow.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 74f3fd62..ea7d5967 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -578,7 +578,6 @@ void MainWindow::setupModList() ui->modList->sortByColumn(ModList::COL_PRIORITY, Qt::AscendingOrder); - connect( ui->modList, SIGNAL(dropModeUpdate(bool)), m_OrganizerCore.modList(), SLOT(dropModeUpdate(bool))); @@ -653,6 +652,10 @@ void MainWindow::setupModList() ui->modList->header()->setSectionHidden(ModList::COL_NAME, false); ui->modList->installEventFilter(m_OrganizerCore.modList()); + + connect(m_OrganizerCore.modList(), &ModList::downloadArchiveDropped, this, [this](int row, int priority) { + m_OrganizerCore.installDownload(row, priority); + }); } void MainWindow::resetActionIcons() @@ -743,6 +746,7 @@ MainWindow::~MainWindow() } } + void MainWindow::updateWindowTitle(const APIUserAccount& user) { //"\xe2\x80\x93" is an "em dash", a longer "-" @@ -2483,15 +2487,23 @@ void MainWindow::modorder_changed() void MainWindow::modInstalled(const QString &modName) { - QModelIndexList posList = - m_OrganizerCore.modList()->match(m_OrganizerCore.modList()->index(0, 0), Qt::DisplayRole, modName); - if (posList.count() == 1) { - ui->modList->scrollTo(posList.at(0)); + unsigned int index = ModInfo::getIndex(modName); + + if (index == UINT_MAX) { + return; + } + + QModelIndex qIndex = m_OrganizerCore.modList()->index(index, 0); + + if (m_ModListSortProxy->sourceModel() == m_ModListByPriorityProxy) { + qIndex = m_ModListByPriorityProxy->mapFromSource(qIndex); + ui->modList->expand(m_ModListSortProxy->mapFromSource(qIndex)); } + ui->modList->scrollTo(m_ModListSortProxy->mapFromSource(qIndex)); // force an update to happen std::multimap IDs; - ModInfo::Ptr info = ModInfo::getByIndex(ModInfo::getIndex(modName)); + ModInfo::Ptr info = ModInfo::getByIndex(index); IDs.insert(std::make_pair(info->gameName(), info->nexusId())); modUpdateCheck(IDs); } -- cgit v1.3.1