Fix obsolete code.
This commit is contained in:
parent
3d2abecc67
commit
f1b3184aaa
14 changed files with 53 additions and 43 deletions
|
@ -43,8 +43,11 @@ void FeedDownloader::updateAvailableFeeds() {
|
|||
}
|
||||
|
||||
while (!m_feeds.isEmpty()) {
|
||||
connect(m_feeds.first(), &Feed::messagesObtained, this, &FeedDownloader::oneFeedUpdateFinished,
|
||||
(Qt::ConnectionType)(Qt::UniqueConnection | Qt::AutoConnection));
|
||||
connect(m_feeds.first(),
|
||||
&Feed::messagesObtained,
|
||||
this,
|
||||
&FeedDownloader::oneFeedUpdateFinished,
|
||||
Qt::ConnectionType(Qt::UniqueConnection | Qt::AutoConnection));
|
||||
|
||||
if (m_threadPool->tryStart(m_feeds.first())) {
|
||||
m_feeds.removeFirst();
|
||||
|
@ -150,11 +153,9 @@ void FeedDownloadResults::appendUpdatedFeed(const QPair<QString, int>& feed) {
|
|||
}
|
||||
|
||||
void FeedDownloadResults::sort() {
|
||||
qSort(m_updatedFeeds.begin(), m_updatedFeeds.end(), FeedDownloadResults::lessThan);
|
||||
}
|
||||
|
||||
bool FeedDownloadResults::lessThan(const QPair<QString, int>& lhs, const QPair<QString, int>& rhs) {
|
||||
return lhs.second > rhs.second;
|
||||
std::sort(m_updatedFeeds.begin(), m_updatedFeeds.end(), [](const QPair<QString, int>& lhs, const QPair<QString, int>& rhs) {
|
||||
return lhs.second > rhs.second;
|
||||
});
|
||||
}
|
||||
|
||||
void FeedDownloadResults::clear() {
|
||||
|
|
|
@ -23,8 +23,6 @@ class FeedDownloadResults {
|
|||
void sort();
|
||||
void clear();
|
||||
|
||||
static bool lessThan(const QPair<QString, int>& lhs, const QPair<QString, int>& rhs);
|
||||
|
||||
private:
|
||||
|
||||
// QString represents title if the feed, int represents count of newly downloaded messages.
|
||||
|
|
|
@ -48,7 +48,9 @@ void DynamicShortcutsWidget::updateShortcuts() {
|
|||
|
||||
void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
|
||||
m_actionBindings.clear();
|
||||
qSort(actions.begin(), actions.end(), DynamicShortcutsWidget::lessThan);
|
||||
std::sort(actions.begin(), actions.end(), [](QAction* lhs, QAction* rhs) {
|
||||
return QString::localeAwareCompare(lhs->text().replace(QL1S("&"), QString()), rhs->text().replace(QL1S("&"), QString())) < 0;
|
||||
});
|
||||
int row_id = 0;
|
||||
|
||||
// FIXME: Maybe separate actions into "categories". Each category will start with label.
|
||||
|
@ -93,7 +95,3 @@ void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
|
|||
m_layout->setRowStretch(row_id, 1);
|
||||
m_layout->setColumnStretch(1, 1);
|
||||
}
|
||||
|
||||
bool DynamicShortcutsWidget::lessThan(QAction* lhs, QAction* rhs) {
|
||||
return QString::localeAwareCompare(lhs->text().replace(QL1S("&"), QString()), rhs->text().replace(QL1S("&"), QString())) < 0;
|
||||
}
|
||||
|
|
|
@ -38,9 +38,6 @@ class DynamicShortcutsWidget : public QWidget {
|
|||
signals:
|
||||
void setupChanged();
|
||||
|
||||
private:
|
||||
static bool lessThan(QAction* lhs, QAction* rhs);
|
||||
|
||||
private:
|
||||
QGridLayout* m_layout;
|
||||
|
||||
|
|
|
@ -9,7 +9,11 @@ void SqueezeLabel::paintEvent(QPaintEvent* event) {
|
|||
m_squeezedTextCache = text();
|
||||
QFontMetrics fm = fontMetrics();
|
||||
|
||||
#if QT_VERSION >= 0x050B00 // Qt >= 5.11.0
|
||||
if (fm.horizontalAdvance(m_squeezedTextCache) > contentsRect().width()) {
|
||||
#else
|
||||
if (fm.width(m_squeezedTextCache) > contentsRect().width()) {
|
||||
#endif
|
||||
setText(fm.elidedText(text(), Qt::ElideMiddle, width()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class SqueezeLabel : public QLabel {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SqueezeLabel(QWidget* parent = 0);
|
||||
explicit SqueezeLabel(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event);
|
||||
|
|
|
@ -24,7 +24,7 @@ AutoSaver::~AutoSaver() {
|
|||
}
|
||||
|
||||
void AutoSaver::changeOccurred() {
|
||||
if (m_firstChange.isNull()) {
|
||||
if (!m_firstChange.isValid()) {
|
||||
m_firstChange.start();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ void AutoSaver::timerEvent(QTimerEvent* event) {
|
|||
void AutoSaver::saveIfNeccessary() {
|
||||
if (m_timer.isActive()) {
|
||||
m_timer.stop();
|
||||
m_firstChange = QTime();
|
||||
m_firstChange.invalidate();
|
||||
|
||||
if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) {
|
||||
qWarning("AutoSaver: error invoking slot save() on parent.");
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#define AUTOSAVER_H
|
||||
|
||||
#include <QBasicTimer>
|
||||
#include <QElapsedTimer>
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
|
||||
class AutoSaver : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -24,7 +24,7 @@ class AutoSaver : public QObject {
|
|||
|
||||
private:
|
||||
QBasicTimer m_timer;
|
||||
QTime m_firstChange;
|
||||
QElapsedTimer m_firstChange;
|
||||
};
|
||||
|
||||
#endif // AUTOSAVER_H
|
||||
|
|
|
@ -104,8 +104,18 @@ DatabaseFactory::MySQLError DatabaseFactory::mysqlTestConnection(const QString&
|
|||
}
|
||||
}
|
||||
else if (database.lastError().isValid()) {
|
||||
// Connection failed, do cleanup and return specific error code.
|
||||
return static_cast<MySQLError>(database.lastError().number());
|
||||
auto nat = database.lastError().nativeErrorCode();
|
||||
bool nat_converted = false;
|
||||
auto nat_int = nat.toInt(&nat_converted);
|
||||
|
||||
if (nat_converted) {
|
||||
return static_cast<MySQLError>(nat_int);
|
||||
}
|
||||
else {
|
||||
qWarning("Failed to recognize MySQL error code: '%s'.", qPrintable(nat));
|
||||
|
||||
return MySQLError::MySQLUnknownError;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return MySQLError::MySQLUnknownError;
|
||||
|
|
|
@ -30,7 +30,11 @@ int TextFactory::stringWidth(const QString& string, const QFontMetrics& metrics)
|
|||
int width = 0;
|
||||
|
||||
foreach (const QString& line, lines) {
|
||||
#if QT_VERSION >= 0x050B00 // Qt >= 5.11.0
|
||||
int line_width = metrics.horizontalAdvance(line);
|
||||
#else
|
||||
int line_width = metrics.width(line);
|
||||
#endif
|
||||
|
||||
if (line_width > width) {
|
||||
width = line_width;
|
||||
|
|
|
@ -15,12 +15,6 @@ class TextFactory {
|
|||
TextFactory();
|
||||
|
||||
public:
|
||||
|
||||
// Returns true if lhs is smaller than rhs if case-insensitive string comparison is used.
|
||||
static inline bool isCaseInsensitiveLessThan(const QString& lhs, const QString& rhs) {
|
||||
return lhs.toLower() < rhs.toLower();
|
||||
}
|
||||
|
||||
static int stringHeight(const QString& string, const QFontMetrics& metrics);
|
||||
static int stringWidth(const QString& string, const QFontMetrics& metrics);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "gui/tabcontent.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QFile>
|
||||
#include <QNetworkReply>
|
||||
|
||||
|
@ -27,7 +28,7 @@ class DownloadItem : public QWidget {
|
|||
public:
|
||||
|
||||
// Constructors.
|
||||
explicit DownloadItem(QNetworkReply* reply = 0, QWidget* parent = 0);
|
||||
explicit DownloadItem(QNetworkReply* reply = 0, QWidget* parent = nullptr);
|
||||
virtual ~DownloadItem();
|
||||
|
||||
bool downloading() const;
|
||||
|
@ -67,7 +68,7 @@ class DownloadItem : public QWidget {
|
|||
QFile m_output;
|
||||
QNetworkReply* m_reply;
|
||||
qint64 m_bytesReceived;
|
||||
QTime m_downloadTime;
|
||||
QElapsedTimer m_downloadTime;
|
||||
QTime m_lastProgressTime;
|
||||
bool m_requestFileName;
|
||||
bool m_startedSaving;
|
||||
|
@ -95,7 +96,7 @@ class DownloadManager : public TabContent {
|
|||
|
||||
Q_ENUM(RemovePolicy)
|
||||
|
||||
explicit DownloadManager(QWidget* parent = 0);
|
||||
explicit DownloadManager(QWidget* parent = nullptr);
|
||||
virtual ~DownloadManager();
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
|
@ -159,7 +160,7 @@ class DownloadModel : public QAbstractListModel {
|
|||
friend class DownloadManager;
|
||||
|
||||
public:
|
||||
explicit DownloadModel(DownloadManager* download_manager, QObject* parent = 0);
|
||||
explicit DownloadModel(DownloadManager* download_manager, QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||
|
|
|
@ -22,15 +22,15 @@ void CacheForServiceRoot::addMessageStatesToCache(const QList<Message>& ids_of_m
|
|||
|
||||
// Store changes, they will be sent to server later.
|
||||
list_act.append(ids_of_messages);
|
||||
QSet<Message> set_act = list_act.toSet();
|
||||
QSet<Message> set_other = list_other.toSet();
|
||||
QSet<Message> set_act(list_act.begin(), list_act.end());
|
||||
QSet<Message> set_other(list_other.begin(), list_other.end());
|
||||
|
||||
// Now, we want to remove all IDS from list_other, which are contained in list.
|
||||
set_other -= set_act;
|
||||
list_act.clear();
|
||||
list_act.append(set_act.toList());
|
||||
list_act.append(set_act.values());
|
||||
list_other.clear();
|
||||
list_other.append(set_other.toList());
|
||||
list_other.append(set_other.values());
|
||||
|
||||
m_cacheSaveMutex->unlock();
|
||||
}
|
||||
|
@ -43,15 +43,15 @@ void CacheForServiceRoot::addMessageStatesToCache(const QStringList& ids_of_mess
|
|||
|
||||
// Store changes, they will be sent to server later.
|
||||
list_act.append(ids_of_messages);
|
||||
QSet<QString> set_act = list_act.toSet();
|
||||
QSet<QString> set_other = list_other.toSet();
|
||||
QSet<QString> set_act(list_act.begin(), list_act.end());
|
||||
QSet<QString> set_other(list_other.begin(), list_other.end());
|
||||
|
||||
// Now, we want to remove all IDS from list_other, which are contained in list.
|
||||
set_other -= set_act;
|
||||
list_act.clear();
|
||||
list_act.append(set_act.toList());
|
||||
list_act.append(set_act.values());
|
||||
list_other.clear();
|
||||
list_other.append(set_other.toList());
|
||||
list_other.append(set_other.values());
|
||||
|
||||
m_cacheSaveMutex->unlock();
|
||||
}
|
||||
|
|
|
@ -330,7 +330,10 @@ void FormFeedDetails::initialize() {
|
|||
}
|
||||
|
||||
// Sort encodings and add them.
|
||||
qSort(encoded_encodings.begin(), encoded_encodings.end(), TextFactory::isCaseInsensitiveLessThan);
|
||||
std::sort(encoded_encodings.begin(), encoded_encodings.end(), [](const QString& lhs, const QString& rhs) {
|
||||
return lhs.toLower() < rhs.toLower();
|
||||
});
|
||||
|
||||
m_ui->m_cmbEncoding->addItems(encoded_encodings);
|
||||
|
||||
// Setup menu & actions for icon selection.
|
||||
|
|
Loading…
Add table
Reference in a new issue