Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit e103e0be authored by Nicolas Carion's avatar Nicolas Carion

[Timeline2] Document ItemModel organization

parent 6cb4ecdf
......@@ -76,7 +76,7 @@ QModelIndex TimelineModel::index(int row, int column, const QModelIndex &parent)
// LOG_DEBUG() << __FUNCTION__ << row << column << parent;
QModelIndex result;
if (parent.isValid()) {
int trackId = static_cast<int>(parent.internalId());
int trackId = int(parent.internalId());
Q_ASSERT(isTrack(trackId));
int clipId = getTrackById_const(trackId)->getClipByRow(row);
if (clipId != -1) {
......
......@@ -34,7 +34,18 @@ class ClipModel;
class GroupsModel;
/* @brief This class represents a Timeline object, as viewed by the backend.
In general, the Gui associated with it will send modification queries (such as resize or move), and this class authorize them or not depending on the validity of the modifications
In general, the Gui associated with it will send modification queries (such as resize or move), and this class authorize them or not depending on the validity of the modifications.
This class also serves to keep track of all objects. It holds pointers to all tracks and clips, and gives them unique IDs on creation. These Ids are used in any interactions with the objects and have nothing to do with Melt IDs.
It derives from AbstractItemModel to provide the model to the QML interface. An itemModel is organized with row and columns that contain the data. It can be hierarchical, meaning that a given index (row,column) can contain another level of rows and column.
Our organization is as follows: at the top level, each row contains a track. These rows are in the same order as in the actual timeline.
Then each of this row contains itself sub-rows that correspond to the clips. Here the order of these sub-rows is unrelated to the chronological order of the clips, but correspond to an insertion order in the track. This is because the order actually doesn't matter since the clips are rendered based on their positions rather than their row order. The insertion order in the track has been choosed because it is consistant with a valid ordering of the clips.
The columns are never used, so the data is always in column 0
An ModelIndex in the ItemModel consists of a row number, a column number, and a parent index. In our case, tracks have always an empty parent, and the clip have a track index as parent.
A ModelIndex can also store one additional integer, and we exploit this feature to store the unique ID of the object it corresponds to.
*/
class TimelineModel : public QAbstractItemModel
{
......
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