Warning, /multimedia/kdenlive/src/timeline2/model/moveableItem.ipp is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright (C) 2017 by Nicolas Carion                                  *
0003  * SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004  */
0005 
0006 #include "macros.hpp"
0007 #include <utility>
0008 
0009 template <typename Service>
0010 MoveableItem<Service>::MoveableItem(std::weak_ptr<TimelineModel> parent, int id)
0011     : m_parent(std::move(parent))
0012     , m_id(id == -1 ? TimelineModel::getNextId() : id)
0013     , m_position(-1)
0014     , m_currentTrackId(-1)
0015     , m_grabbed(false)
0016     , m_lock(QReadWriteLock::Recursive)
0017 {
0018 }
0019 
0020 template <typename Service> int MoveableItem<Service>::getId() const
0021 {
0022     READ_LOCK();
0023     return m_id;
0024 }
0025 
0026 template <typename Service> QUuid MoveableItem<Service>::getUuid() const
0027 {
0028     READ_LOCK();
0029     if (auto ptr = m_parent.lock()) {
0030         return ptr->uuid();
0031     }
0032     return QUuid();
0033 }
0034 
0035 template <typename Service> int MoveableItem<Service>::getCurrentTrackId() const
0036 {
0037     READ_LOCK();
0038     return m_currentTrackId;
0039 }
0040 
0041 template <typename Service> int MoveableItem<Service>::getPosition() const
0042 {
0043     READ_LOCK();
0044     return m_position;
0045 }
0046 
0047 template <typename Service> std::pair<int, int> MoveableItem<Service>::getInOut() const
0048 {
0049     READ_LOCK();
0050     return {getIn(), getOut()};
0051 }
0052 
0053 template <typename Service> int MoveableItem<Service>::getIn() const
0054 {
0055     READ_LOCK();
0056     return service()->get_in();
0057 }
0058 
0059 template <typename Service> int MoveableItem<Service>::getOut() const
0060 {
0061     READ_LOCK();
0062     return service()->get_out();
0063 }
0064 
0065 template <typename Service> bool MoveableItem<Service>::isValid()
0066 {
0067     READ_LOCK();
0068     return service()->is_valid();
0069 }
0070 
0071 template <typename Service> void MoveableItem<Service>::setPosition(int pos)
0072 {
0073     QWriteLocker locker(&m_lock);
0074     m_position = pos;
0075 }
0076 
0077 template <typename Service> void MoveableItem<Service>::setCurrentTrackId(int tid, bool finalMove)
0078 {
0079     Q_UNUSED(finalMove);
0080     QWriteLocker locker(&m_lock);
0081     m_currentTrackId = tid;
0082 }
0083 
0084 template <typename Service> void MoveableItem<Service>::setInOut(int in, int out)
0085 {
0086     QWriteLocker locker(&m_lock);
0087     service()->set_in_and_out(in, out);
0088 }
0089 
0090 template <typename Service> bool MoveableItem<Service>::isGrabbed() const
0091 {
0092     READ_LOCK();
0093     return m_grabbed;
0094 }
0095