Commit f3826b8b authored by Laurent Montel's avatar Laurent Montel
Browse files

Fix some compile error when building against qt6

parent e8642436
Pipeline #241450 passed with stage
in 40 seconds
......@@ -65,7 +65,7 @@ void ConfigWizard::initCommandPage()
void ConfigWizard::initBookPage()
{
QString standardBook = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("standard.phrasebook"));
QString standardBook = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("standard.phrasebook"));
bool displayBook = (standardBook.isNull() || standardBook.isEmpty());
if (displayBook) {
......@@ -82,7 +82,7 @@ void ConfigWizard::initBookPage()
void ConfigWizard::initCompletion()
{
if (!WordCompletion::isConfigured()) {
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("dictionary.txt"));
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("dictionary.txt"));
QFile file(dictionaryFile);
if (file.exists()) {
// If there is a word completion dictionary but no entry in the
......
......@@ -490,7 +490,7 @@ void KMouthApp::slotStatusMsg(const QString &text)
void KMouthApp::slotPhrasebookConfirmed()
{
QString standardBook = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("standard.phrasebook"));
QString standardBook = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("standard.phrasebook"));
if (!standardBook.isEmpty()) {
PhraseBook book;
book.open(QUrl::fromLocalFile(standardBook));
......
......@@ -295,7 +295,11 @@ int PhraseBook::save(QWidget *parent, const QString &title, QUrl &url, bool phra
if (url.fileName(QUrl::PrettyDecoded).contains(QLatin1Char('.')) == 0) {
url = url.adjusted(QUrl::RemoveFilename);
url.setPath(url.path() + url.fileName(QUrl::PrettyDecoded) + QStringLiteral(".phrasebook"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
} else if (url.fileName(QUrl::PrettyDecoded).rightRef(11).contains(QLatin1String(".phrasebook"), Qt::CaseInsensitive) == 0) {
#else
} else if (url.fileName(QUrl::PrettyDecoded).right(11).contains(QLatin1String(".phrasebook"), Qt::CaseInsensitive) == 0) {
#endif
int filetype = KMessageBox::questionYesNoCancel(nullptr, QStringLiteral("<qt>%1</qt>").arg(i18n("Your chosen filename <i>%1</i> has a different extension than <i>.phrasebook</i>. "
"Do you wish to add <i>.phrasebook</i> to the filename?", url.fileName())), i18n("File Extension"), KGuiItem(i18n("Add")), KGuiItem(i18n("Do Not Add")));
if (filetype == KMessageBox::Cancel) {
......
......@@ -93,7 +93,7 @@ PhraseBookDialog::PhraseBookDialog()
initGUI();
initActions();
initStandardPhraseBooks();
QString standardBook = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("standard.phrasebook"));
QString standardBook = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("standard.phrasebook"));
if (!standardBook.isNull() && !standardBook.isEmpty()) {
QFile file(standardBook);
file.open(QIODevice::ReadOnly);
......@@ -616,7 +616,7 @@ void PhraseBookDialog::slotAddPhrase()
void PhraseBookDialog::slotSave()
{
QString standardBook = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("standard.phrasebook"));
QString standardBook = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("standard.phrasebook"));
if (!standardBook.isNull() && !standardBook.isEmpty()) {
QFile file(standardBook);
file.open(QIODevice::WriteOnly);
......
......@@ -188,10 +188,10 @@ QString DictionaryCreationWizard::createDictionary()
do {
dictnumber++;
filename = QStringLiteral("wordcompletion%1.dict").arg(dictnumber);
dictionaryFile = QStandardPaths::locate(QStandardPaths::DataLocation, filename);
dictionaryFile = QStandardPaths::locate(QStandardPaths::AppDataLocation, filename);
} while (QFile::exists(dictionaryFile));
dictionaryFile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("/") + filename;
dictionaryFile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1Char('/') + QStringLiteral("/") + filename;
if (WordList::saveWordList(map, dictionaryFile))
return filename;
else
......@@ -276,7 +276,7 @@ QMap <QString, int> MergeWidget::mergeParameters()
it.next();
if (it.value()->isChecked()) {
QString name = it.key();
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::DataLocation, name);
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::AppDataLocation, name);
files[dictionaryFile] = weights.value(name)->value();
}
}
......@@ -328,7 +328,7 @@ void CompletionWizardWidget::ok()
QString dictionaryFile;
dictionaryFile = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QStringLiteral("/");
dictionaryFile = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1Char('/') + QStringLiteral("/");
qDebug() << "dictionaryFile is " << dictionaryFile;
if (WordList::saveWordList(map, dictionaryFile)) {
KConfigGroup cg(KSharedConfig::openConfig(), "Dictionary 0");
......
......@@ -179,11 +179,13 @@ bool WordCompletion::setWordList(const QString &wordlist)
}
QString filename = d->dictDetails[d->current].filename;
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::DataLocation, filename);
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::AppDataLocation, filename);
QFile file(dictionaryFile);
if (file.exists() && file.open(QIODevice::ReadOnly)) {
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif
if (!stream.atEnd()) {
if (stream.readLine() == QLatin1String("WPDictFile")) {
while (!stream.atEnd()) {
......@@ -232,7 +234,7 @@ void WordCompletion::save()
{
if (d->wordsToSave) {
QString filename = d->dictDetails[d->current].filename;
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::DataLocation, filename);
QString dictionaryFile = QStandardPaths::locate(QStandardPaths::AppDataLocation, filename);
QFile file(dictionaryFile);
if (!file.exists())
return;
......@@ -240,8 +242,9 @@ void WordCompletion::save()
return;
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif
stream << "WPDictFile\n";
QMap<QString, int>::ConstIterator it;
for (it = d->map.constBegin(); it != d->map.constEnd(); ++it) {
......
......@@ -99,7 +99,7 @@ void WordCompletionWidget::load()
// Clean up disc space
for (QStringList::const_iterator it = newDictionaryFiles.constBegin(); it != newDictionaryFiles.constEnd(); ++it) {
QString filename = QStandardPaths::locate(QStandardPaths::DataLocation, *it);
QString filename = QStandardPaths::locate(QStandardPaths::AppDataLocation, *it);
if (!filename.isEmpty() && !filename.isNull())
QFile::remove(filename);
}
......@@ -125,7 +125,7 @@ void WordCompletionWidget::save()
// Clean up disc space
for (QStringList::const_iterator it = removedDictionaryFiles.constBegin(); it != removedDictionaryFiles.constEnd(); ++it) {
QString filename = QStandardPaths::locate(QStandardPaths::DataLocation, *it);
QString filename = QStandardPaths::locate(QStandardPaths::AppDataLocation, *it);
if (!filename.isEmpty() && !filename.isNull())
QFile::remove(filename);
}
......@@ -212,7 +212,7 @@ void WordCompletionWidget::exportDictionary()
}
}
QUrl src;
src.setPath(QStandardPaths::locate(QStandardPaths::DataLocation, nameItem->data().toString()));
src.setPath(QStandardPaths::locate(QStandardPaths::AppDataLocation, nameItem->data().toString()));
KIO::FileCopyJob *job = KIO::file_copy(src, url);
job->exec();
}
......
......@@ -88,8 +88,9 @@ bool saveWordList(const WordMap &map, const QString &filename)
return false;
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif
stream << "WPDictFile\n";
WordMap::ConstIterator it;
for (it = map.constBegin(); it != map.constEnd(); ++it)
......@@ -137,7 +138,9 @@ void addWordsFromFile(WordMap &map, const QString &filename, QTextCodec *codec)
QFile wpdfile(filename);
if (wpdfile.open(QIODevice::ReadOnly)) {
QTextStream stream(&wpdfile);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec("UTF-8");
#endif
if (!stream.atEnd()) {
QString line = stream.readLine();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment