MCPcopy Create free account
hub / github.com/KDAB/GammaRay / sendSelection

Method sendSelection

common/networkselectionmodel.cpp:84–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void NetworkSelectionModel::sendSelection()
85{
86 if (!isConnected())
87 return;
88
89 clearPendingSelection();
90
91 if (!hasSelection()) {
92 if (model()->rowCount() > 0) {
93 const QItemSelectionModel::SelectionFlags selectionFlags = QItemSelectionModel::ClearAndSelect
94 | QItemSelectionModel::Rows
95 | QItemSelectionModel::Current;
96 const Qt::MatchFlags matchFlags = Qt::MatchExactly | Qt::MatchRecursive | Qt::MatchWrap;
97 QAbstractItemModel *sourceModel = findSourceModel(model());
98 QModelIndex index = model()->index(0, 0);
99
100 // Query the model to get its default selected index
101 if (sourceModel) {
102 QPair<int, QVariant> result;
103 QModelIndex defaultIndex;
104
105 QMetaObject::invokeMethod(sourceModel, "defaultSelectedItem", Qt::DirectConnection,
106 QReturnArgument<QPair<int, QVariant>>("QPair<int,QVariant>",
107 result));
108
109 if (result.second.userType() == qMetaTypeId<ModelUtils::MatchAcceptor>()) {
110 defaultIndex = ModelUtils::match(index, result.first,
111 result.second.value<ModelUtils::MatchAcceptor>(),
112 1, matchFlags)
113 .value(0);
114 } else {
115 defaultIndex = model()->match(index, result.first, result.second, 1,
116 matchFlags)
117 .value(0);
118 }
119
120 if (defaultIndex.isValid())
121 index = defaultIndex;
122 }
123
124 select(QItemSelection(index, index), selectionFlags);
125 }
126 } else {
127 Message msg(m_myAddress, Protocol::SelectionModelSelect);
128 writeSelection(&msg, selection());
129 msg << ClearAndSelect;
130 Endpoint::send(msg);
131 }
132}
133
134Protocol::ItemSelection GammaRay::NetworkSelectionModel::readSelection(const GammaRay::Message &msg)
135{

Callers

nothing calls this directly

Calls 8

findSourceModelFunction · 0.85
writeSelectionFunction · 0.85
QItemSelectionClass · 0.50
rowCountMethod · 0.45
indexMethod · 0.45
valueMethod · 0.45
matchMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected