1 /***************************************************************************
2 * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
22 #ifndef ABSTRACTSERVICE_H
23 #define ABSTRACTSERVICE_H
26 #include <QListWidget>
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;
41 enum SERVICETYPE { NOSERVICE = 0, FREESOUND = 1, OPENCLIPART = 2, ARCHIVEORG = 3 };
43 struct OnlineItemInfo {
56 class AbstractService : public QObject
61 explicit AbstractService(QListWidget *listWidget, QObject * parent = 0);
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. */
69 /** @brief Does this service provide meta info about the item. */
71 /** @brief Should we show the "import" button or does this service provide download urls in info browser. */
73 /** @brief The type for this service. */
74 SERVICETYPE serviceType;
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);
83 QListWidget *m_listWidget;
86 void searchInfo(const QString &);
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. */