X-Git-Url: https://git.sesse.net/?p=kdenlive;a=blobdiff_plain;f=src%2Fprojectlist.h;h=bd80c8b8324314c5c4e7ba1529c516057b808f36;hp=830e40348796b8d538a33d97c790ffd78e9ad2b5;hb=a3eee7be24126f5a3458d488f44cd61c66135e17;hpb=ed5a2c50b2402499f775bee428e079cac7bde423 diff --git a/src/projectlist.h b/src/projectlist.h index 830e4034..bd80c8b8 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -47,19 +46,25 @@ #include #endif +#ifdef NEPOMUKCORE +#include +#include +#endif + #include "definitions.h" #include "timecode.h" #include "kdenlivesettings.h" #include "folderprojectitem.h" #include "subprojectitem.h" #include "projecttree/abstractclipjob.h" -#include +#include "widgets/invaliddialog.h" #if KDE_IS_VERSION(4,7,0) #include #else // Dummy KMessageWidget to allow compilation of MyMessageWidget class since Qt's moc doesn work inside #ifdef #include + class KMessageWidget: public QLabel { public: @@ -86,7 +91,7 @@ signals: namespace Mlt { class Producer; -}; +} class ProjectItem; class ProjectListView; @@ -94,10 +99,8 @@ class Render; class KdenliveDoc; class DocClipBase; class AbstractClipJob; - -const int NameRole = Qt::UserRole; -const int DurationRole = NameRole + 1; -const int UsageRole = NameRole + 2; +class ItemDelegate; +class QGLWidget; class SmallInfoLabel: public QPushButton { @@ -106,6 +109,12 @@ public: SmallInfoLabel(QWidget *parent = 0); static const QString getStyleSheet(const QPalette &p); private: + enum ItemRole { + NameRole = Qt::UserRole, + DurationRole, + UsageRole + }; + QTimeLine* m_timeLine; public slots: @@ -115,121 +124,13 @@ private slots: void slotTimeLineChanged(qreal value); void slotTimeLineFinished(); }; - -class InvalidDialog: public KDialog -{ - Q_OBJECT -public: - InvalidDialog(const QString &caption, const QString &message, bool infoOnly, QWidget *parent = 0); - virtual ~InvalidDialog(); - void addClip(const QString &id, const QString &path); - QStringList getIds() const; -private: - QListWidget *m_clipList; -}; - - -class ItemDelegate: public QStyledItemDelegate -{ -public: - ItemDelegate(QAbstractItemView* parent = 0): QStyledItemDelegate(parent) { - } - - /*void drawFocus(QPainter *, const QStyleOptionViewItem &, const QRect &) const { - }*/ - - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - if (index.column() == 0 && !index.data(DurationRole).isNull()) { - QRect r1 = option.rect; - painter->save(); - QStyleOptionViewItemV4 opt(option); - QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); - style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); - - if (option.state & QStyle::State_Selected) { - painter->setPen(option.palette.highlightedText().color()); - } - const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1; - QPixmap pixmap = qVariantValue(index.data(Qt::DecorationRole)); - QPoint pixmapPoint(r1.left() + textMargin, r1.top() + (r1.height() - pixmap.height()) / 2); - painter->drawPixmap(pixmapPoint, pixmap); - int decoWidth = pixmap.width() + 2 * textMargin; - - QFont font = painter->font(); - font.setBold(true); - painter->setFont(font); - int mid = (int)((r1.height() / 2)); - r1.adjust(decoWidth, 0, 0, -mid); - QRect r2 = option.rect; - r2.adjust(decoWidth, mid, 0, 0); - painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom, index.data().toString()); - font.setBold(false); - painter->setFont(font); - QString subText = index.data(DurationRole).toString(); - int usage = index.data(UsageRole).toInt(); - if (usage != 0) subText.append(QString(" (%1)").arg(usage)); - QRectF bounding; - painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText, &bounding); - int jobProgress = index.data(Qt::UserRole + 5).toInt(); - if (jobProgress != 0 && jobProgress != JOBDONE && jobProgress != JOBABORTED) { - if (jobProgress != JOBCRASHED) { - // Draw job progress bar - QColor color = option.palette.alternateBase().color(); - color.setAlpha(150); - painter->setPen(option.palette.link().color()); - QRect progress(pixmapPoint.x() + 2, pixmapPoint.y() + pixmap.height() - 9, pixmap.width() - 4, 7); - painter->setBrush(QBrush(color)); - painter->drawRect(progress); - painter->setBrush(option.palette.link()); - progress.adjust(2, 2, -2, -2); - if (jobProgress == JOBWAITING) { - progress.setLeft(progress.right() - 2); - painter->drawRect(progress); - progress.moveLeft(progress.left() - 5); - painter->drawRect(progress); - } - else if (jobProgress > 0) { - progress.setWidth(progress.width() * jobProgress / 100); - painter->drawRect(progress); - } - } else if (jobProgress == JOBCRASHED) { - QString jobText = index.data(Qt::UserRole + 7).toString(); - if (!jobText.isEmpty()) { - QRectF txtBounding = painter->boundingRect(r2, Qt::AlignRight | Qt::AlignVCenter, " " + jobText + " "); - painter->setPen(Qt::NoPen); - painter->setBrush(option.palette.highlight()); - painter->drawRoundedRect(txtBounding, 2, 2); - painter->setPen(option.palette.highlightedText().color()); - painter->drawText(txtBounding, Qt::AlignCenter, jobText); - } - } - } - - painter->restore(); - } else if (index.column() == 2 && KdenliveSettings::activate_nepomuk()) { - if (index.data().toString().isEmpty()) { - QStyledItemDelegate::paint(painter, option, index); - return; - } - QRect r1 = option.rect; - if (option.state & (QStyle::State_Selected)) { - painter->fillRect(r1, option.palette.highlight()); - } -#ifdef NEPOMUK - KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); -#endif - } else { - QStyledItemDelegate::paint(painter, option, index); - } - } -}; class ProjectList : public QWidget { Q_OBJECT public: - ProjectList(QWidget *parent = 0); + ProjectList(QGLWidget *glContext, QWidget *parent = 0); virtual ~ProjectList(); QDomElement producersList(); @@ -242,8 +143,8 @@ public: void setupGeneratorMenu(const QHash& menus); QString currentClipUrl() const; KUrl::List getConditionalUrls(const QString &condition) const; - /** @brief Get a list of selected clip Id's that match a condition. */ - QStringList getConditionalIds(const QString &condition) const; + /** @brief Get a list of selected clip Id's and url's that match a condition. */ + QMap getConditionalIds(const QString &condition) const; QDomDocument generateTemplateXml(QString data, const QString &replaceString); void cleanup(); void trashUnusedClips(); @@ -251,8 +152,8 @@ public: void addClipCut(const QString &id, int in, int out, const QString desc, bool newItem); void removeClipCut(const QString &id, int in, int out); void focusTree() const; - SubProjectItem *getSubItem(ProjectItem *clip, QPoint zone); - void doUpdateClipCut(const QString &id, const QPoint oldzone, const QPoint zone, const QString &comment); + SubProjectItem *getSubItem(ProjectItem *clip, const QPoint &zone); + void doUpdateClipCut(const QString &id, const QPoint &oldzone, const QPoint &zone, const QString &comment); bool hasMissingClips(); void deleteProjectFolder(QMap map); void selectItemById(const QString &clipId); @@ -287,7 +188,7 @@ public: void updatePalette(); public slots: - void updateAllClips(bool displayRatioChanged, bool fpsChanged, QStringList brokenClips); + void updateAllClips(bool displayRatioChanged, bool fpsChanged, const QStringList &brokenClips); void slotReplyGetImage(const QString &clipId, const QImage &img); void slotReplyGetImage(const QString &clipId, const QString &name, int width, int height); void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const stringMap &properties, const stringMap &metadata, bool replace); @@ -302,13 +203,13 @@ public slots: /** @brief Prepares removing the selected items. */ void slotRemoveClip(); - void slotAddClip(const QString url, const QString &groupName, const QString &groupId); - void slotAddClip(const QList givenList = QList (), const QString &groupName = QString(), const QString &groupId = QString()); + void slotAddClip(const QString &url, const QString &groupName, const QString &groupId); + void slotAddClip(const QList &givenList = QList (), const QString &groupName = QString(), const QString &groupId = QString()); /** @brief Adds, edits or deletes a folder item. * * This is triggered by AddFolderCommand and EditFolderCommand. */ - void slotAddFolder(const QString foldername, const QString &clipId, bool remove, bool edit = false); + void slotAddFolder(const QString &foldername, const QString &clipId, bool remove, bool edit = false); void slotResetProjectList(); void slotOpenClip(); void slotEditClip(); @@ -363,6 +264,7 @@ private: QList m_thumbnailQueue; QAction *m_proxyAction; QMutex m_jobMutex; + QMutex m_processMutex; bool m_abortAllJobs; /** @brief We are cleaning up the project list, so stop processing signals. */ bool m_closing; @@ -379,8 +281,9 @@ private: /** @brief The action that will trigger the log dialog. */ QAction *m_logAction; #endif + QGLWidget *m_mainGLContext; - void requestClipThumbnail(const QString id); + void requestClipThumbnail(const QString &id); /** @brief Creates an EditFolderCommand to change the name of an folder item. */ void editFolder(const QString folderName, const QString oldfolderName, const QString &clipId); @@ -400,13 +303,13 @@ private: /** @brief Sets the buttons enabled/disabled according to selected item. */ void updateButtons() const; - /** @brief Set the Proxy status on a clip. + /** @brief Set the Proxy status on a clip. * @param item The clip item to set status - * @param jobType The job type + * @param jobType The job type * @param status The job status (see definitions.h) * @param progress The job progress (in percents) * @param statusMessage The job info message */ - void setJobStatus(ProjectItem *item, JOBTYPE jobType, CLIPJOBSTATUS status, int progress = 0, const QString &statusMessage = QString()); + void setJobStatus(ProjectItem *item, JOBTYPE jobType, ClipJobStatus status, int progress = 0, const QString &statusMessage = QString()); void monitorItemEditing(bool enable); /** @brief Get cached thumbnail for a project's clip or create it if no cache. */ void getCachedThumbnail(ProjectItem *item); @@ -422,10 +325,10 @@ private: /** @brief Get the list of job names for current clip. */ QStringList getPendingJobs(const QString &id); /** @brief Start an MLT process job. */ - void processClipJob(QStringList ids, const QString&destination, bool autoAdd, QStringList jobParams, const QString &description, QMap extraParams = QMap ()); + void processClipJob(QStringList ids, const QString&destination, bool autoAdd, QStringList jobParams, const QString &description, stringMap extraParams = stringMap()); /** @brief Create rounded shape pixmap for project tree thumb. */ - QPixmap roundedPixmap(QImage img); - QPixmap roundedPixmap(QPixmap source); + QPixmap roundedPixmap(const QImage &img); + QPixmap roundedPixmap(const QPixmap &source); /** @brief Extract a clip's metadata with the exiftool program. */ void extractMetadata(DocClipBase *clip); /** @brief Add a special FFmpeg tag if clip matches some properties (for example set full_luma for Sony NEX camcorders. */ @@ -458,16 +361,16 @@ private slots: /** @brief Try to find a matching profile for given item. */ bool adjustProjectProfileToItem(ProjectItem *item = NULL); /** @brief Add a sequence from the stopmotion widget. */ - void slotAddOrUpdateSequence(const QString frameName); + void slotAddOrUpdateSequence(const QString &frameName); /** @brief A proxy clip was created, update display. */ void slotGotProxy(const QString &proxyPath); void slotGotProxy(ProjectItem *item); /** @brief Enable / disable proxy for current clip. */ void slotProxyCurrentItem(bool doProxy, ProjectItem *itemToProxy = NULL); /** @brief Put clip in the proxy waiting list. */ - void slotCreateProxy(const QString id); + void slotCreateProxy(const QString &id); /** @brief Stop creation of this clip's proxy. */ - void slotAbortProxy(const QString id, const QString path); + void slotAbortProxy(const QString &id, const QString& path); /** @brief Start creation of clip jobs. */ void slotProcessJobs(); /** @brief Discard running and pending clip jobs. */ @@ -475,7 +378,7 @@ private slots: /** @brief Discard a running clip jobs. */ void slotCancelRunningJob(const QString id, stringMap); /** @brief Update a clip's job status. */ - void slotProcessLog(const QString, int progress, int, const QString = QString()); + void slotProcessLog(const QString&, int progress, int, const QString & tmp= QString()); /** @brief A clip job crashed, inform user. */ void slotUpdateJobStatus(const QString id, int type, int status, const QString label, const QString actionName, const QString details); void slotUpdateJobStatus(ProjectItem *item, int type, int status, const QString &label, const QString &actionName = QString(), const QString details = QString()); @@ -499,21 +402,21 @@ private slots: void slotGotFilterJobResults(QString ,int , int, stringMap, stringMap); signals: - void clipSelected(DocClipBase *, QPoint zone = QPoint(), bool forceUpdate = false); + void clipSelected(DocClipBase *, const QPoint &zone = QPoint(), bool forceUpdate = false); void receivedClipDuration(const QString &); void showClipProperties(DocClipBase *); - void showClipProperties(QList , QMap commonproperties); + void showClipProperties(const QList &, const QMap &commonproperties); void projectModified(); void loadingIsOver(); - void displayMessage(const QString, int progress, MessageType type = DefaultMessage); - void clipNameChanged(const QString, const QString); + void displayMessage(const QString&, int progress, MessageType type = DefaultMessage); + void clipNameChanged(const QString&, const QString&); void clipNeedsReload(const QString&); /** @brief A property affecting display was changed, so we need to update monitors and thumbnails * @param id: The clip's id string * @param resetThumbs Should we recreate the timeline thumbnails. */ void refreshClip(const QString &id, bool resetThumbs); void updateRenderStatus(); - void deleteProjectClips(QStringList ids, QMap folderids); + void deleteProjectClips(const QStringList &ids, const QMap &folderids); void findInTimeline(const QString &clipId); /** @brief Request a profile change for current document. */ void updateProfile(const QString &); @@ -522,17 +425,17 @@ signals: void raiseClipMonitor(bool forceRefresh); /** @brief Set number of running jobs. */ void jobCount(int); - void cancelRunningJob(const QString, stringMap); - void processLog(const QString, int , int, const QString = QString()); + void cancelRunningJob(const QString&, const stringMap&); + void processLog(const QString&, int , int, const QString & = QString()); void addClip(const QString, const QString &, const QString &); - void updateJobStatus(const QString, int, int, const QString label = QString(), const QString actionName = QString(), const QString details = QString()); - void gotProxy(const QString); + void updateJobStatus(const QString&, int, int, const QString &label = QString(), const QString &actionName = QString(), const QString &details = QString()); + void gotProxy(const QString&); void checkJobProcess(); /** @brief A Filter Job produced results, send them back to the clip. */ - void gotFilterJobResults(const QString &id, int startPos, int track, stringMap params, stringMap extra); + void gotFilterJobResults(const QString &id, int startPos, int track, const stringMap ¶ms, const stringMap &extra); void pauseMonitor(); void updateAnalysisData(DocClipBase *); - void addMarkers(const QString &, QList ); + void addMarkers(const QString &, const QList &); }; #endif