mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-09 08:25:16 +00:00
Simplify numbered_widget_item
This commit is contained in:
parent
46dc40f3f1
commit
dd41ee68de
4 changed files with 70 additions and 44 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "pkg_install_dialog.h"
|
||||
#include "game_compatibility.h"
|
||||
#include "numbered_widget_item.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue