1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#include "datatab.h"
#include "ui_mainwindow.h"
#include "settings.h"
#include "organizercore.h"
#include "directoryentry.h"
#include "messagedialog.h"
#include "filetree.h"
#include "filetreemodel.h"
#include <log.h>
#include <report.h>
using namespace MOShared;
using namespace MOBase;
// in mainwindow.cpp
QString UnmanagedModName();
DataTab::DataTab(
OrganizerCore& core, PluginContainer& pc,
QWidget* parent, Ui::MainWindow* mwui) :
m_core(core), m_pluginContainer(pc), m_parent(parent),
ui{
mwui->dataTabRefresh, mwui->dataTree,
mwui->dataTabShowOnlyConflicts, mwui->dataTabShowFromArchives}
{
m_filetree.reset(new FileTree(core, m_pluginContainer, ui.tree));
m_filter.setEdit(mwui->dataTabFilter);
m_filter.setList(mwui->dataTree);
m_filter.setUseSourceSort(true);
m_filter.setFilterColumn(FileTreeModel::FileName);
if (auto* m=m_filter.proxyModel()) {
m->setDynamicSortFilter(false);
}
connect(
&m_filter, &FilterWidget::aboutToChange,
[&]{ m_filetree->ensureFullyLoaded(); });
connect(
ui.refresh, &QPushButton::clicked,
[&]{ onRefresh(); });
connect(
ui.conflicts, &QCheckBox::toggled,
[&]{ onConflicts(); });
connect(
ui.archives, &QCheckBox::toggled,
[&]{ onArchives(); });
connect(
m_filetree.get(), &FileTree::executablesChanged,
this, &DataTab::executablesChanged);
connect(
m_filetree.get(), &FileTree::originModified,
this, &DataTab::originModified);
connect(
m_filetree.get(), &FileTree::displayModInformation,
this, &DataTab::displayModInformation);
}
void DataTab::saveState(Settings& s) const
{
s.geometry().saveState(ui.tree->header());
s.widgets().saveChecked(ui.conflicts);
s.widgets().saveChecked(ui.archives);
}
void DataTab::restoreState(const Settings& s)
{
s.geometry().restoreState(ui.tree->header());
// prior to 2.3, the list was not sortable, and this remembered in the
// widget state, for whatever reason
ui.tree->setSortingEnabled(true);
s.widgets().restoreChecked(ui.conflicts);
s.widgets().restoreChecked(ui.archives);
}
void DataTab::activated()
{
updateTree();
}
void DataTab::onRefresh()
{
if (QGuiApplication::keyboardModifiers() & Qt::ShiftModifier) {
m_filetree->clear();
}
m_core.refreshDirectoryStructure();
}
void DataTab::updateTree()
{
m_filetree->refresh();
if (!m_filter.empty()) {
m_filetree->ensureFullyLoaded();
if (auto* m=m_filter.proxyModel()) {
m->invalidate();
}
}
}
void DataTab::onConflicts()
{
updateOptions();
}
void DataTab::onArchives()
{
updateOptions();
}
void DataTab::updateOptions()
{
using M = FileTreeModel;
M::Flags flags = M::NoFlags;
if (ui.conflicts->isChecked()) {
flags |= M::ConflictsOnly | M::PruneDirectories;
}
if (ui.archives->isChecked()) {
flags |= M::Archives;
}
m_filetree->model()->setFlags(flags);
updateTree();
}
|