MCPcopy Create free account
hub / github.com/ElementsProject/elements / data

Method data

src/qt/addresstablemodel.cpp:194–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194QVariant AddressTableModel::data(const QModelIndex &index, int role) const
195{
196 if(!index.isValid())
197 return QVariant();
198
199 AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
200
201 const auto column = static_cast<ColumnIndex>(index.column());
202 if (role == Qt::DisplayRole || role == Qt::EditRole) {
203 switch (column) {
204 case Label:
205 if (rec->label.isEmpty() && role == Qt::DisplayRole) {
206 return tr("(no label)");
207 } else {
208 return rec->label;
209 }
210 case Address:
211 return rec->address;
212 } // no default case, so the compiler can warn about missing cases
213 assert(false);
214 } else if (role == Qt::FontRole) {
215 switch (column) {
216 case Label:
217 return QFont();
218 case Address:
219 return GUIUtil::fixedPitchFont();
220 } // no default case, so the compiler can warn about missing cases
221 assert(false);
222 } else if (role == TypeRole) {
223 switch(rec->type)
224 {
225 case AddressTableEntry::Sending:
226 return Send;
227 case AddressTableEntry::Receiving:
228 return Receive;
229 case AddressTableEntry::Hidden:
230 return {};
231 } // no default case, so the compiler can warn about missing cases
232 assert(false);
233 }
234 return QVariant();
235}
236
237bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
238{

Callers

nothing calls this directly

Calls 3

QFontClass · 0.85
fixedPitchFontFunction · 0.85
isValidMethod · 0.45

Tested by

no test coverage detected