File indexing completed on 2022-11-29 13:02:27

0001 /*
0002     SPDX-FileCopyrightText: 2011-2015 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef RESOURCEINSTANCE_H
0008 #define RESOURCEINSTANCE_H
0009 
0010 // Qt
0011 #include <QQuickItem>
0012 #include <QUrl>
0013 
0014 // STL
0015 #include <memory>
0016 
0017 namespace KActivities
0018 {
0019 class ResourceInstance;
0020 }
0021 
0022 class QTimer;
0023 
0024 namespace KActivities
0025 {
0026 namespace Imports
0027 {
0028 class ResourceInstance : public QQuickItem
0029 {
0030     Q_OBJECT
0031 
0032     Q_PROPERTY(QUrl uri READ uri WRITE setUri NOTIFY uriChanged)
0033     Q_PROPERTY(QString mimetype READ mimetype WRITE setMimetype NOTIFY mimetypeChanged)
0034     Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
0035 
0036 public:
0037     explicit ResourceInstance(QQuickItem *parent = nullptr);
0038     ~ResourceInstance() override;
0039 
0040     QUrl uri() const;
0041     void setUri(const QUrl &uri);
0042 
0043     QString mimetype() const;
0044     void setMimetype(const QString &mimetype);
0045 
0046     QString title() const;
0047     void setTitle(const QString &title);
0048 
0049 protected Q_SLOTS:
0050     void syncWid();
0051 
0052 Q_SIGNALS:
0053     void uriChanged();
0054     void mimetypeChanged();
0055     void titleChanged();
0056 
0057 public Q_SLOTS:
0058     /**
0059      * Call this method to notify the system that you modified
0060      * (the contents of) the resource
0061      */
0062     void notifyModified();
0063 
0064     /**
0065      * Call this method to notify the system that the resource
0066      * has the focus in your application
0067      * @note You only need to call this in MDI applications
0068      */
0069     void notifyFocusedIn();
0070 
0071     /**
0072      * Call this method to notify the system that the resource
0073      * lost the focus in your application
0074      * @note You only need to call this in MDI applications
0075      */
0076     void notifyFocusedOut();
0077 
0078 private:
0079     std::unique_ptr<KActivities::ResourceInstance> m_resourceInstance;
0080     QUrl m_uri;
0081     QString m_mimetype;
0082     QString m_title;
0083     QTimer *m_syncTimer;
0084 };
0085 
0086 }
0087 }
0088 
0089 #endif