implemented basic track delete function
This commit is contained in:
@@ -71,6 +71,16 @@ public:
|
||||
void ArrayAppend(bool undoable = false);
|
||||
void ArrayRemoveLast(bool undoable = false);
|
||||
|
||||
int GetArrayIndexFromCacheIndex(int index) const
|
||||
{
|
||||
return track_array_indexes_.at(index);
|
||||
}
|
||||
|
||||
int GetCacheIndexFromArrayIndex(int index) const
|
||||
{
|
||||
return track_array_indexes_.indexOf(index);
|
||||
}
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Slot for when the track connection is added
|
||||
@@ -100,16 +110,6 @@ private:
|
||||
QVector<Track*> track_cache_;
|
||||
QVector<int> track_array_indexes_;
|
||||
|
||||
int GetArrayIndexFromCacheIndex(int index) const
|
||||
{
|
||||
return track_array_indexes_.at(index);
|
||||
}
|
||||
|
||||
int GetCacheIndexFromArrayIndex(int index) const
|
||||
{
|
||||
return track_array_indexes_.indexOf(index);
|
||||
}
|
||||
|
||||
QString track_input_;
|
||||
|
||||
rational total_length_;
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
|
||||
#include "core.h"
|
||||
#include "widget/menu/menu.h"
|
||||
#include "widget/timelinewidget/undo/timelineundogeneral.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
TrackViewItem::TrackViewItem(Track* track, QWidget *parent) :
|
||||
@@ -63,8 +67,10 @@ TrackViewItem::TrackViewItem(Track* track, QWidget *parent) :
|
||||
layout->addWidget(lock_button_);
|
||||
|
||||
setMinimumHeight(mute_button_->height());
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
connect(track, &Track::MutedChanged, mute_button_, &QPushButton::setChecked);
|
||||
connect(this, &QWidget::customContextMenuRequested, this, &TrackViewItem::ShowContextMenu);
|
||||
}
|
||||
|
||||
QPushButton *TrackViewItem::CreateMSLButton(const QString& text, const QColor& checked_color) const
|
||||
@@ -114,4 +120,19 @@ void TrackViewItem::UpdateLabel()
|
||||
label_->setText(track_->GetLabelOrName());
|
||||
}
|
||||
|
||||
void TrackViewItem::ShowContextMenu(const QPoint &p)
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
QAction *delete_action = m.addAction(tr("&Delete"));
|
||||
connect(delete_action, &QAction::triggered, this, &TrackViewItem::DeleteTrack, Qt::QueuedConnection);
|
||||
|
||||
m.exec(mapToGlobal(p));
|
||||
}
|
||||
|
||||
void TrackViewItem::DeleteTrack()
|
||||
{
|
||||
Core::instance()->undo_stack()->push(new TimelineRemoveTrackCommand(track_));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,10 @@ private slots:
|
||||
|
||||
void UpdateLabel();
|
||||
|
||||
void ShowContextMenu(const QPoint &p);
|
||||
|
||||
void DeleteTrack();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ void TrackViewSplitter::SetHeightWithSizes(QList<int> sizes)
|
||||
if (alignment_ == Qt::AlignBottom) {
|
||||
sizes.replace(0, spacer_height_);
|
||||
} else {
|
||||
sizes.replace(count() - 1, spacer_height_);
|
||||
sizes.replace(sizes.size() - 1, spacer_height_);
|
||||
}
|
||||
|
||||
foreach (int s, sizes) {
|
||||
|
||||
@@ -591,4 +591,22 @@ void TrackReplaceBlockWithGapCommand::CreateRemoveTransitionCommandIfNecessary(b
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineRemoveTrackCommand::redo()
|
||||
{
|
||||
list_ = track_->sequence()->track_list(track_->type());
|
||||
|
||||
index_ = list_->GetArrayIndexFromCacheIndex(track_->Index());
|
||||
|
||||
Node::DisconnectEdge(track_, list_->track_input(index_));
|
||||
|
||||
list_->parent()->InputArrayRemove(list_->track_input(), index_);
|
||||
}
|
||||
|
||||
void TimelineRemoveTrackCommand::undo()
|
||||
{
|
||||
list_->parent()->InputArrayInsert(list_->track_input(), index_);
|
||||
|
||||
Node::ConnectEdge(track_, list_->track_input(index_));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -163,6 +163,32 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class TimelineRemoveTrackCommand : public UndoCommand
|
||||
{
|
||||
public:
|
||||
TimelineRemoveTrackCommand(Track *track) :
|
||||
track_(track)
|
||||
{}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return track_->project();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Track *track_;
|
||||
|
||||
TrackList *list_;
|
||||
|
||||
int index_;
|
||||
|
||||
};
|
||||
|
||||
class TransitionRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
TransitionRemoveCommand(TransitionBlock* block, bool remove_from_graph) :
|
||||
|
||||
Reference in New Issue
Block a user