| 68 if(role == Qt::DisplayRole) { |
68 if(role == Qt::DisplayRole) { |
| 69 UiList *ls = (UiList*)var->value; |
69 UiList *ls = (UiList*)var->value; |
| 70 void *rowData = ls->get(ls, index.row()); |
70 void *rowData = ls->get(ls, index.row()); |
| 71 if(rowData && getvalue) { |
71 if(rowData && getvalue) { |
| 72 void *value = getvalue(rowData, 0); |
72 void *value = getvalue(rowData, 0); |
| 73 return QString::fromUtf8((char*)value); |
73 if(value) { |
| |
74 return QString::fromUtf8((char*)value); |
| |
75 } |
| 74 } |
76 } |
| 75 } |
77 } |
| 76 return QVariant(); |
78 return QVariant(); |
| 77 } |
79 } |
| 78 |
80 |
| 141 QVariant TableModel::data(const QModelIndex &index, int role) const { |
143 QVariant TableModel::data(const QModelIndex &index, int role) const { |
| 142 if(role == Qt::DisplayRole) { |
144 if(role == Qt::DisplayRole) { |
| 143 UiList *ls = (UiList*)var->value; |
145 UiList *ls = (UiList*)var->value; |
| 144 void *rowData = ls->get(ls, index.row()); |
146 void *rowData = ls->get(ls, index.row()); |
| 145 if(rowData && model->getvalue) { |
147 if(rowData && model->getvalue) { |
| 146 void *value = model->getvalue(rowData, index.column()); |
148 int col = index.column(); |
| 147 return QString::fromUtf8((char*)value); |
149 void *value = model->getvalue(rowData, col); |
| |
150 if(value) { |
| |
151 UiModelType type = model->types[col]; |
| |
152 switch(type) { |
| |
153 case UI_STRING: { |
| |
154 return QString::fromUtf8((char*)value); |
| |
155 } |
| |
156 case UI_STRING_FREE: { |
| |
157 QString s = QString::fromUtf8((char*)value); |
| |
158 free(value); |
| |
159 return s; |
| |
160 } |
| |
161 case UI_INTEGER: { |
| |
162 int *i = (int*)value; |
| |
163 return QString::number(*i); |
| |
164 } |
| |
165 case UI_ICON: { |
| |
166 break; |
| |
167 } |
| |
168 case UI_ICON_TEXT: { |
| |
169 break; |
| |
170 } |
| |
171 case UI_ICON_TEXT_FREE: { |
| |
172 break; |
| |
173 } |
| |
174 } |
| |
175 } |
| 148 } |
176 } |
| 149 } |
177 } |
| 150 return QVariant(); |
178 return QVariant(); |
| 151 } |
179 } |
| 152 |
180 |