MCPcopy Create free account
hub / github.com/KDE/kdevelop / partialExpandRect

Method partialExpandRect

plugins/quickopen/expandingtree/expandingwidgetmodel.cpp:272–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272QRect ExpandingWidgetModel::partialExpandRect(const QModelIndex& idx_) const
273{
274 Q_ASSERT(idx_.model() == this);
275
276 QModelIndex idx(firstColumn(idx_));
277
278 if (!idx.isValid()) {
279 return QRect();
280 }
281
282 ExpansionType expansion = ExpandDownwards;
283
284 if (m_partiallyExpanded.find(idx) != m_partiallyExpanded.constEnd()) {
285 expansion = m_partiallyExpanded[idx];
286 }
287
288 //Get the whole rectangle of the row:
289 const QModelIndex viewIndex = mapFromSource(idx);
290 QModelIndex rightMostIndex = viewIndex;
291 QModelIndex tempIndex = viewIndex;
292 while ((tempIndex = rightMostIndex.sibling(rightMostIndex.row(), rightMostIndex.column() + 1)).isValid())
293 rightMostIndex = tempIndex;
294
295 QRect rect = treeView()->visualRect(viewIndex);
296 QRect rightMostRect = treeView()->visualRect(rightMostIndex);
297
298 rect.setLeft(rect.left() + 20);
299 rect.setRight(rightMostRect.right() - 5);
300
301 //These offsets must match exactly those used in ExpandingDelegate::sizeHint()
302 int top = rect.top() + 5;
303 int bottom = rightMostRect.bottom() - 5;
304
305 if (expansion == ExpandDownwards) {
306 top += basicRowHeight(viewIndex);
307 } else {
308 bottom -= basicRowHeight(viewIndex);
309 }
310
311 rect.setTop(top);
312 rect.setBottom(bottom);
313
314 return rect;
315}
316
317bool ExpandingWidgetModel::isExpandable(const QModelIndex& idx_) const
318{

Callers 1

drawRowMethod · 0.80

Calls 10

firstColumnFunction · 0.85
QRectClass · 0.85
constEndMethod · 0.80
siblingMethod · 0.80
topMethod · 0.80
modelMethod · 0.45
isValidMethod · 0.45
findMethod · 0.45
rowMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected