MCPcopy Create free account
hub / github.com/QtExcel/QXlsx / data

Method data

HelloAndroid/XlsxTableModel.cpp:88–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88QVariant XlsxTableModel::data(const QModelIndex &index, int role) const
89{
90 // current column & row
91 int col = index.column();
92 int row = index.row();
93
94 // check boundaries
95 if (col < 0 || columnCount() <= col || row < 0 || rowCount() <= row) {
96 qDebug() << "[Warning]"
97 << " col=" << col << ", row=" << row;
98 return QVariant();
99 }
100
101 // Nominal case
102
103 QVariant ret;
104 int cmpRole;
105
106 for (int ic = 0; ic < m_the_data.size(); ic++) {
107 if (row == ic) {
108 QList<QVariant> vList = m_the_data.at(ic);
109 for (int jc = 0; jc < vList.size(); jc++) {
110 int plusOneRole = (int) (Qt::UserRole);
111 plusOneRole = plusOneRole + 1;
112 cmpRole = plusOneRole + jc;
113 if (role == cmpRole) {
114 QVariant var = vList.at(jc);
115 if (!var.isValid())
116 var.setValue(QString(""));
117 if (var.isNull())
118 var.setValue(QString(""));
119 ret = var;
120 }
121 }
122 }
123 }
124
125 qDebug() << "data: "
126 << " col=" << col << ", row=" << row << ", role=" << role << ", cmpRole=" << cmpRole
127 << ", value=" << ret.toString();
128
129 return ret;
130}
131
132QHash<int, QByteArray> XlsxTableModel::roleNames() const
133{

Callers

nothing calls this directly

Calls 8

columnCountFunction · 0.85
rowCountFunction · 0.85
columnMethod · 0.80
isNullMethod · 0.80
rowMethod · 0.45
isValidMethod · 0.45
setValueMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected