mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-12-03 19:33:33 +01:00
Qt: Move MemoryCardListItem into MemoryCardListWidget
This commit is contained in:
1 parent
a861607ae1
commit
01927fac7a
2 files changed
+25
-28
No files matched your search
@@ -27,34 +27,17 @@ static std::string getSlotFilenameKey(u32 slot)
|
||||
return StringUtil::StdStringFromFormat("Slot%u_Filename", slot + 1);
|
||||
}
|
||||
|
||||
namespace
|
||||
bool MemoryCardListWidget::MemoryCardListItem::operator<(const QTreeWidgetItem& other) const
|
||||
{
|
||||
enum MemoryCardListColumn : int
|
||||
const QTreeWidget* tree = treeWidget();
|
||||
const int column = tree ? tree->sortColumn() : 0;
|
||||
if (column == MemoryCardListColumn::LastModified)
|
||||
{
|
||||
Name,
|
||||
Type,
|
||||
Formatted,
|
||||
LastModified,
|
||||
};
|
||||
|
||||
class MemoryCardListItem : public QTreeWidgetItem
|
||||
{
|
||||
public:
|
||||
using QTreeWidgetItem::QTreeWidgetItem;
|
||||
|
||||
bool operator<(const QTreeWidgetItem& other) const override
|
||||
{
|
||||
const QTreeWidget* tree = treeWidget();
|
||||
const int column = tree ? tree->sortColumn() : 0;
|
||||
if (column == MemoryCardListColumn::LastModified)
|
||||
{
|
||||
return data(MemoryCardListColumn::LastModified, Qt::UserRole).toLongLong() <
|
||||
other.data(MemoryCardListColumn::LastModified, Qt::UserRole).toLongLong();
|
||||
}
|
||||
return text(column).localeAwareCompare(other.text(column)) < 0;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
return data(MemoryCardListColumn::LastModified, Qt::UserRole).toLongLong() <
|
||||
other.data(MemoryCardListColumn::LastModified, Qt::UserRole).toLongLong();
|
||||
}
|
||||
return text(column).localeAwareCompare(other.text(column)) < 0;
|
||||
}
|
||||
|
||||
MemoryCardSettingsWidget::MemoryCardSettingsWidget(SettingsWindow* settings_dialog, QWidget* parent)
|
||||
: SettingsWidget(settings_dialog, parent)
|
||||
@@ -386,8 +369,8 @@ void MemoryCardSettingsWidget::saveCardListSortState()
|
||||
void MemoryCardSettingsWidget::loadCardListSortState()
|
||||
{
|
||||
int sort_column = Host::GetBaseIntSettingValue("MemoryCardListView", "SortColumn", 0);
|
||||
if (sort_column < 0 || sort_column > MemoryCardListColumn::LastModified)
|
||||
sort_column = MemoryCardListColumn::Name;
|
||||
if (sort_column < 0 || sort_column > MemoryCardListWidget::MemoryCardListColumn::LastModified)
|
||||
sort_column = MemoryCardListWidget::MemoryCardListColumn::Name;
|
||||
const bool sort_descending = Host::GetBaseBoolSettingValue("MemoryCardListView", "SortDescending", false);
|
||||
m_ui.cardList->sortByColumn(sort_column, sort_descending ? Qt::DescendingOrder : Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,26 @@ class MemoryCardListWidget final : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum MemoryCardListColumn : int
|
||||
{
|
||||
Name,
|
||||
Type,
|
||||
Formatted,
|
||||
LastModified,
|
||||
};
|
||||
|
||||
explicit MemoryCardListWidget(QWidget* parent);
|
||||
~MemoryCardListWidget() override;
|
||||
|
||||
void refresh(SettingsWindow* dialog);
|
||||
|
||||
protected:
|
||||
class MemoryCardListItem : public QTreeWidgetItem
|
||||
{
|
||||
public:
|
||||
bool operator<(const QTreeWidgetItem& other) const override;
|
||||
};
|
||||
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
|
||||
|
||||
Reference in new issue
Block a user