diff --git a/src/qtquick/quickengine.h b/src/qtquick/quickengine.h index 8187e0c0..b0343fde 100644 --- a/src/qtquick/quickengine.h +++ b/src/qtquick/quickengine.h @@ -1,120 +1,120 @@ /* * Copyright (C) 2016 Dan Leinir Turthra Jensen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #ifndef ENGINE_H #define ENGINE_H #include #include /** * @short Encapsulates a KNSCore::Engine for use in Qt Quick * * This class takes care of initialisation of a KNSCore::Engine when assigned a config file. * The actual KNSCore:Engine can be read through the Engine::engine property. * * @see ItemsModel */ class Engine : public QObject { Q_OBJECT Q_PROPERTY(bool allowedByKiosk READ allowedByKiosk CONSTANT) Q_PROPERTY(QString configFile READ configFile WRITE setConfigFile NOTIFY configFileChanged) Q_PROPERTY(QObject* engine READ engine NOTIFY engineChanged) /** * Whether or not the engine is performing its initial loading operations - * @since 5.64 + * @since 5.65 */ Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged) Q_PROPERTY(bool hasAdoptionCommand READ hasAdoptionCommand NOTIFY engineInitialized) Q_PROPERTY(QString name READ name NOTIFY engineInitialized) Q_PROPERTY(QObject* categories READ categories NOTIFY categoriesChanged) Q_PROPERTY(QStringList categoriesFilter READ categoriesFilter WRITE setCategoriesFilter RESET resetCategoriesFilter NOTIFY categoriesFilterChanged) Q_PROPERTY(int filter READ filter WRITE setFilter NOTIFY filterChanged) Q_PROPERTY(int sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged) Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm RESET resetSearchTerm NOTIFY searchTermChanged) Q_PROPERTY(KNSCore::EntryInternal::List changedEntries READ changedEntries RESET resetChangedEntries NOTIFY changedEntriesChanged) Q_PROPERTY(int changedEntriesCount READ changedEntriesCount NOTIFY changedEntriesChanged) public: explicit Engine(QObject *parent = nullptr); virtual ~Engine(); bool allowedByKiosk() const; QString configFile() const; void setConfigFile(const QString &newFile); Q_SIGNAL void configFileChanged(); QObject *engine() const; Q_SIGNAL void engineChanged(); /** * Whether or not the engine is performing its initial loading operations - * @since 5.64 + * @since 5.65 */ bool isLoading() const; /** * Fired when the isLoading value changes - * @since 5.64 + * @since 5.65 */ Q_SIGNAL void isLoadingChanged(); bool hasAdoptionCommand() const; QString name() const; Q_SIGNAL void engineInitialized(); QObject *categories() const; Q_SIGNAL void categoriesChanged(); QStringList categoriesFilter() const; void setCategoriesFilter(const QStringList &newCategoriesFilter); Q_INVOKABLE void resetCategoriesFilter(); Q_SIGNAL void categoriesFilterChanged(); int filter() const; void setFilter(int newFilter); Q_SIGNAL void filterChanged(); int sortOrder() const; void setSortOrder(int newSortOrder); Q_SIGNAL void sortOrderChanged(); QString searchTerm() const; void setSearchTerm(const QString &newSearchTerm); Q_INVOKABLE void resetSearchTerm(); Q_SIGNAL void searchTermChanged(); KNSCore::EntryInternal::List changedEntries() const; Q_INVOKABLE void resetChangedEntries(); Q_SIGNAL void changedEntriesChanged(); int changedEntriesCount() const; Q_SIGNALS: void message(const QString &message); void idleMessage(const QString &message); void busyMessage(const QString &message); void errorMessage(const QString &message); private: class Private; Private *d; }; #endif//ENGINE_H diff --git a/src/qtquick/quickitemsmodel.h b/src/qtquick/quickitemsmodel.h index 4aba37dc..f472c762 100644 --- a/src/qtquick/quickitemsmodel.h +++ b/src/qtquick/quickitemsmodel.h @@ -1,188 +1,188 @@ /* * Copyright (C) 2016 Dan Leinir Turthra Jensen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . * */ #ifndef ITEMSMODEL_H #define ITEMSMODEL_H #include /** * @short A model which shows the contents found in an Engine * * Use an instance of this model to show the content items represented by the configuration * file passed to an engine. The following sample assumes you are using the Engine component, * however it is also possible to pass a KNSCore::Engine instance created from C++ to this * property, if you have specific requirements not covered by the convenience component. * * Most data in the model is simple, but the DownloadLinks role will return a list of * DownloadLinkInfo entries, which you will need to manage in some way. * * You might also look at NewStuffList, NewStuffItem, and the other items, to see some more * detail on what can be done with the data. * * @see NewStuffList * @see NewStuffItem * @see NewStuffPage * @see NewStuffEntryDetails * @see NewStuffEntryComments * * \code import org.kde.newstuff 1.0 as NewStuff Item { NewStuff.ItemsModel { id: newStuffModel; engine: newStuffEngine.engine; } NewStuff.Engine { id: newStuffEngine; configFile: "/some/filesystem/location/wallpaper.knsrc"; onMessage: console.log("KNS Message: " + message); onIdleMessage: console.log("KNS Idle: " + message); onBusyMessage: console.log("KNS Busy: " + message); onErrorMessage: console.log("KNS Error: " + message); } } \endcode */ class ItemsModel : public QAbstractListModel { Q_OBJECT /** * The NewStuffQuickEngine to show items from */ Q_PROPERTY(QObject* engine READ engine WRITE setEngine NOTIFY engineChanged) /** * Whether or not the model is fetching information from a remote location - * @since 5.64 + * @since 5.65 */ Q_PROPERTY(bool isLoadingData READ isLoadingData NOTIFY isLoadingDataChanged) public: explicit ItemsModel(QObject *parent = nullptr); virtual ~ItemsModel(); enum Roles { NameRole = Qt::UserRole + 1, UniqueIdRole, CategoryRole, HomepageRole, AuthorRole, LicenseRole, ShortSummaryRole, SummaryRole, ChangelogRole, VersionRole, ReleaseDateRole, UpdateVersionRole, UpdateReleaseDateRole, PayloadRole, PreviewsSmallRole, ///@< this will return a list here, rather than be tied so tightly to the remote api PreviewsRole, ///@< this will return a list here, rather than be tied so tightly to the remote api InstalledFilesRole, UnInstalledFilesRole, RatingRole, NumberOfCommentsRole, DownloadCountRole, NumberFansRole, NumberKnowledgebaseEntriesRole, KnowledgebaseLinkRole, DownloadLinksRole, DonationLinkRole, ProviderIdRole, SourceRole, StatusRole, CommentsModelRole }; Q_ENUM(Roles) enum ItemStatus { InvalidStatus, DownloadableStatus, InstalledStatus, UpdateableStatus, DeletedStatus, InstallingStatus, UpdatingStatus }; Q_ENUM(ItemStatus) 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; bool canFetchMore(const QModelIndex & parent) const override; void fetchMore(const QModelIndex & parent) override; QObject *engine() const; void setEngine(QObject *newEngine); Q_SIGNAL void engineChanged(); /** * Whether or not the model is fetching information from a remote location - * @since 5.64 + * @since 5.65 */ bool isLoadingData() const; /** * Fired when the isLoadingData value changes - * @since 5.64 + * @since 5.65 */ Q_SIGNAL void isLoadingDataChanged(); /** * @brief This will install (or update, if already installed) the item at the given index * * There are no side effects of this function if it is called on an item which cannot be * installed or updated (that is, if the status is not one such that these are possible, * the function will simply return without performing any actions) * * @param index The index of the item to install or update */ Q_INVOKABLE void installItem(int index, int linkId); /** * @brief Uninstall an already installed item * * There are no side effects of this function if it is called on an item which cannot be * uninstalled (that is, if the status is not one such that this is possible, * the function will simply return without performing any actions) * * @param index The index of the item to be uninstalled */ Q_INVOKABLE void uninstallItem(int index); /** * @brief Run the adoption command on an already installed item * * @note This will simply fail quietly if the item is not installed * * @param index The intex of the item to be adopted */ Q_INVOKABLE void adoptItem(int index); /** * @brief Fired when an entry's data changes * * @param index The index of the item which has changed */ Q_SIGNAL void entryChanged(int index); private: class Private; Private *d; }; Q_DECLARE_METATYPE(ItemsModel::ItemStatus) #endif//ITEMSMODEL_H