Skip to content

Commit 6dac6e5

Browse files
committed
#3403 refactor: fix more build warnings
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent aba015d commit 6dac6e5

File tree

6 files changed

+102
-35
lines changed

6 files changed

+102
-35
lines changed

src/entities/calendaritem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <QSqlQuery>
1414
#include <QSqlRecord>
1515
#include <QUuid>
16+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
17+
#include <QTimeZone>
18+
#endif
1619

1720
#include "services/settingsservice.h"
1821

@@ -797,7 +800,11 @@ QDateTime CalendarItem::getDateTimeFromString(const QString &dateString) {
797800
// see: https://github.com/pbek/QOwnNotes/issues/1966
798801
if (!dateTime.isValid()) {
799802
dateTime = QDateTime::fromString(dateString, ICS_DATETIME_FORMAT_UTC);
803+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
804+
dateTime = QDateTime(dateTime.date(), dateTime.time(), QTimeZone::utc()).toLocalTime();
805+
#else
800806
dateTime = QDateTime(dateTime.date(), dateTime.time(), Qt::UTC).toLocalTime();
807+
#endif
801808
}
802809

803810
return dateTime;

src/helpers/codetohtmlconverter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,11 @@ QString CodeToHtmlConverter::xmlHighlighter(StringView input) const {
546546
StringView tag = input.mid(i, found - i);
547547

548548
static const QRegularExpression re(R"(([a-zA-Z0-9]+(\s*=\s*"[^"]*")?))");
549+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
550+
QRegularExpressionMatchIterator matchIt = re.globalMatchView(tag);
551+
#else
549552
QRegularExpressionMatchIterator matchIt = re.globalMatch(TO_QSTRING(tag));
553+
#endif
550554

551555
while (matchIt.hasNext()) {
552556
QRegularExpressionMatch match = matchIt.next();

src/helpers/flowlayout.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ QSize FlowLayout::sizeHint() const { return minimumSize(); }
126126

127127
QSize FlowLayout::minimumSize() const {
128128
QSize size;
129-
#if QT_VERSION >= 0x050700
129+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
130+
for (const QLayoutItem *item : std::as_const(itemList))
131+
#elif QT_VERSION >= 0x050700
130132
for (const QLayoutItem *item : qAsConst(itemList))
131133
#else
132134
for (const QLayoutItem *item : itemList)
@@ -150,7 +152,9 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const {
150152
//! [9]
151153

152154
//! [10]
153-
#if QT_VERSION >= 0x050700
155+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
156+
for (QLayoutItem *item : std::as_const(itemList)) {
157+
#elif QT_VERSION >= 0x050700
154158
for (QLayoutItem *item : qAsConst(itemList)) {
155159
#else
156160
for (QLayoutItem *item : itemList) {

src/libraries/fakevim/fakevim/fakevimhandler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5818,7 +5818,11 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) {
58185818
FvBaseAspect *act = s.item(optionName);
58195819
if (!act) {
58205820
showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args);
5821+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
5822+
} else if (act->defaultValue().typeId() == QMetaType::Bool) {
5823+
#else
58215824
} else if (act->defaultValue().type() == QVariant::Bool) {
5825+
#endif
58225826
bool oldValue = act->value().toBool();
58235827
if (printOption) {
58245828
showMessage(MessageInfo,

src/mainwindow.cpp

Lines changed: 73 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4425,7 +4425,7 @@ void MainWindow::searchInNoteTextEdit(QString str) {
44254425
QList<QTextEdit::ExtraSelection> extraSelections2;
44264426
QList<QTextEdit::ExtraSelection> extraSelections3;
44274427

4428-
if (str.count() >= 2) {
4428+
if (str.size() >= 2) {
44294429
// do an in-note search
44304430
doSearchInNote(str);
44314431
ui->noteTextEdit->moveCursor(QTextCursor::Start);
@@ -5545,12 +5545,19 @@ void MainWindow::showAppMetricsNotificationIfNeeded() {
55455545
if (showDialog) {
55465546
settings.setValue(QStringLiteral("appMetrics/notificationShown"), true);
55475547

5548-
if (QMessageBox::information(this, QStringLiteral("QOwnNotes"),
5549-
tr("QOwnNotes will track anonymous usage data, that helps to "
5550-
"decide what parts of QOwnNotes to improve next "
5551-
"and to find and fix bugs. You can disable that "
5552-
"behaviour in the settings."),
5553-
tr("&Ok"), tr("Open &settings"), QString(), 0, 1) == 1) {
5548+
QMessageBox msgBox(QMessageBox::Information, QStringLiteral("QOwnNotes"),
5549+
tr("QOwnNotes will track anonymous usage data, that helps to "
5550+
"decide what parts of QOwnNotes to improve next "
5551+
"and to find and fix bugs. You can disable that "
5552+
"behaviour in the settings."),
5553+
QMessageBox::NoButton, this);
5554+
QPushButton *okButton = msgBox.addButton(tr("&Ok"), QMessageBox::AcceptRole);
5555+
QPushButton *settingsButton =
5556+
msgBox.addButton(tr("Open &settings"), QMessageBox::ActionRole);
5557+
msgBox.setDefaultButton(settingsButton);
5558+
msgBox.exec();
5559+
5560+
if (msgBox.clickedButton() == settingsButton) {
55545561
openSettingsDialog(SettingsDialog::NetworkPage);
55555562
}
55565563
}
@@ -5561,11 +5568,18 @@ void MainWindow::showAppMetricsNotificationIfNeeded() {
55615568
*/
55625569
void MainWindow::openTodoDialog(const QString &taskUid) {
55635570
if (!OwnCloudService::isTodoCalendarSupportEnabled()) {
5564-
if (QMessageBox::warning(nullptr, tr("Todo lists disabled!"),
5565-
tr("You have disabled the todo lists.<br />"
5566-
"Please check your <strong>Todo</strong> "
5567-
"configuration in the settings!"),
5568-
tr("Open &settings"), tr("&Cancel"), QString(), 0, 1) == 0) {
5571+
QMessageBox msgBox(QMessageBox::Warning, tr("Todo lists disabled!"),
5572+
tr("You have disabled the todo lists.<br />"
5573+
"Please check your <strong>Todo</strong> "
5574+
"configuration in the settings!"),
5575+
QMessageBox::NoButton, nullptr);
5576+
QPushButton *settingsButton =
5577+
msgBox.addButton(tr("Open &settings"), QMessageBox::AcceptRole);
5578+
msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
5579+
msgBox.setDefaultButton(settingsButton);
5580+
msgBox.exec();
5581+
5582+
if (msgBox.clickedButton() == settingsButton) {
55695583
openSettingsDialog(SettingsDialog::TodoPage);
55705584
}
55715585

@@ -5581,11 +5595,18 @@ void MainWindow::openTodoDialog(const QString &taskUid) {
55815595

55825596
// check if we have got any task list enabled
55835597
if (todoCalendarEnabledUrlList.count() == 0) {
5584-
if (QMessageBox::warning(nullptr, tr("No selected todo lists!"),
5585-
tr("You have not selected any todo lists.<br />"
5586-
"Please check your <strong>Todo</strong> "
5587-
"configuration in the settings!"),
5588-
tr("Open &settings"), tr("&Cancel"), QString(), 0, 1) == 0) {
5598+
QMessageBox msgBox(QMessageBox::Warning, tr("No selected todo lists!"),
5599+
tr("You have not selected any todo lists.<br />"
5600+
"Please check your <strong>Todo</strong> "
5601+
"configuration in the settings!"),
5602+
QMessageBox::NoButton, nullptr);
5603+
QPushButton *settingsButton =
5604+
msgBox.addButton(tr("Open &settings"), QMessageBox::AcceptRole);
5605+
msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
5606+
msgBox.setDefaultButton(settingsButton);
5607+
msgBox.exec();
5608+
5609+
if (msgBox.clickedButton() == settingsButton) {
55895610
openSettingsDialog(SettingsDialog::TodoPage);
55905611
}
55915612

@@ -6950,12 +6971,18 @@ void MainWindow::on_actionDecrypt_note_triggered() {
69506971
return;
69516972
}
69526973

6953-
if (QMessageBox::warning(this, tr("Decrypt note and store it as plain text"),
6954-
tr("Your note will be decrypted and stored as plain text again. "
6955-
"Keep in mind that the unencrypted note will possibly be "
6956-
"synced to your server and sensitive text may be exposed!"
6957-
"<br />Do you want to decrypt your note?"),
6958-
tr("&Decrypt"), tr("&Cancel"), QString(), 0, 1) == 1) {
6974+
QMessageBox msgBox(QMessageBox::Warning, tr("Decrypt note and store it as plain text"),
6975+
tr("Your note will be decrypted and stored as plain text again. "
6976+
"Keep in mind that the unencrypted note will possibly be "
6977+
"synced to your server and sensitive text may be exposed!"
6978+
"<br />Do you want to decrypt your note?"),
6979+
QMessageBox::NoButton, this);
6980+
QPushButton *decryptButton = msgBox.addButton(tr("&Decrypt"), QMessageBox::AcceptRole);
6981+
QPushButton *cancelButton = msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
6982+
msgBox.setDefaultButton(cancelButton);
6983+
msgBox.exec();
6984+
6985+
if (msgBox.clickedButton() == cancelButton) {
69596986
return;
69606987
}
69616988

@@ -9957,12 +9984,18 @@ void MainWindow::openNotesContextMenu(const QPoint globalPos, bool multiNoteMenu
99579984
ui->noteTreeWidget->editItem(item);
99589985
}
99599986
} else {
9960-
if (QMessageBox::warning(this, tr("Note renaming not enabled!"),
9961-
tr("If you want to rename your note you have to enable "
9962-
"the option to allow the note filename to be "
9963-
"different from the headline."),
9964-
tr("Open &settings"), tr("&Cancel"), QString(), 0,
9965-
1) == 0) {
9987+
QMessageBox msgBox(QMessageBox::Warning, tr("Note renaming not enabled!"),
9988+
tr("If you want to rename your note you have to enable "
9989+
"the option to allow the note filename to be "
9990+
"different from the headline."),
9991+
QMessageBox::NoButton, this);
9992+
QPushButton *settingsButton =
9993+
msgBox.addButton(tr("Open &settings"), QMessageBox::AcceptRole);
9994+
msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
9995+
msgBox.setDefaultButton(settingsButton);
9996+
msgBox.exec();
9997+
9998+
if (msgBox.clickedButton() == settingsButton) {
99669999
openSettingsDialog(SettingsDialog::NoteFolderPage);
996710000
}
996810001
}
@@ -11329,10 +11362,17 @@ void MainWindow::gitCommitCurrentNoteFolder() { Utils::Git::commitCurrentNoteFol
1132911362
*/
1133011363
void MainWindow::on_actionShow_note_git_versions_triggered() {
1133111364
if (!Utils::Git::isCurrentNoteFolderUseGit()) {
11332-
if (QMessageBox::information(this, QStringLiteral("Git support"),
11333-
tr("Git support is not enabled for the current note folder, "
11334-
"do you want to enable it in the settings?"),
11335-
tr("Open &settings"), tr("&Cancel"), QString(), 0, 1) == 0) {
11365+
QMessageBox msgBox(QMessageBox::Information, QStringLiteral("Git support"),
11366+
tr("Git support is not enabled for the current note folder, "
11367+
"do you want to enable it in the settings?"),
11368+
QMessageBox::NoButton, this);
11369+
QPushButton *settingsButton =
11370+
msgBox.addButton(tr("Open &settings"), QMessageBox::AcceptRole);
11371+
QPushButton *cancelButton = msgBox.addButton(tr("&Cancel"), QMessageBox::RejectRole);
11372+
msgBox.setDefaultButton(settingsButton);
11373+
msgBox.exec();
11374+
11375+
if (msgBox.clickedButton() == settingsButton) {
1133611376
openSettingsDialog(SettingsDialog::NoteFolderPage);
1133711377
} else {
1133811378
// User doesn't want to enable git support

src/widgets/todoitemtreewidget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
TodoItemTreeWidget::TodoItemTreeWidget(QWidget *parent) : QTreeWidget(parent) { Q_UNUSED(parent); }
99

1010
void TodoItemTreeWidget::dropEvent(QDropEvent *e) {
11+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
12+
QModelIndex droppedIndex = indexAt(e->position().toPoint());
13+
#else
1114
QModelIndex droppedIndex = indexAt(e->pos());
15+
#endif
1216

1317
if (!droppedIndex.isValid()) {
1418
return;
1519
}
1620

21+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
22+
auto destItem = itemAt(e->position().toPoint());
23+
#else
1724
auto destItem = itemAt(e->pos());
25+
#endif
1826
auto destUid = destItem->data(0, Qt::UserRole).toString();
1927

2028
qDebug() << __func__ << " - 'destUid': " << destUid;

0 commit comments

Comments
 (0)