X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fprojectlist.h;h=1352cd7172acffcda7e10b84aa78c6c9acaebb4a;hb=0e9a1f923a067e05ba721722f9417547f9cd76da;hp=34ac7f9f08cd07c038569d0ccc0d732bd886af83;hpb=1ecbd5b62783247938e9873868e6ce625ef23b6c;p=kdenlive diff --git a/src/projectlist.h b/src/projectlist.h index 34ac7f9f..1352cd71 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -1,40 +1,205 @@ -#ifndef PRJECTLIST_H -#define PRJECTLIST_H +/*************************************************************************** + * 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 PROJECTLIST_H +#define PROJECTLIST_H #include +#include +#include #include +#include +#include +#include + + +#include +#include +#include +#include + +#include "definitions.h" +#include "timecode.h" +#include "kdenlivesettings.h" + +namespace Mlt +{ +class Producer; +}; -#include "ui_projectlist_ui.h" -#include "docclipbase.h" -#include "renderer.h" +class ProjectItem; +class ProjectListView; +class Render; +class KdenliveDoc; +class DocClipBase; + +const int NameRole = Qt::UserRole; +const int DurationRole = NameRole + 1; +const int UsageRole = NameRole + 2; + +class ItemDelegate: public QItemDelegate +{ +public: + ItemDelegate(QAbstractItemView* parent = 0): QItemDelegate(parent) { + } + /* + static_cast( index.internalPointer() ); + + 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) { + QRect r1 = option.rect; + painter->save(); + if (option.state & (QStyle::State_Selected)) { + painter->setPen(option.palette.color(QPalette::HighlightedText)); + painter->fillRect(r1, option.palette.highlight()); + } + QFont font = painter->font(); + 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->setPen(option.palette.color(QPalette::Mid)); + painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText); + painter->restore(); + } else if (index.column() == 3 && KdenliveSettings::activate_nepomuk()) { + if (index.data().toString().isEmpty()) { + QItemDelegate::paint(painter, option, index); + return; + } + QRect r1 = option.rect; + if (option.state & (QStyle::State_Selected)) { + painter->fillRect(r1, option.palette.highlight()); + } + KRatingPainter::paintRating(painter, r1, Qt::AlignCenter, index.data().toInt()); + } else { + QItemDelegate::paint(painter, option, index); + } + } +}; class ProjectList : public QWidget { - Q_OBJECT - - public: - ProjectList(Render *projectRender, QWidget *parent=0); - - public slots: - void populate(QDomNodeList prods); - void addProducer(QDomElement producer); + Q_OBJECT + +public: + ProjectList(QWidget *parent = 0); + virtual ~ProjectList(); + + QDomElement producersList(); void setRenderer(Render *projectRender); - void slotReplyGetImage(const KUrl &url, int pos, const QPixmap &pix, int w, int h); - void slotReplyGetFileProperties(const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata); + void slotUpdateClipProperties(const QString &id, QMap properties); + void updateAllClips(); + QByteArray headerInfo() const; + void setHeaderInfo(const QByteArray &state); + void setupMenu(QMenu *addMenu, QAction *defaultAction); + void setupGeneratorMenu(QMenu *addMenu, QMenu *transcodeMenu); + QString currentClipUrl() const; + void reloadClipThumbnails(); + +public slots: + void setDocument(KdenliveDoc *doc); + void slotReplyGetImage(const QString &clipId, const QPixmap &pix); + void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace); + void slotAddClip(DocClipBase *clip, bool getProperties); + void slotDeleteClip(const QString &clipId); + void slotUpdateClip(const QString &id); + void slotRefreshClipThumbnail(const QString &clipId, bool update = true); + void slotRefreshClipThumbnail(ProjectItem *item, bool update = true); + void slotRemoveInvalidClip(const QString &id, bool replace); + void slotSelectClip(const QString &ix); + void slotRemoveClip(); + void slotAddClip(const QList givenList = QList (), QString group = QString()); + void slotAddFolder(const QString foldername, const QString &clipId, bool remove, bool edit = false); + void slotResetProjectList(); + void slotOpenClip(); + void slotEditClip(); + void slotReloadClip(); + void slotAddColorClip(); - private: - Ui::ProjectList_UI ui; +private: + ProjectListView *m_listView; Render *m_render; + Timecode m_timecode; + double m_fps; + QToolBar *m_toolbar; + QMenu *m_menu; + QUndoStack *m_commandStack; + void selectItemById(const QString &clipId); + ProjectItem *getItemById(const QString &id); + ProjectItem *getFolderItemById(const QString &id); + QAction *m_editAction; + QAction *m_deleteAction; + QAction *m_openAction; + QAction *m_reloadAction; + KdenliveDoc *m_doc; + ProjectItem *m_selectedItem; + bool m_refreshed; + QToolButton *m_addButton; + QMap m_infoQueue; + void requestClipInfo(const QDomElement xml, const QString id); + QList m_thumbnailQueue; + void requestClipThumbnail(const QString &id); + void deleteProjectFolder(QMap map); + void editFolder(const QString folderName, const QString oldfolderName, const QString &clipId); - private slots: - void slotDoubleClicked(QListWidgetItem *, const QPoint &); - void slotAddClip(); - void slotEditClip(QTreeWidgetItem *item, int column); +private slots: void slotClipSelected(); + void slotAddSlideshowClip(); + void slotAddTitleClip(); + void slotContextMenu(const QPoint &pos, QTreeWidgetItem *); + void slotAddFolder(); + /** This is triggered when a clip description has been modified */ + void slotItemEdited(QTreeWidgetItem *item, int column); + void slotUpdateClipProperties(ProjectItem *item, QMap properties); + void slotProcessNextClipInQueue(); + void slotProcessNextThumbnail(); + void slotCheckForEmptyQueue(); + void slotPauseMonitor(); + //void slotShowMenu(const QPoint &pos); - signals: - void clipSelected(const QDomElement &); - void getFileProperties(const KUrl &, uint); +signals: + void clipSelected(DocClipBase *); + void getFileProperties(const QDomElement&, const QString &, bool); + void receivedClipDuration(const QString &); + void showClipProperties(DocClipBase *); + void projectModified(); + void loadingIsOver(); + void clipNameChanged(const QString, const QString); }; #endif