Commit 71c7f6c1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch 'lintondawson/kdenlive-timeline-archive'

parents d143ef0a c8b8909a
......@@ -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();
......
......@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QCameraInfo>
#include <memory>
#include <utility>
#include <QAudioOutput>
MediaCapture::MediaCapture(QObject *parent)
: QObject(parent)
......
......@@ -842,6 +842,16 @@ QString Core::getTimelineClipBinId(int cid)
}
return QString();
}
std::unordered_set<QString> Core::getAllTimelineTracksId()
{
std::unordered_set<int> timelineClipIds = m_mainWindow->getCurrentTimeline()->controller()->getModel()->getItemsInRange(-1,0);
std::unordered_set<QString> tClipBinIds;
for(int id : timelineClipIds) {
auto idString = m_mainWindow->getCurrentTimeline()->controller()->getModel()->getClipBinId(id);
tClipBinIds.insert(idString);
}
return tClipBinIds;
}
int Core::getDurationFromString(const QString &time)
{
......
......@@ -21,6 +21,7 @@ the Free Software Foundation, either version 3 of the License, or
#include <memory>
#include <QPoint>
#include <KSharedDataCache>
#include <unordered_set>
#include "timecode.h"
class Bin;
......@@ -206,6 +207,8 @@ public:
QString getProjectFolderName();
/** @brief Returns a timeline clip's bin id */
QString getTimelineClipBinId(int cid);
/** @brief Returns all track ids in timeline */
std::unordered_set<QString> getAllTimelineTracksId();
/** @brief Returns a frame duration from a timecode */
int getDurationFromString(const QString &time);
/** @brief An error occurred within a filter, inform user */
......
......@@ -60,6 +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::onlyTimelineItems);
// Prepare xml
m_doc.setContent(xmlData);
......@@ -429,9 +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->bin()->getUsedClipIds();
while (it != items.constEnd()) {
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();
......@@ -1129,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();
}
......@@ -21,6 +21,7 @@
#define ARCHIVEWIDGET_H
#include "ui_archivewidget_ui.h"
#include "timeline2/model/timelinemodel.hpp"
#include <KIO/CopyJob>
#include <QTemporaryFile>
......@@ -41,7 +42,6 @@ class KArchive;
*/
class KMessageWidget;
class ArchiveWidget : public QDialog, public Ui::ArchiveWidget_UI
{
Q_OBJECT
......@@ -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;
......
......@@ -1830,7 +1830,11 @@ void TitleWidget::itemHCenter()
newPos += item->pos().x() - br.left(); // Check item transformation
item->setPos(newPos, item->pos().y());
updateCoordinates(item);
slotAdjustZoom();
graphicsView->centerOn(m_frameBorder);
slotAdjustZoom();
graphicsView->centerOn(m_frameBorder);
}
}
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>266</width>
<height>244</height>
<width>285</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
......@@ -54,6 +54,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="timeline_archive">
<property name="text">
<string>Archive only timeline clips</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
......@@ -129,7 +136,7 @@
<customwidgets>
<customwidget>
<class>KUrlRequester</class>
<extends>QFrame</extends>
<extends>QWidget</extends>
<header>kurlrequester.h</header>
</customwidget>
</customwidgets>
......
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