]> git.sesse.net Git - kdenlive/commitdiff
cleanup and better monitor handling from project view
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 11 Jun 2008 20:39:38 +0000 (20:39 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 11 Jun 2008 20:39:38 +0000 (20:39 +0000)
svn path=/branches/KDE4/; revision=2250

src/customtrackview.cpp
src/customtrackview.h
src/monitor.cpp
src/projectlist.cpp
src/projectlist.h
src/projectlistview.cpp
src/projectlistview.h
src/trackview.cpp

index c1ccf221e28f1b2381944eb1881ac174109f45cf..aa6f0294cc1e812e640782a18a1e3bfc53e1fd01 100644 (file)
@@ -1432,14 +1432,14 @@ void CustomTrackView::slotAddGuide() {
 }
 
 void CustomTrackView::slotDeleteGuide() {
-       GenTime pos = GenTime(m_cursorPos, m_document->fps());
-       for (int i = 0; i < m_guides.count(); i++) {
-               if (m_guides.at(i)->position() == pos) {
-                       EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true);
-                       m_commandStack->push(command);
+    GenTime pos = GenTime(m_cursorPos, m_document->fps());
+    for (int i = 0; i < m_guides.count(); i++) {
+        if (m_guides.at(i)->position() == pos) {
+            EditGuideCommand *command = new EditGuideCommand(this, m_guides.at(i)->position(), m_guides.at(i)->label(), GenTime(), QString(), true);
+            m_commandStack->push(command);
             break;
         }
-       }
+    }
 }
 
 void CustomTrackView::setTool(PROJECTTOOL tool) {
@@ -1448,15 +1448,15 @@ void CustomTrackView::setTool(PROJECTTOOL tool) {
 
 void CustomTrackView::setScale(double scaleFactor) {
     //scale(scaleFactor, scaleFactor);
-       m_animationTimer->stop();
+    m_animationTimer->stop();
     if (m_visualTip) {
-               delete m_visualTip;
+        delete m_visualTip;
         m_visualTip = NULL;
-       }
-       if (m_animation) {
-               delete m_animation;
-               m_animation = NULL;
-       }
+    }
+    if (m_animation) {
+        delete m_animation;
+        m_animation = NULL;
+    }
     double pos = cursorPos() / m_scale;
     m_scale = scaleFactor;
     int vert = verticalScrollBar()->value();
@@ -1507,7 +1507,7 @@ QDomElement CustomTrackView::xmlInfo() {
         e.setAttribute("comment", m_guides.at(i)->label());
         guides.appendChild(e);
     }
-       return guides;
+    return guides;
 }
 
 /*
index 016160866edb8fb529b4d361b33664c9925e292e..790b9a2eb14025cfd807d0ec4dfcdf7ac3a188db 100644 (file)
@@ -82,7 +82,7 @@ public:
     void slotSeekToPreviousSnap();
     void slotSeekToNextSnap();
     double getSnapPointForPos(double pos);
-       QDomElement xmlInfo();
+    QDomElement xmlInfo();
 
 public slots:
     void setCursorPos(int pos, bool seek = true);
@@ -103,7 +103,7 @@ public slots:
     void slotAddClipMarker(int id, GenTime t, QString c);
     void addGuide(const GenTime pos, const QString &comment);
     void slotAddGuide();
-       void slotDeleteGuide();
+    void slotDeleteGuide();
     void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment);
 
 protected:
index b0bda7e4174aaab2cb73ac505f4e92cb49c6abf4..155d0a71544c4c63e0b477eba75abb56ab385091 100644 (file)
@@ -266,6 +266,7 @@ void Monitor::slotPlay() {
 void Monitor::slotSetXml(const QDomElement &e) {
     if (render == NULL) return;
     if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+    if (e.isNull()) return;
     QDomDocument doc;
     QDomElement westley = doc.createElement("westley");
     doc.appendChild(westley);
index 7580fbf1ceb6955943eae18275d9fb2b8c51bf3d..51429e4446e58194f702bd3c6bb326b19abc537d 100644 (file)
@@ -53,7 +53,7 @@
 #include "projectlistview.h"
 
 ProjectList::ProjectList(QWidget *parent)
-        : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL) {
+        : QWidget(parent), m_render(NULL), m_fps(-1), m_commandStack(NULL), m_selectedItem(NULL) {
 
     QWidget *vbox = new QWidget;
     listView = new ProjectListView(this);;
@@ -111,6 +111,7 @@ ProjectList::ProjectList(QWidget *parent)
     m_menu->insertSeparator(m_deleteAction);
 
     connect(listView, SIGNAL(itemSelectionChanged()), this, SLOT(slotClipSelected()));
+    connect(listView, SIGNAL(focusMonitor()), this, SLOT(slotClipSelected()));
     connect(listView, SIGNAL(requestMenu(const QPoint &, QTreeWidgetItem *)), this, SLOT(slotContextMenu(const QPoint &, QTreeWidgetItem *)));
     connect(listView, SIGNAL(addClip()), this, SLOT(slotAddClip()));
     connect(listView, SIGNAL(addClip(QUrl, const QString &)), this, SLOT(slotAddClip(QUrl, const QString &)));
@@ -140,7 +141,15 @@ void ProjectList::setRenderer(Render *projectRender) {
 
 void ProjectList::slotClipSelected() {
     ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
-    if (item && !item->isGroup()) emit clipSelected(item->toXml());
+    if (item && !item->isGroup()) {
+        if (item == m_selectedItem) {
+            // if user clicked on the active clip item, just focus monitor, don't update it.
+            emit clipSelected(QDomElement());
+            return;
+        }
+        m_selectedItem = item;
+        emit clipSelected(item->toXml());
+    }
 }
 
 void ProjectList::slotUpdateClipProperties(int id, QMap <QString, QString> properties) {
@@ -214,78 +223,6 @@ 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, const QString &group, int parentId) {
-    kDebug() << "/////////  ADDING VCLIP=: " << name;
-    ProjectItem *item;
-    ProjectItem *groupItem = NULL;
-    QString groupName;
-    if (group.isEmpty()) groupName = elem.attribute("groupname", QString::null);
-    else groupName = group;
-    if (elem.isNull() && url.isEmpty()) {
-        // this is a folder
-        groupName = name.at(1);
-        QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
-        if (groupList.isEmpty())  {
-            (void) new ProjectItem(listView, name, m_doc->getFreeClipId());
-        }
-        return;
-    }
-
-    if (parentId != -1) {
-        groupItem = getItemById(parentId);
-    } else if (!groupName.isEmpty()) {
-        // Clip is in a group
-        QList<QTreeWidgetItem *> groupList = listView->findItems(groupName, Qt::MatchExactly, 1);
-
-        if (groupList.isEmpty())  {
-            QStringList itemName;
-            itemName << QString::null << groupName;
-            kDebug() << "-------  CREATING NEW GRP: " << itemName;
-            groupItem = new ProjectItem(listView, itemName, m_doc->getFreeClipId());
-        } else groupItem = (ProjectItem *) groupList.first();
-    }
-    if (groupItem) item = new ProjectItem(groupItem, name, elem, clipId);
-    else item = new ProjectItem(listView, name, elem, clipId);
-    if (!url.isEmpty()) {
-        // if file has Nepomuk comment, use it
-        Nepomuk::Resource f(url.path());
-        QString annotation;
-        if (f.isValid()) annotation = f.description();
-
-        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");
-        element.setAttribute("resource", url.path());
-        emit getFileProperties(element, clipId);
-    } else emit getFileProperties(elem, clipId);
-    selectItemById(clipId);
-}
 
 void ProjectList::slotDeleteClip(int clipId) {
     ProjectItem *item = getItemById(clipId);
@@ -293,7 +230,9 @@ void ProjectList::slotDeleteClip(int clipId) {
     if (p) {
         kDebug() << "///////  DELETEED CLIP HAS A PARENT... " << p->indexOfChild(item);
         QTreeWidgetItem *clone = p->takeChild(p->indexOfChild(item));
-    } else if (item) delete item;
+    } else if (item) {
+        delete item;
+    }
 }
 
 void ProjectList::slotAddFolder() {
@@ -479,15 +418,6 @@ void ProjectList::setDocument(KdenliveDoc *doc) {
     m_timecode = doc->timecode();
     m_commandStack = doc->commandStack();
     m_doc = doc;
-    /*    QDomNodeList prods = doc->producersList();
-        int ct = prods.count();
-        kDebug() << "////////////  SETTING DOC, FOUND CLIPS: " << prods.count();
-        listView->clear();
-        for (int i = 0; i <  ct ; i++) {
-            QDomElement e = prods.item(i).toElement();
-            kDebug() << "// IMPORT: " << i << ", :" << e.attribute("id", "non") << ", NAME: " << e.attribute("name", "non");
-            if (!e.isNull()) addProducer(e);
-        }*/
     QTreeWidgetItem *first = listView->topLevelItem(0);
     if (first) listView->setCurrentItem(first);
     m_toolbar->setEnabled(true);
@@ -547,46 +477,4 @@ ProjectItem *ProjectList::getItemById(int id) {
     return NULL;
 }
 
-
-void ProjectList::addProducer(QDomElement producer, int parentId) {
-    if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!!  NO CMD STK";
-    CLIPTYPE type = (CLIPTYPE) producer.attribute("type").toInt();
-
-    /*QDomDocument doc;
-    QDomElement prods = doc.createElement("list");
-    doc.appendChild(prods);
-    prods.appendChild(doc.importNode(producer, true));*/
-
-
-    //kDebug()<<"//////  ADDING PRODUCER:\n "<<doc.toString()<<"\n+++++++++++++++++";
-    int id = producer.attribute("id").toInt();
-    QString groupName = producer.attribute("groupname");
-    if (id >= m_clipIdCounter) m_clipIdCounter = id + 1;
-    else if (id == 0) id = m_clipIdCounter++;
-
-    if (parentId != -1) {
-        // item is a westley playlist, adjust subproducers ids
-        id = (parentId + 1) * 10000 + id;
-    }
-    if (type == AUDIO || type == VIDEO || type == AV || type == IMAGE  || type == 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, groupName, parentId);
-        }
-    } else if (type == COLOR) {
-        QString colour = producer.attribute("colour");
-        QPixmap pix(60, 40);
-        colour = colour.replace(0, 2, "#");
-        pix.fill(QColor(colour.left(7)));
-        QStringList itemEntry;
-        itemEntry.append(QString::null);
-        itemEntry.append(producer.attribute("name", i18n("Color clip")));
-        addClip(itemEntry, producer, id, KUrl(), groupName, parentId);
-    }
-
-}
-
 #include "projectlist.moc"
