Commit a48d9611 authored by Pierre Ducroquet's avatar Pierre Ducroquet 🛩
Browse files

Fix a bunch of deprecated calls

These were found through the use of -DQT_DISABLE_DEPRECATED_BEFORE=0x050600
not commited here due to dependency on kdelibs4support.
Also increase min dependency to Qt 5.6 and KF5 5.30
Both are years old, but this way we won't break the jolla usecases.
parent 5866cef5
......@@ -199,7 +199,7 @@ include(MacroEnsureVersion)
include(MacroDesktopToJson)
set(REQUIRED_KF5_VERSION "5.7.0")
set(REQUIRED_KF5_VERSION "5.30.0")
find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED
COMPONENTS
......@@ -241,12 +241,7 @@ if(KF5Activities_FOUND)
set(HAVE_KACTIVITIES TRUE)
endif()
if(${KF5_VERSION} VERSION_LESS "5.16.0")
set(CALLIGRA_OLD_PLUGIN_METADATA TRUE)
endif()
set(REQUIRED_QT_VERSION "5.3.0")
set(REQUIRED_QT_VERSION "5.6.0")
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED
COMPONENTS
......@@ -268,11 +263,6 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} QUIET
Sql
)
# Qt5Declarative was removed in Qt 5.6.0 so search for it in a separate call
# Including it in a collected find_package(Qt5 ...) call can lead to a fatal not-found error:
# * Qt5 (required version >= 5.3.0)
find_package(Qt5Declarative ${REQUIRED_QT_VERSION} QUIET)
set_package_properties(Qt5DBus PROPERTIES
TYPE RECOMMENDED
)
......
......@@ -50,6 +50,3 @@
/* Defines if we use KActivities */
#cmakedefine HAVE_KACTIVITIES 1
/* Defines if the old plugin metadata for mimetypes is used */
#cmakedefine CALLIGRA_OLD_PLUGIN_METADATA 1
......@@ -32,7 +32,7 @@
void processEvents()
{
int i = 100;
while (QCoreApplication::hasPendingEvents() && i > 0) {
while (QCoreApplication::eventDispatcher()->hasPendingEvents() && i > 0) {
--i;
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
......
......@@ -28,6 +28,7 @@
#include <QApplication>
#include <QEventLoop>
#include <QAbstractEventDispatcher>
CSThumbProviderStage::CSThumbProviderStage(KoPADocument *doc)
: m_doc(doc)
......@@ -42,7 +43,7 @@ QVector<QImage> CSThumbProviderStage::createThumbnails(const QSize &thumbSize)
{
// make sure all is rendered before painting
int i = 100;
while (QCoreApplication::hasPendingEvents() && i > 0) {
while (QCoreApplication::eventDispatcher()->hasPendingEvents() && i > 0) {
--i;
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
......@@ -54,7 +55,7 @@ QVector<QImage> CSThumbProviderStage::createThumbnails(const QSize &thumbSize)
// make sure there are no events this fixes a crash on shutdown
i = 100;
while (QCoreApplication::hasPendingEvents() && i > 0) {
while (QCoreApplication::eventDispatcher()->hasPendingEvents() && i > 0) {
--i;
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
......
......@@ -58,7 +58,7 @@ QVector<QImage> CSThumbProviderWords::createThumbnails(const QSize &thumbSize)
while (!m_doc->layoutFinishedAtleastOnce()) {
QCoreApplication::processEvents();
if (!QCoreApplication::hasPendingEvents())
if (!QCoreApplication::eventDispatcher()->hasPendingEvents())
break;
}
......
......@@ -106,7 +106,7 @@ bool OkularOdtGenerator::loadDocument( const QString &fileName, QVector<Okular::
while (!m_doc->layoutFinishedAtleastOnce()) {
QCoreApplication::processEvents();
if (!QCoreApplication::hasPendingEvents())
if (!QCoreApplication::eventDispatcher()->hasPendingEvents())
break;
}
......
......@@ -37,15 +37,15 @@ public:
OkularOdtGenerator( QObject *parent, const QVariantList &args );
~OkularOdtGenerator();
bool loadDocument( const QString &fileName, QVector<Okular::Page*> &pages );
bool loadDocument( const QString &fileName, QVector<Okular::Page*> &pages ) override;
bool canGeneratePixmap() const;
void generatePixmap( Okular::PixmapRequest *request );
bool canGeneratePixmap() const override;
void generatePixmap( Okular::PixmapRequest *request ) override;
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const;
const Okular::DocumentSynopsis* generateDocumentSynopsis();
Okular::DocumentInfo generateDocumentInfo( const QSet<Okular::DocumentInfo::Key> &keys ) const override;
const Okular::DocumentSynopsis* generateDocumentSynopsis() override;
bool canGenerateTextPage() const;
bool canGenerateTextPage() const override;
protected:
bool doCloseDocument();
......
......@@ -141,8 +141,8 @@ void CalligraCreator::onLoadingCompleted()
ThumbCreator::Flags CalligraCreator::flags() const
{
#ifdef NO_ICON_BLENDING
return DrawFrame;
return None;
#else
return (Flags)(DrawFrame | BlendIcon);
return BlendIcon;
#endif
}
......@@ -516,6 +516,7 @@ void SvgOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
bool interpolate, const int *maskColors, bool inlineImg)
#endif
{
Q_UNUSED(ref)
Q_UNUSED(interpolate)
Q_UNUSED(inlineImg)
ImageStream * imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), colorMap->getBits());
......
......@@ -73,7 +73,7 @@ bool DBase::load(const QString& filename)
quint8 y, m, d;
m_stream >> y >> m >> d;
// because dBASE saves 102 instead of 2002 (very Y2K-save ;-)
m_lastUpdate.setYMD(y + 1900, m, d);
m_lastUpdate.setDate(y + 1900, m, d);
// check for valid date
if (!m_lastUpdate.isValid()) return false;
......
......@@ -667,7 +667,7 @@ bool GNUMERICFilter::setType(const Cell& kspread_cell,
GnumericDate::jul2greg(val, y, m, d);
kDebug(30521) << " num:" << val << ", y:" << y << ", m:" << m << ", d:" << d;
date.setYMD(y, m, d);
date.setDate(y, m, d);
} else
date = kspread_cell.value().asDate(kspread_cell.sheet()->map()->calculationSettings());
......
......@@ -38,6 +38,7 @@
#include <QPair>
#include <QRectF>
#include <QColor>
#include <QHash>
class KoGenStyles;
class KoGenStyle;
......
......@@ -132,6 +132,15 @@ public:
CloudAccountsModel::CloudAccountsModel(QObject* parent)
: QAbstractListModel(parent)
, d(new Private(this))
{
}
CloudAccountsModel::~CloudAccountsModel()
{
delete d;
}
QHash<int, QByteArray> CloudAccountsModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[TextRole] = "text";
......@@ -139,12 +148,7 @@ CloudAccountsModel::CloudAccountsModel(QObject* parent)
roles[AccountTypeRole] = "accountType";
roles[StackComponentRole] = "stackComponent";
roles[AccountDetailsRole] = "accountDetails";
setRoleNames(roles);
}
CloudAccountsModel::~CloudAccountsModel()
{
delete d;
return roles;
}
QVariant CloudAccountsModel::data(const QModelIndex& index, int role) const
......
......@@ -37,6 +37,8 @@ public:
};
explicit CloudAccountsModel(QObject* parent = 0);
~CloudAccountsModel() override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent) const override;
Q_INVOKABLE void selectIndex(int newSelection);
......
......@@ -89,18 +89,6 @@ DocumentListModel::DocumentListModel(QObject *parent)
{
qRegisterMetaType<DocumentInfo>();
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
roleNames[FileNameRole] = "fileName";
roleNames[FilePathRole] = "filePath";
roleNames[DocTypeRole] = "docType";
roleNames[SectionCategoryRole] = "sectionCategory";
roleNames[FileSizeRole] = "fileSize";
roleNames[AuthorNameRole] = "authorName";
roleNames[AccessedTimeRole] = "accessedTime";
roleNames[ModifiedTimeRole] = "modifiedTime";
roleNames[UUIDRole] = "uuid";
setRoleNames(roleNames);
m_docTypes["odt"] = TextDocumentType;
m_docTypes["doc"] = TextDocumentType;
m_docTypes["docx"] = TextDocumentType;
......@@ -117,6 +105,21 @@ DocumentListModel::~DocumentListModel()
stopSearch();
}
QHash<int, QByteArray> DocumentListModel::roleNames() const
{
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
roleNames[FileNameRole] = "fileName";
roleNames[FilePathRole] = "filePath";
roleNames[DocTypeRole] = "docType";
roleNames[SectionCategoryRole] = "sectionCategory";
roleNames[FileSizeRole] = "fileSize";
roleNames[AuthorNameRole] = "authorName";
roleNames[AccessedTimeRole] = "accessedTime";
roleNames[ModifiedTimeRole] = "modifiedTime";
roleNames[UUIDRole] = "uuid";
return roleNames;
}
void DocumentListModel::startSearch()
{
if (m_searchThread) {
......@@ -268,7 +271,8 @@ void DocumentListModel::setFilter(DocumentListModel::DocumentType newFilter)
void DocumentListModel::componentComplete()
{
reset();
beginResetModel();
endResetModel();
startSearch();
}
......@@ -76,6 +76,7 @@ public:
};
// reimp from QAbstractListModel
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
......
......@@ -246,7 +246,7 @@ bool DocumentManager::save()
void DocumentManager::saveAs(const QString &filename, const QString &mimetype)
{
d->document->setOutputMimeType(mimetype.toAscii());
d->document->setOutputMimeType(mimetype.toLatin1());
d->saveAsFilename = filename;
// Yes. This is a massive hack. Basically, we need to wait a little while, to ensure
// the save call happens late enough for a variety of UI things to happen first.
......
......@@ -54,11 +54,6 @@ public:
KeyboardModel::KeyboardModel(QObject* parent)
: QAbstractListModel(parent), d(new Private)
{
QHash<int, QByteArray> roleNames;
roleNames.insert(TextRole, "text");
roleNames.insert(TypeRole, "keyType");
roleNames.insert(WidthRole, "width");
setRoleNames(roleNames);
}
KeyboardModel::~KeyboardModel()
......@@ -66,6 +61,15 @@ KeyboardModel::~KeyboardModel()
delete d;
}
QHash<int, QByteArray> KeyboardModel::roleNames() const
{
QHash<int, QByteArray> roleNames;
roleNames.insert(TextRole, "text");
roleNames.insert(TypeRole, "keyType");
roleNames.insert(WidthRole, "width");
return roleNames;
}
void KeyboardModel::classBegin()
{
......
......@@ -61,7 +61,9 @@ public:
void classBegin() override;
void componentComplete() override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
......
......@@ -65,7 +65,6 @@
#include <KoFileDialog.h>
#include <KoDialog.h>
#include <KoIcon.h>
#include <KoConfig.h> // CALLIGRA_OLD_PLUGIN_METADATA
#include "PropertyContainer.h"
#include "RecentFileManager.h"
......@@ -608,11 +607,7 @@ void MainWindow::openFile()
KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(WORDS_MIME_TYPE);
if (!entry.isEmpty()) {
QJsonObject json = entry.metaData();
#ifdef CALLIGRA_OLD_PLUGIN_METADATA
QStringList mimeTypes = json.value("X-KDE-ExtraNativeMimeTypes").toString().split(',');
#else
QStringList mimeTypes = json.value("X-KDE-ExtraNativeMimeTypes").toVariant().toStringList();
#endif
mimeFilter << KoFilterManager::mimeFilter(WORDS_MIME_TYPE,
KoFilterManager::Import,
......@@ -621,11 +616,7 @@ void MainWindow::openFile()
entry = KoDocumentEntry::queryByMimeType(STAGE_MIME_TYPE);
if (!entry.isEmpty()) {
QJsonObject json = entry.metaData();
#ifdef CALLIGRA_OLD_PLUGIN_METADATA
QStringList mimeTypes = json.value("X-KDE-ExtraNativeMimeTypes").toString().split(',');
#else
QStringList mimeTypes = json.value("X-KDE-ExtraNativeMimeTypes").toVariant().toStringList();
#endif
mimeFilter << KoFilterManager::mimeFilter(STAGE_MIME_TYPE,
KoFilterManager::Import,
mimeTypes);
......
......@@ -61,6 +61,16 @@ public:
ParagraphStylesModel::ParagraphStylesModel()
: d(new Private(this))
{
}
ParagraphStylesModel::~ParagraphStylesModel()
{
delete d;
}
QHash<int, QByteArray> ParagraphStylesModel::roleNames() const
{
QHash<int,QByteArray> roleNames;
roleNames[Name] = "name";
......@@ -71,12 +81,7 @@ ParagraphStylesModel::ParagraphStylesModel()
roleNames[FontWeight] = "fontWeight";
roleNames[FontItalic] = "fontItalic";
roleNames[FontUnderline] = "fontUnderline";
setRoleNames(roleNames);
}
ParagraphStylesModel::~ParagraphStylesModel()
{
delete d;
return roleNames;
}
QVariant ParagraphStylesModel::data(const QModelIndex& index, int role) const
......
......@@ -46,6 +46,7 @@ public:
};
ParagraphStylesModel();
~ParagraphStylesModel() override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent) const override;
......
......@@ -30,12 +30,12 @@ PropertyContainer::~PropertyContainer()
void PropertyContainer::writeProperty(QString name, QVariant value)
{
setProperty(name.toAscii(), value);
setProperty(name.toLatin1(), value);
}
QVariant PropertyContainer::readProperty(QString name)
{
return property(name.toAscii());
return property(name.toLatin1());
}
QString PropertyContainer::name()
......
......@@ -35,19 +35,22 @@ RecentFilesModel::RecentFilesModel(QObject *parent)
, d(new Private())
{
d->recentFileManager = 0;
}
RecentFilesModel::~RecentFilesModel()
{
delete d;
}
QHash<int, QByteArray> RecentFilesModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[ImageRole] = "image";
roles[TextRole] = "text";
roles[UrlRole] = "url";
roles[NameRole] = "name";
roles[DateRole] = "filedate";
setRoleNames(roles);
}
RecentFilesModel::~RecentFilesModel()
{
delete d;
return roles;
}
int RecentFilesModel::rowCount(const QModelIndex &/*parent*/) const
......@@ -138,7 +141,8 @@ void RecentFilesModel::setRecentFileManager(QObject *recentFileManager)
void RecentFilesModel::recentFilesListChanged()
{
reset();
beginResetModel();
endResetModel();
}
void RecentFilesModel::addRecent(const QString &_url)
......
......@@ -37,6 +37,7 @@ public:
explicit RecentFilesModel(QObject *parent = 0);
~RecentFilesModel() override;
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
......
......@@ -80,7 +80,8 @@ void Settings::setCurrentFile(const QString& fileName)
else if (fileName != d->currentFile) {
QUrl url(fileName);
if(url.scheme() == "newfile") {
d->currentFileClass = url.queryItemValue("mimetype");
QUrlQuery query(url.query());
d->currentFileClass = query.queryItemValue("mimetype");
}
else {
QMimeDatabase db;
......
......@@ -47,6 +47,15 @@ public:
TemplateVariantsModel::TemplateVariantsModel(QObject* parent)
: QAbstractListModel(parent)
, d(new Private())
{
}
TemplateVariantsModel::~TemplateVariantsModel()
{
delete d;
}
QHash<int, QByteArray> TemplateVariantsModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[NameRole] = "text";
......@@ -54,12 +63,7 @@ TemplateVariantsModel::TemplateVariantsModel(QObject* parent)
roles[ThumbnailRole] = "thumbnail";
roles[SwatchRole] = "swatch";
roles[UrlRole] = "url";
setRoleNames(roles);
}
TemplateVariantsModel::~TemplateVariantsModel()
{
delete d;
return roles;
}
QVariant TemplateVariantsModel::data(const QModelIndex& index, int role) const
......
......@@ -37,6 +37,7 @@ public:
explicit TemplateVariantsModel(QObject* parent = 0);
~TemplateVariantsModel() override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
......
......@@ -101,6 +101,15 @@ public:
TemplatesModel::TemplatesModel(QObject* parent)
: QAbstractListModel(parent)
, d(new Private())
{
}
TemplatesModel::~TemplatesModel()
{
delete d;
}
QHash<int, QByteArray> TemplatesModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[TitleRole] = "text";
......@@ -110,12 +119,7 @@ TemplatesModel::TemplatesModel(QObject* parent)
roles[UrlRole] = "url";
roles[VariantCountRole] = "variantCount";
roles[VariantsRole] = "variants";
setRoleNames(roles);
}
TemplatesModel::~TemplatesModel()
{
delete d;
return roles;
}
QVariant TemplatesModel::data(const QModelIndex& index, int role) const
......
......@@ -39,6 +39,7 @@ public:
explicit TemplatesModel(QObject* parent = 0);
~TemplatesModel() override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex& index, int role) const override;
int rowCount(const QModelIndex& parent) const override;
......
......@@ -75,18 +75,6 @@ void SearchThread::run()
DocumentListModel::DocumentListModel(QObject *parent)
: QAbstractListModel(parent), m_searchThread(0), m_groupBy(GroupByName), m_filter(UnknownType)
{
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
roleNames[FileNameRole] = "fileName";
roleNames[FilePathRole] = "filePath";
roleNames[DocTypeRole] = "docType";
roleNames[SectionCategoryRole] = "sectionCategory";
roleNames[FileSizeRole] = "fileSize";
roleNames[AuthorNameRole] = "authorName";
roleNames[AccessedTimeRole] = "accessedTime";
roleNames[ModifiedTimeRole] = "modifiedTime";
roleNames[UUIDRole] = "uuid";
setRoleNames(roleNames);
m_docTypes["odt"] = TextDocumentType;
m_docTypes["doc"] = TextDocumentType;
m_docTypes["docx"] = TextDocumentType;
......@@ -103,6 +91,21 @@ DocumentListModel::~DocumentListModel()
stopSearch();
}
QHash<int, QByteArray> DocumentListModel::roleNames() const
{
QHash<int, QByteArray> roleNames = QAbstractListModel::roleNames();
roleNames[FileNameRole] = "fileName";
roleNames[FilePathRole] = "filePath";
roleNames[DocTypeRole] = "docType";
roleNames[SectionCategoryRole] = "sectionCategory";
roleNames[FileSizeRole] = "fileSize";
roleNames[AuthorNameRole] = "authorName";
roleNames[AccessedTimeRole] = "accessedTime";
roleNames[ModifiedTimeRole] = "modifiedTime";
roleNames[UUIDRole] = "uuid";
return roleNames;
}
void DocumentListModel::startSearch()
{
if (m_searchThread) {
......@@ -275,6 +278,7 @@ void DocumentListModel::setFilter(DocumentListModel::DocumentType newFilter)