| 86 | } |
| 87 | |
| 88 | QVariant 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 | |
| 132 | QHash<int, QByteArray> XlsxTableModel::roleNames() const |
| 133 | { |