Skip to content

Commit

Permalink
Fixed compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 17, 2024
1 parent 5397dfc commit a3da097
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/accountregdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void AccountRegDlg::done(int r)
{
if (ui_.busy->isActive()) {
int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to cancel the registration?"),
tr("&Yes"), tr("&No"));
QMessageBox::Yes | QMessageBox::No);
if (n != 0)
return;
}
Expand Down
24 changes: 22 additions & 2 deletions src/contactlistdragview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,22 @@ bool ContactListDragView::supportsDropOnIndex(QDropEvent *e, const QModelIndex &

static void updateDefaultDropAction(QDropEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (e->keyboardModifiers() == Qt::NoModifier) {
#else
if (e->modifiers() == Qt::NoModifier) {
#endif
e->setDropAction(Qt::MoveAction);
}
}

static void acceptDropAction(QDropEvent *e)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (e->keyboardModifiers() == Qt::NoModifier) {
#else
if (e->modifiers() == Qt::NoModifier) {
#endif
if (e->dropAction() != Qt::MoveAction) {
// qWarning("acceptDropAction(): e->dropAction() != Qt::MoveAction");
return;
Expand All @@ -322,7 +330,11 @@ static void acceptDropAction(QDropEvent *e)

void ContactListDragView::dragMoveEvent(QDragMoveEvent *e)
{
QModelIndex index = indexAt(e->pos());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QModelIndex index = indexAt(e->pos());
#else
QModelIndex index = indexAt(e->position().toPoint());
#endif
dropIndicatorRect_ = QRect();
dropIndicatorPosition_ = OnViewport;

Expand Down Expand Up @@ -373,7 +385,11 @@ void ContactListDragView::dropEvent(QDropEvent *e)
{
updateDefaultDropAction(e);

QModelIndex index = indexAt(e->pos());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QModelIndex index = indexAt(e->pos());
#else
QModelIndex index = indexAt(e->position().toPoint());
#endif
dropIndicatorRect_ = QRect();

if (dropIndicatorPosition_ == OnViewport || !supportsDropOnIndex(e, index)) {
Expand Down Expand Up @@ -409,7 +425,11 @@ QAbstractItemView::DropIndicatorPosition ContactListDragView::dropPosition(QDrop
QModelIndex group = itemToReorderGroup(selection, index);
if (group.isValid()) {
QRect rect = groupVisualRect(group);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (e->pos().y() >= rect.center().y()) {
#else
if (e->position().toPoint().y() >= rect.center().y()) {
#endif
return BelowItem;
} else {
return AboveItem;
Expand Down
4 changes: 4 additions & 0 deletions src/contactlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ void ContactListView::keyPressEvent(QKeyEvent *event)
if (item->isGroup()) {
toggleExpandedState(currentIndex());
} else {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QContextMenuEvent e(QContextMenuEvent::Keyboard, visualRect(currentIndex()).center());
#else
QContextMenuEvent e(QContextMenuEvent::Keyboard, visualRect(currentIndex()).center(), QCursor::pos());
#endif
QCoreApplication::sendEvent(this, &e);
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/contactlistviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ QPixmap ContactListViewDelegate::Private::statusPixmap(const QModelIndex &index,
QVariant alertData = index.data(ContactListModel::AlertPictureRole);
QIcon alert;
if (alertData.isValid()) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (alertData.type() == QVariant::Icon) {
#else
if (alertData.typeId() == QMetaType::QIcon) {
#endif
alert = qvariant_cast<QIcon>(alertData);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/discodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ PsiIcon category2icon(PsiAccount *acc, const Jid &jid, const QString &category,
if (acc->bookmarkManager()->isBookmarked(jid)) {
static QImage img;
if (img.isNull()) {
auto is = int(qApp->fontMetrics().height() * EqTextIconK + .5);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const auto fontSize = qApp->fontMetrics().height();
#else
const auto fontSize = QFontMetrics(qApp->font()).height();
#endif
auto is = int(fontSize * EqTextIconK + .5);
img = icon.pixmap(QSize(is, is)).toImage();
QPainter p(&img);
PsiIcon bicon = IconsetFactory::icon("psi/bookmark_remove");
Expand Down
7 changes: 7 additions & 0 deletions src/edbsqlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,17 @@ bool EDBSqLite::appendEvent(const QString &accId, const XMPP::Jid &jid, const Ps
}
query->bindValue(":extra_data", extraData);
} else {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
query->bindValue(":subject", QVariant(QVariant::String));
query->bindValue(":m_text", QVariant(QVariant::String));
query->bindValue(":lang", QVariant(QVariant::String));
query->bindValue(":extra_data", QVariant(QVariant::String));
#else
query->bindValue(":subject", QVariant(QMetaType::fromType<QString>()));
query->bindValue(":m_text", QVariant(QMetaType::fromType<QString>()));
query->bindValue(":lang", QVariant(QMetaType::fromType<QString>()));
query->bindValue(":extra_data", QVariant(QMetaType::fromType<QString>()));
#endif
}
bool res = query->exec();
return res;
Expand Down
4 changes: 2 additions & 2 deletions src/filesharinghttpproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void FileSharingHttpProxy::setupHeaders(qint64 fileSize, QString contentType, QD
{
if (lastModified.isValid())
response->addHeader("Last-Modified", lastModified.toString(Qt::RFC2822Date).toLatin1());
if (contentType.count())
if (contentType.size())
response->addHeader("Content-Type", contentType.toLatin1());

bool keepAlive = true;
Expand Down Expand Up @@ -291,7 +291,7 @@ void FileSharingHttpProxy::transfer()
} else {
response->write(data);
}
qDebug("FSP transferred %d bytes of %lld bytes", data.size(), toTransfer);
qDebug("FSP transferred %lld bytes of %lld bytes", data.size(), toTransfer);
} else {
qDebug("FSP we have to wait for readyRead or disconnected");
}
Expand Down
2 changes: 1 addition & 1 deletion src/filesharingnamproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void FileSharingNAMReply::setupHeaders(qint64 fileSize, QString contentType, QDa
{
if (lastModified.isValid())
setRawHeader("Last-Modified", lastModified.toString(Qt::RFC2822Date).toLatin1());
if (contentType.count())
if (contentType.size())
setRawHeader("Content-Type", contentType.toLatin1());

bool keepAlive = true;
Expand Down
2 changes: 1 addition & 1 deletion src/filetransdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ void FileRequestDlg::done(int r)
{
if (busy->isActive()) {
int n = QMessageBox::information(this, tr("Warning"), tr("Are you sure you want to cancel the transfer?"),
tr("&Yes"), tr("&No"));
QMessageBox::Yes | QMessageBox::No);
if (n != 0)
return;

Expand Down
6 changes: 5 additions & 1 deletion src/groupchattopicdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GroupchatTopicDlg::GroupchatTopicDlg(GCMainDlg *parent) :
m_ui->setupUi(this);
QKeySequence sendKey = ShortcutManager::instance()->shortcut("chat.send");
if (sendKey == QKeySequence(Qt::Key_Enter) || sendKey == QKeySequence(Qt::Key_Return)) {
sendKey = QKeySequence(Qt::CTRL + Qt::Key_Return);
sendKey = QKeySequence(Qt::CTRL | Qt::Key_Return);
}
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setShortcut(sendKey);

Expand Down Expand Up @@ -139,7 +139,11 @@ void GroupchatTopicDlg::populateCountryAndScript()
for (auto const &loc : locales) {
if (loc != QLocale::c()) {
scripts.insert(QLocale::scriptToString(loc.script()), loc.script());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
countries.insert(QLocale::countryToString(loc.country()), loc.country());
#else
countries.insert(QLocale::territoryToString(loc.territory()), loc.territory());
#endif
}
}
m_addLangUi->cmbScript->setVisible(scripts.count() > 1);
Expand Down
2 changes: 1 addition & 1 deletion src/infodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ bool InfoWidget::aboutToClose()
? tr("You have not published conference information changes.\nAre you sure you want to discard them?")
: tr("You have not published your account information changes.\nAre you sure you want to discard "
"them?"),
tr("Close and discard"), tr("Don't close"));
QMessageBox::Discard | QMessageBox::No);
if (n != 0) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpsi
4 changes: 2 additions & 2 deletions src/options/opt_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void OptionsTabChat::applyOptions()
if (d->ck_chatSoftReturn->isChecked()) {
vl << QVariant::fromValue(QKeySequence(Qt::Key_Enter)) << QVariant::fromValue(QKeySequence(Qt::Key_Return));
} else {
vl << QVariant::fromValue(QKeySequence(Qt::Key_Enter + Qt::CTRL))
<< QVariant::fromValue(QKeySequence(Qt::CTRL + Qt::Key_Return));
vl << QVariant::fromValue(QKeySequence(Qt::Key_Enter | Qt::CTRL))
<< QVariant::fromValue(QKeySequence(Qt::CTRL | Qt::Key_Return));
}
o->setOption("options.shortcuts.chat.send", vl);
}
Expand Down
3 changes: 1 addition & 2 deletions src/profiledlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "applicationinfo.h"
#include "common.h"
#include "iconset.h"
#include "iconwidget.h"
#include "profiles.h"
#include "psioptions.h"

Expand Down Expand Up @@ -281,7 +280,7 @@ void ProfileManageDlg::slotProfileDelete()
"<b>%1</b><br><br>\n"
"Proceed?")
.arg(paths.join("\n")),
tr("&No"), tr("&Yes"));
QMessageBox::Yes | QMessageBox::No);

if (r == 1) {
if (!profileDelete(paths)) {
Expand Down
19 changes: 16 additions & 3 deletions src/psidbusnotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ bool PsiDBusNotifier::checkServer()
QDBusMessage ret = QDBusConnection::sessionBus().call(m);
if (ret.type() != QDBusMessage::InvalidMessage && !ret.arguments().isEmpty()) {
QVariant v = ret.arguments().constFirst();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (v.type() == QVariant::StringList)
#else
if (v.typeId() == QMetaType::QStringList)
#endif
caps_ = v.toStringList();
}

Expand Down Expand Up @@ -208,7 +212,12 @@ void PsiDBusNotifier::popup(PsiAccount *account, PopupManager::PopupType type, c
}

if (im.isNull() && ico) {
im = ico->pixmap(QSize(qApp->fontMetrics().height(), qApp->fontMetrics().height())).toImage();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const auto fontSize = qApp->fontMetrics().height();
#else
const auto fontSize = QFontMetrics(qApp->font()).height();
#endif
im = ico->pixmap(QSize(fontSize, fontSize)).toImage();
}

if (!im.isNull()) {
Expand Down Expand Up @@ -278,7 +287,7 @@ void PsiDBusNotifier::popup(PsiAccount *account, PopupManager::PopupType type, c
QDBusMessage m = createMessage("Notify");
QVariantList args;
args << QString(ApplicationInfo::name());
args << QVariant(QVariant::UInt);
args << quint32(0);
args << QVariant("");
args << QString(title);
args << QString(text);
Expand Down Expand Up @@ -323,7 +332,7 @@ void PsiDBusNotifier::popup(PsiAccount *account, PopupManager::PopupType /*type*
QDBusMessage m = createMessage("Notify");
QVariantList args;
args << QString(ApplicationInfo::name());
args << QVariant(QVariant::UInt);
args << quint32(0);
args << QVariant("");
args << QString(titleText);
args << QString(plainText);
Expand Down Expand Up @@ -351,7 +360,11 @@ void PsiDBusNotifier::asyncCallFinished(QDBusPendingCallWatcher *watcher)
}

QVariant repl = m.arguments().constFirst();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (repl.type() != QVariant::UInt || repl.toUInt() == 0) {
#else
if (repl.typeId() != QMetaType::UInt || repl.toUInt() == 0) {
#endif
readyToDie();
} else {
id_ = repl.toUInt();
Expand Down
4 changes: 2 additions & 2 deletions src/theme_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ZipResourceLoader : public Theme::ResourceLoader {
QByteArray ba;

if (!z.readFile(n, &ba)) {
z.readFile(n.mid(baseName.count()), &ba);
z.readFile(n.mid(baseName.size()), &ba);
}

return ba;
Expand All @@ -137,7 +137,7 @@ class ZipResourceLoader : public Theme::ResourceLoader {
if (z.fileExists(n)) {
return true;
}
return z.fileExists(n.mid(baseName.count()));
return z.fileExists(n.mid(baseName.size()));
}
};
#endif
Expand Down
1 change: 1 addition & 0 deletions src/tools/optionstree/optionstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define OPTIONSTREE_H

#include "varianttree.h"

#include <optional>

/**
Expand Down
66 changes: 47 additions & 19 deletions src/tools/optionstree/optionstreereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,38 +59,66 @@ void OptionsTreeReader::readTree(VariantTree *tree)
QVariant OptionsTreeReader::readVariant(const QString &type)
{
QVariant result;
if (type == "QStringList") {
if (type == QLatin1String("QStringList")) {
result = readStringList();
} else if (type == "QVariantList") {
} else if (type == QLatin1String("QVariantList")) {
result = readVariantList();
} else if (type == "QSize") {
} else if (type == QLatin1String("QSize")) {
result = readSize();
} else if (type == "QRect") {
} else if (type == QLatin1String("QRect")) {
result = readRect();
} else if (type == "QByteArray") {
} else if (type == QLatin1String("QByteArray")) {
result = QByteArray();
result = QByteArray::fromBase64(readElementText().toLatin1());
} else {
QVariant::Type varianttype;
bool known = true;

if (type == "QString") {
varianttype = QVariant::String;
} else if (type == "bool") {
varianttype = QVariant::Bool;
} else if (type == "int") {
varianttype = QVariant::Int;
} else if (type == "QKeySequence") {
varianttype = QVariant::KeySequence;
} else if (type == "QColor") {
varianttype = QVariant::Color;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QVariant::Type variantType;
#else
QMetaType::Type variantType;
#endif
bool known = true;

if (type == QLatin1String("QString")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
variantType = QVariant::String;
#else
variantType = QMetaType::QString;
#endif
} else if (type == QLatin1String("bool")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
variantType = QVariant::Bool;
#else
variantType = QMetaType::Bool;
#endif
} else if (type == QLatin1String("int")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
variantType = QVariant::Int;
#else
variantType = QMetaType::Int;
#endif
} else if (type == QLatin1String("QKeySequence")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
variantType = QVariant::KeySequence;
#else
variantType = QMetaType::QKeySequence;
#endif
} else if (type == QLatin1String("QColor")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
variantType = QVariant::Color;
#else
variantType = QMetaType::QColor;
#endif
} else {
known = false;
}

if (known) {
result = readElementText();
result.convert(int(varianttype));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
result.convert(int(variantType));
#else
result.convert(QMetaType(variantType));
#endif
} else {
[[maybe_unused]] QString result;
QByteArray ba;
Expand Down
Loading

0 comments on commit a3da097

Please sign in to comment.