From d679fbf19a2511b181570418dc7fa7c815728bcb Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Artaud Date: Sat, 11 Jan 2014 16:23:27 +0100 Subject: [PATCH] Replace roles into projectlistview. Turn const int into enum. --- src/projectlist.cpp | 10 ++++++---- src/projectlist.h | 11 ++++++----- src/projectlistview.h | 17 +++++++++-------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 286860f6..1cc47e57 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1308,7 +1308,7 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties) if (item == NULL) { item = new ProjectItem(m_listView, clip, pixelSize); } - if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading")); + if (item->data(0, ItemDelegate::DurationRole).isNull()) item->setData(0, ItemDelegate::DurationRole, i18n("Loading")); connect(clip, SIGNAL(createProxy(QString)), this, SLOT(slotCreateProxy(QString))); connect(clip, SIGNAL(abortProxy(QString,QString)), this, SLOT(slotAbortProxy(QString,QString))); @@ -1444,7 +1444,9 @@ void ProjectList::slotUpdateClip(const QString &id) { ProjectItem *item = getItemById(id); monitorItemEditing(false); - if (item) item->setData(0, UsageRole, QString::number(item->numReferences())); + if (item){ + item->setData(0, ItemDelegate::UsageRole, QString::number(item->numReferences())); + } monitorItemEditing(true); } @@ -1611,7 +1613,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, cons else if (!item->hasPixmap()) { getCachedThumbnail(item); } - if (item->data(0, DurationRole).toString().isEmpty()) { + if (item->data(0, ItemDelegate::DurationRole).toString().isEmpty()) { item->changeDuration(clip->getProducer()->get_playtime()); } if (clip->isPlaceHolder()) { @@ -1630,7 +1632,7 @@ void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged, cons slotCreateProxy(clip->getId()); } } - item->setData(0, UsageRole, QString::number(item->numReferences())); + item->setData(0, ItemDelegate::UsageRole, QString::number(item->numReferences())); } ++it; } diff --git a/src/projectlist.h b/src/projectlist.h index d24a1d02..ca6a1026 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -51,7 +51,6 @@ #include #endif - #include "definitions.h" #include "timecode.h" #include "kdenlivesettings.h" @@ -102,10 +101,6 @@ class DocClipBase; class AbstractClipJob; class ItemDelegate; -const int NameRole = Qt::UserRole; -const int DurationRole = NameRole + 1; -const int UsageRole = NameRole + 2; - class SmallInfoLabel: public QPushButton { Q_OBJECT @@ -113,6 +108,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: diff --git a/src/projectlistview.h b/src/projectlistview.h index 67a7823f..e644be1b 100644 --- a/src/projectlistview.h +++ b/src/projectlistview.h @@ -32,20 +32,21 @@ class DocClipBase; class ItemDelegate: public QStyledItemDelegate { public: - ItemDelegate(QAbstractItemView* parent = 0): QStyledItemDelegate(parent) { + enum ItemRole { + NameRole = Qt::UserRole, + DurationRole, + UsageRole + }; + + 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; - -private: - enum ItemRole { - NameRole = Qt::UserRole, - DurationRole, - UsageRole - }; }; class ProjectListView : public QTreeWidget -- 2.39.2