[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdenlive/refactoring_timeline] src/timeline2/model: [Timeline2] Document ItemModel organization
From:       Nicolas Carion <null () kde ! org>
Date:       2017-02-02 12:27:03
Message-ID: E1cZGTf-00061B-9G () code ! kde ! org
[Download RAW message or body]

Git commit e103e0bef6890bfca4fce13ad9b83b00a05fde6f by Nicolas Carion.
Committed on 02/02/2017 at 00:05.
Pushed by alcinos into branch 'refactoring_timeline'.

[Timeline2] Document ItemModel organization

M  +1    -1    src/timeline2/model/timelinemodel.cpp
M  +12   -1    src/timeline2/model/timelinemodel.hpp

https://commits.kde.org/kdenlive/e103e0bef6890bfca4fce13ad9b83b00a05fde6f

diff --git a/src/timeline2/model/timelinemodel.cpp \
b/src/timeline2/model/timelinemodel.cpp index 1fa88022e..04b11d982 100644
--- a/src/timeline2/model/timelinemodel.cpp
+++ b/src/timeline2/model/timelinemodel.cpp
@@ -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) {
diff --git a/src/timeline2/model/timelinemodel.hpp \
b/src/timeline2/model/timelinemodel.hpp index 4fc3e7566..46d4a1a3e 100644
--- a/src/timeline2/model/timelinemodel.hpp
+++ b/src/timeline2/model/timelinemodel.hpp
@@ -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
 {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic