Stop using deprecated methods from QtAlgorithms.

This commit is contained in:
Felix Geyer 2015-10-13 22:52:07 +02:00
parent a408b01111
commit 5de0ec94e0
4 changed files with 28 additions and 6 deletions

View File

@ -18,6 +18,7 @@
#include "AutoTypeXCB.h" #include "AutoTypeXCB.h"
#include "KeySymMap.h" #include "KeySymMap.h"
#include "core/Tools.h"
#include <time.h> #include <time.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
@ -404,7 +405,7 @@ KeySym AutoTypePlatformX11::charToKeySym(const QChar& ch)
} }
/* mapping table generated from keysymdef.h */ /* mapping table generated from keysymdef.h */
const uint* match = qBinaryFind(m_unicodeToKeysymKeys, const uint* match = Tools::binaryFind(m_unicodeToKeysymKeys,
m_unicodeToKeysymKeys + m_unicodeToKeysymLen, m_unicodeToKeysymKeys + m_unicodeToKeysymLen,
unicode); unicode);
int index = match - m_unicodeToKeysymKeys; int index = match - m_unicodeToKeysymKeys;

View File

@ -18,10 +18,14 @@
#ifndef KEEPASSX_TOOLS_H #ifndef KEEPASSX_TOOLS_H
#define KEEPASSX_TOOLS_H #define KEEPASSX_TOOLS_H
#include "core/Global.h"
#include <QDateTime> #include <QDateTime>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <algorithm>
class QIODevice; class QIODevice;
namespace Tools { namespace Tools {
@ -36,6 +40,19 @@ void sleep(int ms);
void wait(int ms); void wait(int ms);
void disableCoreDumps(); 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 } // namespace Tools
#endif // KEEPASSX_TOOLS_H #endif // KEEPASSX_TOOLS_H

View File

@ -20,6 +20,8 @@
#include "core/Entry.h" #include "core/Entry.h"
#include "core/Tools.h" #include "core/Tools.h"
#include <algorithm>
EntryAttachmentsModel::EntryAttachmentsModel(QObject* parent) EntryAttachmentsModel::EntryAttachmentsModel(QObject* parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, m_entryAttachments(nullptr) , m_entryAttachments(nullptr)
@ -102,7 +104,7 @@ void EntryAttachmentsModel::attachmentAboutToAdd(const QString& key)
{ {
QList<QString> rows = m_entryAttachments->keys(); QList<QString> rows = m_entryAttachments->keys();
rows.append(key); rows.append(key);
qSort(rows); std::sort(rows.begin(), rows.end());
int row = rows.indexOf(key); int row = rows.indexOf(key);
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
} }

View File

@ -20,6 +20,8 @@
#include "core/Entry.h" #include "core/Entry.h"
#include "core/Tools.h" #include "core/Tools.h"
#include <algorithm>
EntryAttributesModel::EntryAttributesModel(QObject* parent) EntryAttributesModel::EntryAttributesModel(QObject* parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, m_entryAttributes(nullptr) , m_entryAttributes(nullptr)
@ -152,7 +154,7 @@ void EntryAttributesModel::attributeAboutToAdd(const QString& key)
{ {
QList<QString> rows = m_attributes; QList<QString> rows = m_attributes;
rows.append(key); rows.append(key);
qSort(rows); std::sort(rows.begin(), rows.end());
int row = rows.indexOf(key); int row = rows.indexOf(key);
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
} }
@ -182,7 +184,7 @@ void EntryAttributesModel::attributeAboutToRename(const QString& oldKey, const Q
QList<QString> rows = m_attributes; QList<QString> rows = m_attributes;
rows.removeOne(oldKey); rows.removeOne(oldKey);
rows.append(newKey); rows.append(newKey);
qSort(rows); std::sort(rows.begin(), rows.end());
int newRow = rows.indexOf(newKey); int newRow = rows.indexOf(newKey);
if (newRow > oldRow) { if (newRow > oldRow) {
newRow++; newRow++;