index 4806cb3223221dea8153d2e184301ea99d5e8bf8..27ee804d198774fdc22a2fbb6bc902334c215cc8 100644 (file)
@@ -104,13 +104,10 @@ public:
 
     QDomElement producersList();
     void setRenderer(Render *projectRender);
-
-    void addClip(const QStringList &name, const QDomElement &elem, const int clipId, const KUrl &url = KUrl(), const QString &group = QString::null, int parentId = -1);
     void slotUpdateClipProperties(int id, QMap <QString, QString> properties);
 
 public slots:
     void setDocument(KdenliveDoc *doc);
-    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);
@@ -136,6 +133,7 @@ private:
     QAction *m_deleteAction;
     KdenliveDoc *m_doc;
     ItemDelegate *m_listViewDelegate;
+    ProjectItem *m_selectedItem;
 
 private slots:
     void slotAddClip(QUrl givenUrl = QUrl(), QString group = QString());
index 2cfa436d8bfe4b2c546f85d40cbfe29e47b4673f..fde83832c13a69e320d04bd7976fdfe5bea0827c 100644 (file)
@@ -192,6 +192,8 @@ void ProjectListView::mousePressEvent(QMouseEvent *event) {
     if (event->button() == Qt::LeftButton) {
         this->m_DragStartPosition = event->pos();
         m_dragStarted = true;
+        QTreeWidgetItem *underMouse = itemAt(event->pos());
+        if (underMouse && underMouse->isSelected()) emit focusMonitor();
     }
     QTreeWidget::mousePressEvent(event);
 }
index 474b8d9336d57768f82e5141b39820dfb1e59491..b30e7dc506ae88a317e28513e0540d8c5041c0e7 100644 (file)
@@ -59,6 +59,7 @@ signals:
     void addClip();
     void addClip(QUrl, const QString &);
     void showProperties(DocClipBase *);
+    void focusMonitor();
 };
 
 #endif
index fe941cbbfe5703dabb5cc7b53cf05ff5d15ba994..32e162d68fed5a8b49f46ada784d0ecd23aebda5 100644 (file)
@@ -233,15 +233,14 @@ void TrackView::parseDocument(QDomDocument doc) {
         }
     }
 
-       // Add guides
+    // Add guides
     QDomNodeList guides = doc.elementsByTagName("guide");
-    kDebug() << "//////////// OPENING PRJECT FILE, FOUND: " << guides.count() << " GUIDES$$$$$$$$$";
     for (int i = 0; i < guides.count(); i++) {
         e = guides.item(i).toElement();
-               const QString comment = e.attribute("comment");
-               const GenTime pos = GenTime(e.attribute("time").toDouble());
-               m_trackview->addGuide(pos, comment);
-       }
+        const QString comment = e.attribute("comment");
+        const GenTime pos = GenTime(e.attribute("time").toDouble());
+        m_trackview->addGuide(pos, comment);
+    }
 
     m_trackview->setDuration(duration);
     kDebug() << "///////////  TOTAL PROJECT DURATION: " << duration;