From dd41ee68de1feb41a889b6340538e4b9b232dc6c Mon Sep 17 00:00:00 2001 From: Megamouse Date: Tue, 12 Jan 2021 13:15:14 +0100 Subject: [PATCH] Simplify numbered_widget_item --- rpcs3/rpcs3.vcxproj | 7 +++++ rpcs3/rpcs3.vcxproj.filters | 34 +++++++++++++++++----- rpcs3/rpcs3qt/numbered_widget_item.h | 31 ++++++++++++++++++++ rpcs3/rpcs3qt/pkg_install_dialog.cpp | 42 ++++------------------------ 4 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 rpcs3/rpcs3qt/numbered_widget_item.h diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 6b5509c6d4..d4195e1302 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -2429,6 +2429,7 @@ .\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DQT_CONCURRENT_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\flatbuffers\include" "-I.\..\3rdparty\wolfssl" "-I.\..\3rdparty\curl\include" "-I.\..\3rdparty\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\XAudio2Redist\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" "-I$(QTDIR)\include\QtConcurrent" + $(QTDIR)\bin\moc.exe;%(FullPath) @@ -3044,6 +3045,12 @@ "$(QTDIR)\bin\uic.exe" -o ".\QTGeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + + + + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index d797365bc7..e45b4743a9 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -137,6 +137,9 @@ {ff7eb8a7-5545-41af-bab1-348032b9a430} + + {949cff6d-9cc5-4a8a-a453-a5144da8ecf4} + @@ -1109,7 +1112,7 @@ Io\DualSense - Gui\game list + Gui\custom items @@ -1155,15 +1158,9 @@ Gui\game list - - Gui\game list - Io\evdev - - Gui\game list - Gui\utils @@ -1215,6 +1212,15 @@ Io\DualSense + + Gui\custom items + + + Gui\custom items + + + Gui\custom items + @@ -1449,4 +1455,18 @@ + + + Generated Files\Release - LLVM + + + Generated Files\Debug + + + Generated Files\Release + + + Generated Files\Debug - LLVM + + \ No newline at end of file diff --git a/rpcs3/rpcs3qt/numbered_widget_item.h b/rpcs3/rpcs3qt/numbered_widget_item.h new file mode 100644 index 0000000000..eba7a17918 --- /dev/null +++ b/rpcs3/rpcs3qt/numbered_widget_item.h @@ -0,0 +1,31 @@ +#pragma once + +#include + +class numbered_widget_item final : public QListWidgetItem +{ +public: + explicit numbered_widget_item(const QString& text, QListWidget* listview = nullptr, int type = QListWidgetItem::Type) + : QListWidgetItem(text, listview, type) + { + } + + QVariant data(int role) const override + { + switch (role) + { + case Qt::DisplayRole: + // Return number and original display text (e.g. "14. My Cool Game (BLUS12345)") + return QStringLiteral("%1. %2").arg(listWidget()->row(this) + 1).arg(QListWidgetItem::data(Qt::DisplayRole).toString()); + default: + // Return original data + return QListWidgetItem::data(role); + } + } + + bool operator<(const QListWidgetItem& other) const override + { + // Compare original display text + return QListWidgetItem::data(Qt::DisplayRole).toString() < other.QListWidgetItem::data(Qt::DisplayRole).toString(); + } +}; diff --git a/rpcs3/rpcs3qt/pkg_install_dialog.cpp b/rpcs3/rpcs3qt/pkg_install_dialog.cpp index de1286abf7..3ca7d6ebc9 100644 --- a/rpcs3/rpcs3qt/pkg_install_dialog.cpp +++ b/rpcs3/rpcs3qt/pkg_install_dialog.cpp @@ -1,5 +1,6 @@ #include "pkg_install_dialog.h" #include "game_compatibility.h" +#include "numbered_widget_item.h" #include #include @@ -11,11 +12,10 @@ enum Roles { FullPathRole = Qt::UserRole + 0, - BaseDisplayRole = Qt::UserRole + 1, - ChangelogRole = Qt::UserRole + 2, - TitleRole = Qt::UserRole + 3, - TitleIdRole = Qt::UserRole + 4, - VersionRole = Qt::UserRole + 5, + ChangelogRole = Qt::UserRole + 1, + TitleRole = Qt::UserRole + 2, + TitleIdRole = Qt::UserRole + 3, + VersionRole = Qt::UserRole + 4, }; pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibility* compat, QWidget* parent) @@ -23,38 +23,6 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil { m_dir_list = new QListWidget(this); - class numbered_widget_item final : public QListWidgetItem - { - public: - explicit numbered_widget_item(const QString& text, QListWidget* listview = nullptr, int type = QListWidgetItem::Type) - : QListWidgetItem(text, listview, type) - { - } - - QVariant data(int role) const override - { - QVariant result; - switch (role) - { - case Qt::DisplayRole: - result = QStringLiteral("%1. %2").arg(listWidget()->row(this) + 1).arg(data(Roles::BaseDisplayRole).toString()); - break; - case Roles::BaseDisplayRole: - result = QListWidgetItem::data(Qt::DisplayRole); - break; - default: - result = QListWidgetItem::data(role); - break; - } - return result; - } - - bool operator<(const QListWidgetItem& other) const override - { - return data(Roles::BaseDisplayRole).toString() < other.data(Roles::BaseDisplayRole).toString(); - } - }; - for (const QString& path : paths) { const compat::package_info info = game_compatibility::GetPkgInfo(path, compat);