X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.h;h=dc1fa24a278e61ae85af42f3b8461f33f8b26e56;hb=0a21eb6dd5c5a44882c51c2c857eec96758d5285;hp=8e555fb99dbf6c6588e2cf7d3e5144f20aa53433;hpb=97e4197dbc794db76bd84d3b01284c24e71464f8;p=kdenlive diff --git a/src/projectlist.h b/src/projectlist.h index 8e555fb9..dc1fa24a 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -24,11 +24,13 @@ #include #include #include +#include #include #include +#include -#include "docclipbase.h" +#include "definitions.h" #include "kdenlivedoc.h" #include "renderer.h" #include "timecode.h" @@ -36,6 +38,63 @@ class ProjectItem; + const int NameRole = Qt::UserRole; + const int DurationRole = NameRole + 1; + const int FullPathRole = NameRole + 2; + const int ClipTypeRole = NameRole + 3; + +class ItemDelegate: public KExtendableItemDelegate +{ + public: + ItemDelegate(QAbstractItemView* parent = 0): KExtendableItemDelegate(parent) + { + } +/* +void expand() +{ + QWidget *w = new QWidget; + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget( new KColorButton(w)); + w->setLayout( layout ); + extendItem(w, +} +*/ + +void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +{ + if (index.column() == 1) + { + const bool hover = option.state & (QStyle::State_Selected|QStyle::State_MouseOver|QStyle::State_HasFocus); + QRect r1 = option.rect; + painter->save(); + if (hover) { + painter->setPen(option.palette.color(QPalette::HighlightedText)); + QColor backgroundColor = option.palette.color(QPalette::Highlight); + painter->setBrush(QBrush(backgroundColor)); + painter->fillRect(r1, QBrush(backgroundColor)); + } + QFont font = painter->font(); + font.setPointSize(font.pointSize() - 1 ); + font.setBold(true); + painter->setFont(font); + int mid = (int) ((r1.height() / 2 )); + r1.setBottom(r1.y() + mid); + QRect r2 = option.rect; + r2.setTop(r2.y() + mid); + painter->drawText(r1, Qt::AlignLeft | Qt::AlignBottom , index.data().toString()); + //painter->setPen(Qt::green); + font.setBold(false); + painter->setFont(font); + painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , index.data(DurationRole).toString()); + painter->restore(); + } + else + { + KExtendableItemDelegate::paint(painter, option, index); + } +} +}; + class ProjectList : public QWidget { Q_OBJECT @@ -47,7 +106,7 @@ class ProjectList : public QWidget QDomElement producersList(); void setRenderer(Render *projectRender); - void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), int parentId = -1); + void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), const QString &group = QString::null, int parentId = -1); void deleteClip(const int clipId); public slots: @@ -55,6 +114,7 @@ class ProjectList : public QWidget void addProducer(QDomElement producer, int parentId = -1); void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h); void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata); + void slotAddClip(DocClipBase *clip); private: @@ -71,15 +131,20 @@ class ProjectList : public QWidget ProjectItem *getItemById(int id); QAction *m_editAction; QAction *m_deleteAction; + ItemDelegate *m_listViewDelegate; + KdenliveDoc *m_doc; private slots: - void slotAddClip(); + void slotAddClip(QUrl givenUrl = QUrl(), const QString &group = QString::null); void slotRemoveClip(); void slotEditClip(); void slotClipSelected(); void slotAddColorClip(); void slotEditClip(QTreeWidgetItem *, int); void slotContextMenu( const QPoint &pos, QTreeWidgetItem * ); + void slotAddFolder(); + /** This is triggered when a clip description has been modified */ + void slotUpdateItemDescription(QTreeWidgetItem *item, int column); //void slotShowMenu(const QPoint &pos); @@ -87,6 +152,7 @@ class ProjectList : public QWidget signals: void clipSelected(const QDomElement &); void getFileProperties(const QDomElement&, int); + void receivedClipDuration(int, int); }; #endif