diff --git a/plugins/extensions/resourcemanager/CMakeLists.txt b/plugins/extensions/resourcemanager/CMakeLists.txt index 4700afeda7..ca645c5803 100644 --- a/plugins/extensions/resourcemanager/CMakeLists.txt +++ b/plugins/extensions/resourcemanager/CMakeLists.txt @@ -1,47 +1,48 @@ find_package(KF5NewStuffCore ${KF5_DEP_VERSION} CONFIG REQUIRED) set_package_properties(KF5NewStuffCore PROPERTIES DESCRIPTION "The KNewStuff library implements collaborative data sharing for applications." URL "https://api.kde.org/frameworks/knewstuff/html/index.html" TYPE REQUIRED PURPOSE "Required to implement sharing functionality with share.krita.org and krita") find_package(KF5Attica ${KF5_DEP_VERSION} CONFIG REQUIRED) set_package_properties(KF5Attica PROPERTIES DESCRIPTION "A Qt library that implements the Open Collaboration Services API" PURPOSE "Support for KF5NewStuffCore to get the contents." URL "https://projects.kde.org/attica" TYPE REQUIRED ) set(kritaresourcemanager_SOURCES resourcemanager.cpp dlg_create_bundle.cpp dlg_bundle_manager.cpp widgetquestionlistener.cpp entrydetailsdialog.cpp itemsgridviewdelegate.cpp itemsviewbasedelegate.cpp itemsviewdelegate.cpp itemsview.cpp imagepreviewwidget.cpp dlg_content_downloader.cpp + entry.cpp ) ki18n_wrap_ui(kritaresourcemanager_SOURCES wdgdlgcreatebundle.ui wdgdlgbundlemanager.ui wdgdlgcontentdownloader.ui ) install( FILES data/kritapresets.knsrc datakritabrushes.knsrc data/kritapatterns.knsrc data/kritagradients.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) add_library(kritaresourcemanager MODULE ${kritaresourcemanager_SOURCES}) target_link_libraries(kritaresourcemanager kritawidgets kritaui kritalibpaintop KF5::NewStuffCore) install(TARGETS kritaresourcemanager DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) install(FILES resourcemanager.xmlgui DESTINATION ${DATA_INSTALL_DIR}/kritaplugins) diff --git a/plugins/extensions/resourcemanager/dlg_content_downloader.cpp b/plugins/extensions/resourcemanager/dlg_content_downloader.cpp index 1251127e0a..caf3ed2b87 100644 --- a/plugins/extensions/resourcemanager/dlg_content_downloader.cpp +++ b/plugins/extensions/resourcemanager/dlg_content_downloader.cpp @@ -1,388 +1,389 @@ /* * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "dlg_content_downloader.h" #include "dlg_content_downloader_p.h" #include "itemsviewbasedelegate_p.h" #include "itemsviewdelegate_p.h" #include "itemsgridviewdelegate_p.h" #include #include #include #include #include #include #include +#include "entry_p.h" using namespace KNS3; DlgContentDownloader::DlgContentDownloader(QWidget *parent) : QWidget(parent) , d(new DlgContentDownloaderPrivate(this)) { const Qstring name = QCoreApplication::applicationName(); init(name + ".knsrc") } DlgContentDownloader::DlgContentDownloader(const QString &knsrc, QWidget *parent) : QWidget(parent) , d(new DlgContentDownloaderPrivate(this)) { init(knsrc); } void DlgContentDownloader::init(const QString &knsrc) { d->init(knsrc); } DlgContentDownloader::~DlgContentDownloader() { delete d; } void DlgContentDownloader::setTitle(const Qstring &title) { d->ui.m_titleWidget->setText(title); } void DlgContentDownloader::title() const { return d->ui.m_titleWidget->text(); } KNSCore::Engine *DlgContentDownloader::engine() { return d->engine; } Entry::List DlgContentDownloader::changedEntries() { Entry::List entries; foreach (const KNSCore::EntryInternal &e, d->changedEntries) { entries.append(EntryPrivate::fromInternal(&e)); } return entries; } Entry::List DlgContentDownloader::installedEntries() { Entry::List entries; foreach (const KNSCore::EntryInternal &e, d->changedEntries) { if (e.status() == Entry::Installed) { entries.append(EntryPrivate::fromInternal(&e)); } } return entries; } DlgContentDownloaderPrivate::DlgContentDownloaderPrivate(DlgContentDownloader *q) : q(q) , engine(new KNSCore::Engine) , model(new KNSCore::ItemsModel(engine)) , messageTimer(nullptr) , dialogMode(false) { } DlgContentDownloaderPrivate::~DlgContentDownloaderPrivate() { delete messageTimer; delete delegate; delete model; delete engine; } void DlgContentDownloaderPrivate::slotResetMessage() { ui.m_titleWidget->setComment(QString()); } void DlgContentDownloaderPrivate::slotNetworkTimeout() { displayMessage(i18n("Timeout. Please Check your Internet connection."), KTitleWidget::ErrrorMessage); } void DlgContentDownloaderPrivate::sortingChanged() { KNSCore::Provider::SortMode sortMode = KNSCore::Provider::Newest; KNSCore::Provider::Filter filter = KNSCore::Provider::None; if (ui.ratingRadio->isChecked()) { sortMode = KNSCore::Provider::Rating; } else if (ui.mostDownloadsRadio->isChecked()) { sortMode = KNSCore::Provider::Downloads; } else if (ui.installedRadio->isChecked()) { filter = KNSCore::Provider::Installed; } model->clearEntries(); if (filter == KNSCore::Provider::Installed) { ui.m_searchEdit->clear(); } ui.m_searchEdit->setEnabled(filter != KNSCore::Provider::Installed); engine->setSortMode(sortMode); engine->setFilter(filter); } void DlgContentDownloaderPrivate::slotUpdateSearch() { if (searchTerm == ui.m_searchEdit->text().trimmed()) { return; } searchTerm = ui.m_searchEdit->text().trimmed(); } void DlgContentDownloaderPrivate::slotSearchTextChanged() { if (searchTerm == ui.m_searchEdit->text().trimmed()) { return; } searchTerm = ui.m_searchEdit->text().trimmed(); engine->setSearchTerm(ui.m_searchEdit->text().trimmed()); } void DlgContentDownloaderPrivate::slotCategoryChanged(int idx) { if (idx == 0) { // All Categories item selected, reset filter engine->setCategoriesFilter(QStringList()); } else { QString category = ui.m_categoryCombo->currentData().toString(); if (!category.isEmpty()) { QStringList filter(category); engine->setCategoriesFilter(filter); } } } void DlgContentDownloaderPrivate::slotEntryChanged(const KNSCore::EntryInternal &entry) { changedEntries.insert(entry); model->slotEntryChanged(entry); } void DlgContentDownloaderPrivate::slotPayloadFailed(const KNSCore::EntryInternal &entry) { KMessageBox::error(nullptr, i18n("Could not install %1", entry.name()), i18n("Get Hot New Stuff!")); } void DlgContentDownloaderPrivate::slotPayloadLoaded(QUrl url) { Q_UNUSED(url) } void DlgContentDownloaderPrivate::init(const QString &configFile) { m_configFile = configFile; ui.setupUi(q); ui.m_titleWidget->setVisible(false); ui.closeButton->setVisible(dialogMode); ui.backButton->setVisible(false); KStandardGuiItem::assign(ui.backButton, KStandardGuiItem::Back); q->connect(ui.backButton, &QPushButton::clicked, this, &DlgContentDownloaderPrivate::slotShowOverview); q->connect(engine, &KNSCore::Engine::signalMessage, this, &DlgContentDownloaderPrivate::slotShowMessage); q->connect(engine, &KNSCore::Engine::signalProvidersLoaded, this, &DlgContentDownloaderPrivate::slotProvidersLoaded); // Entries have been fetched and should be shown: q->connect(engine, &KNSCore::Engine::signalEntriesLoaded, this, &DlgContentDownloaderPrivate::slotEntriesLoaded); // An entry has changes - eg because it was installed q->connect(engine, &KNSCore::Engine::signalEntryChanged, this, &DlgContentDownloaderPrivate::slotEntryChanged); q->connect(engine, &KNSCore::Engine::signalResetView, model, &KNSCore::ItemsModel::clearEntries); q->connect(engine, &KNSCore::Engine::signalEntryPreviewLoaded, model, &KNSCore::ItemsModel::slotEntryPreviewLoaded); engine->init(configFile); delegate = new ItemsViewDelegate(ui.m_listView, engine, q); ui.m_listView->setItemDelegate(delegate); ui.m_listView->setModel(model); ui.iconViewButton->setIcon(QIcon::fromTheme(QStringLiteral("view-list-icons"))); ui.iconViewButton->setToolTip(i18n("Icons view mode")); ui.listViewButton->setIcon(QIcon::fromTheme(QStringLiteral("view-list-details"))); ui.listViewButton->setToolTip(i18n("Details view mode")); q->connect(ui.listViewButton, &QPushButton::clicked, this, &DlgContentDownloaderPrivate::slotListViewListMode); q->connect(ui.iconViewButton, &QPushButton::clicked, this, &DlgContentDownloaderPrivate::slotListViewIconMode); q->connect(ui.newestRadio, &QRadioButton::clicked, this, &DlgContentDownloaderPrivate::sortingChanged); q->connect(ui.ratingRadio, &QRadioButton::clicked, this, &DlgContentDownloaderPrivate::sortingChanged); q->connect(ui.mostDownloadsRadio, &QRadioButton::clicked, this, &DlgContentDownloaderPrivate::sortingChanged); q->connect(ui.installedRadio, &QRadioButton::clicked, this, &DlgContentDownloaderPrivate::sortingChanged); q->connect(ui.m_searchEdit, &KLineEdit::textChanged, this, &DlgContentDownloaderPrivate::slotSearchTextChanged); q->connect(ui.m_searchEdit, &KLineEdit::editingFinished, this, &DlgContentDownloaderPrivate::slotUpdateSearch); QStringList categories = engine->categories(); if (categories.size() < 2) { ui.m_categoryLabel->setVisible(false); ui.m_categoryCombo->setVisible(false); } else { ui.m_categoryCombo->addItem(i18n("All Categories")); //NOTE: categories will be populated when we will get metadata from the server } connect(engine, &KNSCore::Engine::signalCategoriesMetadataLoded, this, [this](const QList &categories) { for (auto data : categories) { if (!data.displayName.isEmpty()) { ui.m_categoryCombo->addItem(data.displayName, data.name); } else { ui.m_categoryCombo->addItem(data.name, data.name); } } }); ui.detailsStack->widget(0)->layout()->setMargin(0); ui.detailsStack->widget(1)->layout()->setMargin(0); q->connect(ui.m_categoryCombo, static_cast(&KComboBox::activated), this, &DlgContentDownloaderPrivate::slotCategoryChanged); // let the search line edit trap the enter key, otherwise it closes the dialog ui.m_searchEdit->setTrapReturnKey(true); q->connect(ui.m_listView->verticalScrollBar(), &QScrollBar::valueChanged, this, &DlgContentDownloaderPrivate::scrollbarValueChanged); q->connect(ui.m_listView, SIGNAL(doubleClicked(QModelIndex)), delegate, SLOT(slotDetailsClicked(QModelIndex))); details = new EntryDetails(engine, &ui); q->connect(delegate, &KNS3::ItemsViewBaseDelegate::signalShowDetails, this, &DlgContentDownloaderPrivate::slotShowDetails); slotShowOverview(); } void DlgContentDownloaderPrivate::slotListViewListMode() { ui.listViewButton->setChecked(true); ui.iconViewButton->setChecked(false); setListViewMode(QListView::ListMode); } void DlgContentDownloaderPrivate::slotListViewIconMode() { ui.listViewButton->setChecked(false); ui.iconViewButton->setChecked(true); setListViewMode(QListView::IconMode); } void DlgContentDownloaderPrivate::setListViewMode(QListView::ViewMode mode) { if (ui.m_listView->viewMode() == mode) { return; } ItemsViewBaseDelegate *oldDelegate = delegate; if (mode == QListView::ListMode) { delegate = new ItemsViewDelegate(ui.m_listView, engine, q); ui.m_listView->setViewMode(QListView::ListMode); ui.m_listView->setResizeMode(QListView::Fixed); } else { delegate = new ItemsGridViewDelegate(ui.m_listView, engine, q); ui.m_listView->setViewMode(QListView::IconMode); ui.m_listView->setResizeMode(QListView::Adjust); } ui.m_listView->setItemDelegate(delegate); delete oldDelegate; q->connect(ui.m_listView, SIGNAL(doubleClicked(QModelIndex)), delegate, SLOT(slotDetailsClicked(QModelIndex))); q->connect(delegate, &ItemsViewBaseDelegate::signalShowDetails, this, &DlgContentDownloaderPrivate::slotShowDetails); } void DlgContentDownloaderPrivate::slotProvidersLoaded() { engine->reloadEntries(); } void DlgContentDownloaderPrivate::slotEntriesLoaded(const KNSCore::EntryInternal::List &entries) { foreach (const KNSCore::EntryInternal &entry, entries) { if (!categories.contains(entry.category())) { categories.insert(entry.category()); } } model->slotEntriesLoaded(entries); } void DlgContentDownloaderPrivate::slotShowMessage(const QString& msg) { displayMessage(msg, KTitleWidget::InfoMessage); } void DlgContentDownloaderPrivate::displayMessage(const QString &msg, KTitleWidget::MessageType type, int timeOutMs) { if (!messageTimer) { messageTimer = new QTimer; messageTimer->setSingleShot(true); q->connect(messageTimer, &QTimer::timeout, this, &DlgContentDownloaderPrivate::slotResetMessage); } // stop the pending timer if present messageTimer->stop(); // set text to messageLabel ui.m_titleWidget->setComment(msg, type); // single shot the resetColors timer (and create it if null) if (timeOutMs > 0) { messageTimer->start(timeOutMs); } } void DlgContentDownloaderPrivate::slotShowDetails(const KNSCore::EntryInternal &entry) { if (!entry.isValid()) { return; } titleText = ui.m_titleWidget->text(); ui.backButton->setVisible(true); ui.detailsStack->setCurrentIndex(1); ui.descriptionScrollArea->verticalScrollBar()->setValue(0); ui.preview1->setImage(QImage()); ui.preview2->setImage(QImage()); ui.preview3->setImage(QImage()); ui.previewBig->setImage(QImage()); details->setEntry(entry); } void DlgContentDownloaderPrivate::slotShowOverview() { ui.backButton->setVisible(false); ui.updateButton->setVisible(false); ui.installButton->setVisible(false); ui.becomeFanButton->setVisible(false); ui.uninstallButton->setVisible(false); ui.detailsStack->setCurrentIndex(0); ui.m_titleWidget->setText(titleText); } #include "moc_dlg_content_downloader.cpp" diff --git a/plugins/extensions/resourcemanager/dlg_content_downloader_p.h b/plugins/extensions/resourcemanager/dlg_content_downloader_p.h index 0ec2558c11..521b627cd0 100644 --- a/plugins/extensions/resourcemanager/dlg_content_downloader_p.h +++ b/plugins/extensions/resourcemanager/dlg_content_downloader_p.h @@ -1,112 +1,100 @@ /* * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef DLG_CONTENT_DOWNLOADER_P_H #define DLG_CONTENT_DOWNLOADER_P_H #include #include #include #include #include #include #include #include "entrydetailsdialog_p.h" #include "itemsviewbasedelegate_p.h" #include "ui_wdgdlgcontentdownloader.h" namespace Ui { class WdgDlgContentDownloader; } class DlgContentDownloader; class DlgContentDownloaderPrivate : public QObject { Q_OBJECT public: DlgContentDownloader *q; EntryDetails *details; // The engine that does all the work KNSCore::Engine *engine; Ui::WdgDlgContentDownloader ui; // Model to show the entries KNSCore::ItemsModel *model; // Timeout for messge display QTimer *messageTimer; ItemsViewBaseDelegate *delegate; QString searchTerm; QSet changedEntries; QSet categories; QSet providers; QString titleText; QString m_knsrc; bool dialogMode; explicit DlgContentDownloaderPrivate(DlgContentDownloader *q); ~DlgContentDownloaderPrivate(); void init(const QString &knsrc); void slotShowMessage(const QString& msg); void displayMessage(const QString &msg, KTitleWidget::MessageType type, int timeOutMs = 0); void slotProvidersLoaded(); void slotEntriesLoaded(const KNSCore::EntryInternal::List &entries); void slotEntryChanged(const KNSCore::EntryInternal &entry); void slotShowDetails(const KNSCore::EntryInternal &entry); void slotShowOverview(); void slotPayloadFailed(const KNSCore::EntryInternal &entry); void slotPayloadLoaded(QUrl url); void slotResetMessage(); void slotNetworkTimeout(); void sortingChanged(); void slotSearchTextChanged(); void slotUpdateSearch(); void slotCategoryChanged(int); void slotListViewListMode(); void slotListViewIconMode(); void setListViewMode(QListView::ViewMode mode); }; -class EntryPrivate : public QSharedData -{ -public: - KNSCore::EntryInternal e; - static KNS3::Entry fromInternal(const KNSCore::EntryInternal* internal) - { - KNS3::Entry e; - e.d->e = *internal; - return e; - } -}; - #endif // DLG_CONTENT_DOWNLOADER_P_H diff --git a/plugins/extensions/resourcemanager/entry.cpp b/plugins/extensions/resourcemanager/entry.cpp new file mode 100644 index 0000000000..0210df8703 --- /dev/null +++ b/plugins/extensions/resourcemanager/entry.cpp @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2009 Frederik Gladhorn + * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "entry.h" +#include "entry_p.h" + +#include + +using namespace KNS3; + +Entry::Entry() + : d(new EntryPrivate) +{ +} + +Entry::Entry(const Entry &other) + : d(other.d) +{ +} + +Entry &Entry::operator=(const Entry &other) +{ + d = other.d; + return *this; +} + +Entry::~Entry() +{ +} + +QString Entry::id() const +{ + return d->e.uniqueId(); +} + +QString Entry::providerId() const +{ + return d->e.providerId(); +} + +QString Entry::name() const +{ + return d->e.name(); +} + +QString Entry::category() const +{ + return d->e.category(); +} + +QString Entry::license() const +{ + return d->e.license(); +} + +QString Entry::summary() const +{ + return d->e.summary(); +} + +QString Entry::version() const +{ + return d->e.version(); +} + +Entry::Status Entry::status() const +{ + return static_cast(d->e.status()); +} + +QStringList Entry::installedFiles() const +{ + return d->e.installedFiles(); +} + +QStringList Entry::uninstalledFiles() const +{ + return d->e.uninstalledFiles(); +} + +QUrl Entry::url() const +{ + return d->e.homepage(); +} + +static void appendIfValid(QList& list, const QUrl &value) +{ + if (value.isValid() && !value.isEmpty()) + list << value; +} + +QList Entry::previewImages() const +{ + QList ret; + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewBig1))); + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewBig2))); + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewBig3))); + return ret; +} + +QList Entry::previewThumbnails() const +{ + QList ret; + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewSmall1))); + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewSmall2))); + appendIfValid(ret, QUrl(d->e.previewUrl(KNSCore::EntryInternal::PreviewSmall3))); + return ret; +} + +quint64 Entry::size() const +{ + const auto downloadInfo = d->e.downloadLinkInformationList(); + return downloadInfo.isEmpty() ? 0 : downloadInfo.at(0).size; +} + +uint Entry::numberOfComments() const +{ + return d->e.numberOfComments(); +} + +uint Entry::rating() const +{ + return d->e.rating(); +} + +QString Entry::updateVersion() const +{ + return d->e.updateVersion(); +} + +QString Entry::changelog() const +{ + return d->e.changelog(); +} + +QString Entry::shortSummary() const +{ + return d->e.shortSummary(); +} diff --git a/plugins/extensions/resourcemanager/entry.h b/plugins/extensions/resourcemanager/entry.h new file mode 100644 index 0000000000..14b0168dba --- /dev/null +++ b/plugins/extensions/resourcemanager/entry.h @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2002 Cornelius Schumacher + * Copyright (c) 2003 - 2007 Josef Spillner + * Copyright (c) 2009 Jeremy Whiting + * Copyright (C) 2009 Frederik Gladhorn + * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ENTRY_H +#define ENTRY_H + +#include +#include +#include + +namespace KNSCore { class EntryInternal; } + +class EntryPrivate; +/** + * + * This class provides information about the entries that + * have been installed while the content dialog was shown. + * + */ +class Entry +{ +public: + typedef QList List; + + /** + * Status of the entry. An entry will be downloadable from the provider's + * site prior to the download. Once downloaded and installed, it will + * be either installed or updateable, implying an out-of-date + * installation. Finally, the entry can be deleted and hence show up as + * downloadable again. + * Entries not taking part in this cycle, for example those in upload, + * have an invalid status. + */ + enum Status { + Invalid, + Downloadable, + Installed, + Updateable, + Deleted, + Installing, + Updating + }; + + ~Entry(); + Entry(const Entry &other); + Entry &operator=(const Entry &other); + + /** + * Retrieve the name of the data object. + * + * @return object name + */ + QString name() const; + + /** + * Retrieve the category of the data object. + * + * @return object category + */ + QString category() const; + + /** + * Retrieve the locally installed files. + * @return file names + */ + QStringList installedFiles() const; + + /** + * Retrieve the locally uninstalled files. + * @return file names + */ + QStringList uninstalledFiles() const; + + /** + * Retrieves the entry's status. + * + * @return Current status of the entry + */ + Status status() const; + + /** + * Retrieve the license name of the object. + * + * @return object license + */ + QString license() const; + + /** + * Retrieve a short description about the object. + * + * @return object description + */ + QString summary() const; + + /** + * Retrieve the version string of the object. + * + * @return object version + * + * @sa installedVersion() + */ + QString version() const; + + /** + * Id of this Entry. It is guaranteed to be unique for one provider. + * Id and ProviderId together identifiy this entry. + * @return the id + * @since 4.5 + */ + QString id() const; + + /** + * The Provider which is the source of the Entry. + * @return the Id of the Provider + * @since 4.5 + */ + QString providerId() const; + + /** + * @returns if available an url identifying the asset + */ + QUrl url() const; + + /** + * @returns a list of urls to small previews to be displayed as thumbnails + */ + QList previewThumbnails() const; + + /** + * @returns a list of full previews of the asset + */ + QList previewImages() const; + + /** + * @returns the advertised disk size of the asset + */ + quint64 size() const; + + /** + * @returns the number of comments in the asset + */ + uint numberOfComments() const; + + /** + * @returns the rating of the asset, between 0 and 100 + */ + uint rating() const; + + /** + * @returns the asset's change log + */ + QString changelog() const; + + /** + * @returns a short one-line summary of the asset + */ + QString shortSummary() const; + + /** + * @returns the available version + * + * If the entry is not updateable, it will be the same as version. + * + * @sa version() + * + */ + QString updateVersion() const; + +private: + Entry(); + + QExplicitlySharedDataPointer d; + + friend class KNSCore::EntryInternal; + friend class EntryPrivate; +}; + +#endif // ENTRY_H diff --git a/plugins/extensions/resourcemanager/entry_p.h b/plugins/extensions/resourcemanager/entry_p.h new file mode 100644 index 0000000000..82fdbdc809 --- /dev/null +++ b/plugins/extensions/resourcemanager/entry_p.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 Frederik Gladhorn + * Copyright (c) 2017 Aniketh Girish anikethgireesh@gmail.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ENTRY_P_H +#define ENTRY_P_H + +#include +#include + +class EntryPrivate : public QSharedData +{ +public: + KNSCore::EntryInternal e; + static Entry fromInternal(const KNSCore::EntryInternal* internal) + { + Entry e; + e.d->e = *internal; + return e; + } +}; + +#endif // ENTRY_P_H