X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.h;h=fe3e6c0be6424d4e0e534fa8a515fa3f8a6b7517;hb=2a223cff6e45c560c28857b72c0cb7e584f9a4ef;hp=f2a2d494ba5ba94956b1cb7070f9b8d368712596;hpb=fef92ec8923f6fe591b0609021573175e1ae0898;p=kdenlive diff --git a/src/projectlist.h b/src/projectlist.h index f2a2d494..fe3e6c0b 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -1,58 +1,155 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + #ifndef PRJECTLIST_H #define PRJECTLIST_H #include #include #include +#include #include #include +#include "kextendableitemdelegate.h" -#include "docclipbase.h" +#include "definitions.h" #include "kdenlivedoc.h" #include "renderer.h" #include "timecode.h" +#include "projectlistview.h" + +class ProjectItem; + +const int NameRole = Qt::UserRole; +const int DurationRole = NameRole + 1; +const int UsageRole = NameRole + 2; + +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, + } + */ -class ProjectList : public QWidget -{ - Q_OBJECT - - public: - ProjectList(KUndoStack *commandStack, QWidget *parent=0); + 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); + QString subText = index.data(DurationRole).toString(); + int usage = index.data(UsageRole).toInt(); + if (usage != 0) subText.append(QString(" (%1)").arg(usage)); + painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText); + painter->restore(); + } else { + KExtendableItemDelegate::paint(painter, option, index); + } + } +}; + +class ProjectList : public QWidget { + Q_OBJECT + +public: + ProjectList(QWidget *parent = 0); + virtual ~ProjectList(); QDomElement producersList(); void setRenderer(Render *projectRender); - void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl()); - void deleteClip(const int clipId); + void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), const QString &group = QString::null, int parentId = -1); - public slots: +public slots: void setDocument(KdenliveDoc *doc); - void addProducer(QDomElement producer); + 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); + void slotDeleteClip(int clipId); + void slotUpdateClip(int id); - private: - QTreeWidget *listView; +private: + ProjectListView *listView; KTreeWidgetSearchLine *searchView; Render *m_render; Timecode m_timecode; double m_fps; QToolBar *m_toolbar; + QMenu *m_menu; KUndoStack *m_commandStack; int m_clipIdCounter; + void selectItemById(const int clipId); + ProjectItem *getItemById(int id); + QAction *m_editAction; + QAction *m_deleteAction; + ItemDelegate *m_listViewDelegate; + KdenliveDoc *m_doc; - private slots: - void slotAddClip(); +private slots: + void slotAddClip(QUrl givenUrl = QUrl(), const QString &group = QString::null); void slotRemoveClip(); void slotEditClip(); void slotClipSelected(); void slotAddColorClip(); + void slotAddTitleClip(); + 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); + + - signals: +signals: void clipSelected(const QDomElement &); void getFileProperties(const QDomElement&, int); + void receivedClipDuration(int, int); }; #endif