]> git.sesse.net Git - kdenlive/blobdiff - src/projectlist.h
Various changes for getting an OpenGL context (almost) everywhere it is needed.
[kdenlive] / src / projectlist.h
index 3470239dd7010889e14bb30121ee0d25e50cebd8..bd80c8b8324314c5c4e7ba1529c516057b808f36 100644 (file)
@@ -27,7 +27,6 @@
 #include <QToolButton>
 #include <QTreeWidget>
 #include <QPainter>
-#include <QStyledItemDelegate>
 #include <QUndoStack>
 #include <QTimer>
 #include <QApplication>
 #include <nepomuk2/resource.h>
 #endif
 
-
 #include "definitions.h"
 #include "timecode.h"
 #include "kdenlivesettings.h"
 #include "folderprojectitem.h"
 #include "subprojectitem.h"
 #include "projecttree/abstractclipjob.h"
-#include <kdialog.h>
+#include "widgets/invaliddialog.h"
 
 #if KDE_IS_VERSION(4,7,0)
 #include <KMessageWidget>
@@ -101,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
 {
@@ -113,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:
@@ -123,124 +125,12 @@ private slots:
     void slotTimeLineFinished();
 };
 
-class InvalidDialog: public KDialog
-{
-    Q_OBJECT
-public:
-    explicit InvalidDialog(const QString &caption, const QString &message, bool infoOnly, QWidget *parent = 0);
-    ~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<QPixmap>(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
-#ifdef NEPOMUKCORE
-          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();
@@ -298,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);
@@ -313,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 <QUrl> givenList = QList <QUrl> (), const QString &groupName = QString(), const QString &groupId = QString());
+    void slotAddClip(const QString &url, const QString &groupName, const QString &groupId);
+    void slotAddClip(const QList <QUrl> &givenList = QList <QUrl> (), 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();
@@ -391,6 +281,7 @@ private:
     /** @brief The action that will trigger the log dialog. */
     QAction *m_logAction;
 #endif
+    QGLWidget *m_mainGLContext;
     
     void requestClipThumbnail(const QString &id);
 
@@ -418,7 +309,7 @@ private:
      * @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);
@@ -514,7 +405,7 @@ signals:
     void clipSelected(DocClipBase *, const QPoint &zone = QPoint(), bool forceUpdate = false);
     void receivedClipDuration(const QString &);
     void showClipProperties(DocClipBase *);
-    void showClipProperties(QList <DocClipBase *>, QMap<QString, QString> commonproperties);
+    void showClipProperties(const QList <DocClipBase *>&, const QMap<QString, QString> &commonproperties);
     void projectModified();
     void loadingIsOver();
     void displayMessage(const QString&, int progress, MessageType type = DefaultMessage);
@@ -534,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 &params, const stringMap &extra);
     void pauseMonitor();
     void updateAnalysisData(DocClipBase *);
-    void addMarkers(const QString &, QList <CommentedTime>);
+    void addMarkers(const QString &, const QList <CommentedTime>&);
 };
 
 #endif