mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Stop using deprecated methods from QtAlgorithms.
This commit is contained in:
parent
a408b01111
commit
5de0ec94e0
@ -18,6 +18,7 @@
|
||||
|
||||
#include "AutoTypeXCB.h"
|
||||
#include "KeySymMap.h"
|
||||
#include "core/Tools.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <xcb/xcb.h>
|
||||
@ -404,7 +405,7 @@ KeySym AutoTypePlatformX11::charToKeySym(const QChar& ch)
|
||||
}
|
||||
|
||||
/* mapping table generated from keysymdef.h */
|
||||
const uint* match = qBinaryFind(m_unicodeToKeysymKeys,
|
||||
const uint* match = Tools::binaryFind(m_unicodeToKeysymKeys,
|
||||
m_unicodeToKeysymKeys + m_unicodeToKeysymLen,
|
||||
unicode);
|
||||
int index = match - m_unicodeToKeysymKeys;
|
||||
|
@ -18,10 +18,14 @@
|
||||
#ifndef KEEPASSX_TOOLS_H
|
||||
#define KEEPASSX_TOOLS_H
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
class QIODevice;
|
||||
|
||||
namespace Tools {
|
||||
@ -36,6 +40,19 @@ void sleep(int ms);
|
||||
void wait(int ms);
|
||||
void disableCoreDumps();
|
||||
|
||||
template <typename RandomAccessIterator, typename T>
|
||||
KEEPASSX_EXPORT RandomAccessIterator binaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T& value)
|
||||
{
|
||||
RandomAccessIterator it = std::lower_bound(begin, end, value);
|
||||
|
||||
if ((it == end) || (value < *it)) {
|
||||
return end;
|
||||
}
|
||||
else {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
#endif // KEEPASSX_TOOLS_H
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "core/Entry.h"
|
||||
#include "core/Tools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
EntryAttachmentsModel::EntryAttachmentsModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_entryAttachments(nullptr)
|
||||
@ -102,7 +104,7 @@ void EntryAttachmentsModel::attachmentAboutToAdd(const QString& key)
|
||||
{
|
||||
QList<QString> rows = m_entryAttachments->keys();
|
||||
rows.append(key);
|
||||
qSort(rows);
|
||||
std::sort(rows.begin(), rows.end());
|
||||
int row = rows.indexOf(key);
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "core/Entry.h"
|
||||
#include "core/Tools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
EntryAttributesModel::EntryAttributesModel(QObject* parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_entryAttributes(nullptr)
|
||||
@ -152,7 +154,7 @@ void EntryAttributesModel::attributeAboutToAdd(const QString& key)
|
||||
{
|
||||
QList<QString> rows = m_attributes;
|
||||
rows.append(key);
|
||||
qSort(rows);
|
||||
std::sort(rows.begin(), rows.end());
|
||||
int row = rows.indexOf(key);
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
}
|
||||
@ -182,7 +184,7 @@ void EntryAttributesModel::attributeAboutToRename(const QString& oldKey, const Q
|
||||
QList<QString> rows = m_attributes;
|
||||
rows.removeOne(oldKey);
|
||||
rows.append(newKey);
|
||||
qSort(rows);
|
||||
std::sort(rows.begin(), rows.end());
|
||||
int newRow = rows.indexOf(newKey);
|
||||
if (newRow > oldRow) {
|
||||
newRow++;
|
||||
|
Loading…
Reference in New Issue
Block a user