improve subclips visual info (display zone over thumbnail), minor cleanup

parent 02920d3a
Pipeline #6032 passed with stage
in 15 minutes and 35 seconds
......@@ -136,9 +136,15 @@ QVariant AbstractProjectItem::getData(DataType type) const
case DataDuration:
data = QVariant(m_duration);
break;
case ParentDuration:
data = QVariant(m_parentDuration);
break;
case DataInPoint:
data = QVariant(m_inPoint);
break;
case DataOutPoint:
data = QVariant(m_outPoint);
break;
case DataDate:
data = QVariant(m_date);
break;
......
......@@ -121,10 +121,14 @@ public:
IconOverlay,
// item type (clip, subclip, folder)
ItemTypeRole,
// Duration of the clip
// Duration of the clip as displayabe string
DataDuration,
// Duration of the clip in frames
ParentDuration,
// Inpoint of the subclip (0 for clips)
DataInPoint,
// Outpoint of the subclip (0 for clips)
DataOutPoint,
// If there is a running job, which type
JobType,
// Current progress of the job
......@@ -201,7 +205,9 @@ protected:
QString m_description;
QIcon m_thumbnail;
QString m_duration;
int m_parentDuration;
int m_inPoint;
int m_outPoint;
QDateTime m_date;
QString m_binId;
uint m_usage;
......
......@@ -285,6 +285,17 @@ public:
QIcon warning = QIcon::fromTheme(QStringLiteral("process-stop"));
warning.paint(painter, r2);
}
} else {
// Subclip, overlay zone rect
QRect zoneRect = m_thumbRect;
int duration = index.data(AbstractProjectItem::ParentDuration).toInt();
double factor = ((double) m_thumbRect.width()) / duration;
int zoneIn = index.data(AbstractProjectItem::DataInPoint).toInt();
int zoneOut = index.data(AbstractProjectItem::DataOutPoint).toInt() - duration;
zoneRect.adjust(0, zoneRect.height() * 0.96, 0, 0);
painter->fillRect(zoneRect, Qt::darkGreen);
zoneRect.adjust(zoneIn * factor, 0, zoneOut * factor, 0);
painter->fillRect(zoneRect, Qt::green);
}
} else {
// Folder or Folder Up items
......@@ -2470,7 +2481,7 @@ void Bin::renameSubClipCommand(const QString &id, const QString &newName, const
m_doc->commandStack()->push(command);
}
void Bin::renameSubClip(const QString &id, const QString &newName, const QString &oldName, int in, int out)
void Bin::renameSubClip(const QString &id, const QString &newName, int in, int out)
{
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (!clip) {
......
......@@ -223,7 +223,7 @@ public:
/** @brief Build a rename subclip command. */
void renameSubClipCommand(const QString &id, const QString &newName, const QString &oldName, int in, int out);
/** @brief Rename a clip zone (subclip). */
void renameSubClip(const QString &id, const QString &newName, const QString &oldName, int in, int out);
void renameSubClip(const QString &id, const QString &newName, int in, int out);
/** @brief Returns current project's timecode. */
Timecode projectTimecode() const;
/** @brief Trigger timecode format refresh where needed. */
......
......@@ -77,12 +77,12 @@ RenameBinSubClipCommand::RenameBinSubClipCommand(Bin *bin, QString clipId, QStri
// virtual
void RenameBinSubClipCommand::undo()
{
m_bin->renameSubClip(m_clipId, m_oldName, m_newName, m_in, m_out);
m_bin->renameSubClip(m_clipId, m_oldName, m_in, m_out);
}
// virtual
void RenameBinSubClipCommand::redo()
{
m_bin->renameSubClip(m_clipId, m_newName, m_oldName, m_in, m_out);
m_bin->renameSubClip(m_clipId, m_newName, m_in, m_out);
}
EditClipCommand::EditClipCommand(Bin *bin, QString id, QMap<QString, QString> oldparams, QMap<QString, QString> newparams, bool doIt, QUndoCommand *parent)
......
......@@ -88,6 +88,7 @@ ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, const std::share
m_name = clipName();
m_duration = getStringDuration();
m_inPoint = 0;
m_outPoint = 0;
m_date = date;
m_description = ClipController::description();
if (m_clipType == ClipType::Audio) {
......
......@@ -37,10 +37,11 @@ ProjectSubClip::ProjectSubClip(const QString &id, const std::shared_ptr<ProjectC
const QString &timecode, const QString &name)
: AbstractProjectItem(AbstractProjectItem::SubClipItem, id, model)
, m_masterClip(parent)
, m_out(out)
{
m_inPoint = in;
m_outPoint = out;
m_duration = timecode;
m_parentDuration = m_masterClip->frameDuration();
QPixmap pix(64, 36);
pix.fill(Qt::lightGray);
m_thumbnail = QIcon(pix);
......@@ -103,7 +104,7 @@ GenTime ProjectSubClip::duration() const
QPoint ProjectSubClip::zone() const
{
return {m_inPoint, m_out};
return {m_inPoint, m_outPoint};
}
std::shared_ptr<ProjectClip> ProjectSubClip::clipAt(int ix)
......@@ -117,13 +118,13 @@ QDomElement ProjectSubClip::toXml(QDomDocument &document, bool, bool)
QDomElement sub = document.createElement(QStringLiteral("subclip"));
sub.setAttribute(QStringLiteral("id"), m_masterClip->AbstractProjectItem::clipId());
sub.setAttribute(QStringLiteral("in"), m_inPoint);
sub.setAttribute(QStringLiteral("out"), m_out);
sub.setAttribute(QStringLiteral("out"), m_outPoint);
return sub;
}
std::shared_ptr<ProjectSubClip> ProjectSubClip::subClip(int in, int out)
{
if (m_inPoint == in && m_out == out) {
if (m_inPoint == in && m_outPoint == out) {
return std::static_pointer_cast<ProjectSubClip>(shared_from_this());
}
return std::shared_ptr<ProjectSubClip>();
......@@ -151,7 +152,7 @@ bool ProjectSubClip::rename(const QString &name, int column)
return false;
}
// Rename folder
auto *command = new RenameBinSubClipCommand(pCore->bin(), m_masterClip->clipId(), name, m_name, m_inPoint, m_out);
auto *command = new RenameBinSubClipCommand(pCore->bin(), m_masterClip->clipId(), name, m_name, m_inPoint, m_outPoint);
pCore->currentDoc()->commandStack()->push(command);
return true;
}
......
......@@ -86,7 +86,6 @@ public:
private:
std::shared_ptr<ProjectClip> m_masterClip;
int m_out;
private slots:
void gotThumb(int pos, const QImage &img);
......
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