Commit 39d67032 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Use more deprecation macros and do internal porting

parent aa164a1a
......@@ -400,7 +400,10 @@ void Engine::addProvider(QSharedPointer<KNSCore::Provider> provider)
connect(provider.data(), &Provider::loadingFinished, this, &Engine::slotEntriesLoaded);
connect(provider.data(), &Provider::entryDetailsLoaded, this, &Engine::slotEntryDetailsLoaded);
connect(provider.data(), &Provider::payloadLinkLoaded, this, &Engine::downloadLinkLoaded);
connect(provider.data(), &Provider::signalError, this, &Engine::signalError);
connect(provider.data(), &Provider::signalError, this, [this, provider](const QString &msg) {
Q_EMIT signalErrorCode(ErrorCode::ProviderError, msg, m_providerFileUrl);
});
connect(provider.data(), &Provider::signalErrorCode, this, &Engine::signalErrorCode);
connect(provider.data(), &Provider::signalInformation, this, [this](const QString &message) {
Q_EMIT signalMessage(message);
......
......@@ -479,7 +479,7 @@ public:
*/
bool setEntryXML(QXmlStreamReader &reader);
#if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 36)
//#if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 36) // TODO This is still internally used and has not been fully ported
/**
* set the xml for the entry
* parses the xml and sets the private members accordingly
......@@ -493,7 +493,7 @@ public:
*/
KNEWSTUFFCORE_DEPRECATED_VERSION(5, 36, "Use EntryInternal::setEntryXML(QXmlStreamReader &)")
bool setEntryXML(const QDomElement &xmldata);
#endif
//#endif
/**
* get the xml string for the entry
......
......@@ -189,10 +189,12 @@ void DownloadWidgetPrivate::slotInfo(QString provider, QString server, QString v
i18n("Provider information"));
}
void DownloadWidgetPrivate::slotEntryChanged(const KNSCore::EntryInternal &entry)
void DownloadWidgetPrivate::slotEntryEvent(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event)
{
changedEntries.insert(entry);
model->slotEntryChanged(entry);
if (event == KNSCore::EntryInternal::StatusChangedEvent) {
changedEntries.insert(entry);
model->slotEntryChanged(entry);
}
}
void DownloadWidgetPrivate::slotPayloadFailed(const KNSCore::EntryInternal &entry)
......@@ -230,16 +232,21 @@ void DownloadWidgetPrivate::init(const QString &configFile)
q->connect(engine, &KNSCore::Engine::signalMessage, this, &DownloadWidgetPrivate::slotShowMessage);
q->connect(engine, &KNSCore::Engine::signalBusy, ui.progressIndicator, &ProgressIndicator::busy);
q->connect(engine, &KNSCore::Engine::signalErrorCode, ui.progressIndicator, &ProgressIndicator::error);
q->connect(engine, &KNSCore::Engine::signalIdle, ui.progressIndicator, &ProgressIndicator::idle);
q->connect(engine, &KNSCore::Engine::busyStateChanged, this ,[this]() {
if (!engine->busyState()) {
ui.progressIndicator->idle(QString());
} else {
ui.progressIndicator->busy(engine->busyMessage());
}
});
q->connect(engine, &KNSCore::Engine::signalProvidersLoaded, this, &DownloadWidgetPrivate::slotProvidersLoaded);
// Entries have been fetched and should be shown:
q->connect(engine, &KNSCore::Engine::signalEntriesLoaded, this, &DownloadWidgetPrivate::slotEntriesLoaded);
// An entry has changes - eg because it was installed
q->connect(engine, &KNSCore::Engine::signalEntryChanged, this, &DownloadWidgetPrivate::slotEntryChanged);
q->connect(engine, &KNSCore::Engine::signalEntryEvent, this, &DownloadWidgetPrivate::slotEntryEvent);
q->connect(engine, &KNSCore::Engine::signalResetView, model, &KNSCore::ItemsModel::clearEntries);
q->connect(engine, &KNSCore::Engine::signalEntryPreviewLoaded,
......
......@@ -133,7 +133,6 @@ private:
Q_PRIVATE_SLOT(d, void slotProvidersLoaded())
Q_PRIVATE_SLOT(d, void slotEntriesLoaded(const KNSCore::EntryInternal::List &entries))
Q_PRIVATE_SLOT(d, void slotEntryChanged(const KNSCore::EntryInternal &entry))
Q_PRIVATE_SLOT(d, void slotShowDetails(const KNSCore::EntryInternal &entry))
Q_PRIVATE_SLOT(d, void slotShowOverview())
......
......@@ -63,7 +63,7 @@ public:
void slotProvidersLoaded();
void slotEntriesLoaded(const KNSCore::EntryInternal::List &entries);
void slotEntryChanged(const KNSCore::EntryInternal &entry);
void slotEntryEvent(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event);
void slotShowDetails(const KNSCore::EntryInternal &entry);
void slotShowOverview();
......
......@@ -92,9 +92,13 @@ void Engine::setConfigFile(const QString &newFile)
Q_EMIT isLoadingChanged();
});
connect(d->engine, &KNSCore::Engine::signalMessage, this, &Engine::message);
connect(d->engine, &KNSCore::Engine::signalIdle, this, &Engine::idleMessage);
connect(d->engine, &KNSCore::Engine::signalBusy, this, &Engine::busyMessage);
connect(d->engine, &KNSCore::Engine::signalError, this, &Engine::errorMessage);
connect(d->engine, &KNSCore::Engine::busyStateChanged, this, [this]() {
if (!d->engine->busyState()) {
idleMessage(QString());
} else {
busyMessage(d->engine->busyMessage());
}
});
connect(d->engine, &KNSCore::Engine::signalErrorCode, this, [=](const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &/*metadata*/) {
if (errorCode == KNSCore::ProviderError) {
// This means loading the providers file failed entirely and we cannot complete the
......@@ -105,13 +109,17 @@ void Engine::setConfigFile(const QString &newFile)
}
Q_EMIT errorMessage(message);
});
connect(d->engine, &KNSCore::Engine::signalEntryChanged, this, [this](const KNSCore::EntryInternal &entry){
if (d->changedEntries.contains(entry) ) {
d->changedEntries.removeAll(entry);
}
d->changedEntries << entry;
Q_EMIT changedEntriesChanged();
});
connect(d->engine, &KNSCore::Engine::signalEntryEvent,
this, [this](const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event) {
if (event != KNSCore::EntryInternal::StatusChangedEvent) {
return;
}
if (d->changedEntries.contains(entry)) {
d->changedEntries.removeAll(entry);
}
d->changedEntries << entry;
Q_EMIT changedEntriesChanged();
});
Q_EMIT engineChanged();
KNewStuffQuick::QuickQuestionListener::instance();
d->categoriesModel = new CategoriesModel(this);
......
......@@ -69,20 +69,9 @@ public:
}
});
// An entry has changes - eg because it was installed
q->connect(coreEngine, &KNSCore::Engine::signalEntryChanged, model, &KNSCore::ItemsModel::slotEntryChanged);
q->connect(coreEngine, &KNSCore::Engine::signalEntryChanged, q, [=](const KNSCore::EntryInternal &entry){
Q_EMIT q->entryChanged(model->row(entry));
});
// If we update/uninstall an entry we have to update the UI, see BUG: 425135
q->connect(coreEngine, &KNSCore::Engine::signalEntryChanged, q, [=](const KNSCore::EntryInternal &entry){
if (coreEngine->filter() == KNSCore::Provider::Updates && entry.status() != KNS3::Entry::Updateable) {
model->removeEntry(entry);
} else if (coreEngine->filter() == KNSCore::Provider::Installed && entry.status() == KNS3::Entry::Deleted) {
model->removeEntry(entry);
}
q->connect(coreEngine, &KNSCore::Engine::signalEntryEvent, q, [this](const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event) {
onEntryEvent(entry, event);
});
q->connect(coreEngine, &KNSCore::Engine::signalResetView, model, &KNSCore::ItemsModel::clearEntries);
q->connect(coreEngine, &KNSCore::Engine::signalEntryPreviewLoaded, model, &KNSCore::ItemsModel::slotEntryPreviewLoaded);
......@@ -92,6 +81,21 @@ public:
q->connect(model, &KNSCore::ItemsModel::modelReset, q, &ItemsModel::modelReset);
return true;
}
void onEntryEvent(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event)
{
if (event == KNSCore::EntryInternal::StatusChangedEvent) {
model->slotEntryChanged(entry);
Q_EMIT q->entryChanged(model->row(entry));
// If we update/uninstall an entry we have to update the UI, see BUG: 425135
if (coreEngine->filter() == KNSCore::Provider::Updates && entry.status() != KNS3::Entry::Updateable) {
model->removeEntry(entry);
} else if (coreEngine->filter() == KNSCore::Provider::Installed && entry.status() == KNS3::Entry::Deleted) {
model->removeEntry(entry);
}
}
}
};
ItemsModel::ItemsModel(QObject *parent)
......
......@@ -50,10 +50,10 @@ void EntryDetails::init()
[this](const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::EntryEvent event) {
if (event == KNSCore::EntryInternal::DetailsLoadedEvent) {
Q_EMIT entryChanged(entry);
} else if (event == KNSCore::EntryInternal::StatusChangedEvent) {
updateButtons();
}
});
connect(m_engine, &KNSCore::Engine::signalEntryChanged,
this, &EntryDetails::entryStatusChanged);
connect(m_engine, &KNSCore::Engine::signalEntryPreviewLoaded,
this, &EntryDetails::slotEntryPreviewLoaded);
}
......@@ -157,12 +157,6 @@ void EntryDetails::entryChanged(const KNSCore::EntryInternal &entry)
updateButtons();
}
void EntryDetails::entryStatusChanged(const KNSCore::EntryInternal &entry)
{
Q_UNUSED(entry);
updateButtons();
}
void EntryDetails::updateButtons()
{
if (ui->detailsStack->currentIndex() == 0) {
......
......@@ -43,7 +43,6 @@ private Q_SLOTS:
// more details loaded
void entryChanged(const KNSCore::EntryInternal &entry);
// installed/updateable etc
void entryStatusChanged(const KNSCore::EntryInternal &entry);
void updateButtons();
void preview1Selected();
......
......@@ -105,7 +105,7 @@ void KNewStuff2Test::engineTest()
m_engine = new KNSCore::Engine(this);
connect(m_engine,
&KNSCore::Engine::signalError,
&KNSCore::Engine::signalErrorCode,
this, &KNewStuff2Test::slotEngineError);
connect(m_engine,
&KNSCore::Engine::signalProvidersLoaded,
......@@ -114,7 +114,7 @@ void KNewStuff2Test::engineTest()
&KNSCore::Engine::signalEntriesLoaded,
this, &KNewStuff2Test::slotEntriesLoaded);
connect(m_engine,
&KNSCore::Engine::signalEntryChanged,
&KNSCore::Engine::signalEntryEvent,
this, &KNewStuff2Test::slotInstallationFinished);
bool ret = m_engine->init(m_configFile);
......@@ -159,9 +159,9 @@ void KNewStuff2Test::slotInstallationFinished()
addMessage(QStringLiteral("SLOT: slotInstallationFinished"));
}
void KNewStuff2Test::slotEngineError(const QString &error)
void KNewStuff2Test::slotEngineError(const KNSCore::ErrorCode &, const QString &message, const QVariant &)
{
addMessage(QStringLiteral("SLOT: slotEngineError %1").arg(error), QStringLiteral("msg_error"));
addMessage(QStringLiteral("SLOT: slotEngineError %1").arg(message), QStringLiteral("msg_error"));
}
QObject *KNewStuff2Test::messages()
......
......@@ -40,7 +40,7 @@ public:
public Q_SLOTS:
void slotProvidersLoaded();
void slotEngineError(const QString &error);
void slotEngineError(const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &metadata);
void slotEntriesLoaded(const KNSCore::EntryInternal::List &entries);
void slotInstallationFinished();
......
Markdown is supported
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