From: Jean-Baptiste Mardelle Date: Sun, 13 Jan 2008 12:22:19 +0000 (+0000) Subject: Add license, continue work on project tree view X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=187158b0450f465536c15cc31499bcc277d2a451;p=kdenlive Add license, continue work on project tree view svn path=/branches/KDE4/; revision=1798 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6bdd8332..ec0f9d65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,18 +1,21 @@ add_subdirectory( widgets ) +find_package(Nepomuk REQUIRED) include_directories( ${CMAKE_SOURCE_DIR}/src/widgets ${LIBMLT_INCLUDE_DIR} ${LIBMLTPLUS_INCLUDE_DIR} ${LIBFFMPEG_INCLUDE_DIR} + ${NEPOMUK_INCLUDES} ) LINK_DIRECTORIES( ${LIBMLT_LIBRARY} ${LIBMLTPLUS_LIBRARY} ${LIBFFMPEG_LIBRARY} +${NEPOMUK_LIBRARIES} ) @@ -24,6 +27,7 @@ kde4_add_ui_files(kdenlive_UI ) set(kdenlive_SRCS + addclipcommand.cpp main.cpp mainwindow.cpp customruler.cpp @@ -42,6 +46,9 @@ set(kdenlive_SRCS documentvideotrack.cpp documentaudiotrack.cpp headertrack.cpp + trackpanelfunctionfactory.cpp + trackpanelfunction.cpp + trackpanelclipmovefunction.cpp ) kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc ) @@ -53,6 +60,7 @@ target_link_libraries(kdenlive ${KDE4_KIO_LIBS} ${LIBMLTPLUS_LIBRARY} ${LIBMLT_LIBRARY} + ${NEPOMUK_LIBRARIES} ) install(TARGETS kdenlive DESTINATION ${BIN_INSTALL_DIR}) diff --git a/src/addclipcommand.cpp b/src/addclipcommand.cpp new file mode 100644 index 00000000..2121c3db --- /dev/null +++ b/src/addclipcommand.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + +#include "addclipcommand.h" + +AddClipCommand::AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, bool doIt) + : m_list(list), m_names(names), m_xml(xml), m_id(id), m_url(url), m_doIt(doIt) { + if (doIt) setText(i18n("Add clip")); + else setText(i18n("Delete clip")); + } + + +// virtual +void AddClipCommand::undo() +{ + if (!m_list) kDebug()<<"---- ERROR, NO LIST FOR undoing action"; +kDebug()<<"---- undoing action"; + if (m_doIt) m_list->deleteClip(m_id); + else m_list->addClip(m_names, m_xml, m_id, m_url); +} +// virtual +void AddClipCommand::redo() +{ + if (!m_list) kDebug()<<"---- ERROR, NO LIST FOR redoing action"; +kDebug()<<"---- redoing action"; + if (m_doIt) m_list->addClip(m_names, m_xml, m_id, m_url); + else m_list->deleteClip(m_id); +} + +#include "addclipcommand.moc" diff --git a/src/addclipcommand.h b/src/addclipcommand.h index a8b05fa5..2fb455bd 100644 --- a/src/addclipcommand.h +++ b/src/addclipcommand.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 ADDCLIPCOMMAND_H #define ADDCLIPCOMMAND_H @@ -9,23 +29,11 @@ class AddClipCommand : public QUndoCommand { public: - AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, bool doIt) - : m_list(list), m_names(names), m_xml(xml), m_id(id), m_url(url), m_doIt(doIt) { - if (doIt) setText(i18n("Add clip")); - else setText(i18n("Delete clip")); - } - virtual void undo() - { - kDebug()<<"---- undoing action"; - if (m_doIt) m_list->deleteClip(m_id); - else m_list->addClip(m_names, m_xml, m_id, m_url); - } - virtual void redo() - { - kDebug()<<"---- redoing action"; - if (m_doIt) m_list->addClip(m_names, m_xml, m_id, m_url); - else m_list->deleteClip(m_id); - } + AddClipCommand(ProjectList *list, const QStringList &names, const QDomElement &xml, const int id, const KUrl &url, bool doIt); + + virtual void undo(); + virtual void redo(); + private: ProjectList *m_list; QStringList m_names; diff --git a/src/customruler.cpp b/src/customruler.cpp index 9cf8037c..f1edad9a 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -110,8 +110,7 @@ void CustomRuler::paintEvent(QPaintEvent * /*e*/) int value = this->value(), minval = minimum(), maxval; - maxval = maximum() - + offset() - endOffset(); + maxval = maximum() + offset() - endOffset(); //ioffsetval = value-offset; // pixelpm = (int)ppm; @@ -121,11 +120,15 @@ void CustomRuler::paintEvent(QPaintEvent * /*e*/) offsetmin=(double)(minval-offset()), offsetmax=(double)(maxval-offset()), fontOffset = (((double)minval)>offsetmin)?(double)minval:offsetmin; - + QRect bg = QRect(offsetmin, 0, offsetmax, height()); + + QPalette palette; + //p.fillRect(bg, palette.light()); // draw labels QFont font = p.font(); font.setPointSize(LABEL_SIZE); p.setFont( font ); + p.setPen(palette.dark().color()); // draw littlemarklabel // draw mediummarklabel diff --git a/src/definitions.h b/src/definitions.h index b1e6f226..efeb5648 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -1,6 +1,33 @@ +/*************************************************************************** + * 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 DEFINITIONS_H #define DEFINITIONS_H #define FRAME_SIZE 90 +struct TrackViewClip { + int startTime; + int duration; + int cropTime; + QString producer; +}; + #endif diff --git a/src/documenttrack.cpp b/src/documenttrack.cpp index fa65d2cc..060f55a8 100644 --- a/src/documenttrack.cpp +++ b/src/documenttrack.cpp @@ -14,9 +14,29 @@ DocumentTrack::DocumentTrack(QDomElement xml, TrackView * view, QWidget *parent) : QWidget(parent), m_xml(xml), m_trackDuration(0) { setFixedHeight(50); + addFunctionDecorator("move", "move"); parseXml(); } +int DocumentTrack::documentTrackIndex() +{ + return 0; +} + +TrackViewClip *DocumentTrack::getClipAt(GenTime pos) +{ + return 0; +} + +void DocumentTrack::addFunctionDecorator(const QString & mode, const QString & function) +{ + m_trackPanelFunctions[mode].append(function); +} + +QStringList DocumentTrack::applicableFunctions(const QString & mode) +{ + return m_trackPanelFunctions[mode]; +} void DocumentTrack::parseXml() { diff --git a/src/documenttrack.h b/src/documenttrack.h index 26143e51..2084634e 100644 --- a/src/documenttrack.h +++ b/src/documenttrack.h @@ -3,15 +3,17 @@ #include #include +#include +#include +#include +#include "definitions.h" +#include "gentime.h" + + +class TrackPanelFunction; class TrackView; -struct TrackViewClip { - int startTime; - int duration; - int cropTime; - QString producer; -}; class DocumentTrack : public QWidget { @@ -22,6 +24,10 @@ class DocumentTrack : public QWidget QList clipList(); int duration(); + int documentTrackIndex(); + TrackViewClip *getClipAt(GenTime pos); + void addFunctionDecorator(const QString & mode, const QString & function); + QStringList applicableFunctions(const QString & mode); protected: virtual void paintEvent(QPaintEvent * /*e*/); @@ -31,6 +37,9 @@ class DocumentTrack : public QWidget QList m_clipList; void parseXml(); int m_trackDuration; + /** A map of lists of track panel functions. */ + QMap < QString, QStringList > m_trackPanelFunctions; + public slots: diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index d372a33c..bab68a29 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -1,28 +1,22 @@ /*************************************************************************** - kdenlivedoc.cpp - description - ------------------- - begin : Fri Nov 22 2002 - copyright : (C) 2002 by Jason Wood - email : jasonwood@blueyonder.co.uk - copyright : (C) 2005 Lucio Flavio Correa - email : lucio.correa@gmail.com - copyright : (C) Marco Gittler - email : g.marco@freenet.de - copyright : (C) 2006 Jean-Baptiste Mardelle - email : jb@ader.ch - -***************************************************************************/ - -/*************************************************************************** + * 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 * ***************************************************************************/ - #include #include #include @@ -37,7 +31,7 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL) { - m_commandStack = new KUndoStack(this); + m_commandStack = new KUndoStack(); if (!url.isEmpty()) { QString tmpFile; if(KIO::NetAccess::download(url.path(), tmpFile, parent)) @@ -102,6 +96,7 @@ KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *p KdenliveDoc::~KdenliveDoc() { + delete m_commandStack; } KUndoStack *KdenliveDoc::commandStack() diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 4788639c..0b1967f1 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -1,20 +1,23 @@ /*************************************************************************** - krender.h - description - ------------------- - begin : Fri Nov 22 2002 - copyright : (C) 2002 by Jason Wood - email : jasonwood@blueyonder.co.uk -***************************************************************************/ - -/*************************************************************************** + * 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 KDENLIVEDOC_H #define KDENLIVEDOC_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3efa1c45..98a9d04e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + #include @@ -26,7 +45,7 @@ MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent), - fileName(QString()), m_activeDocument(NULL) + fileName(QString()), m_activeDocument(NULL), m_commandStack(NULL) { m_timelineArea = new KTabWidget(this); m_timelineArea->setHoverCloseButton(true); @@ -35,7 +54,6 @@ MainWindow::MainWindow(QWidget *parent) setCentralWidget(m_timelineArea); m_monitorManager = new MonitorManager(); - m_commandStack = new KUndoStack(this); projectListDock = new QDockWidget(i18n("Project Tree"), this); projectListDock->setObjectName("project_tree"); @@ -79,6 +97,7 @@ MainWindow::MainWindow(QWidget *parent) undoViewDock->setObjectName("undo_history"); m_undoView = new QUndoView(this); undoViewDock->setWidget(m_undoView); + m_undoView->setStack(m_commandStack); addDockWidget(Qt::TopDockWidgetArea, undoViewDock); setupActions(); @@ -212,7 +231,7 @@ void MainWindow::saveFile() void MainWindow::openFile() //changed { - openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive")); + openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive,*.kdenlive")); } void MainWindow::openFile(const QString &inputFileName) //new @@ -221,7 +240,7 @@ void MainWindow::openFile(const QString &inputFileName) //new TrackView *trackView = new TrackView(doc); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName())); m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path()); - connectDocument(trackView, doc); + //connectDocument(trackView, doc); } void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed @@ -235,6 +254,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang m_projectList->setDocument(doc); m_monitorManager->setTimecode(doc->timecode()); doc->setRenderer(m_projectMonitor->render); + //m_undoView->setStack(0); m_commandStack = doc->commandStack(); QAction *redo = m_commandStack->createRedoAction(actionCollection()); @@ -252,8 +272,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang w->addAction(undo); w->addAction(redo); } - m_undoView->setStack(m_commandStack); - + m_undoView->setStack(doc->commandStack()); m_activeDocument = doc; } diff --git a/src/mainwindow.h b/src/mainwindow.h index cc67ed8d..5c47b182 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 MAINWINDOW_H #define MAINWINDOW_H diff --git a/src/monitor.cpp b/src/monitor.cpp index dacacf3b..111156fc 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + #include #include diff --git a/src/monitor.h b/src/monitor.h index 6472a608..42596773 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 MONITOR_H #define MONITOR_H diff --git a/src/monitormanager.cpp b/src/monitormanager.cpp index 6ef4bd80..1660fadc 100644 --- a/src/monitormanager.cpp +++ b/src/monitormanager.cpp @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + + #include #include diff --git a/src/monitormanager.h b/src/monitormanager.h index 075b6369..f9b8d76d 100644 --- a/src/monitormanager.h +++ b/src/monitormanager.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 MONITORMANAGER_H #define MONITORMANAGER_H diff --git a/src/projectitem.cpp b/src/projectitem.cpp index a5c4e9de..4a46eb3b 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + #include #include diff --git a/src/projectitem.h b/src/projectitem.h index 72fa3a03..34d39f9d 100644 --- a/src/projectitem.h +++ b/src/projectitem.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 PROJECTITEM_H #define PROJECTITEM_H @@ -15,7 +35,7 @@ class ProjectItem : public QTreeWidgetItem ProjectItem(QTreeWidget * parent, const QStringList & strings, QDomElement xml, int clipId); ProjectItem(QTreeWidgetItem * parent, const QStringList & strings, QDomElement xml, int clipId); ProjectItem(QTreeWidget * parent, const QStringList & strings); - ~ProjectItem(); + virtual ~ProjectItem(); QDomElement toXml(); void setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index b4580532..369370d0 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + #include #include @@ -9,6 +28,8 @@ #include #include #include +#include +#include #include "projectlist.h" #include "projectitem.h" @@ -143,6 +164,7 @@ void ProjectList::slotEditClip() void ProjectList::slotRemoveClip() { + if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK"; if (!listView->currentItem()) return; ProjectItem *item = ((ProjectItem *)listView->currentItem()); AddClipCommand *command = new AddClipCommand(this, item->names(), item->toXml(), item->clipId(), KUrl(item->data(1, FullPathRole).toString()), false); @@ -156,15 +178,19 @@ void ProjectList::selectItemById(const int clipId) if (item) listView->setCurrentItem(item); } -void ProjectList::addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url) +void ProjectList::addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url, int parentId) { kDebug()<<"///////// ADDING VCLIP=: "< groupList = listView->findItems(group, Qt::MatchExactly, 1); - ProjectItem *groupItem; + if (groupList.isEmpty()) { QStringList groupName; groupName<setData(1, FullPathRole, url.path()); +/* Nepomuk::File f( url.path() ); + QString annotation = f.getAnnotation(); + if (!annotation.isEmpty()) item->setText(2, annotation);*/ + QString resource = url.path(); + if (resource.endsWith("westley") || resource.endsWith("kdenlive")) { + QString tmpfile; + QDomDocument doc; + if (KIO::NetAccess::download(url, tmpfile, 0)) { + QFile file(tmpfile); + if (file.open(QIODevice::ReadOnly)) { + doc.setContent(&file, false); + file.close(); + } + KIO::NetAccess::removeTempFile(tmpfile); + + QDomNodeList subProds = doc.elementsByTagName("producer"); + int ct = subProds.count(); + for (int i = 0; i < ct ; i++) + { + QDomElement e = subProds.item(i).toElement(); + if (!e.isNull()) { + addProducer(e, clipId); + } + } + } + } + } + if (elem.isNull() ) { QDomDocument doc; QDomElement element = doc.createElement("producer"); @@ -196,7 +250,7 @@ void ProjectList::deleteClip(const int clipId) void ProjectList::slotAddClip() { - + if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK"; KUrl::List list = KFileDialog::getOpenUrls( KUrl(), "application/vnd.kde.kdenlive application/vnd.westley.scenelist application/flv application/vnd.rn-realmedia video/x-dv video/x-msvideo video/mpeg video/x-ms-wmv audio/x-mp3 audio/x-wav application/ogg *.m2t *.dv video/mp4 video/quicktime image/gif image/jpeg image/png image/x-bmp image/svg+xml image/tiff image/x-xcf-gimp image/x-vnd.adobe.photoshop image/x-pcx image/x-exr"); if (list.isEmpty()) return; KUrl::List::Iterator it; @@ -217,6 +271,7 @@ void ProjectList::slotAddClip() void ProjectList::slotAddColorClip() { + if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK"; QDialog *dia = new QDialog; Ui::ColorClip_UI *dia_ui = new Ui::ColorClip_UI(); dia_ui->setupUi(dia); @@ -239,7 +294,7 @@ void ProjectList::slotAddColorClip() itemEntry.append(dia_ui->clip_name->text()); AddClipCommand *command = new AddClipCommand(this, itemEntry, element, m_clipIdCounter++, KUrl(), true); m_commandStack->push(command); - //ProjectItem *item = new ProjectItem(listView, itemEntry, element); + // ProjectItem *item = new ProjectItem(listView, itemEntry, element, m_clipIdCounter++); /*QPixmap pix(60, 40); pix.fill(dia_ui->clip_color->color()); item->setIcon(0, QIcon(pix));*/ @@ -275,7 +330,7 @@ QDomElement ProjectList::producersList() QDomDocument doc; QDomElement prods = doc.createElement("producerlist"); doc.appendChild(prods); - + kDebug()<<"//////////// PRO LIST BUILD PRDSLIST "; QTreeWidgetItemIterator it(listView); while (*it) { if (!((ProjectItem *)(*it))->isGroup()) @@ -312,8 +367,9 @@ ProjectItem *ProjectList::getItemById(int id) } -void ProjectList::addProducer(QDomElement producer) +void ProjectList::addProducer(QDomElement producer, int parentId) { + if (!m_commandStack) kDebug()<<"!!!!!!!!!!!!!!!!  NO CMD STK"; DocClipBase::CLIPTYPE type = (DocClipBase::CLIPTYPE) producer.attribute("type").toInt(); /*QDomDocument doc; @@ -325,15 +381,16 @@ void ProjectList::addProducer(QDomElement producer) //kDebug()<<"////// ADDING PRODUCER:\n "<= m_clipIdCounter) m_clipIdCounter = id + 1; + else if (id == 0) id = m_clipIdCounter++; - if (type == DocClipBase::AUDIO || type == DocClipBase::VIDEO || type == DocClipBase::AV) + if (type == DocClipBase::AUDIO || type == DocClipBase::VIDEO || type == DocClipBase::AV || type == DocClipBase::IMAGE || type == DocClipBase::PLAYLIST) { KUrl resource = KUrl(producer.attribute("resource")); if (!resource.isEmpty()) { QStringList itemEntry; itemEntry.append(QString::null); itemEntry.append(resource.fileName()); - addClip(itemEntry, producer, id, resource); + addClip(itemEntry, producer, id, resource, parentId); /*AddClipCommand *command = new AddClipCommand(this, itemEntry, producer, id, resource, true); m_commandStack->push(command);*/ @@ -351,8 +408,8 @@ void ProjectList::addProducer(QDomElement producer) pix.fill(QColor(colour.left(7))); QStringList itemEntry; itemEntry.append(QString::null); - itemEntry.append(producer.attribute("name")); - addClip(itemEntry, producer, id, KUrl()); + itemEntry.append(producer.attribute("name", i18n("Color clip"))); + addClip(itemEntry, producer, id, KUrl(), parentId); /*AddClipCommand *command = new AddClipCommand(this, itemEntry, producer, id, KUrl(), true); m_commandStack->push(command);*/ //ProjectItem *item = new ProjectItem(listView, itemEntry, producer); diff --git a/src/projectlist.h b/src/projectlist.h index 042ed4d7..95cd4d6c 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 @@ -25,12 +45,12 @@ 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()); + void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), int parentId = -1); void deleteClip(const int clipId); 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); diff --git a/src/smallruler.cpp b/src/smallruler.cpp index a7265072..b1353db6 100644 --- a/src/smallruler.cpp +++ b/src/smallruler.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * 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 * + ***************************************************************************/ + #include #include diff --git a/src/smallruler.h b/src/smallruler.h index 04404c39..c4731b16 100644 --- a/src/smallruler.h +++ b/src/smallruler.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * 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 SMALLRULER_H #define SMALLRULER_H diff --git a/src/trackview.cpp b/src/trackview.cpp index 236e3ee3..77b76dfe 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -10,10 +10,12 @@ #include "documentaudiotrack.h" #include "headertrack.h" #include "trackview.h" +#include "trackpanelclipmovefunction.h" TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) - : QWidget(parent), m_doc(doc), m_scale(1.0) + : QWidget(parent), m_doc(doc), m_scale(1.0), m_panelUnderMouse(NULL), m_function(NULL) { + setMouseTracking(true); view = new Ui::TimeLine_UI(); view->setupUi(this); m_ruler = new CustomRuler(doc->timecode()); @@ -49,9 +51,18 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) parseDocument(doc->toXml()); + TrackPanelClipMoveFunction *m_moveFunction = new TrackPanelClipMoveFunction(this); + registerFunction("move", m_moveFunction); + setEditMode("move"); + connect(view->horizontalSlider, SIGNAL(valueChanged ( int )), this, SLOT(slotChangeZoom( int ))); } +void TrackView::registerFunction(const QString & name, TrackPanelFunction * function) +{ + m_factory.registerFunction(name, function); +} + void TrackView::parseDocument(QDomDocument doc) { QDomNodeList tracks = doc.elementsByTagName("playlist"); @@ -89,6 +100,11 @@ const double TrackView::zoomFactor() const return m_scale * FRAME_SIZE; } +const int TrackView::mapLocalToValue(int x) const +{ + return (int) x * zoomFactor(); +} + KdenliveDoc *TrackView::document() { return m_doc; @@ -116,4 +132,80 @@ int TrackView::slotAddVideoTrack(int ix, QDomElement xml) //track->show(); } +DocumentTrack *TrackView::panelAt(int y) +{ + return NULL; +} + +void TrackView::setEditMode(const QString & editMode) +{ + m_editMode = editMode; +} + +const QString & TrackView::editMode() const +{ + return m_editMode; +} + +/** This event occurs when the mouse has been moved. */ + void TrackView::mouseMoveEvent(QMouseEvent * event) { + kDebug()<<"-------- TRACKVIEW MOUSE MOVE EVENT -----"; + if (m_panelUnderMouse) { + if (event->buttons() & Qt::LeftButton) { + bool result = false; + if (m_function) + result = + m_function->mouseMoved(m_panelUnderMouse, event); + if (!result) { + m_panelUnderMouse = 0; + m_function = 0; + } + } else { + if (m_function) { + m_function->mouseReleased(m_panelUnderMouse, event); + m_function = 0; + } + m_panelUnderMouse = 0; + } + } else { + DocumentTrack *panel = panelAt(event->y()); + if (panel) { + QCursor result(Qt::ArrowCursor); + + TrackPanelFunction *function = + getApplicableFunction(panel, editMode(), + event); + if (function) + result = function->getMouseCursor(panel, event); + + setCursor(result); + } else { + setCursor(QCursor(Qt::ArrowCursor)); + } + } + } + + TrackPanelFunction *TrackView::getApplicableFunction(DocumentTrack * + panel, const QString & editMode, QMouseEvent * event) { + TrackPanelFunction *function = 0; + + QStringList list = panel->applicableFunctions(editMode); + QStringList::iterator itt = list.begin(); + + while (itt != list.end()) { + TrackPanelFunction *testFunction = m_factory.function(*itt); + if (testFunction) { + if (testFunction->mouseApplies(panel, event)) { + function = testFunction; + break; + } + } + + ++itt; + } + + return function; + } + + #include "trackview.moc" diff --git a/src/trackview.h b/src/trackview.h index e7797b2f..410ecef0 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -12,6 +12,8 @@ #include "customruler.h" #include "kdenlivedoc.h" #include "documenttrack.h" +#include "trackpanelfunctionfactory.h" +#include "trackpanelfunction.h" class TrackView : public QWidget { @@ -20,7 +22,14 @@ class TrackView : public QWidget public: TrackView(KdenliveDoc *doc, QWidget *parent=0); + /** This event occurs when the mouse has been moved. */ + void mouseMoveEvent(QMouseEvent * event); + const double zoomFactor() const; + DocumentTrack *panelAt(int y); + const int mapLocalToValue(int x) const; + void setEditMode(const QString & editMode); + const QString & editMode() const; public slots: KdenliveDoc *document(); @@ -31,6 +40,11 @@ class TrackView : public QWidget double m_scale; QList documentTracks; int m_projectDuration; + TrackPanelFunctionFactory m_factory; + DocumentTrack *m_panelUnderMouse; + /** The currently applied function. This lasts from mousePressed until mouseRelease. */ + TrackPanelFunction *m_function; + QString m_editMode; KdenliveDoc *m_doc; QVBoxLayout *m_tracksLayout; @@ -41,7 +55,8 @@ class TrackView : public QWidget void parseDocument(QDomDocument doc); int slotAddAudioTrack(int ix, QDomElement xml); int slotAddVideoTrack(int ix, QDomElement xml); - + void registerFunction(const QString & name, TrackPanelFunction * function); + TrackPanelFunction *getApplicableFunction(DocumentTrack * panel, const QString & editMode, QMouseEvent * event); private slots: void slotChangeZoom(int factor);