mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2026-07-27 13:58:24 -07:00
Merge pull request #1057 from isanae/warning-fixes
Fixed warnings about Q_OBJECT and thousand separators
This commit is contained in:
@@ -64,6 +64,7 @@ SET(organizer_SRCS
|
||||
modinfodialog.cpp
|
||||
modinfodialogcategories.cpp
|
||||
modinfodialogconflicts.cpp
|
||||
modinfodialogconflictsmodels.cpp
|
||||
modinfodialogesps.cpp
|
||||
modinfodialogfiletree.cpp
|
||||
modinfodialogimages.cpp
|
||||
@@ -198,6 +199,7 @@ SET(organizer_HDRS
|
||||
modinfodialog.h
|
||||
modinfodialogcategories.h
|
||||
modinfodialogconflicts.h
|
||||
modinfodialogconflictsmodels.h
|
||||
modinfodialogesps.h
|
||||
modinfodialogfiletree.h
|
||||
modinfodialogfwd.h
|
||||
@@ -445,6 +447,7 @@ set(modinfo\\dialog
|
||||
modinfodialog
|
||||
modinfodialogcategories
|
||||
modinfodialogconflicts
|
||||
modinfodialogconflictsmodels
|
||||
modinfodialogesps
|
||||
modinfodialogfiletree
|
||||
modinfodialogfwd
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ public:
|
||||
HandleCloserThread()
|
||||
: m_ready(false)
|
||||
{
|
||||
m_handles.reserve(50'000);
|
||||
m_handles.reserve(50000);
|
||||
}
|
||||
|
||||
void shrink()
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static const std::size_t bufferSize = 50'000;
|
||||
static const std::size_t bufferSize = 50000;
|
||||
|
||||
env::HandlePtr m_stdout;
|
||||
env::HandlePtr m_readEvent;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "modinfodialogconflicts.h"
|
||||
#include "ui_modinfodialog.h"
|
||||
#include "modinfodialogconflictsmodels.h"
|
||||
#include "modinfodialog.h"
|
||||
#include "utility.h"
|
||||
#include "settings.h"
|
||||
@@ -15,337 +16,6 @@ using namespace MOBase;
|
||||
// checking whether menu items apply to them, just show all of them
|
||||
const std::size_t max_small_selection = 50;
|
||||
|
||||
class ConflictItem
|
||||
{
|
||||
public:
|
||||
ConflictItem(
|
||||
QString before, QString relativeName, QString after,
|
||||
FileIndex index, QString fileName,
|
||||
bool hasAltOrigins, QString altOrigin, bool archive) :
|
||||
m_before(std::move(before)),
|
||||
m_relativeName(std::move(relativeName)),
|
||||
m_after(std::move(after)),
|
||||
m_index(index),
|
||||
m_fileName(std::move(fileName)),
|
||||
m_hasAltOrigins(hasAltOrigins),
|
||||
m_altOrigin(std::move(altOrigin)),
|
||||
m_isArchive(archive)
|
||||
{
|
||||
}
|
||||
|
||||
const QString& before() const
|
||||
{
|
||||
return m_before;
|
||||
}
|
||||
|
||||
const QString& relativeName() const
|
||||
{
|
||||
return m_relativeName;
|
||||
}
|
||||
|
||||
const QString& after() const
|
||||
{
|
||||
return m_after;
|
||||
}
|
||||
|
||||
const QString& fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
const QString& altOrigin() const
|
||||
{
|
||||
return m_altOrigin;
|
||||
}
|
||||
|
||||
bool hasAlts() const
|
||||
{
|
||||
return m_hasAltOrigins;
|
||||
}
|
||||
|
||||
bool isArchive() const
|
||||
{
|
||||
return m_isArchive;
|
||||
}
|
||||
|
||||
FileIndex fileIndex() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
bool canHide() const
|
||||
{
|
||||
return canHideFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool canUnhide() const
|
||||
{
|
||||
return canUnhideFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool canRun() const
|
||||
{
|
||||
return canRunFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool canOpen() const
|
||||
{
|
||||
return canOpenFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool canPreview(PluginContainer& pluginContainer) const
|
||||
{
|
||||
return canPreviewFile(pluginContainer, isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool canExplore() const
|
||||
{
|
||||
return canExploreFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_before;
|
||||
QString m_relativeName;
|
||||
QString m_after;
|
||||
FileIndex m_index;
|
||||
QString m_fileName;
|
||||
bool m_hasAltOrigins;
|
||||
QString m_altOrigin;
|
||||
bool m_isArchive;
|
||||
};
|
||||
|
||||
|
||||
class ConflictListModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
struct Column
|
||||
{
|
||||
QString caption;
|
||||
const QString& (ConflictItem::*getText)() const;
|
||||
};
|
||||
|
||||
ConflictListModel(QTreeView* tree, std::vector<Column> columns) :
|
||||
m_tree(tree), m_columns(std::move(columns)),
|
||||
m_sortColumn(-1), m_sortOrder(Qt::AscendingOrder)
|
||||
{
|
||||
m_tree->setModel(this);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_items.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void reserve(std::size_t s)
|
||||
{
|
||||
m_items.reserve(s);
|
||||
}
|
||||
|
||||
QModelIndex index(int row, int col, const QModelIndex& ={}) const override
|
||||
{
|
||||
return createIndex(row, col);
|
||||
}
|
||||
|
||||
QModelIndex parent(const QModelIndex&) const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int rowCount(const QModelIndex& parent={}) const override
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<int>(m_items.size());
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex& ={}) const override
|
||||
{
|
||||
return static_cast<int>(m_columns.size());
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override
|
||||
{
|
||||
if (role == Qt::DisplayRole || role == Qt::FontRole) {
|
||||
const auto row = index.row();
|
||||
if (row < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto i = static_cast<std::size_t>(row);
|
||||
if (i >= m_items.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto col = index.column();
|
||||
if (col < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto c = static_cast<std::size_t>(col);
|
||||
if (c >= m_columns.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto& item = m_items[i];
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return (item.*m_columns[c].getText)();
|
||||
} else if (role == Qt::FontRole) {
|
||||
if (item.isArchive()) {
|
||||
QFont f = m_tree->font();
|
||||
f.setItalic(true);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant headerData(int col, Qt::Orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (col < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto i = static_cast<std::size_t>(col);
|
||||
if (i >= m_columns.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return m_columns[i].caption;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void sort(int colIndex, Qt::SortOrder order=Qt::AscendingOrder)
|
||||
{
|
||||
m_sortColumn = colIndex;
|
||||
m_sortOrder = order;
|
||||
|
||||
doSort();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
|
||||
void add(ConflictItem item)
|
||||
{
|
||||
m_items.emplace_back(std::move(item));
|
||||
}
|
||||
|
||||
void finished()
|
||||
{
|
||||
endResetModel();
|
||||
doSort();
|
||||
}
|
||||
|
||||
const ConflictItem* getItem(std::size_t row) const
|
||||
{
|
||||
if (row >= m_items.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &m_items[row];
|
||||
}
|
||||
|
||||
private:
|
||||
QTreeView* m_tree;
|
||||
std::vector<Column> m_columns;
|
||||
std::vector<ConflictItem> m_items;
|
||||
int m_sortColumn;
|
||||
Qt::SortOrder m_sortOrder;
|
||||
|
||||
void doSort()
|
||||
{
|
||||
if (m_items.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sortColumn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto c = static_cast<std::size_t>(m_sortColumn);
|
||||
if (c >= m_columns.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& col = m_columns[c];
|
||||
|
||||
// avoids branching on sort order while sorting
|
||||
auto sortAsc = [&](const auto& a, const auto& b) {
|
||||
return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) < 0);
|
||||
};
|
||||
|
||||
auto sortDesc = [&](const auto& a, const auto& b) {
|
||||
return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) > 0);
|
||||
};
|
||||
|
||||
if (m_sortOrder == Qt::AscendingOrder) {
|
||||
std::sort(m_items.begin(), m_items.end(), sortAsc);
|
||||
} else {
|
||||
std::sort(m_items.begin(), m_items.end(), sortDesc);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class OverwriteConflictListModel : public ConflictListModel
|
||||
{
|
||||
public:
|
||||
OverwriteConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Overwritten Mods"), &ConflictItem::before}
|
||||
})
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class OverwrittenConflictListModel : public ConflictListModel
|
||||
{
|
||||
public:
|
||||
OverwrittenConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Providing Mod"), &ConflictItem::after}
|
||||
})
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class NoConflictListModel : public ConflictListModel
|
||||
{
|
||||
public:
|
||||
NoConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName}
|
||||
})
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class AdvancedConflictListModel : public ConflictListModel
|
||||
{
|
||||
public:
|
||||
AdvancedConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("Overwrites"), &ConflictItem::before},
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Overwritten By"), &ConflictItem::after}
|
||||
})
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
std::size_t smallSelectionSize(const QTreeView* tree)
|
||||
{
|
||||
const std::size_t too_many = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
#include "modinfodialogconflictsmodels.h"
|
||||
#include "modinfodialog.h"
|
||||
|
||||
ConflictItem::ConflictItem(
|
||||
QString before, QString relativeName, QString after,
|
||||
MOShared::FileIndex index, QString fileName,
|
||||
bool hasAltOrigins, QString altOrigin, bool archive) :
|
||||
m_before(std::move(before)),
|
||||
m_relativeName(std::move(relativeName)),
|
||||
m_after(std::move(after)),
|
||||
m_index(index),
|
||||
m_fileName(std::move(fileName)),
|
||||
m_hasAltOrigins(hasAltOrigins),
|
||||
m_altOrigin(std::move(altOrigin)),
|
||||
m_isArchive(archive)
|
||||
{
|
||||
}
|
||||
|
||||
const QString& ConflictItem::before() const
|
||||
{
|
||||
return m_before;
|
||||
}
|
||||
|
||||
const QString& ConflictItem::relativeName() const
|
||||
{
|
||||
return m_relativeName;
|
||||
}
|
||||
|
||||
const QString& ConflictItem::after() const
|
||||
{
|
||||
return m_after;
|
||||
}
|
||||
|
||||
const QString& ConflictItem::fileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
const QString& ConflictItem::altOrigin() const
|
||||
{
|
||||
return m_altOrigin;
|
||||
}
|
||||
|
||||
bool ConflictItem::hasAlts() const
|
||||
{
|
||||
return m_hasAltOrigins;
|
||||
}
|
||||
|
||||
bool ConflictItem::isArchive() const
|
||||
{
|
||||
return m_isArchive;
|
||||
}
|
||||
|
||||
MOShared::FileIndex ConflictItem::fileIndex() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
bool ConflictItem::canHide() const
|
||||
{
|
||||
return canHideFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool ConflictItem::canUnhide() const
|
||||
{
|
||||
return canUnhideFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool ConflictItem::canRun() const
|
||||
{
|
||||
return canRunFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool ConflictItem::canOpen() const
|
||||
{
|
||||
return canOpenFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool ConflictItem::canPreview(PluginContainer& pluginContainer) const
|
||||
{
|
||||
return canPreviewFile(pluginContainer, isArchive(), fileName());
|
||||
}
|
||||
|
||||
bool ConflictItem::canExplore() const
|
||||
{
|
||||
return canExploreFile(isArchive(), fileName());
|
||||
}
|
||||
|
||||
|
||||
ConflictListModel::ConflictListModel(QTreeView* tree, std::vector<Column> columns) :
|
||||
m_tree(tree), m_columns(std::move(columns)),
|
||||
m_sortColumn(-1), m_sortOrder(Qt::AscendingOrder)
|
||||
{
|
||||
m_tree->setModel(this);
|
||||
}
|
||||
|
||||
void ConflictListModel::clear()
|
||||
{
|
||||
m_items.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ConflictListModel::reserve(std::size_t s)
|
||||
{
|
||||
m_items.reserve(s);
|
||||
}
|
||||
|
||||
QModelIndex ConflictListModel::index(int row, int col, const QModelIndex&) const
|
||||
{
|
||||
return createIndex(row, col);
|
||||
}
|
||||
|
||||
QModelIndex ConflictListModel::parent(const QModelIndex&) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int ConflictListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<int>(m_items.size());
|
||||
}
|
||||
|
||||
int ConflictListModel::columnCount(const QModelIndex&) const
|
||||
{
|
||||
return static_cast<int>(m_columns.size());
|
||||
}
|
||||
|
||||
QVariant ConflictListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole || role == Qt::FontRole) {
|
||||
const auto row = index.row();
|
||||
if (row < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto i = static_cast<std::size_t>(row);
|
||||
if (i >= m_items.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto col = index.column();
|
||||
if (col < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto c = static_cast<std::size_t>(col);
|
||||
if (c >= m_columns.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto& item = m_items[i];
|
||||
|
||||
if (role == Qt::DisplayRole) {
|
||||
return (item.*m_columns[c].getText)();
|
||||
} else if (role == Qt::FontRole) {
|
||||
if (item.isArchive()) {
|
||||
QFont f = m_tree->font();
|
||||
f.setItalic(true);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant ConflictListModel::headerData(int col, Qt::Orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (col < 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto i = static_cast<std::size_t>(col);
|
||||
if (i >= m_columns.size()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return m_columns[i].caption;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void ConflictListModel::sort(int colIndex, Qt::SortOrder order)
|
||||
{
|
||||
m_sortColumn = colIndex;
|
||||
m_sortOrder = order;
|
||||
|
||||
doSort();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
|
||||
void ConflictListModel::add(ConflictItem item)
|
||||
{
|
||||
m_items.emplace_back(std::move(item));
|
||||
}
|
||||
|
||||
void ConflictListModel::finished()
|
||||
{
|
||||
endResetModel();
|
||||
doSort();
|
||||
}
|
||||
|
||||
const ConflictItem* ConflictListModel::getItem(std::size_t row) const
|
||||
{
|
||||
if (row >= m_items.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &m_items[row];
|
||||
}
|
||||
|
||||
void ConflictListModel::doSort()
|
||||
{
|
||||
if (m_items.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sortColumn < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto c = static_cast<std::size_t>(m_sortColumn);
|
||||
if (c >= m_columns.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& col = m_columns[c];
|
||||
|
||||
// avoids branching on sort order while sorting
|
||||
auto sortAsc = [&](const auto& a, const auto& b) {
|
||||
return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) < 0);
|
||||
};
|
||||
|
||||
auto sortDesc = [&](const auto& a, const auto& b) {
|
||||
return (naturalCompare((a.*col.getText)(), (b.*col.getText)()) > 0);
|
||||
};
|
||||
|
||||
if (m_sortOrder == Qt::AscendingOrder) {
|
||||
std::sort(m_items.begin(), m_items.end(), sortAsc);
|
||||
} else {
|
||||
std::sort(m_items.begin(), m_items.end(), sortDesc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OverwriteConflictListModel::OverwriteConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Overwritten Mods"), &ConflictItem::before}
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
OverwrittenConflictListModel::OverwrittenConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Providing Mod"), &ConflictItem::after}
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NoConflictListModel::NoConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("File"), &ConflictItem::relativeName}
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AdvancedConflictListModel::AdvancedConflictListModel(QTreeView* tree)
|
||||
: ConflictListModel(tree, {
|
||||
{tr("Overwrites"), &ConflictItem::before},
|
||||
{tr("File"), &ConflictItem::relativeName},
|
||||
{tr("Overwritten By"), &ConflictItem::after}
|
||||
})
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "shared/fileentry.h"
|
||||
|
||||
class PluginContainer;
|
||||
|
||||
class ConflictItem
|
||||
{
|
||||
public:
|
||||
ConflictItem(
|
||||
QString before, QString relativeName, QString after,
|
||||
MOShared::FileIndex index, QString fileName,
|
||||
bool hasAltOrigins, QString altOrigin, bool archive);
|
||||
|
||||
const QString& before() const;
|
||||
const QString& relativeName() const;
|
||||
const QString& after() const;
|
||||
|
||||
const QString& fileName() const;
|
||||
const QString& altOrigin() const;
|
||||
|
||||
bool hasAlts() const;
|
||||
bool isArchive() const;
|
||||
|
||||
MOShared::FileIndex fileIndex() const;
|
||||
|
||||
bool canHide() const;
|
||||
bool canUnhide() const;
|
||||
bool canRun() const;
|
||||
bool canOpen() const;
|
||||
bool canPreview(PluginContainer& pluginContainer) const;
|
||||
bool canExplore() const;
|
||||
|
||||
private:
|
||||
QString m_before;
|
||||
QString m_relativeName;
|
||||
QString m_after;
|
||||
MOShared::FileIndex m_index;
|
||||
QString m_fileName;
|
||||
bool m_hasAltOrigins;
|
||||
QString m_altOrigin;
|
||||
bool m_isArchive;
|
||||
};
|
||||
|
||||
|
||||
class ConflictListModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
struct Column
|
||||
{
|
||||
QString caption;
|
||||
const QString& (ConflictItem::*getText)() const;
|
||||
};
|
||||
|
||||
ConflictListModel(QTreeView* tree, std::vector<Column> columns);
|
||||
|
||||
void clear();
|
||||
void reserve(std::size_t s);
|
||||
|
||||
QModelIndex index(int row, int col, const QModelIndex& ={}) const override;
|
||||
QModelIndex parent(const QModelIndex&) const override;
|
||||
int rowCount(const QModelIndex& parent={}) const override;
|
||||
int columnCount(const QModelIndex& ={}) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
QVariant headerData(int col, Qt::Orientation, int role) const;
|
||||
|
||||
void sort(int colIndex, Qt::SortOrder order=Qt::AscendingOrder);
|
||||
void add(ConflictItem item);
|
||||
|
||||
void finished();
|
||||
|
||||
const ConflictItem* getItem(std::size_t row) const;
|
||||
|
||||
private:
|
||||
QTreeView* m_tree;
|
||||
std::vector<Column> m_columns;
|
||||
std::vector<ConflictItem> m_items;
|
||||
int m_sortColumn;
|
||||
Qt::SortOrder m_sortOrder;
|
||||
|
||||
void doSort();
|
||||
};
|
||||
|
||||
|
||||
class OverwriteConflictListModel : public ConflictListModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OverwriteConflictListModel(QTreeView* tree);
|
||||
};
|
||||
|
||||
|
||||
class OverwrittenConflictListModel : public ConflictListModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OverwrittenConflictListModel(QTreeView* tree);
|
||||
};
|
||||
|
||||
|
||||
class NoConflictListModel : public ConflictListModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
NoConflictListModel(QTreeView* tree);
|
||||
};
|
||||
|
||||
|
||||
class AdvancedConflictListModel : public ConflictListModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
AdvancedConflictListModel(QTreeView* tree);
|
||||
};
|
||||
@@ -27,50 +27,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <QShortcut>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
|
||||
using namespace MOBase;
|
||||
|
||||
|
||||
class MyFileSystemModel : public QFileSystemModel {
|
||||
public:
|
||||
MyFileSystemModel(QObject *parent)
|
||||
: QFileSystemModel(parent), m_RegularColumnCount(0) {}
|
||||
|
||||
virtual int columnCount(const QModelIndex &parent) const {
|
||||
m_RegularColumnCount = QFileSystemModel::columnCount(parent);
|
||||
return m_RegularColumnCount;
|
||||
}
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if ((orientation == Qt::Horizontal) &&
|
||||
(section >= m_RegularColumnCount)) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
return tr("Overwrites");
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QFileSystemModel::headerData(section, orientation, role);
|
||||
}
|
||||
}
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const {
|
||||
if (index.column() == m_RegularColumnCount + 0) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
return tr("not implemented");
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QFileSystemModel::data(index, role);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable int m_RegularColumnCount;
|
||||
};
|
||||
|
||||
|
||||
OverwriteInfoDialog::OverwriteInfoDialog(ModInfo::Ptr modInfo, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::OverwriteInfoDialog), m_FileSystemModel(nullptr),
|
||||
m_DeleteAction(nullptr), m_RenameAction(nullptr), m_OpenAction(nullptr)
|
||||
@@ -79,7 +37,7 @@ OverwriteInfoDialog::OverwriteInfoDialog(ModInfo::Ptr modInfo, QWidget *parent)
|
||||
|
||||
this->setWindowModality(Qt::NonModal);
|
||||
|
||||
m_FileSystemModel = new MyFileSystemModel(this);
|
||||
m_FileSystemModel = new OverwriteFileSystemModel(this);
|
||||
m_FileSystemModel->setReadOnly(false);
|
||||
setModInfo(modInfo);
|
||||
ui->filesView->setModel(m_FileSystemModel);
|
||||
|
||||
@@ -28,6 +28,49 @@ namespace Ui {
|
||||
class OverwriteInfoDialog;
|
||||
}
|
||||
|
||||
class OverwriteFileSystemModel : public QFileSystemModel
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
OverwriteFileSystemModel(QObject *parent)
|
||||
: QFileSystemModel(parent), m_RegularColumnCount(0) {}
|
||||
|
||||
virtual int columnCount(const QModelIndex &parent) const {
|
||||
m_RegularColumnCount = QFileSystemModel::columnCount(parent);
|
||||
return m_RegularColumnCount;
|
||||
}
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if ((orientation == Qt::Horizontal) &&
|
||||
(section >= m_RegularColumnCount)) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
return tr("Overwrites");
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QFileSystemModel::headerData(section, orientation, role);
|
||||
}
|
||||
}
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role) const {
|
||||
if (index.column() == m_RegularColumnCount + 0) {
|
||||
if (role == Qt::DisplayRole) {
|
||||
return tr("not implemented");
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QFileSystemModel::data(index, role);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable int m_RegularColumnCount;
|
||||
};
|
||||
|
||||
|
||||
class OverwriteInfoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -33,6 +33,8 @@ private:
|
||||
|
||||
class StatusBar : public QStatusBar
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
StatusBar(QWidget* parent=nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user