MCPcopy Create free account
hub / github.com/YACReader/yacreader / index

Method index

YACReaderLibrary/db/reading_list_model.cpp:123–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123QModelIndex ReadingListModel::index(int row, int column, const QModelIndex &parent) const
124{
125 if (!hasIndex(row, column, parent))
126 return QModelIndex();
127
128 if (!parent.isValid()) {
129 int separatorsCount = 2; // labels.isEmpty()?1:2;
130
131 if (rowIsSpecialList(row, parent))
132 return createIndex(row, column, specialLists.at(row));
133
134 if (row == specialLists.count())
135 return createIndex(row, column, separator1);
136
137 if (rowIsLabel(row, parent))
138 return createIndex(row, column, labels.at(row - specialLists.count() - 1));
139
140 if (separatorsCount == 2)
141 if (row == specialLists.count() + labels.count() + 1)
142 return createIndex(row, column, separator2);
143
144 if (rowIsReadingList(row, parent))
145 return createIndex(row, column, rootItem->child(row - (specialLists.count() + labels.count() + separatorsCount)));
146
147 } else // sublist
148 {
149 ReadingListItem *parentItem;
150
151 if (!parent.isValid())
152 parentItem = rootItem; // this should be impossible
153 else
154 parentItem = static_cast<ReadingListItem *>(parent.internalPointer());
155
156 ReadingListItem *childItem = parentItem->child(row);
157 return createIndex(row, column, childItem);
158 }
159 /*FolderItem *childItem = parentItem->child(row);
160 if (childItem)
161 return createIndex(row, column, childItem);
162 else*/
163 return QModelIndex();
164}
165
166QModelIndex ReadingListModel::parent(const QModelIndex &index) const
167{

Callers

nothing calls this directly

Calls 3

QModelIndexClass · 0.50
isValidMethod · 0.45
childMethod · 0.45

Tested by

no test coverage detected