]> git.sesse.net Git - kdenlive/blob - src/utils/abstractservice.h
Const'ref
[kdenlive] / src / utils / abstractservice.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
19  ***************************************************************************/
20
21
22 #ifndef ABSTRACTSERVICE_H
23 #define ABSTRACTSERVICE_H
24
25
26 #include <QListWidget>
27
28 const int imageRole = Qt::UserRole;
29 const int urlRole = Qt::UserRole + 1;
30 const int downloadRole = Qt::UserRole + 2;
31 const int durationRole = Qt::UserRole + 3;
32 const int previewRole = Qt::UserRole + 4;
33 const int authorRole = Qt::UserRole + 5;
34 const int authorUrl = Qt::UserRole + 6;
35 const int infoUrl = Qt::UserRole + 7;
36 const int infoData = Qt::UserRole + 8;
37 const int idRole = Qt::UserRole + 9;
38 const int licenseRole = Qt::UserRole + 10;
39 const int descriptionRole = Qt::UserRole + 11;
40
41 enum SERVICETYPE { NOSERVICE = 0, FREESOUND = 1, OPENCLIPART = 2, ARCHIVEORG = 3 };
42
43 struct OnlineItemInfo {
44     QString itemPreview;
45     QString itemName;
46     QString itemDownload;
47     QString itemId;
48     QString infoUrl;
49     QString license;
50     QString author;
51     QString authorUrl;
52     QString description;
53 };
54
55
56 class AbstractService : public QObject
57 {
58     Q_OBJECT
59
60 public:
61     explicit AbstractService(QListWidget *listWidget, QObject * parent = 0);
62     ~AbstractService();
63     /** @brief Get file extension for currently selected item. */
64     virtual QString getExtension(QListWidgetItem *item);
65     /** @brief Get recommanded download file name. */
66     virtual QString getDefaultDownloadName(QListWidgetItem *item);
67         /** @brief Does this service provide a preview (for example preview a sound. */
68     bool hasPreview;
69     /** @brief Does this service provide meta info about the item. */
70     bool hasMetadata;
71     /** @brief Should we show the "import" button or does this service provide download urls in info browser. */
72     bool inlineDownload;
73     /** @brief The type for this service. */
74     SERVICETYPE serviceType;
75
76 public slots:
77     virtual void slotStartSearch(const QString &searchText, int page = 0);
78     virtual OnlineItemInfo displayItemDetails(QListWidgetItem *item);
79     virtual bool startItemPreview(QListWidgetItem *item);
80     virtual void stopItemPreview(QListWidgetItem *item);
81
82 protected:
83     QListWidget *m_listWidget;
84     
85 signals:
86     void searchInfo(const QString &);
87     void maxPages(int);
88     /** @brief Emit meta info for current item in formatted html. */
89     void gotMetaInfo(const QString &);
90     /** @brief Emit some extra meta info (description, license). */
91     void gotMetaInfo(const QMap <QString, QString> &info);
92     /** @brief We have an url for current item's preview thumbnail. */
93     void gotThumb(const QString &url);
94     /** @brief The requested search query is finished. */
95     void searchDone();
96 };
97
98
99 #endif
100