Commit 33634f32 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix open clip in bin when multiple bins and in icon view

parent 9ce629db
Pipeline #151926 passed with stage
in 7 minutes and 18 seconds
......@@ -3005,6 +3005,10 @@ void Bin::selectClip(const std::shared_ptr<ProjectClip> &clip)
// Make sure parent folder is expanded
auto *view = static_cast<QTreeView *>(m_itemView);
view->expand(m_proxyModel->mapFromSource(ix.parent()));
} else {
// Ensure parent folder is currently opened
m_itemView->setRootIndex(m_proxyModel->mapFromSource(ix.parent()));
m_upAction->setEnabled(!ix.parent().data(AbstractProjectItem::DataId).toString().isEmpty());
}
m_itemView->scrollTo(m_proxyModel->mapFromSource(ix), QAbstractItemView::EnsureVisible);
}
......@@ -5041,3 +5045,21 @@ void Bin::showBinInfo()
{
pCore->window()->showKeyBinding(QString("%1%2").arg(m_clipsCountMessage, m_keyBindingMessage));
}
bool Bin::containsId(const QString &clipId) const
{
if (m_listType == BinIconView) {
// Check if the clip is in our folder
const QString rootId = m_itemView->rootIndex().data(AbstractProjectItem::DataId).toString();
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(clipId);
if (clip) {
std::shared_ptr<AbstractProjectItem> par = clip->parent();
if (par && par->clipId() == rootId) {
return true;
}
}
return false;
} else {
}
return true;
}
......@@ -344,6 +344,8 @@ public:
std::atomic<bool> shouldCheckProfile;
/** @brief Set the message for key binding info. */
void updateKeyBinding(const QString &bindingMessage = QString());
/** @brief Returns true if a clip with id cid is visible in this bin. */
bool containsId(const QString &cid) const;
private slots:
void slotAddClip();
......
......@@ -3273,7 +3273,7 @@ void MainWindow::slotClipInTimeline(const QString &clipId, const QList<int> &ids
void MainWindow::raiseBin()
{
Bin *bin = activeBin();
if (bin && !bin->isVisible()) {
if (bin) {
bin->parentWidget()->setVisible(true);
bin->parentWidget()->raise();
}
......@@ -3283,7 +3283,24 @@ void MainWindow::slotClipInProjectTree()
{
QList<int> ids = getMainTimeline()->controller()->selection();
if (!ids.isEmpty()) {
raiseBin();
const QString binId = getMainTimeline()->controller()->getClipBinId(ids.constFirst());
// If we have multiple bins, check first if a visible bin contains it
bool binFound = false;
if (binCount() > 1) {
for (auto &bin : m_binWidgets) {
if (bin->isVisible() && !bin->visibleRegion().isEmpty()) {
// Check if clip is a child of this bin
if (bin->containsId(binId)) {
binFound = true;
bin->setFocus();
raiseBin();
}
}
}
}
if (!binFound) {
raiseBin();
}
ObjectId id(ObjectType::TimelineClip, ids.constFirst());
int start = pCore->getItemIn(id);
int duration = pCore->getItemDuration(id);
......@@ -3318,7 +3335,7 @@ void MainWindow::slotClipInProjectTree()
if (!containsPos) {
pos = start;
}
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), true, pos, zone);
activeBin()->selectClipById(binId, pos, zone, true);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment