summaryrefslogtreecommitdiff
path: root/src/pluginlistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pluginlistview.cpp')
-rw-r--r--src/pluginlistview.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/pluginlistview.cpp b/src/pluginlistview.cpp
index 39db7163..f95226fc 100644
--- a/src/pluginlistview.cpp
+++ b/src/pluginlistview.cpp
@@ -20,7 +20,9 @@ using namespace MOBase;
PluginListView::PluginListView(QWidget *parent)
: QTreeView(parent)
+ , m_sortProxy(nullptr)
, m_Scrollbar(new ViewMarkingScrollBar(this->model(), this))
+ , m_didUpdateMasterList(false)
{
setVerticalScrollBar(m_Scrollbar);
MOBase::setCustomizableColumns(this);
@@ -123,6 +125,49 @@ void PluginListView::onFilterChanged(const QString& filter)
updatePluginCount();
}
+void PluginListView::onSortButtonClicked()
+{
+ const bool offline = m_core->settings().network().offlineMode();
+
+ auto r = QMessageBox::No;
+
+ if (offline) {
+ r = QMessageBox::question(
+ topLevelWidget(), tr("Sorting plugins"),
+ tr("Are you sure you want to sort your plugins list?") + "\r\n\r\n" +
+ tr("Note: You are currently in offline mode and LOOT will not update the master list."),
+ QMessageBox::Yes | QMessageBox::No);
+ }
+ else {
+ r = QMessageBox::question(
+ topLevelWidget(), tr("Sorting plugins"),
+ tr("Are you sure you want to sort your plugins list?"),
+ QMessageBox::Yes | QMessageBox::No);
+ }
+
+ if (r != QMessageBox::Yes) {
+ return;
+ }
+
+ m_core->savePluginList();
+
+ topLevelWidget()->setEnabled(false);
+ Guard g([=]() { topLevelWidget()->setEnabled(true); });
+
+ // don't try to update the master list in offline mode
+ const bool didUpdateMasterList = offline ? true : m_didUpdateMasterList;
+
+ if (runLoot(topLevelWidget(), *m_core, didUpdateMasterList)) {
+ // don't assume the master list was updated in offline mode
+ if (!offline) {
+ m_didUpdateMasterList = true;
+ }
+
+ m_core->refreshESPList(false);
+ m_core->savePluginList();
+ }
+}
+
std::pair<QModelIndex, QModelIndexList> PluginListView::selected() const
{
return { indexViewToModel(currentIndex()), indexViewToModel(selectionModel()->selectedRows()) };
@@ -151,8 +196,11 @@ void PluginListView::setup(OrganizerCore& core, MainWindow* mw, Ui::MainWindow*
setItemDelegateForColumn(PluginList::COL_FLAGS, new GenericIconDelegate(this));
// counter
- connect(core.pluginList(), &PluginList::writePluginsList, [=]() { updatePluginCount(); });
- connect(core.pluginList(), &PluginList::esplist_changed, [=]() { updatePluginCount(); });
+ connect(core.pluginList(), &PluginList::writePluginsList, [=]{ updatePluginCount(); });
+ connect(core.pluginList(), &PluginList::esplist_changed, [=]{ updatePluginCount(); });
+
+ // sort
+ connect(mwui->bossButton, &QPushButton::clicked, [=]{ onSortButtonClicked(); });
// filter
connect(ui.filter, &QLineEdit::textChanged, m_sortProxy, &PluginListSortProxy::updateFilter);