MCPcopy Create free account
hub / github.com/XRay3D/GERBER_X3 / updateFileModel

Method updateFileModel

file_plugins/dxf/dxf_plugin.cpp:226–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void Plugin::updateFileModel(FileInterface* file)
227{
228 const auto fm = App::fileModel();
229 const QModelIndex& fileIndex(file->node()->index());
230 const QModelIndex index = fm->createIndex_(0, 0, fileIndex.internalId());
231 // clean before insert new layers
232 if (int count = fm->getItem(fileIndex)->childCount(); count) {
233 fm->beginRemoveRows_(index, 0, count - 1);
234 auto item = fm->getItem(index);
235 do {
236 item->remove(--count);
237 } while (count);
238 fm->endRemoveRows_();
239 }
240 Dxf::Layers layers;
241 for (auto& [name, layer] : reinterpret_cast<File*>(file)->layers()) {
242 // qDebug() << name << layer;
243 if (!layer->isEmpty())
244 layers[name] = layer;
245 }
246 fm->beginInsertRows_(index, 0, int(layers.size() - 1));
247 for (auto& [name, layer] : layers) {
248 // qDebug() << name << layer;
249 fm->getItem(index)->addChild(new Dxf::NodeLayer(name, layer));
250 }
251 fm->endInsertRows_();
252}
253
254class DrillPrGI final : public AbstractDrillPrGI {
255 const GraphicObject& go;

Callers 2

addFileMethod · 0.45
reloadMethod · 0.45

Calls 11

createIndex_Method · 0.80
beginRemoveRows_Method · 0.80
endRemoveRows_Method · 0.80
isEmptyMethod · 0.80
beginInsertRows_Method · 0.80
sizeMethod · 0.80
endInsertRows_Method · 0.80
childCountMethod · 0.45
getItemMethod · 0.45
removeMethod · 0.45
addChildMethod · 0.45

Tested by

no test coverage detected