Commit c8b8909a authored by Pushkar Kukde's avatar Pushkar Kukde

Implemented enhancement suggestion #561

parent 68e2dcfb
......@@ -4322,3 +4322,15 @@ void Bin::loadFolderState(QStringList foldersToExpand)
}
}
}
QList<int> Bin::getUsedClipIds()
{
QList<int> timelineClipIds;
QList<std::shared_ptr<ProjectClip>> allClipIds = m_itemModel->getRootFolder()->childClips();
for(auto clip : allClipIds) {
if(clip->isIncludedInTimeline()) {
timelineClipIds.push_back(clip->binId().toInt());
}
}
return timelineClipIds;
}
......@@ -294,6 +294,8 @@ public:
void saveFolderState();
/** @brief Load folder state (expanded or not) */
void loadFolderState(QStringList foldersToExpand);
/** @brief gets a QList of all clips used in timeline */
QList<int> getUsedClipIds();
// TODO refac: remove this and call directly the function in ProjectItemModel
void cleanup();
......
......@@ -60,7 +60,7 @@ ArchiveWidget::ArchiveWidget(const QString &projectName, const QString xmlData,
connect(this, &ArchiveWidget::archivingFinished, this, &ArchiveWidget::slotArchivingBoolFinished);
connect(this, &ArchiveWidget::archiveProgress, this, &ArchiveWidget::slotArchivingIntProgress);
connect(proxy_only, &QCheckBox::stateChanged, this, &ArchiveWidget::slotProxyOnly);
//connect(timeline_archive, &QCheckBox::stateChanged, this, &ArchiveWidget::generateItems);
connect(timeline_archive, &QCheckBox::stateChanged, this, &ArchiveWidget::onlyTimelineItems);
// Prepare xml
m_doc.setContent(xmlData);
......@@ -430,17 +430,17 @@ void ArchiveWidget::generateItems(QTreeWidgetItem *parentItem, const QMap<QStrin
int ix = 0;
bool isSlideshow = parentItem->data(0, Qt::UserRole).toString() == QLatin1String("slideshows");
QMap<QString, QString>::const_iterator it = items.constBegin();
const auto timelineBinId = pCore->getAllTimelineTracksId();
bool TimelineArchive = timeline_archive->isChecked();
const auto timelineBinId = pCore->bin()->getUsedClipIds();
while (it != items.constEnd()) {
if(TimelineArchive) {
if(timelineBinId.find(it.key()) == timelineBinId.end()) {
++it;
continue;
}
}
QString file = it.value();
QTreeWidgetItem *item = new QTreeWidgetItem(parentItem, QStringList() << file);
item->setData(0, Qt::UserRole + 4,0);
for(int id : timelineBinId) {
if(id == it.key().toInt()) {
m_timelineSize = static_cast<KIO::filesize_t>(QFileInfo(it.value()).size());
item->setData(0,Qt::UserRole + 4, 1);
}
}
// Store the clip's id
item->setData(0, Qt::UserRole + 2, it.key());
fileName = QUrl::fromLocalFile(file).fileName();
......@@ -1138,3 +1138,46 @@ void ArchiveWidget::slotProxyOnly(int onlyProxy)
project_files->setText(i18np("%1 file to archive, requires %2", "%1 files to archive, requires %2", total, KIO::convertSize(m_requestedSize)));
slotCheckSpace();
}
void ArchiveWidget::onlyTimelineItems(int onlyTimeline)
{
int count = files_list->topLevelItemCount();
for(int idx = 0 ; idx < count ; ++idx) {
QTreeWidgetItem *parent = files_list->topLevelItem(idx);
int childCount = parent->childCount();
for(int cidx = 0 ; cidx < childCount; ++cidx) {
parent->child(cidx)->setHidden(true);
if(onlyTimeline == Qt::Checked) {
if(parent->child(cidx)->data(0,Qt::UserRole + 4).toInt() > 0) {
parent->child(cidx)->setHidden(false);
}
}
else {
parent->child(cidx)->setHidden(false);
}
}
}
//calculating total number of files
int total = 0;
for (int i = 0; i < files_list->topLevelItemCount(); ++i) {
QTreeWidgetItem *parentItem = files_list->topLevelItem(i);
int items = parentItem->childCount();
int itemsCount = 0;
bool isSlideshow = parentItem->data(0, Qt::UserRole).toString() == QLatin1String("slideshows");
for (int j = 0; j < items; ++j) {
if (!parentItem->child(j)->isHidden() && !parentItem->child(j)->isDisabled()) {
if (isSlideshow) {
total += parentItem->child(j)->data(0, Qt::UserRole + 4).toStringList().count();
} else {
total++;
}
itemsCount++;
}
}
parentItem->setText(0, parentItem->text(0).section(QLatin1Char('('), 0, 0) + i18np("(%1 item)", "(%1 items)", itemsCount));
}
project_files->setText(i18np("%1 file to archive, requires %2", "%1 files to archive, requires %2", total, KIO::convertSize((onlyTimeline == Qt::Checked) ? m_timelineSize : m_requestedSize)));
slotCheckSpace();
}
......@@ -73,12 +73,13 @@ private slots:
void slotDisplayMessage(const QString &icon, const QString &text);
void slotJobResult(bool success, const QString &text);
void slotProxyOnly(int onlyProxy);
void onlyTimelineItems(int onlyTimeline);
protected:
void closeEvent(QCloseEvent *e) override;
private:
KIO::filesize_t m_requestedSize;
KIO::filesize_t m_requestedSize, m_timelineSize;
KIO::CopyJob *m_copyJob;
QMap<QUrl, QUrl> m_duplicateFiles;
QMap<QUrl, QUrl> m_replacementList;
......
......@@ -962,15 +962,7 @@ void TitleWidget::slotAdjustZoom()
if (scalex > scaley) scalex = scaley;
int zoompos = (int)(scalex * 7 + 0.5);*/
graphicsView->fitInView(m_frameBorder, Qt::KeepAspectRatio);
<<<<<<< HEAD
int zoompos = graphicsView->transform().m11() * 100 ;
=======
<<<<<<< HEAD
int zoompos = graphicsView->transform().m11() * 100 ;
=======
int zoompos = graphicsView->transform().m11() * 100 ;
>>>>>>> 4f51bc3e2baf25fccae8e1742bc992b92e89abbf
>>>>>>> a8279d49c156b7769d662c04991c833f74043a69
zoom_slider->setValue(zoompos);
graphicsView->centerOn(m_frameBorder);
}
......@@ -1838,16 +1830,11 @@ void TitleWidget::itemHCenter()
newPos += item->pos().x() - br.left(); // Check item transformation
item->setPos(newPos, item->pos().y());
updateCoordinates(item);
<<<<<<< HEAD
slotAdjustZoom();
graphicsView->centerOn(m_frameBorder);
=======
<<<<<<< HEAD
slotAdjustZoom();
=======
graphicsView->centerOn(m_frameBorder);
>>>>>>> 4f51bc3e2baf25fccae8e1742bc992b92e89abbf
>>>>>>> a8279d49c156b7769d662c04991c833f74043a69
}
}
......
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