[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive/refactoring_timeline] src: Always select first clip added to bin
From:       Jean-Baptiste Mardelle <null () kde ! org>
Date:       2017-12-14 23:17:13
Message-ID: E1ePckb-0007QV-Eo () code ! kde ! org
[Download RAW message or body]

Git commit 0de81d990fe0403a990f9347bd37d2bc09e7765b by Jean-Baptiste Mardelle.
Committed on 14/12/2017 at 23:16.
Pushed by mardelle into branch 'refactoring_timeline'.

Always select first clip added to bin

M  +5    -0    src/abstractmodel/abstracttreemodel.cpp
M  +3    -0    src/abstractmodel/abstracttreemodel.hpp
M  +5    -0    src/core.cpp
M  +2    -0    src/core.h
M  +4    -0    src/jobs/loadjob.cpp
M  +2    -2    src/mainwindow.cpp

https://commits.kde.org/kdenlive/0de81d990fe0403a990f9347bd37d2bc09e7765b

diff --git a/src/abstractmodel/abstracttreemodel.cpp \
b/src/abstractmodel/abstracttreemodel.cpp index 94342de18..e50a31dc7 100644
--- a/src/abstractmodel/abstracttreemodel.cpp
+++ b/src/abstractmodel/abstracttreemodel.cpp
@@ -197,6 +197,11 @@ void AbstractTreeModel::deregisterItem(int id, TreeItem *item)
     m_allItems.erase(id);
 }
 
+int AbstractTreeModel::clipsCount() const
+{
+    return m_allItems.size();
+}
+
 std::shared_ptr<TreeItem> AbstractTreeModel::getItemById(int id) const
 {
     if (id == rootItem->getId()) {
diff --git a/src/abstractmodel/abstracttreemodel.hpp \
b/src/abstractmodel/abstracttreemodel.hpp index 41faa9e8a..4b53dff04 100644
--- a/src/abstractmodel/abstracttreemodel.hpp
+++ b/src/abstractmodel/abstracttreemodel.hpp
@@ -78,6 +78,9 @@ public:
     /* @brief Helper function to generate a lambda that changes the row of an item \
*/  Fun moveItem_lambda(int id, int destRow);
 
+    /* @brief Returns the number of clips in bin */
+    int clipsCount() const;
+
     friend class TreeItem;
     friend class AbstractProjectItem;
 
diff --git a/src/core.cpp b/src/core.cpp
index e904ad4bd..bfc34fd1f 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -233,6 +233,11 @@ Bin *Core::bin()
     return m_binWidget;
 }
 
+void Core::selectBinClip(const QString &clipId, int frame, const QPoint &zone)
+{
+    m_binWidget->selectClipById(clipId, frame, zone);
+}
+
 std::shared_ptr<JobManager> Core::jobManager()
 {
     return m_jobManager;
diff --git a/src/core.h b/src/core.h
index 5dd06379f..5daac912c 100644
--- a/src/core.h
+++ b/src/core.h
@@ -91,6 +91,8 @@ public:
     std::shared_ptr<BinController> binController();
     /** @brief Returns a pointer to the view of the project bin. */
     Bin *bin();
+    /** @brief Select a clip in the Bin from its id. */
+    void selectBinClip(const QString &id, int frame = -1, const QPoint &zone = \
QPoint());  /** @brief Returns a pointer to the model of the project bin. */
     std::shared_ptr<ProjectItemModel> projectItemModel();
     /** @brief Returns a pointer to the job manager. Please do not store it. */
diff --git a/src/jobs/loadjob.cpp b/src/jobs/loadjob.cpp
index 8b75261db..4e81f47d9 100644
--- a/src/jobs/loadjob.cpp
+++ b/src/jobs/loadjob.cpp
@@ -531,6 +531,10 @@ bool LoadJob::commitResult(Fun &undo, Fun &redo)
     };
     bool ok = operation();
     if (ok) {
+        if (pCore->projectItemModel()->clipsCount() == 2) {
+            // Always select first added clip
+            pCore->selectBinClip(m_clipId);
+        }
         UPDATE_UNDO_REDO_NOLOCK(operation, reverse, undo, redo);
     }
     return ok;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9dca3f826..d54e476ae 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1901,7 +1901,7 @@ void MainWindow::addTimelineClip(const QString &url)
     if (pCore->currentDoc()) {
         QStringList ids = \
pCore->binController()->getBinIdsByResource(QFileInfo(url));  if (!ids.isEmpty()) {
-            pCore->bin()->selectClipById(ids.constFirst());
+            pCore->selectBinClip(ids.constFirst());
             slotInsertClipInsert();
         }
     }
@@ -2942,7 +2942,7 @@ void MainWindow::slotClipInProjectTree()
         if (m_projectMonitor->isActive()) {
             slotSwitchMonitors();
         }
-        pCore->bin()->selectClipById(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), \
-1, zone); +        pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), \
-1, zone);  }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic