Skip to content

Commit

Permalink
Replace deprecated Qt API
Browse files Browse the repository at this point in the history
  • Loading branch information
yan12125 committed Apr 29, 2024
1 parent 11841ff commit 22e5cfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elseif(MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()

add_definitions(-DTESTDATA="${PROJECT_SOURCE_DIR}/test/data")
add_definitions(-DTESTDATA="${PROJECT_SOURCE_DIR}/test/data" -DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)

find_package(PkgConfig)
find_package(Qt5Widgets REQUIRED)
Expand Down
7 changes: 6 additions & 1 deletion src/model/UserphraseModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "UserphraseModel.h"

#include <QDebug>
#include <algorithm>
#include <functional>

static void logger(void *data, int level, const char *fmt, ...)
{
Expand Down Expand Up @@ -86,7 +88,10 @@ void UserphraseModel::remove(QModelIndexList indexList)
return;
}

qSort(indexList.begin(), indexList.end(), qGreater<QModelIndex>());
std::sort(indexList.begin(), indexList.end(), [] (const QModelIndex& a, const QModelIndex& b) {
// QModelIndex provides operator< but no operator>
return !(a < b);
});

// XXX: indexList is in revsrsed order, so first is actual last, and vice
// verse.
Expand Down
4 changes: 2 additions & 2 deletions src/view/ChewingEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ void ChewingEditor::execFileDialog(DialogType type)
fileDialog_->setWindowTitle(tr("Import"));
fileDialog_->setAcceptMode(QFileDialog::AcceptOpen);
fileDialog_->setFileMode(QFileDialog::ExistingFile);
fileDialog_->setConfirmOverwrite(false);
fileDialog_->setOption(QFileDialog::DontConfirmOverwrite, true);
fileDialog_->selectFile("");
break;

case DIALOG_EXPORT:
fileDialog_->setWindowTitle(tr("Export"));
fileDialog_->setAcceptMode(QFileDialog::AcceptSave);
fileDialog_->setFileMode(QFileDialog::AnyFile);
fileDialog_->setConfirmOverwrite(true);
fileDialog_->setOption(QFileDialog::DontConfirmOverwrite, false);
fileDialog_->selectFile("chewing.json");
break;

Expand Down

0 comments on commit 22e5cfb

Please sign in to comment.