Qt: Fix deprecreated errors with 5.15
This commit is contained in:
parent
73c9a31b86
commit
f443691ad0
|
@ -208,6 +208,88 @@ public:
|
|||
return ascending ? (left.title < right.title) : (right.title < left.title);
|
||||
}
|
||||
|
||||
bool lessThan(const QModelIndex& left_index, const QModelIndex& right_index, int column, bool ascending) const
|
||||
{
|
||||
if (!left_index.isValid() || !right_index.isValid())
|
||||
return false;
|
||||
|
||||
const int left_row = left_index.row();
|
||||
const int right_row = right_index.row();
|
||||
if (left_row < 0 || left_row >= static_cast<int>(m_game_list->GetEntryCount()) || right_row < 0 ||
|
||||
right_row >= static_cast<int>(m_game_list->GetEntryCount()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const GameListEntry& left = m_game_list->GetEntries()[left_row];
|
||||
const GameListEntry& right = m_game_list->GetEntries()[right_row];
|
||||
switch (column)
|
||||
{
|
||||
case Column_Type:
|
||||
{
|
||||
if (left.type == right.type)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
|
||||
return ascending ? (static_cast<int>(left.type) < static_cast<int>(right.type)) :
|
||||
(static_cast<int>(right.type) > static_cast<int>(left.type));
|
||||
}
|
||||
|
||||
case Column_Code:
|
||||
{
|
||||
if (left.code == right.code)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
return ascending ? (left.code < right.code) : (right.code > left.code);
|
||||
}
|
||||
|
||||
case Column_Title:
|
||||
{
|
||||
if (left.title == right.title)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
|
||||
return ascending ? (left.title < right.title) : (right.title > left.title);
|
||||
}
|
||||
|
||||
case Column_FileTitle:
|
||||
{
|
||||
const std::string_view file_title_left(GameList::GetTitleForPath(left.path.c_str()));
|
||||
const std::string_view file_title_right(GameList::GetTitleForPath(right.path.c_str()));
|
||||
if (file_title_left == file_title_right)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
|
||||
return ascending ? (file_title_left < file_title_right) : (file_title_right > file_title_left);
|
||||
}
|
||||
|
||||
case Column_Region:
|
||||
{
|
||||
if (left.region == right.region)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
return ascending ? (static_cast<int>(left.region) < static_cast<int>(right.region)) :
|
||||
(static_cast<int>(right.region) > static_cast<int>(left.region));
|
||||
}
|
||||
|
||||
case Column_Compatibility:
|
||||
{
|
||||
if (left.compatibility_rating == right.compatibility_rating)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
|
||||
return ascending ?
|
||||
(static_cast<int>(left.compatibility_rating) < static_cast<int>(right.compatibility_rating)) :
|
||||
(static_cast<int>(right.compatibility_rating) > static_cast<int>(left.compatibility_rating));
|
||||
}
|
||||
|
||||
case Column_Size:
|
||||
{
|
||||
if (left.total_size == right.total_size)
|
||||
return titlesLessThan(left_row, right_row, ascending);
|
||||
|
||||
return ascending ? (left.total_size < right.total_size) : (right.total_size > left.total_size);
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void loadCommonImages()
|
||||
{
|
||||
|
@ -262,13 +344,7 @@ public:
|
|||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override
|
||||
{
|
||||
const bool ascending = sortOrder() == Qt::AscendingOrder;
|
||||
const QVariant left = source_left.data(Qt::InitialSortOrderRole);
|
||||
const QVariant right = source_right.data(Qt::InitialSortOrderRole);
|
||||
if (left != right)
|
||||
return ascending ? (left < right) : (right > left);
|
||||
|
||||
// fallback to sorting by title for equal items
|
||||
return m_model->titlesLessThan(source_left.row(), source_right.row(), ascending);
|
||||
return m_model->lessThan(source_left, source_right, source_left.column(), ascending);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -796,7 +796,7 @@ void QtHostInterface::changeDisc(const QString& new_disc_filename)
|
|||
static QString FormatTimestampForSaveStateMenu(u64 timestamp)
|
||||
{
|
||||
const QDateTime qtime(QDateTime::fromSecsSinceEpoch(static_cast<qint64>(timestamp)));
|
||||
return qtime.toString(Qt::SystemLocaleShortDate);
|
||||
return qtime.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat));
|
||||
}
|
||||
|
||||
void QtHostInterface::populateSaveStateMenus(const char* game_code, QMenu* load_menu, QMenu* save_menu)
|
||||
|
@ -846,6 +846,7 @@ void QtHostInterface::populateGameListContextMenu(const char* game_code, QWidget
|
|||
load_state_menu->setEnabled(false);
|
||||
|
||||
const std::vector<SaveStateInfo> available_states(GetAvailableSaveStates(game_code));
|
||||
const QString timestamp_format = QLocale::system().dateTimeFormat(QLocale::ShortFormat);
|
||||
for (const SaveStateInfo& ssi : available_states)
|
||||
{
|
||||
if (ssi.global)
|
||||
|
@ -853,7 +854,7 @@ void QtHostInterface::populateGameListContextMenu(const char* game_code, QWidget
|
|||
|
||||
const s32 slot = ssi.slot;
|
||||
const QDateTime timestamp(QDateTime::fromSecsSinceEpoch(static_cast<qint64>(ssi.timestamp)));
|
||||
const QString timestamp_str(timestamp.toString(Qt::SystemLocaleShortDate));
|
||||
const QString timestamp_str(timestamp.toString(timestamp_format));
|
||||
const QString path(QString::fromStdString(ssi.path));
|
||||
|
||||
QAction* action;
|
||||
|
|
Loading…
Reference in New Issue