Skip to content

Commit aba015d

Browse files
committed
#3403 refactor: fix lots of build warnings
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent 11a6198 commit aba015d

File tree

11 files changed

+96
-69
lines changed

11 files changed

+96
-69
lines changed

src/dialogs/linkdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ LinkDialog::~LinkDialog() {
8080

8181
void LinkDialog::on_searchLineEdit_textChanged(const QString &arg1) {
8282
// search notes when at least 2 characters were entered
83-
if (arg1.count() >= 2) {
83+
if (arg1.size() >= 2) {
8484
QVector<QString> noteNameList = Note::searchAsNameList(arg1, true);
8585
this->firstVisibleNoteListRow = -1;
8686

src/dialogs/scriptrepositorydialog.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,11 @@ void ScriptRepositoryDialog::on_installButton_clicked() {
385385

386386
// check if platform is supported
387387
if (!infoJson.platformSupported &&
388-
QMessageBox::information(this, tr("Platform not supported!"),
389-
tr("Your platform is not supported by this script!\n"
390-
"Do you want to install it anyway?"),
391-
tr("Install"), tr("Cancel"), QString(), 0, 1) != 0) {
388+
QMessageBox::question(this, tr("Platform not supported!"),
389+
tr("Your platform is not supported by this script!\n"
390+
"Do you want to install it anyway?"),
391+
QMessageBox::Yes | QMessageBox::No,
392+
QMessageBox::No) == QMessageBox::No) {
392393
return;
393394
}
394395

src/dialogs/settingsdialog.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,11 +2061,12 @@ void SettingsDialog::on_legacyOwnCloudCalendarRadioButton_toggled(bool checked)
20612061
}
20622062

20632063
void SettingsDialog::on_reinitializeDatabaseButton_clicked() {
2064-
if (QMessageBox::information(this, tr("Database"),
2065-
tr("Do you really want to clear the local database? "
2066-
"This will also remove your configured note "
2067-
"folders and your cached todo items!"),
2068-
tr("Clear &database"), tr("&Cancel"), QString(), 1) == 0) {
2064+
if (QMessageBox::question(this, tr("Database"),
2065+
tr("Do you really want to clear the local database? "
2066+
"This will also remove your configured note "
2067+
"folders and your cached todo items!"),
2068+
QMessageBox::Yes | QMessageBox::Cancel,
2069+
QMessageBox::Cancel) == QMessageBox::Yes) {
20692070
DatabaseService::reinitializeDiskDatabase();
20702071
NoteFolder::migrateToNoteFolders();
20712072

@@ -2133,11 +2134,12 @@ void SettingsDialog::on_appMetricsCheckBox_toggled(bool checked) {
21332134
* Allows the user to clear all settings and the database and exit the app
21342135
*/
21352136
void SettingsDialog::on_clearAppDataAndExitButton_clicked() {
2136-
if (QMessageBox::information(this, tr("Clear app data and exit"),
2137-
tr("Do you really want to clear all settings, remove the "
2138-
"database and exit QOwnNotes?\n\n"
2139-
"Your notes will stay intact!"),
2140-
tr("Clear and &exit"), tr("&Cancel"), QString(), 1) == 0) {
2137+
if (QMessageBox::question(this, tr("Clear app data and exit"),
2138+
tr("Do you really want to clear all settings, remove the "
2139+
"database and exit QOwnNotes?\n\n"
2140+
"Your notes will stay intact!"),
2141+
QMessageBox::Yes | QMessageBox::Cancel,
2142+
QMessageBox::Cancel) == QMessageBox::Yes) {
21412143
SettingsService settings;
21422144
settings.clear();
21432145
DatabaseService::removeDiskDatabase();
@@ -3146,7 +3148,7 @@ void SettingsDialog::on_shortcutSearchLineEdit_textChanged(const QString &arg1)
31463148
ui->shortcutTreeWidget->findItems(QString(), Qt::MatchContains | Qt::MatchRecursive);
31473149

31483150
// search text if at least one character was entered
3149-
if (arg1.count() >= 1) {
3151+
if (arg1.size() >= 1) {
31503152
// search for items in the description
31513153
QList<QTreeWidgetItem *> foundItems =
31523154
ui->shortcutTreeWidget->findItems(arg1, Qt::MatchContains | Qt::MatchRecursive);
@@ -3605,12 +3607,13 @@ void SettingsDialog::on_applyToolbarButton_clicked() {
36053607
}
36063608

36073609
void SettingsDialog::on_resetToolbarPushButton_clicked() {
3608-
if (QMessageBox::information(this, tr("Reset toolbars and exit"),
3609-
tr("Do you really want to reset all toolbars? "
3610-
"The application will be closed in the process, the "
3611-
"default toolbars will be restored when you start it "
3612-
"again."),
3613-
tr("Reset and &exit"), tr("&Cancel"), QLatin1String(""), 1) == 0) {
3610+
if (QMessageBox::question(this, tr("Reset toolbars and exit"),
3611+
tr("Do you really want to reset all toolbars? "
3612+
"The application will be closed in the process, the "
3613+
"default toolbars will be restored when you start it "
3614+
"again."),
3615+
QMessageBox::Yes | QMessageBox::Cancel,
3616+
QMessageBox::Cancel) == QMessageBox::Yes) {
36143617
SettingsService settings;
36153618

36163619
// remove all settings in the group
@@ -3642,7 +3645,7 @@ void SettingsDialog::on_searchLineEdit_textChanged(const QString &arg1) {
36423645
ui->settingsTreeWidget->findItems(QString(), Qt::MatchContains | Qt::MatchRecursive);
36433646

36443647
// search text if at least one character was entered
3645-
if (arg1.count() >= 1) {
3648+
if (arg1.size() >= 1) {
36463649
QList<int> pageIndexList;
36473650

36483651
// search in the tree widget items themselves

src/dialogs/tododialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void TodoDialog::on_newItemEdit_textChanged() {
664664
QLatin1String(""), Qt::MatchContains | Qt::MatchRecursive);
665665

666666
// search todo item if at least 2 characters were entered
667-
if (arg1.count() >= 2) {
667+
if (arg1.size() >= 2) {
668668
QList<QString> uidList =
669669
CalendarItem::searchAsUidList(arg1, ui->todoListSelector->currentText());
670670

@@ -707,7 +707,7 @@ void TodoDialog::searchForSearchLineTextInNoteTextEdit() {
707707
void TodoDialog::searchInDescriptionTextEdit(QString &str) {
708708
QList<QTextEdit::ExtraSelection> extraSelections;
709709

710-
if (str.count() >= 2) {
710+
if (str.size() >= 2) {
711711
ui->descriptionEdit->moveCursor(QTextCursor::Start);
712712
QColor color = QColor(0, 180, 0, 100);
713713

src/dialogs/updatedialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ bool UpdateDialog::initializeLinuxUpdateProcess(const QString &filePath) {
491491
return false;
492492
}
493493

494-
if (QMessageBox::information(
494+
if (QMessageBox::question(
495495
this, tr("Restart application"),
496496
tr("You now can restart the application to complete the update process.") +
497497
Utils::Misc::appendSingleAppInstanceTextIfNeeded(),
498-
tr("Restart"), tr("Cancel"), QString(), 0, 1) == 0) {
498+
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes) == QMessageBox::Yes) {
499499
Utils::Misc::restartApplication();
500500
}
501501

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ void loadTranslations(QTranslator *translator, const QString &locale) {
4444
// loadTranslation(translator[0], "qt_" + QLocale::system().name(),
4545
// QLibraryInfo::location(QLibraryInfo::TranslationsPath));
4646
loadTranslation(translator[1], "qt_" + locale,
47+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
48+
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
49+
#else
4750
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
51+
#endif
4852
QString appPath = QCoreApplication::applicationDirPath();
4953
loadTranslation(translator[2], "qt_" + locale, appPath + "/translations");
5054
loadTranslation(translator[3], appPath + "/../src/languages/QOwnNotes_" + locale);

src/mainwindow.cpp

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
180180
&MainWindow::showNoteEditTabWidgetContextMenu);
181181

182182
// Set the two shortcuts for the "increase note text size" action
183-
const QList<QKeySequence> shortcuts = {QKeySequence(Qt::CTRL + Qt::Key_Plus),
184-
QKeySequence(Qt::CTRL + Qt::Key_Equal)};
183+
const QList<QKeySequence> shortcuts = {QKeySequence(Qt::CTRL | Qt::Key_Plus),
184+
QKeySequence(Qt::CTRL | Qt::Key_Equal)};
185185
ui->action_Increase_note_text_size->setShortcuts(shortcuts);
186186

187187
initTreeWidgets();
@@ -3808,22 +3808,19 @@ QString MainWindow::selectOwnCloudNotesFolder() {
38083808
updateCurrentFolderTooltip();
38093809
} else {
38103810
if (this->notesPath.isEmpty()) {
3811-
switch (QMessageBox::information(
3812-
this, tr("No folder was selected"),
3813-
Utils::Misc::replaceOwnCloudText(tr("You have to select your ownCloud notes "
3814-
"folder to make this software work!")),
3815-
tr("&Retry"), tr("&Exit"), QString(), 0, 1)) {
3816-
case 0:
3817-
selectOwnCloudNotesFolder();
3818-
break;
3819-
case 1:
3820-
default:
3821-
// No other way to quit the application worked
3822-
// in the constructor
3823-
// Waqar144: this doesn't seem very wise...
3824-
QTimer::singleShot(0, this, SLOT(quitApp()));
3825-
QTimer::singleShot(100, this, SLOT(quitApp()));
3826-
break;
3811+
if (QMessageBox::question(
3812+
this, tr("No folder was selected"),
3813+
Utils::Misc::replaceOwnCloudText(tr("You have to select your ownCloud notes "
3814+
"folder to make this software work!")),
3815+
QMessageBox::Retry | QMessageBox::Close,
3816+
QMessageBox::Retry) == QMessageBox::Retry) {
3817+
selectOwnCloudNotesFolder();
3818+
} else {
3819+
// No other way to quit the application worked
3820+
// in the constructor
3821+
// Waqar144: this doesn't seem very wise...
3822+
QTimer::singleShot(0, this, SLOT(quitApp()));
3823+
QTimer::singleShot(100, this, SLOT(quitApp()));
38273824
}
38283825
}
38293826
}
@@ -5281,11 +5278,12 @@ bool MainWindow::showRestartNotificationIfNeeded(bool force) {
52815278

52825279
qApp->setProperty("needsRestart", false);
52835280

5284-
if (QMessageBox::information(this, tr("Restart application"),
5285-
tr("You may need to restart the application to let the "
5286-
"changes take effect.") +
5287-
Utils::Misc::appendSingleAppInstanceTextIfNeeded(),
5288-
tr("Restart"), tr("Cancel"), QString(), 0, 1) == 0) {
5281+
if (QMessageBox::question(this, tr("Restart application"),
5282+
tr("You may need to restart the application to let the "
5283+
"changes take effect.") +
5284+
Utils::Misc::appendSingleAppInstanceTextIfNeeded(),
5285+
QMessageBox::Yes | QMessageBox::Cancel,
5286+
QMessageBox::Yes) == QMessageBox::Yes) {
52895287
storeSettings();
52905288
Utils::Misc::restartApplication();
52915289

@@ -5759,7 +5757,7 @@ void MainWindow::filterNotesBySearchLineEditText(bool searchInNote) {
57595757
ui->noteTreeWidget->setColumnCount(1);
57605758

57615759
// search notes when at least 2 characters were entered
5762-
if (searchText.count() >= 2) {
5760+
if (searchText.size() >= 2) {
57635761
if (searchInNote) {
57645762
// open search dialog
57655763
doSearchInNote(searchText);
@@ -7155,7 +7153,7 @@ void MainWindow::gotoNextNote() {
71557153
* Activate the context menu in the currently focused widget
71567154
*/
71577155
void MainWindow::activateContextMenu() {
7158-
auto *event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint());
7156+
auto *event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(), QPoint());
71597157
QApplication::postEvent(focusWidget(), event);
71607158
}
71617159

@@ -11190,7 +11188,7 @@ void MainWindow::noteEditCursorPositionChanged() {
1119011188

1119111189
if (!selectedText.isEmpty()) {
1119211190
const QString textAdd = QStringLiteral(" (") +
11193-
tr("%n selected", "Characters selected", selectedText.count()) +
11191+
tr("%n selected", "Characters selected", selectedText.size()) +
1119411192
QStringLiteral(")");
1119511193
text += textAdd;
1119611194
toolTip += textAdd;
@@ -12379,12 +12377,12 @@ bool MainWindow::nextCloudDeckCheck() {
1237912377
NextcloudDeckService nextcloudDeckService(this);
1238012378

1238112379
if (!nextcloudDeckService.isEnabled()) {
12382-
if (QMessageBox::warning(
12380+
if (QMessageBox::question(
1238312381
nullptr, QObject::tr("Nextcloud Deck support disabled!"),
1238412382
QObject::tr(
1238512383
"Nextcloud Deck support is not enabled or the settings are invalid.<br />"
1238612384
"Please check your <strong>Nextcloud</strong> configuration in the settings!"),
12387-
QObject::tr("Open &settings"), QObject::tr("&Cancel"), QString(), 0, 1) == 0) {
12385+
QMessageBox::Open | QMessageBox::Cancel, QMessageBox::Open) == QMessageBox::Open) {
1238812386
openSettingsDialog(SettingsDialog::OwnCloudPage);
1238912387
}
1239012388

src/services/owncloudservice.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,8 +1158,9 @@ void OwnCloudService::showOwnCloudMessage(QString headline, QString message,
11581158
}
11591159

11601160
if (withSettingsButton) {
1161-
if (QMessageBox::warning(nullptr, headline, message, tr("Open &settings"), tr("&Cancel"),
1162-
QString(), 0, 1) == 0) {
1161+
if (QMessageBox::question(nullptr, headline, message,
1162+
QMessageBox::Open | QMessageBox::Cancel,
1163+
QMessageBox::Open) == QMessageBox::Open) {
11631164
#ifndef INTEGRATION_TESTS
11641165
MainWindow *mainWindow = MainWindow::instance();
11651166

@@ -1350,7 +1351,11 @@ QList<CalDAVCalendarData> OwnCloudService::parseCalendarData(QString &data) {
13501351
QDomDocument doc;
13511352
qDebug() << __func__ << " - 'data': " << data;
13521353

1354+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1355+
doc.setContent(data, QDomDocument::ParseOption::UseNamespaceProcessing);
1356+
#else
13531357
doc.setContent(data, true);
1358+
#endif
13541359

13551360
QDomNodeList errorNodes = doc.elementsByTagNameNS(NS_DAV, QStringLiteral("error"));
13561361

@@ -1466,7 +1471,11 @@ QList<CalDAVCalendarData> OwnCloudService::parseCalendarData(QString &data) {
14661471

14671472
void OwnCloudService::loadTodoItems(const QString &calendarName, QString &data) {
14681473
QDomDocument doc;
1474+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1475+
doc.setContent(data, QDomDocument::ParseOption::UseNamespaceProcessing);
1476+
#else
14691477
doc.setContent(data, true);
1478+
#endif
14701479

14711480
// fetch all urls that are currently in the calendar
14721481
QList<QUrl> calendarItemUrlRemoveList = CalendarItem::fetchAllUrlsByCalendar(calendarName);
@@ -1927,7 +1936,11 @@ void OwnCloudService::updateNoteShareStatus(QDomNodeList &dataElements, bool upd
19271936

19281937
void OwnCloudService::loadDirectory(QString &data) {
19291938
QDomDocument doc;
1939+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
1940+
doc.setContent(data, QDomDocument::ParseOption::UseNamespaceProcessing);
1941+
#else
19301942
doc.setContent(data, true);
1943+
#endif
19311944

19321945
if (data.isEmpty()) {
19331946
showOwnCloudServerErrorMessage(QString(), false);
@@ -2430,7 +2443,11 @@ QString OwnCloudService::fetchNoteFileId(const Note &note) {
24302443
QString data = QString(reply->readAll());
24312444

24322445
QDomDocument doc;
2446+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
2447+
doc.setContent(data, QDomDocument::ParseOption::UseNamespaceProcessing);
2448+
#else
24332449
doc.setContent(data, true);
2450+
#endif
24342451

24352452
// Parse the WebDAV XML response to get the file ID
24362453
QDomNodeList responseNodes =

src/services/scriptingservice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ void ScriptingService::noteTextEditSetSelection(int start, int end) {
12691269
QTextCursor c = textEdit->textCursor();
12701270

12711271
start = std::max<int>(start, 0);
1272-
end = std::min<int>(end, textEdit->toPlainText().count());
1272+
end = std::min<int>(end, textEdit->toPlainText().size());
12731273

12741274
c.setPosition(start);
12751275
c.setPosition(end, QTextCursor::KeepAnchor);
@@ -1296,7 +1296,7 @@ void ScriptingService::noteTextEditSetCursorPosition(int position) {
12961296
MainWindow *mainWindow = MainWindow::instance();
12971297
if (mainWindow != nullptr) {
12981298
QOwnNotesMarkdownTextEdit *textEdit = mainWindow->activeNoteTextEdit();
1299-
position = std::min<int>(position, textEdit->toPlainText().count());
1299+
position = std::min<int>(position, textEdit->toPlainText().size());
13001300
QTextCursor c = textEdit->textCursor();
13011301

13021302
if (position < 0) {

src/utils/gui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void Utils::Gui::searchForTextInTreeWidget(QTreeWidget *treeWidget, const QStrin
8282
treeWidget->findItems("", Qt::MatchContains | Qt::MatchRecursive);
8383

8484
// search text if at least one character was entered
85-
if (text.count() >= 1) {
85+
if (text.size() >= 1) {
8686
int searchColumnCount =
8787
searchFlags & TreeWidgetSearchFlag::AllColumnsSearch ? treeWidget->columnCount() : 1;
8888

@@ -143,7 +143,7 @@ void Utils::Gui::searchForTextInListWidget(QListWidget *listWidget, const QStrin
143143
listWidget->findItems("", Qt::MatchContains | Qt::MatchRecursive);
144144

145145
// search text if at least one character was entered
146-
if (text.count() >= 1) {
146+
if (text.size() >= 1) {
147147
// hide all not found items
148148
Q_FOREACH (QListWidgetItem *item, allItems) {
149149
bool show = item->text().contains(text, Qt::CaseInsensitive);
@@ -586,7 +586,7 @@ bool Utils::Gui::autoFormatTableAtCursor(QPlainTextEdit *textEdit) {
586586

587587
const QStringList &stringList = nextBlockText.split(QStringLiteral("|"));
588588
tableTextList.append(stringList);
589-
endPosition = block.position() + nextBlockText.count();
589+
endPosition = block.position() + nextBlockText.size();
590590
maxColumns = std::max(maxColumns, (int)stringList.count());
591591
}
592592

@@ -619,7 +619,7 @@ bool Utils::Gui::autoFormatTableAtCursor(QPlainTextEdit *textEdit) {
619619
continue;
620620
}
621621

622-
maxTextLength = std::max((int)text.count(), maxTextLength);
622+
maxTextLength = std::max((int)text.size(), maxTextLength);
623623
}
624624

625625
// a minimum of 3 headline separator characters are needed for

0 commit comments

Comments
 (0)