137QVariant PropertyNameListModel::headerData(
int section, Qt::Orientation orientation,
int role)
const {
151 InsDel(OP op,
int first,
int count,
int before) : op(op), first(first), count(count), before(before) {}
159 std::vector<InsDel> result;
160 typedef std::vector<PROP_INFO>::iterator IT;
163 for (oldIt = propList_.begin(), newIt = propList.begin(); oldIt < propList_.end() && newIt < propList.end(); ++oldIt, ++newIt) {
164 if (*oldIt == *newIt)
continue;
165 const IT nextNew = std::find(newIt+1, propList.end(), *oldIt);
166 if (nextNew != propList.end()) {
167 const int count = std::distance(newIt, nextNew);
168 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), count, std::distance(propList_.begin(), oldIt) + correction));
173 const IT nextOld = std::find(oldIt+1, propList_.end(), *newIt);
174 if (nextOld != propList_.end()) {
175 const int count = std::distance(oldIt, nextOld);
176 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, count, 0));
183 if (oldIt < propList_.end() && newIt < propList.end()) {
187 if (oldIt < propList_.end())
188 result.push_back(InsDel(InsDel::DEL, std::distance(propList_.begin(), oldIt) + correction, std::distance(oldIt, propList_.end()), 0));
189 if (newIt < propList.end())
190 result.push_back(InsDel(InsDel::INS, std::distance(propList.begin(), newIt), std::distance(newIt, propList.end()), propList_.size() + correction));
192 for (std::vector<InsDel>::iterator it = result.begin(); it != result.end(); ++it) {
193 if (it->op == InsDel::INS) {
194 beginInsertRows(QModelIndex(), it->before, it->before + it->count - 1);
195 propList_.insert(propList_.begin() + it->before, propList.begin() + it->first, propList.begin() + it->first + it->count);
198 beginRemoveRows(QModelIndex(), it->first, it->first + it->count - 1);
199 propList_.erase(propList_.begin() + it->first, propList_.begin() + it->first + it->count);
204 if (propList_ != propList) {
205 std::cerr <<
"Apparently, the function PropertyNameListModel::tryInsertionsDeletions() has an implementation error." << std::endl;
206 throw std::logic_error(
"Apparently, the function PropertyNameListModel::tryInsertionsDeletions() has an implementation error.");