summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-02-08 22:59:35 +0100
committerAl12rs <gabriel.cortesi@outlook.com>2018-02-08 22:59:35 +0100
commit0c4cdb89ade12cacb7e69b0d913a7c83fe7b344a (patch)
tree45bae792f58a180e1029f8fae69f570937cd097d /src
parent28b0411ccaec2ca39685c9b6931fa46e09d484fb (diff)
Changed the data tab to remember the current expanded folders when hiding or un-hiding a file. Using the refresh button will close alll the expanded nodes an return to the initial state as it did before.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp37
-rw-r--r--src/mainwindow.h1
2 files changed, 36 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5f337da3..afb00313 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -142,6 +142,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QToolTip>
#include <QTranslator>
#include <QTreeWidget>
+#include <QTreeWidgetItemIterator>
#include <QUrl>
#include <QVariantList>
#include <QWhatsThis>
@@ -1306,6 +1307,38 @@ void MainWindow::refreshDataTree()
subTree->setExpanded(true);
}
+void MainWindow::refreshDataTreeKeepExpandedNodes()
+{
+ QCheckBox *conflictsBox = findChild<QCheckBox*>("conflictsCheckBox");
+ QTreeWidget *tree = findChild<QTreeWidget*>("dataTree");
+
+ QStringList expandedNodes;
+ QTreeWidgetItemIterator it1(tree, QTreeWidgetItemIterator::NotHidden | QTreeWidgetItemIterator::HasChildren);
+ while (*it1) {
+ QTreeWidgetItem *current = (*it1);
+ if (current->isExpanded() && !(current->text(0)=="data")) {
+ expandedNodes.append(current->text(0)+"/"+current->parent()->text(0));
+ }
+ ++it1;
+ }
+
+ tree->clear();
+ QStringList columns("data");
+ columns.append("");
+ QTreeWidgetItem *subTree = new QTreeWidgetItem(columns);
+ updateTo(subTree, L"", *m_OrganizerCore.directoryStructure(), conflictsBox->isChecked());
+ tree->insertTopLevelItem(0, subTree);
+ subTree->setExpanded(true);
+ QTreeWidgetItemIterator it2(tree, QTreeWidgetItemIterator::HasChildren);
+ while (*it2) {
+ QTreeWidgetItem *current = (*it2);
+ if (!(current->text(0)=="data") && expandedNodes.contains(current->text(0)+"/"+current->parent()->text(0))) {
+ current->setExpanded(true);
+ }
+ ++it2;
+ }
+}
+
void MainWindow::refreshSavesIfOpen()
{
@@ -3705,7 +3738,7 @@ void MainWindow::hideFile()
if (QFile::rename(oldName, newName)) {
originModified(m_ContextItem->data(1, Qt::UserRole + 1).toInt());
- refreshDataTree();
+ refreshDataTreeKeepExpandedNodes();
} else {
reportError(tr("failed to rename \"%1\" to \"%2\"").arg(oldName).arg(QDir::toNativeSeparators(newName)));
}
@@ -3729,7 +3762,7 @@ void MainWindow::unhideFile()
}
if (QFile::rename(oldName, newName)) {
originModified(m_ContextItem->data(1, Qt::UserRole + 1).toInt());
- refreshDataTree();
+ refreshDataTreeKeepExpandedNodes();
} else {
reportError(tr("failed to rename \"%1\" to \"%2\"").arg(QDir::toNativeSeparators(oldName)).arg(QDir::toNativeSeparators(newName)));
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 5c8e4ebc..d7708da6 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -122,6 +122,7 @@ public:
bool addProfile();
void updateBSAList(const QStringList &defaultArchives, const QStringList &activeArchives);
void refreshDataTree();
+ void refreshDataTreeKeepExpandedNodes();
void refreshSaveList();
void setModListSorting(int index);