From a4624f239fe5d152ec8797c1a3f8c2b2aeaef1ba Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Tue, 10 Dec 2019 13:09:44 -0500 Subject: split FileTreeModel, initial implementation, some stuff is broken --- src/mainwindow.ui | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/mainwindow.ui b/src/mainwindow.ui index d0daafc0..b27122ef 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1075,7 +1075,7 @@ p, li { white-space: pre-wrap; } - + Qt::CustomContextMenu @@ -1088,19 +1088,9 @@ p, li { white-space: pre-wrap; } true - + 400 - - - File - - - - - Mod - - -- cgit v1.3.1 From e3211683fd75b4c297f2f670819ad5dacb18a19c Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Tue, 21 Jan 2020 23:45:11 -0500 Subject: shell menu for multiple files --- src/envshell.cpp | 164 +++++++++++++++++++++++++++++++++----------- src/envshell.h | 6 +- src/filetree.cpp | 30 ++++---- src/filetree.h | 3 +- src/mainwindow.ui | 3 + src/shared/directoryentry.h | 2 +- 6 files changed, 153 insertions(+), 55 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/envshell.cpp b/src/envshell.cpp index ca392a9c..dcf337c5 100644 --- a/src/envshell.cpp +++ b/src/envshell.cpp @@ -24,6 +24,24 @@ public: }; +struct IdlsFreer +{ + const std::vector& v; + + IdlsFreer(const std::vector& v) + : v(v) + { + } + + ~IdlsFreer() + { + for (auto&& idl : v) { + ::CoTaskMemFree(const_cast(idl)); + } + } +}; + + class WndProcFilter : public QAbstractNativeEventFilter { public: @@ -191,48 +209,103 @@ private: -CoTaskMemPtr getIDL(const wchar_t* path) +QMainWindow* getMainWindow(QWidget* w) { - LPITEMIDLIST pidl; - SFGAOF sfgao; + QWidget* p = w; - const auto r = SHParseDisplayName(path, nullptr, &pidl, 0, &sfgao); + while (p) { + if (auto* mw=dynamic_cast(p)) { + return mw; + } + + p = p->parentWidget(); + } + + return nullptr; +} + +COMPtr createShellItem(const std::wstring& path) +{ + IShellItem* item = nullptr; + + auto r = SHCreateItemFromParsingName( + path.c_str(), nullptr, IID_IShellItem, (void**)&item); if (FAILED(r)) { - throw MenuFailed(r, "SHParseDisplayName failed"); + throw MenuFailed(r, "SHCreateItemFromParsingName failed"); } - return CoTaskMemPtr(pidl); + return COMPtr(item); } -std::pair, LPCITEMIDLIST> getShellFolder(LPITEMIDLIST idl) +COMPtr getPersistIDList(IShellItem* item) { - IShellFolder* psf = nullptr; - LPCITEMIDLIST pidlChild = nullptr; + IPersistIDList* idl = nullptr; + auto r = item->QueryInterface(IID_IPersistIDList, (void**)&idl); + + if (FAILED(r)) { + throw MenuFailed(r, "QueryInterface IID_IPersistIDList failed"); + } - const auto r = SHBindToParent( - idl, IID_IShellFolder, reinterpret_cast(&psf), &pidlChild); + return COMPtr(idl); +} + +CoTaskMemPtr getIDList(IPersistIDList* pidlist) +{ + LPITEMIDLIST absIdl = nullptr; + auto r = pidlist->GetIDList(&absIdl); if (FAILED(r)) { - throw MenuFailed(r, "SHBindToParent failed"); + throw MenuFailed(r, "GetIDList failed"); } - return {COMPtr(psf), pidlChild}; + return CoTaskMemPtr(absIdl); } -COMPtr getContextMenu(IShellFolder* psf, LPCITEMIDLIST idl) +std::vector createIdls( + const std::vector& files) { - IContextMenu* pcm = nullptr; + std::vector idls; + + for (auto&& f : files) { + const auto path = QDir::toNativeSeparators(f.absoluteFilePath()).toStdWString(); - const auto r = psf->GetUIObjectOf( - 0, 1, &idl, IID_IContextMenu, nullptr, - reinterpret_cast(&pcm)); + auto item = createShellItem(path); + auto pidlist = getPersistIDList(item.get()); + auto absIdl = getIDList(pidlist.get()); + + idls.push_back(absIdl.release()); + } + + return idls; +} + +COMPtr createItemArray( + std::vector& idls) +{ + IShellItemArray* array = nullptr; + auto r = SHCreateShellItemArrayFromIDLists( + static_cast(idls.size()), &idls[0], &array); + + if (FAILED(r)) { + throw MenuFailed(r, "SHCreateShellItemArrayFromIDLists failed"); + } + + return COMPtr(array); +} + +COMPtr createContextMenu(IShellItemArray* array) +{ + IContextMenu* cm = nullptr; + + auto r = array->BindToHandler( + nullptr, BHID_SFUIObject, IID_IContextMenu, (void**)&cm); if (FAILED(r)) { - throw MenuFailed(r, "GetUIObjectOf failed"); + throw MenuFailed(r, "BindToHandler failed"); } - return COMPtr(pcm); + return COMPtr(cm); } HMenuPtr createMenu(IContextMenu* cm) @@ -296,31 +369,29 @@ void invoke(QMainWindow* mw, const QPoint& p, int cmd, IContextMenu* cm) } } -QMainWindow* getMainWindow(QWidget* w) -{ - QWidget* p = w; - - while (p) { - if (auto* mw=dynamic_cast(p)) { - return mw; - } - - p = p->parentWidget(); - } - return nullptr; -} - -void showShellMenu(QWidget* parent, const QFileInfo& file, const QPoint& pos) +void showShellMenu( + QWidget* parent, const std::vector& files, const QPoint& pos) { - const auto path = QDir::toNativeSeparators(file.absoluteFilePath()); + if (files.empty()) { + log::warn("showShellMenu(): no files given"); + return; + } try { auto* mw = getMainWindow(parent); - auto idl = getIDL(path.toStdWString().c_str()); - auto [sf, childIdl] = getShellFolder(idl.get()); - auto cm = getContextMenu(sf.get(), childIdl); + auto idls = createIdls(files); + + if (idls.empty()) { + log::error("no idls, can't create context menu"); + return; + } + + IdlsFreer freer(idls); + + auto array = createItemArray(idls); + auto cm = createContextMenu(array.get()); auto hmenu = createMenu(cm.get()); const int cmd = runMenu(mw, cm.get(), hmenu.get(), pos); @@ -332,8 +403,21 @@ void showShellMenu(QWidget* parent, const QFileInfo& file, const QPoint& pos) } catch(MenuFailed& e) { - log::error("can't create shell menu for '{}': {}", path, e.what()); + if (files.size() == 1) { + log::error( + "can't create shell menu for '{}': {}", + QDir::toNativeSeparators(files[0].absoluteFilePath()), e.what()); + } else { + log::error( + "can't create shell menu for {} files: {}", + files.size(), e.what()); + } } } +void showShellMenu(QWidget* parent, const QFileInfo& file, const QPoint& pos) +{ + showShellMenu(parent, std::vector{file}, pos); +} + } // namespace diff --git a/src/envshell.h b/src/envshell.h index f30495e0..3be53841 100644 --- a/src/envshell.h +++ b/src/envshell.h @@ -7,7 +7,11 @@ namespace env { -void showShellMenu(QWidget* parent, const QFileInfo& file, const QPoint& pos); +void showShellMenu( + QWidget* parent, const QFileInfo& file, const QPoint& pos); + +void showShellMenu( + QWidget* parent, const std::vector& files, const QPoint& pos); } diff --git a/src/filetree.cpp b/src/filetree.cpp index 3c99ab05..d7dbc6e6 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -442,18 +442,8 @@ void FileTree::onContextMenu(const QPoint &pos) const auto m = QApplication::keyboardModifiers(); if (m & Qt::ShiftModifier) { - if (auto* item=singleSelection()) { - if (!item->isDirectory()) { - const auto file = m_core.directoryStructure()->searchFile( - item->dataRelativeFilePath().toStdWString(), nullptr); - - if (file) { - const QFileInfo fi(QString::fromStdWString(file->getFullPath())); - env::showShellMenu(m_tree, fi, m_tree->viewport()->mapToGlobal(pos)); - return; - } - } - } + showShellMenu(pos); + return; } QMenu menu; @@ -476,6 +466,22 @@ void FileTree::onContextMenu(const QPoint &pos) menu.exec(m_tree->viewport()->mapToGlobal(pos)); } +void FileTree::showShellMenu(QPoint pos) +{ + std::vector files; + + for (auto&& index : m_tree->selectionModel()->selectedRows()) { + auto* item = m_model->itemFromIndex(index); + if (!item) { + continue; + } + + files.push_back(item->realPath()); + } + + env::showShellMenu(m_tree, files, m_tree->viewport()->mapToGlobal(pos)); +} + void FileTree::addDirectoryMenus(QMenu&, FileTreeItem&) { // noop diff --git a/src/filetree.h b/src/filetree.h index 40b5b2ff..39c9d0c6 100644 --- a/src/filetree.h +++ b/src/filetree.h @@ -48,9 +48,10 @@ private: FileTreeModel* m_model; FileTreeItem* singleSelection(); + void onExpandedChanged(const QModelIndex& index, bool expanded); void onContextMenu(const QPoint &pos); - void showShellMenu(const MOShared::FileEntry& file, QPoint pos); + void showShellMenu(QPoint pos); void addDirectoryMenus(QMenu& menu, FileTreeItem& item); void addFileMenus(QMenu& menu, const MOShared::FileEntry& file, int originID); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index b27122ef..da9f949c 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1085,6 +1085,9 @@ p, li { white-space: pre-wrap; } true + + QAbstractItemView::ExtendedSelection + true diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h index f1d3ba03..b5a1dced 100644 --- a/src/shared/directoryentry.h +++ b/src/shared/directoryentry.h @@ -416,7 +416,7 @@ public: // path containing the file // const FileEntry::Ptr searchFile( - const std::wstring &path, const DirectoryEntry **directory) const; + const std::wstring &path, const DirectoryEntry **directory=nullptr) const; void insertFile(const std::wstring &filePath, FilesOrigin &origin, FILETIME fileTime); -- cgit v1.3.1 From c6c01f86c64a3a9fa666dddec860e52d388e5e97 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Wed, 22 Jan 2020 05:45:08 -0500 Subject: sort --- src/datatab.cpp | 4 +++ src/filetreeitem.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++ src/filetreeitem.h | 4 +++ src/filetreemodel.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++--------- src/filetreemodel.h | 20 +++++++++---- src/mainwindow.ui | 3 ++ 6 files changed, 159 insertions(+), 19 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/datatab.cpp b/src/datatab.cpp index 1b7baa82..af457b33 100644 --- a/src/datatab.cpp +++ b/src/datatab.cpp @@ -59,6 +59,10 @@ void DataTab::saveState(Settings& s) const 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); } void DataTab::activated() diff --git a/src/filetreeitem.cpp b/src/filetreeitem.cpp index e7510279..a506f0f0 100644 --- a/src/filetreeitem.cpp +++ b/src/filetreeitem.cpp @@ -1,6 +1,8 @@ #include "filetreeitem.h" +#include "filetreemodel.h" #include "modinfo.h" #include "util.h" +#include "modinfodialogfwd.h" #include using namespace MOBase; @@ -63,6 +65,71 @@ void FileTreeItem::remove(std::size_t from, std::size_t n) m_children.erase(begin, end); } + +template +int threeWayCompare(T&& a, T&& b) +{ + if (a < b) { + return -1; + } + + if (a > b) { + return 1; + } + + return 0; +} + +class FileTreeItem::Sorter +{ +public: + static int compare(int column, const FileTreeItem* a, const FileTreeItem* b) + { + switch (column) + { + case FileTreeModel::FileName: + return naturalCompare(a->m_file, b->m_file); + + case FileTreeModel::ModName: + return naturalCompare(a->m_mod, b->m_mod); + + case FileTreeModel::FileType: + return naturalCompare(a->meta().type, b->meta().type); + + case FileTreeModel::FileSize: + return threeWayCompare(a->meta().size, b->meta().size); + + case FileTreeModel::LastModified: + return threeWayCompare(a->meta().lastModified, b->meta().lastModified); + + default: + return 0; + } + } +}; + + +void FileTreeItem::sort(int column, Qt::SortOrder order) +{ + std::sort(m_children.begin(), m_children.end(), [&](auto&& a, auto&& b) { + int r = 0; + + if (a->isDirectory() && !b->isDirectory()) { + r = -1; + } else if (!a->isDirectory() && b->isDirectory()) { + r = 1; + } else { + r = FileTreeItem::Sorter::compare(column, a.get(), b.get()); + } + + if (order == Qt::AscendingOrder) { + return (r < 0); + } else { + return (r > 0); + } + }); +} + QString FileTreeItem::virtualPath() const { QString s = "Data\\"; diff --git a/src/filetreeitem.h b/src/filetreeitem.h index 01cd01a7..fc27b0c0 100644 --- a/src/filetreeitem.h +++ b/src/filetreeitem.h @@ -6,6 +6,8 @@ class FileTreeItem { + class Sorter; + public: using Children = std::vector>; @@ -88,6 +90,8 @@ public: return -1; } + void sort(int column, Qt::SortOrder order); + FileTreeItem* parent() { return m_parent; diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index 5424d14b..aa053eeb 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -326,6 +326,39 @@ Qt::ItemFlags FileTreeModel::flags(const QModelIndex& index) const return f; } +void FileTreeModel::sort(int column, Qt::SortOrder order) +{ + emit layoutAboutToBeChanged(); + + m_sort.column = column; + m_sort.order = order; + + const auto oldList = persistentIndexList(); + std::vector> oldItems; + + const auto itemCount = oldList.size(); + oldItems.reserve(static_cast(itemCount)); + + for (int i=0; i(i)]; + newList.append(indexFromItem(*pair.first, pair.second)); + } + + changePersistentIndexList(oldList, newList); + + emit layoutChanged({}, QAbstractItemModel::VerticalSortHint); +} + FileTreeItem* FileTreeModel::itemFromIndex(const QModelIndex& index) const { if (!index.isValid()) { @@ -349,7 +382,7 @@ FileTreeItem* FileTreeModel::itemFromIndex(const QModelIndex& index) const return parentItem->children()[index.row()].get(); } -QModelIndex FileTreeModel::indexFromItem(FileTreeItem& item) const +QModelIndex FileTreeModel::indexFromItem(FileTreeItem& item, int col) const { auto* parent = item.parent(); if (!parent) { @@ -365,7 +398,7 @@ QModelIndex FileTreeModel::indexFromItem(FileTreeItem& item) const return {}; } - return createIndex(index, 0, parent); + return createIndex(index, col, parent); } void FileTreeModel::update( @@ -383,13 +416,24 @@ void FileTreeModel::update( path += parentEntry.getName(); } - updateDirectories(parentItem, path, parentEntry, FillFlag::None); - updateFiles(parentItem, path, parentEntry); - parentItem.setLoaded(true); + + bool added = false; + + if (updateDirectories(parentItem, path, parentEntry, FillFlag::None)) { + added = true; + } + + if (updateFiles(parentItem, path, parentEntry)) { + added = true; + } + + if (added) { + parentItem.sort(m_sort.column, m_sort.order); + } } -void FileTreeModel::updateDirectories( +bool FileTreeModel::updateDirectories( FileTreeItem& parentItem, const std::wstring& parentPath, const MOShared::DirectoryEntry& parentEntry, FillFlags flags) { @@ -399,7 +443,7 @@ void FileTreeModel::updateDirectories( std::unordered_set seen; removeDisappearingDirectories(parentItem, parentEntry, parentPath, seen); - addNewDirectories(parentItem, parentEntry, parentPath, seen); + return addNewDirectories(parentItem, parentEntry, parentPath, seen); } void FileTreeModel::removeDisappearingDirectories( @@ -453,7 +497,7 @@ void FileTreeModel::removeDisappearingDirectories( range.remove(); } -void FileTreeModel::addNewDirectories( +bool FileTreeModel::addNewDirectories( FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, const std::unordered_set& seen) @@ -462,6 +506,7 @@ void FileTreeModel::addNewDirectories( // avoid calling beginAddRows(), etc. for each item Range range(this, parentItem); std::vector> toAdd; + bool added = false; // for each directory on the filesystem for (auto&& d : parentEntry.getSubDirectories()) { @@ -477,6 +522,8 @@ void FileTreeModel::addNewDirectories( trace([&]{ log::debug("new dir {}", QString::fromStdWString(d->getName())); }); toAdd.push_back(createDirectoryItem(parentItem, parentPath, *d)); + added = true; + range.includeCurrent(); } @@ -485,9 +532,11 @@ void FileTreeModel::addNewDirectories( // add the last directory range, if any range.add(std::move(toAdd)); + + return added; } -void FileTreeModel::updateFiles( +bool FileTreeModel::updateFiles( FileTreeItem& parentItem, const std::wstring& parentPath, const MOShared::DirectoryEntry& parentEntry) { @@ -499,7 +548,7 @@ void FileTreeModel::updateFiles( int firstFileRow = 0; removeDisappearingFiles(parentItem, parentEntry, firstFileRow, seen); - addNewFiles(parentItem, parentEntry, parentPath, firstFileRow, seen); + return addNewFiles(parentItem, parentEntry, parentPath, firstFileRow, seen); } void FileTreeModel::removeDisappearingFiles( @@ -557,7 +606,7 @@ void FileTreeModel::removeDisappearingFiles( } } -void FileTreeModel::addNewFiles( +bool FileTreeModel::addNewFiles( FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, const int firstFileRow, const std::unordered_set& seen) @@ -566,6 +615,7 @@ void FileTreeModel::addNewFiles( // avoid calling beginAddRows(), etc. for each item std::vector> toAdd; Range range(this, parentItem, firstFileRow); + bool added = false; // for each directory on the filesystem parentEntry.forEachFileIndex([&](auto&& fileIndex) { @@ -591,6 +641,8 @@ void FileTreeModel::addNewFiles( trace([&]{ log::debug("new file {}", QString::fromStdWString(file->getName())); }); toAdd.push_back(createFileItem(parentItem, parentPath, *file)); + added = true; + range.includeCurrent(); } @@ -601,6 +653,8 @@ void FileTreeModel::addNewFiles( // add the last file range, if any range.add(std::move(toAdd)); + + return added; } std::unique_ptr FileTreeModel::createDirectoryItem( @@ -650,7 +704,7 @@ QVariant FileTreeModel::displayData(const FileTreeItem* item, int column) const { switch (column) { - case Filename: + case FileName: { return item->filename(); } @@ -681,7 +735,7 @@ QVariant FileTreeModel::displayData(const FileTreeItem* item, int column) const default: { - break; + return {}; } } } diff --git a/src/filetreemodel.h b/src/filetreemodel.h index 96e9e5a7..38f611f9 100644 --- a/src/filetreemodel.h +++ b/src/filetreemodel.h @@ -22,7 +22,7 @@ public: enum Columns { - Filename = 0, + FileName = 0, ModName, FileType, FileSize, @@ -53,6 +53,7 @@ public: QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const override; QVariant headerData(int i, Qt::Orientation ori, int role=Qt::DisplayRole) const override; Qt::ItemFlags flags(const QModelIndex& index) const override; + void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override; FileTreeItem* itemFromIndex(const QModelIndex& index) const; @@ -63,6 +64,12 @@ private: PruneDirectories = 0x01 }; + struct Sort + { + int column = 0; + Qt::SortOrder order = Qt::AscendingOrder; + }; + class Range; Q_DECLARE_FLAGS(FillFlags, FillFlag); @@ -75,6 +82,7 @@ private: mutable std::vector m_iconPending; mutable QTimer m_iconPendingTimer; bool m_isRefreshing; + Sort m_sort; bool showConflicts() const { @@ -89,7 +97,7 @@ private: const std::wstring& parentPath); - void updateDirectories( + bool updateDirectories( FileTreeItem& parentItem, const std::wstring& path, const MOShared::DirectoryEntry& parentEntry, FillFlags flags); @@ -97,13 +105,13 @@ private: FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, std::unordered_set& seen); - void addNewDirectories( + bool addNewDirectories( FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, const std::unordered_set& seen); - void updateFiles( + bool updateFiles( FileTreeItem& parentItem, const std::wstring& path, const MOShared::DirectoryEntry& parentEntry); @@ -111,7 +119,7 @@ private: FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, int& firstFileRow, std::unordered_set& seen); - void addNewFiles( + bool addNewFiles( FileTreeItem& parentItem, const MOShared::DirectoryEntry& parentEntry, const std::wstring& parentPath, int firstFileRow, const std::unordered_set& seen); @@ -138,7 +146,7 @@ private: QString makeTooltip(const FileTreeItem& item) const; QVariant makeIcon(const FileTreeItem& item, const QModelIndex& index) const; - QModelIndex indexFromItem(FileTreeItem& item) const; + QModelIndex indexFromItem(FileTreeItem& item, int col=0) const; }; Q_DECLARE_OPERATORS_FOR_FLAGS(FileTreeModel::Flags); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index da9f949c..62425d8c 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1091,6 +1091,9 @@ p, li { white-space: pre-wrap; } true + + true + 400 -- cgit v1.3.1 From 85a9f810a0ecbf10facc8b8b070eda6f13a65d6b Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 1 Feb 2020 02:35:52 -0500 Subject: moved refresh and checkboxes to the top --- src/mainwindow.ui | 89 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 38 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 62425d8c..f0887f56 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1056,53 +1056,37 @@ p, li { white-space: pre-wrap; } 6 - - - refresh data-directory overview - - - Refresh the overview. This may take a moment. - - - Refresh - - - - :/MO/gui/resources/view-refresh.png:/MO/gui/resources/view-refresh.png - - - - - + - - - Qt::CustomContextMenu + + + refresh data-directory overview - This is an overview of your data directory as visible to the game (and tools). + Refresh the overview. This may take a moment. - - true + + Refresh - - QAbstractItemView::ExtendedSelection + + + :/MO/gui/resources/view-refresh.png:/MO/gui/resources/view-refresh.png - - true + + + + + + Qt::Horizontal - - true + + + 40 + 20 + - - 400 - - + - - - - @@ -1134,6 +1118,35 @@ p, li { white-space: pre-wrap; } + + + + + + Qt::CustomContextMenu + + + This is an overview of your data directory as visible to the game (and tools). + + + true + + + QAbstractItemView::ExtendedSelection + + + true + + + true + + + 400 + + + + + -- cgit v1.3.1 From 34b022a2297b869c7be306e3f6bf8e124adaf1a7 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Wed, 5 Feb 2020 16:21:41 -0500 Subject: fixed warning when comparing empty strings filter in data tab fixed some bad iterators when removing rows fixed empty directories not being marked as such when refreshing always sort directories first even when reversing the sort order fixed children not being sorted fixed errors about file sizes for directories remember state of checkboxes in data tab --- src/datatab.cpp | 28 ++++++++++++++++++-- src/datatab.h | 2 ++ src/filetree.cpp | 24 ++++++++++++++--- src/filetree.h | 3 +++ src/filetreeitem.cpp | 20 ++++++++++++--- src/filetreemodel.cpp | 71 ++++++++++++++++++++++++++++++++++++--------------- src/filetreemodel.h | 3 +++ src/mainwindow.cpp | 22 +++++++--------- src/mainwindow.h | 2 -- src/mainwindow.ui | 13 +++++++--- src/modinfodialog.cpp | 12 +++++++++ 11 files changed, 152 insertions(+), 48 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/datatab.cpp b/src/datatab.cpp index 3923ba4e..74fa35ce 100644 --- a/src/datatab.cpp +++ b/src/datatab.cpp @@ -21,10 +21,21 @@ DataTab::DataTab( QWidget* parent, Ui::MainWindow* mwui) : m_core(core), m_pluginContainer(pc), m_parent(parent), ui{ - mwui->btnRefreshData, mwui->dataTree, - mwui->conflictsCheckBox, mwui->showArchiveDataCheckBox} + mwui->dataTabRefresh, mwui->dataTree, + mwui->dataTabShowOnlyConflicts, mwui->dataTabShowFromArchives} { m_filetree.reset(new FileTree(core, m_pluginContainer, ui.tree)); + m_filter.setUseSourceSort(true); + m_filter.setEdit(mwui->dataTabFilter); + m_filter.setList(mwui->dataTree); + + if (auto* m=m_filter.proxyModel()) { + m->setDynamicSortFilter(false); + } + + connect( + &m_filter, &FilterWidget::aboutToChange, + [&]{ m_filetree->ensureFullyLoaded(); }); connect( ui.refresh, &QPushButton::clicked, @@ -54,6 +65,8 @@ DataTab::DataTab( 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) @@ -63,6 +76,9 @@ void DataTab::restoreState(const Settings& s) // 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() @@ -82,6 +98,14 @@ void DataTab::onRefresh() void DataTab::updateTree() { m_filetree->refresh(); + + if (!m_filter.empty()) { + m_filetree->ensureFullyLoaded(); + + if (auto* m=m_filter.proxyModel()) { + m->invalidate(); + } + } } void DataTab::onConflicts() diff --git a/src/datatab.h b/src/datatab.h index 4545dc5a..7e8eb2b9 100644 --- a/src/datatab.h +++ b/src/datatab.h @@ -1,5 +1,6 @@ #include "modinfodialogfwd.h" #include "modinfo.h" +#include #include #include #include @@ -47,6 +48,7 @@ private: DataTabUi ui; std::unique_ptr m_filetree; std::vector m_removeLater; + MOBase::FilterWidget m_filter; void onRefresh(); void onItemExpanded(QTreeWidgetItem* item); diff --git a/src/filetree.cpp b/src/filetree.cpp index bf3a9a7a..ae1fddfe 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -150,11 +150,16 @@ void FileTree::clear() m_model->clear(); } +void FileTree::ensureFullyLoaded() +{ + m_model->ensureFullyLoaded(); +} + FileTreeItem* FileTree::singleSelection() { const auto sel = m_tree->selectionModel()->selectedRows(); if (sel.size() == 1) { - return m_model->itemFromIndex(sel[0]); + return m_model->itemFromIndex(proxiedIndex(sel[0])); } return nullptr; @@ -357,7 +362,7 @@ void FileTree::dumpToFile() const QString file = QFileDialog::getSaveFileName(m_tree->window()); if (file.isEmpty()) { - log::debug("user cancelled"); + log::debug("user canceled"); return; } @@ -432,7 +437,7 @@ void FileTree::dumpToFile( void FileTree::onExpandedChanged(const QModelIndex& index, bool expanded) { - if (auto* item=m_model->itemFromIndex(index)) { + if (auto* item=m_model->itemFromIndex(proxiedIndex(index))) { item->setExpanded(expanded); } } @@ -494,7 +499,7 @@ bool FileTree::showShellMenu(QPoint pos) bool warnOnEmpty = true; for (auto&& index : m_tree->selectionModel()->selectedRows()) { - auto* item = m_model->itemFromIndex(index); + auto* item = m_model->itemFromIndex(proxiedIndex(index)); if (!item) { continue; } @@ -759,3 +764,14 @@ void FileTree::addCommonMenus(QMenu& menu) .callback([&]{ m_tree->collapseAll(); }) .addTo(menu); } + +QModelIndex FileTree::proxiedIndex(const QModelIndex& index) +{ + auto* model = m_tree->model(); + + if (auto* proxy=dynamic_cast(model)) { + return proxy->mapToSource(index); + } else { + return index; + } +} diff --git a/src/filetree.h b/src/filetree.h index 80704f7b..855a1751 100644 --- a/src/filetree.h +++ b/src/filetree.h @@ -21,6 +21,7 @@ public: FileTreeModel* model(); void refresh(); void clear(); + void ensureFullyLoaded(); void open(); void openHooked(); @@ -60,6 +61,8 @@ private: void toggleVisibility(bool b); + QModelIndex proxiedIndex(const QModelIndex& index); + void dumpToFile( QFile& out, const QString& parentPath, const MOShared::DirectoryEntry& entry) const; diff --git a/src/filetreeitem.cpp b/src/filetreeitem.cpp index bb07568a..3332fb7d 100644 --- a/src/filetreeitem.cpp +++ b/src/filetreeitem.cpp @@ -10,6 +10,8 @@ using namespace MOBase; using namespace MOShared; namespace fs = std::filesystem; +constexpr bool AlwaysSortDirectoriesFirst = true; + const QString& directoryFileType() { static QString name; @@ -179,9 +181,17 @@ void FileTreeItem::sort(int column, Qt::SortOrder order) int r = 0; if (a->isDirectory() && !b->isDirectory()) { - r = -1; + if constexpr (AlwaysSortDirectoriesFirst) { + return true; + } else { + r = -1; + } } else if (!a->isDirectory() && b->isDirectory()) { - r = 1; + if constexpr (AlwaysSortDirectoriesFirst) { + return false; + } else { + r = 1; + } } else { r = FileTreeItem::Sorter::compare(column, a.get(), b.get()); } @@ -192,6 +202,10 @@ void FileTreeItem::sort(int column, Qt::SortOrder order) return (r > 0); } }); + + for (auto& child : m_children) { + child->sort(column, order); + } } QString FileTreeItem::virtualPath() const @@ -232,7 +246,7 @@ QFont FileTreeItem::font() const std::optional FileTreeItem::fileSize() const { - if (m_fileSize.empty()) { + if (m_fileSize.empty() && !m_isDirectory) { std::error_code ec; const auto size = fs::file_size(fs::path(m_wsRealPath), ec); diff --git a/src/filetreemodel.cpp b/src/filetreemodel.cpp index aa87edbf..912e2007 100644 --- a/src/filetreemodel.cpp +++ b/src/filetreemodel.cpp @@ -87,31 +87,32 @@ public: // FileTreeItem::Children::const_iterator remove() { - if (m_first == -1) { - // nothing to remove - return m_parentItem.children().begin() + m_current + 1; - } + if (m_first >= 0) { + const auto last = m_current - 1; + const auto parentIndex = m_model->indexFromItem(m_parentItem); - const auto last = m_current - 1; - const auto parentIndex = m_model->indexFromItem(m_parentItem); + trace(log::debug("Range::remove() {} to {}", m_first, last)); - trace(log::debug("Range::remove() {} to {}", m_first, last)); + m_model->beginRemoveRows(parentIndex, m_first, last); - m_model->beginRemoveRows(parentIndex, m_first, last); + m_parentItem.remove( + static_cast(m_first), + static_cast(last - m_first + 1)); - m_parentItem.remove( - static_cast(m_first), - static_cast(last - m_first + 1)); + m_model->endRemoveRows(); - m_model->endRemoveRows(); + m_model->removePendingIcons(parentIndex, m_first, last); - m_model->removePendingIcons(parentIndex, m_first, last); + // adjust current row to account for those that were just removed + m_current -= (m_current - m_first); - // adjust current row to account for those that were just removed - m_current -= (m_current - m_first); + // reset + m_first = -1; + } - // reset - m_first = -1; + if (m_current >= m_parentItem.children().size()) { + return m_parentItem.children().end(); + } return m_parentItem.children().begin() + m_current + 1; } @@ -138,7 +139,7 @@ void* makeInternalPointer(FileTreeItem* item) FileTreeModel::FileTreeModel(OrganizerCore& core, QObject* parent) : QAbstractItemModel(parent), m_core(core), m_root(FileTreeItem::createDirectory(nullptr, L"", L"")), - m_flags(NoFlags) + m_flags(NoFlags), m_fullyLoaded(false) { m_root->setExpanded(true); @@ -148,16 +149,40 @@ FileTreeModel::FileTreeModel(OrganizerCore& core, QObject* parent) : void FileTreeModel::refresh() { TimeThis tt("FileTreeModel::refresh()"); + + m_fullyLoaded = false; update(*m_root, *m_core.directoryStructure(), L""); } void FileTreeModel::clear() { + m_fullyLoaded = false; + beginResetModel(); m_root->clear(); endResetModel(); } +void FileTreeModel::recursiveFetchMore(const QModelIndex& m) +{ + if (canFetchMore(m)) { + fetchMore(m); + } + + for (int i=0; iareChildrenVisible() && item->isLoaded()) { - // the item is loaded (previously expanded but now collapsed), mark - // it as unloaded so it updates when next expanded - item->setLoaded(false); + if (!d->isEmpty()) { + // the item is loaded (previously expanded but now collapsed) and + // has children, mark it as unloaded so it updates when next + // expanded + item->setLoaded(false); + } } } else { // item wouldn't have any children, prune it @@ -694,6 +722,7 @@ bool FileTreeModel::addNewFiles( } else { // this is a new file, but it shouldn't be shown trace(log::debug("new file {}, not shown", QString::fromStdWString(file->getName()))); + return true; } } diff --git a/src/filetreemodel.h b/src/filetreemodel.h index ffd46fac..3e846a0f 100644 --- a/src/filetreemodel.h +++ b/src/filetreemodel.h @@ -43,6 +43,7 @@ public: void refresh(); void clear(); + void ensureFullyLoaded(); QModelIndex index(int row, int col, const QModelIndex& parent={}) const override; QModelIndex parent(const QModelIndex& index) const override; @@ -75,6 +76,7 @@ private: mutable std::vector m_iconPending; mutable QTimer m_iconPendingTimer; Sort m_sort; + bool m_fullyLoaded; bool showConflictsOnly() const { @@ -141,6 +143,7 @@ private: QVariant makeIcon(const FileTreeItem& item, const QModelIndex& index) const; QModelIndex indexFromItem(FileTreeItem& item, int col=0) const; + void recursiveFetchMore(const QModelIndex& m); }; Q_DECLARE_OPERATORS_FOR_FLAGS(FileTreeModel::Flags); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bf0dc61f..439775f8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -455,15 +455,13 @@ MainWindow::MainWindow(Settings &settings if (m_OrganizerCore.getArchiveParsing()) { - ui->showArchiveDataCheckBox->setCheckState(Qt::Checked); - ui->showArchiveDataCheckBox->setEnabled(true); - m_showArchiveData = true; + ui->dataTabShowFromArchives->setCheckState(Qt::Checked); + ui->dataTabShowFromArchives->setEnabled(true); } else { - ui->showArchiveDataCheckBox->setCheckState(Qt::Unchecked); - ui->showArchiveDataCheckBox->setEnabled(false); - m_showArchiveData = false; + ui->dataTabShowFromArchives->setCheckState(Qt::Unchecked); + ui->dataTabShowFromArchives->setEnabled(false); } QApplication::instance()->installEventFilter(this); @@ -1193,7 +1191,7 @@ void MainWindow::downloadFilterChanged(const QString &filter) void MainWindow::expandModList(const QModelIndex &index) { QAbstractItemModel *model = ui->modList->model(); -#pragma message("why is this so complicated? mapping the index doesn't work, probably a bug in QtGroupingProxy?") + for (int i = 0; i < model->rowCount(); ++i) { QModelIndex targetIdx = model->index(i, 0); if (model->data(targetIdx).toString() == index.data().toString()) { @@ -4949,15 +4947,13 @@ void MainWindow::on_actionSettings_triggered() m_OrganizerCore.setArchiveParsing(state); if (!state) { - ui->showArchiveDataCheckBox->setCheckState(Qt::Unchecked); - ui->showArchiveDataCheckBox->setEnabled(false); - m_showArchiveData = false; + ui->dataTabShowFromArchives->setCheckState(Qt::Unchecked); + ui->dataTabShowFromArchives->setEnabled(false); } else { - ui->showArchiveDataCheckBox->setCheckState(Qt::Checked); - ui->showArchiveDataCheckBox->setEnabled(true); - m_showArchiveData = true; + ui->dataTabShowFromArchives->setCheckState(Qt::Checked); + ui->dataTabShowFromArchives->setEnabled(true); } m_OrganizerCore.refreshModList(); m_OrganizerCore.refreshDirectoryStructure(); diff --git a/src/mainwindow.h b/src/mainwindow.h index d50705e3..608bfa64 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -349,8 +349,6 @@ private: bool m_DidUpdateMasterList; - bool m_showArchiveData{ true }; - MOBase::DelayedFileWriter m_ArchiveListWriter; QAction* m_LinkToolbar; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f0887f56..8bd22ff1 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1058,7 +1058,7 @@ p, li { white-space: pre-wrap; } - + refresh data-directory overview @@ -1088,7 +1088,7 @@ p, li { white-space: pre-wrap; } - + Filters the above list so that only conflicts are displayed. @@ -1101,7 +1101,7 @@ p, li { white-space: pre-wrap; } - + Filters the above list so that files from archives are not shown @@ -1147,6 +1147,13 @@ p, li { white-space: pre-wrap; } + + + + + + + diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index b0a4248e..fb093529 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -47,6 +47,18 @@ int naturalCompare(const QString& a, const QString& b) return c; }(); + + // todo: remove this once the fix is released + // see https://bugreports.qt.io/projects/QTBUG/issues/QTBUG-81673 + // and https://codereview.qt-project.org/c/qt/qtbase/+/287966/5/src/corelib/text/qcollator_win.cpp + if (!a.size()) { + return b.size() ? -1 : 0; + } + if (!b.size()) { + return +1; + } + + return c.compare(a, b); } -- cgit v1.3.1 From ea0429342ade6e908807ff1faef7c8f7e5e46b75 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Wed, 5 Feb 2020 19:11:49 -0500 Subject: harmonized widgets in the tabs, fixed styles --- src/downloadlistwidget.cpp | 1 + src/mainwindow.ui | 262 ++++++++++++----------------------- src/moapplication.cpp | 6 +- src/modlist.cpp | 5 - src/pluginlist.cpp | 5 - src/stylesheets/vs15 Dark-Green.qss | 13 -- src/stylesheets/vs15 Dark-Orange.qss | 15 +- src/stylesheets/vs15 Dark-Purple.qss | 15 +- src/stylesheets/vs15 Dark-Red.qss | 15 +- src/stylesheets/vs15 Dark-Yellow.qss | 16 +-- src/stylesheets/vs15 Dark.qss | 13 -- 11 files changed, 101 insertions(+), 265 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/downloadlistwidget.cpp b/src/downloadlistwidget.cpp index ac37b0ee..5ca6cb51 100644 --- a/src/downloadlistwidget.cpp +++ b/src/downloadlistwidget.cpp @@ -103,6 +103,7 @@ DownloadListWidget::DownloadListWidget(QWidget *parent) { setHeader(new DownloadListHeader(Qt::Horizontal, this)); + header()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); header()->setSectionsMovable(true); header()->setContextMenuPolicy(Qt::CustomContextMenu); header()->setCascadingSectionResizes(true); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8bd22ff1..acf6767f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,7 +6,7 @@ 0 0 - 926 + 1009 710 @@ -97,12 +97,6 @@ true - - true - - - true - false @@ -781,22 +775,16 @@ p, li { white-space: pre-wrap; } Plugins - - 6 - - - 6 - - - 6 - - - 0 - + + Sort the plugins using LOOT. + + + Sort the plugins using LOOT. + Sort @@ -807,22 +795,28 @@ p, li { white-space: pre-wrap; } - - - Qt::Horizontal + + + Filter the list of plugins. - - - 40 - 20 - + + Filter the list of plugins. - + + + + + Filter + + - Restore Backup... + Restore a backup. + + + Restore a backup. @@ -842,7 +836,10 @@ p, li { white-space: pre-wrap; } - Create Backup + Create a backup. + + + Create a backup. @@ -869,7 +866,7 @@ p, li { white-space: pre-wrap; } - This provides statistics about the plugin list. The total number of active plugins is normally displayed. Other statistics may be accessed with the tooltip of this counter. + <html><head/><body><p>This provides statistics about the plugin list. The total number of active plugins is normally displayed. Other statistics may be accessed with the tooltip of this counter.</p></body></html> QFrame::Sunken @@ -896,14 +893,10 @@ p, li { white-space: pre-wrap; } Qt::CustomContextMenu - List of available esp/esm files + List of available esp/esm files. - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This list contains the esps, esms, and esls contained in the active mods. These require their own load order. Use drag&amp;drop to modify this load order. Please note that MO will only save the load order for mods that are active/checked.<br />There is a great tool named &quot;BOSS&quot; to automatically sort these files.</span></p></body></html> + List of available esp/esm files. QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked @@ -949,20 +942,6 @@ p, li { white-space: pre-wrap; } - - - - - - - - - Filter - - - - - @@ -973,18 +952,6 @@ p, li { white-space: pre-wrap; } Archives - - 6 - - - 6 - - - 6 - - - 6 - @@ -1043,27 +1010,15 @@ p, li { white-space: pre-wrap; } Data - - 6 - - - 6 - - - 6 - - - 6 - - refresh data-directory overview + Refresh the data structure. - Refresh the overview. This may take a moment. + Refresh the data structure. Refresh @@ -1075,44 +1030,41 @@ p, li { white-space: pre-wrap; } - - - Qt::Horizontal + + + Filter the Data tree. - - - 40 - 20 - + + Filter the Data tree. - + - Filters the above list so that only conflicts are displayed. + Filter the list so that only conflicts are displayed. - Filters the above list so that only conflicts are displayed. + Filter the list so that only conflicts are displayed. - Show only conflicts + Conflicts only - Filters the above list so that files from archives are not shown + Filter the list so that files from archives are shown. - Filters the above list so that files from archives are not shown + Filter the list so that files from archives are shown. - Show files from Archives + Archives @@ -1147,13 +1099,6 @@ p, li { white-space: pre-wrap; } - - - - - - - @@ -1161,18 +1106,6 @@ p, li { white-space: pre-wrap; } Saves - - 6 - - - 6 - - - 6 - - - 6 - @@ -1208,31 +1141,52 @@ p, li { white-space: pre-wrap; } Downloads - - 2 - - - 2 - - - 2 - - - 2 - - - - Refresh downloads view - - - Refresh - - - - :/MO/gui/resources/view-refresh.png:/MO/gui/resources/view-refresh.png - - + + + + + Refresh the downloads. + + + Refresh the downloads. + + + Refresh + + + + :/MO/gui/resources/view-refresh.png:/MO/gui/resources/view-refresh.png + + + + + + + Filter the list of downloads. + + + Filter the list of downloads. + + + Filter + + + + + + + Show downloads marked as hidden. + + + Show downloads marked as hidden. + + + Hidden files + + + + @@ -1256,9 +1210,6 @@ p, li { white-space: pre-wrap; } This is a list of mods you downloaded from Nexus. Double click one to install it. You can also drag an archive into here. - - Qt::ScrollBarAlwaysOn - true @@ -1287,37 +1238,6 @@ p, li { white-space: pre-wrap; } - - - - - - Show Hidden - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Filter - - - - - @@ -1370,8 +1290,8 @@ p, li { white-space: pre-wrap; } 0 0 - 926 - 21 + 1009 + 22 diff --git a/src/moapplication.cpp b/src/moapplication.cpp index a071d58b..2fb12809 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -80,7 +80,11 @@ public: MOApplication::MOApplication(int &argc, char **argv) : QApplication(argc, argv) { - connect(&m_StyleWatcher, SIGNAL(fileChanged(QString)), SLOT(updateStyle(QString))); + connect(&m_StyleWatcher, &QFileSystemWatcher::fileChanged, [&](auto&& file){ + log::debug("style file '{}' changed, reloading", file); + updateStyle(file); + }); + m_DefaultStyle = style()->objectName(); setStyle(new ProxyStyle(style())); } diff --git a/src/modlist.cpp b/src/modlist.cpp index c0f18821..31eb8387 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -676,11 +676,6 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, return getColumnToolTip(section); } else if (role == Qt::TextAlignmentRole) { return QVariant(Qt::AlignCenter); - } else if (role == Qt::SizeHintRole) { - QSize temp = m_FontMetrics.size(Qt::TextSingleLine, getColumnName(section)); - temp.rwidth() += 20; - temp.rheight() += 12; - return temp; } } return QAbstractItemModel::headerData(section, orientation, role); diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 3f2f4018..266fe35c 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -1315,11 +1315,6 @@ QVariant PluginList::headerData(int section, Qt::Orientation orientation, return getColumnName(section); } else if (role == Qt::ToolTipRole) { return getColumnToolTip(section); - } else if (role == Qt::SizeHintRole) { - QSize temp = m_FontMetrics.size(Qt::TextSingleLine, getColumnName(section)); - temp.rwidth() += 25; - temp.rheight() += 12; - return temp; } } return QAbstractItemModel::headerData(section, orientation, role); diff --git a/src/stylesheets/vs15 Dark-Green.qss b/src/stylesheets/vs15 Dark-Green.qss index 6d95c6cc..0a3150ad 100644 --- a/src/stylesheets/vs15 Dark-Green.qss +++ b/src/stylesheets/vs15 Dark-Green.qss @@ -692,19 +692,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; diff --git a/src/stylesheets/vs15 Dark-Orange.qss b/src/stylesheets/vs15 Dark-Orange.qss index 2dd27df4..0e1d96b1 100644 --- a/src/stylesheets/vs15 Dark-Orange.qss +++ b/src/stylesheets/vs15 Dark-Orange.qss @@ -603,7 +603,7 @@ SaveGameInfoWidget { border-width: 1px; padding: 2px; } - QStatusBar::item {border: None;} +QStatusBar::item {border: None;} /* Progress Bars (Downloads) #QProgressBar */ QProgressBar { @@ -693,19 +693,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; diff --git a/src/stylesheets/vs15 Dark-Purple.qss b/src/stylesheets/vs15 Dark-Purple.qss index 116aaa7d..c19d188b 100644 --- a/src/stylesheets/vs15 Dark-Purple.qss +++ b/src/stylesheets/vs15 Dark-Purple.qss @@ -603,7 +603,7 @@ SaveGameInfoWidget { border-width: 1px; padding: 2px; } - QStatusBar::item {border: None;} +QStatusBar::item {border: None;} /* Progress Bars (Downloads) #QProgressBar */ QProgressBar { @@ -693,19 +693,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; diff --git a/src/stylesheets/vs15 Dark-Red.qss b/src/stylesheets/vs15 Dark-Red.qss index 60f565a1..a6221dff 100644 --- a/src/stylesheets/vs15 Dark-Red.qss +++ b/src/stylesheets/vs15 Dark-Red.qss @@ -603,7 +603,7 @@ SaveGameInfoWidget { border-width: 1px; padding: 2px; } - QStatusBar::item {border: None;} +QStatusBar::item {border: None;} /* Progress Bars (Downloads) #QProgressBar */ QProgressBar { @@ -693,19 +693,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; diff --git a/src/stylesheets/vs15 Dark-Yellow.qss b/src/stylesheets/vs15 Dark-Yellow.qss index bfaa4c94..fb2e0422 100644 --- a/src/stylesheets/vs15 Dark-Yellow.qss +++ b/src/stylesheets/vs15 Dark-Yellow.qss @@ -1,4 +1,3 @@ -/*base*/ /*!************************************* VS15 Dark **************************************** @@ -603,7 +602,7 @@ SaveGameInfoWidget { border-width: 1px; padding: 2px; } - QStatusBar::item {border: None;} +QStatusBar::item {border: None;} /* Progress Bars (Downloads) #QProgressBar */ QProgressBar { @@ -693,19 +692,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; diff --git a/src/stylesheets/vs15 Dark.qss b/src/stylesheets/vs15 Dark.qss index 1d27be17..17def4dd 100644 --- a/src/stylesheets/vs15 Dark.qss +++ b/src/stylesheets/vs15 Dark.qss @@ -692,19 +692,6 @@ QTabBar QToolButton::left-arrow:hover { image: url(./vs15/scrollbar-left-hover.png); } /* Special styles */ -/* fix margins on tabs pane */ -QLineEdit#espFilterEdit { - margin: 0 0 6px 0; } - -QTreeView#downloadView { - margin: 4px 4px 0 4px; } - -QCheckBox#showHiddenBox { - margin: 0 0 4px 4px; } - -QLineEdit#downloadFilterEdit { - margin: 0 4px 4px 0; } - QWidget#tabImages QPushButton { background-color: transparent; margin: 0 .3em; -- cgit v1.3.1 From b7e51b65e832cfbd94789bc0cf3ab015a394aa92 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Wed, 5 Feb 2020 20:37:18 -0500 Subject: removed bad minimum column width in the data tab fixed crash in log when restart MO --- src/datatab.cpp | 2 +- src/filetree.cpp | 4 ---- src/filetree.h | 1 - src/loglist.cpp | 4 ++-- src/mainwindow.ui | 3 --- 5 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/mainwindow.ui') diff --git a/src/datatab.cpp b/src/datatab.cpp index 74fa35ce..4c42339f 100644 --- a/src/datatab.cpp +++ b/src/datatab.cpp @@ -25,9 +25,9 @@ DataTab::DataTab( mwui->dataTabShowOnlyConflicts, mwui->dataTabShowFromArchives} { m_filetree.reset(new FileTree(core, m_pluginContainer, ui.tree)); - m_filter.setUseSourceSort(true); m_filter.setEdit(mwui->dataTabFilter); m_filter.setList(mwui->dataTree); + m_filter.setUseSourceSort(true); if (auto* m=m_filter.proxyModel()) { m->setDynamicSortFilter(false); diff --git a/src/filetree.cpp b/src/filetree.cpp index ae1fddfe..67fd68c1 100644 --- a/src/filetree.cpp +++ b/src/filetree.cpp @@ -296,10 +296,6 @@ void FileTree::openModInfo() } } -void FileTree::toggleVisibility() -{ -} - void FileTree::toggleVisibility(bool visible) { auto* item = singleSelection(); diff --git a/src/filetree.h b/src/filetree.h index 855a1751..d55b321c 100644 --- a/src/filetree.h +++ b/src/filetree.h @@ -31,7 +31,6 @@ public: void exploreOrigin(); void openModInfo(); - void toggleVisibility(); void hide(); void unhide(); diff --git a/src/loglist.cpp b/src/loglist.cpp index af0e6768..28aae0ff 100644 --- a/src/loglist.cpp +++ b/src/loglist.cpp @@ -173,8 +173,8 @@ LogList::LogList(QWidget* parent) this, &QWidget::customContextMenuRequested, [&](auto&& pos){ onContextMenu(pos); }); - connect(model(), &LogModel::rowsInserted, [&]{ onNewEntry(); }); - connect(model(), &LogModel::dataChanged, [&]{ onNewEntry(); }); + connect(model(), &LogModel::rowsInserted, this, [&]{ onNewEntry(); }); + connect(model(), &LogModel::dataChanged, this, [&]{ onNewEntry(); }); m_timer.setSingleShot(true); connect(&m_timer, &QTimer::timeout, [&]{ scrollToBottom(); }); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index acf6767f..b54d54f8 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1092,9 +1092,6 @@ p, li { white-space: pre-wrap; } true - - 400 - -- cgit v1.3.1