Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / XGUI / XGUI_ObjectsBrowser.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "XGUI_ObjectsBrowser.h"
22 #include "XGUI_Tools.h"
23 #include "XGUI_DataModel.h"
24
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Session.h>
27 #include <ModelAPI_Document.h>
28 #include <ModelAPI_ResultCompSolid.h>
29 #include <ModelAPI_Tools.h>
30
31 #include <ModuleBase_Tools.h>
32
33 #include <XGUI_Workshop.h>
34
35 #include <QLayout>
36 #include <QLineEdit>
37 #include <QPixmap>
38 #include <QEvent>
39 #include <QMouseEvent>
40 #include <QAction>
41 #include <QStyledItemDelegate>
42 #include <QMessageBox>
43
44 #ifdef DEBUG_INDXES
45 #include <QToolTip>
46 #endif
47
48 /// Width of second column (minimum acceptable = 27)
49 #define FIRST_COL_WIDTH 20
50 #define SECOND_COL_WIDTH 30
51
52
53 /**
54 * \ingroup GUI
55 * Tree item delegate for definition of data in column items editor
56 */
57 class XGUI_TreeViewItemDelegate: public QStyledItemDelegate
58 {
59 public:
60   /// Constructor
61   /// \param theParent a parent of the delegate
62   XGUI_TreeViewItemDelegate(XGUI_DataTree* theParent):QStyledItemDelegate(theParent),
63     myTreedView(theParent) {}
64
65   /// Set data for item editor (name of the item)
66   /// \param editor a widget of editor
67   /// \param index the tree item index
68   virtual void  setEditorData ( QWidget* editor, const QModelIndex& index ) const
69   {
70     QLineEdit* aEditor = dynamic_cast<QLineEdit*>(editor);
71     if (aEditor) {
72       XGUI_DataModel* aModel = myTreedView->dataModel();
73       ObjectPtr aObj = aModel->object(index);
74       if (aObj.get() != NULL) {
75         aEditor->setText(aObj->data()->name().c_str());
76         return;
77       }
78     }
79     QStyledItemDelegate::setEditorData(editor, index);
80   }
81
82 private:
83   XGUI_DataTree* myTreedView;
84 };
85
86
87 XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
88     : QTreeView(theParent)
89 {
90   setHeaderHidden(true);
91   setTreePosition(1);
92   setEditTriggers(QAbstractItemView::NoEditTriggers);
93   setSelectionBehavior(QAbstractItemView::SelectRows);
94   setSelectionMode(QAbstractItemView::ExtendedSelection);
95
96   setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this));
97
98   connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
99     SLOT(onDoubleClick(const QModelIndex&)));
100 }
101
102 XGUI_DataTree::~XGUI_DataTree()
103 {
104 }
105
106 XGUI_DataModel* XGUI_DataTree::dataModel() const
107 {
108   return static_cast<XGUI_DataModel*>(model());
109 }
110
111 void XGUI_DataTree::contextMenuEvent(QContextMenuEvent* theEvent)
112 {
113   emit contextMenuRequested(theEvent);
114 }
115
116 void XGUI_DataTree::commitData(QWidget* theEditor)
117 {
118   static int aEntrance = 0;
119   if (aEntrance == 0) {
120     // We have to check number of enter and exit of this function because it can be called
121     // recursively by Qt in order to avoid double modifying of a data
122     aEntrance = 1;
123     QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
124     if (aEditor) {
125       QString aName = aEditor->text();
126       QModelIndexList aIndexList = selectionModel()->selectedIndexes();
127       XGUI_DataModel* aModel = dataModel();
128       ObjectPtr aObj = aModel->object(aIndexList.first());
129
130       if (XGUI_Tools::canRename(aObj, aName)) {
131         SessionPtr aMgr = ModelAPI_Session::get();
132         aMgr->startOperation("Rename");
133         aObj->data()->setName(qPrintable(aName));
134         aMgr->finishOperation();
135       }
136     }
137   }
138   aEntrance = 0;
139 }
140
141 void XGUI_DataTree::clear()
142 {
143   dataModel()->clear();
144   reset();
145 }
146
147 void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
148 {
149   QTreeView::resizeEvent(theEvent);
150   QSize aSize = theEvent->size();
151   if (aSize.isValid()) {
152     setColumnWidth(0, FIRST_COL_WIDTH);
153     setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 10);
154     setColumnWidth(2, SECOND_COL_WIDTH);
155   }
156 }
157
158 #ifdef DEBUG_INDXES
159 void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
160 {
161   QTreeView::mousePressEvent(theEvent);
162   if (theEvent->button() != Qt::MidButton)
163     return;
164   QModelIndex aInd = indexAt(theEvent->pos());
165   QString aTxt =
166     QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer());
167
168   QModelIndex aPar = aInd.parent();
169   QString aTxt1 =
170     QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer());
171   QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1);
172 }
173 #endif
174
175 void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent)
176 {
177   QTreeView::mouseReleaseEvent(theEvent);
178 #ifdef DEBUG_INDXES
179   if (theEvent->button() != Qt::MidButton)
180     return;
181   QToolTip::hideText();
182 #endif
183   if (theEvent->button() == Qt::LeftButton) {
184     QModelIndex aInd = indexAt(theEvent->pos());
185     if (aInd.column() == 0)
186       processEyeClick(aInd);
187   }
188 }
189
190 void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
191 {
192   SessionPtr aMgr = ModelAPI_Session::get();
193   // When operation is opened then we can not change history
194   if (aMgr->isOperation())
195     return;
196   XGUI_DataModel* aModel = dataModel();
197   if (aModel->flags(theIndex) == 0)
198     return;
199   ObjectPtr aObj = aModel->object(theIndex);
200
201   DocumentPtr aDoc = aMgr->activeDocument();
202
203   std::string aOpName = tr("History change").toStdString();
204   if (aObj.get()) {
205     if (aObj->document() != aDoc)
206       return;
207     aMgr->startOperation(aOpName);
208     aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObj), true);
209     aMgr->finishOperation();
210   } else {
211     // Ignore clicks on folders outside current document
212     if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
213       // Clicked folder under root but active document is another
214       return;
215     if ((theIndex.internalId() != 0) && (aDoc.get() != theIndex.internalPointer()))
216       // Cliced not on active document folder
217       return;
218
219     aMgr->startOperation(aOpName);
220     aDoc->setCurrentFeature(FeaturePtr(), true);
221     aMgr->finishOperation();
222   }
223   QModelIndex aNewIndex = aModel->lastHistoryIndex();
224   QModelIndex aParent = theIndex.parent();
225   int aSize = aModel->rowCount(aParent);
226   for (int i = 0; i < aSize; i++) {
227     update(aModel->index(i, 0, aParent));
228     update(aModel->index(i, 1, aParent));
229     update(aModel->index(i, 2, aParent));
230   }
231 }
232
233 void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
234 {
235   XGUI_DataModel* aModel = dataModel();
236   ObjectPtr aObj = aModel->object(theIndex);
237   if (aObj.get()) {
238     ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
239     XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
240     if (aResObj.get()) {
241       std::set<ObjectPtr> anObjects;
242       anObjects.insert(aResObj);
243
244       bool hasHiddenState = aModel->hasHiddenState(theIndex);
245       if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
246         return;
247       if (hasHiddenState) // #issue 2335(hide all faces then show solid problem)
248         aResObj->setDisplayed(true);
249       else
250         aResObj->setDisplayed(!aResObj->isDisplayed());
251       Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
252       update(theIndex);
253     }
254     // Update list of selected objects because this event happens after
255     // selection event in object browser
256     if (aObjBrowser) {
257       aObjBrowser->onSelectionChanged();
258     }
259   }
260 }
261
262 void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
263 {
264   switch (theIndex.column()) {
265   case 2:
266     processHistoryChange(theIndex);
267     break;
268   }
269 }
270
271
272 //********************************************************************
273 //********************************************************************
274 //********************************************************************
275 XGUI_ActiveDocLbl::XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent )
276   : QLabel(theText, theParent),
277   myPreSelectionStyle(""),
278   myNeutralStyle(""),
279   mySelectionStyle(""),
280   myIsSelected(false)
281 {
282 }
283
284 void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
285 {
286   myTreeView = theView;
287   setFont(myTreeView->font());
288
289   QPalette aPalet = myTreeView->palette();
290   QColor aHighlight = aPalet.highlight().color();
291   QColor aHighlightText = aPalet.highlightedText().color();
292
293   myPreSelectionStyle = "QLabel {background-color: ";
294   myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
295   //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
296   //  aHighlight.lighter(170).name() + ");";
297   //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
298
299   QString aName = aPalet.color(QPalette::Base).name();
300   myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
301
302
303 #if (!defined HAVE_SALOME) && (defined WIN32)
304   mySelectionStyle = "QLabel {background-color: ";
305   mySelectionStyle += "rgb(205, 232, 255); ";
306   //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
307   //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
308   //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
309   mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
310 #else
311   mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
312   mySelectionStyle += "; color : " + aHighlightText.name() + "}";
313 #endif
314
315   myTreeView->viewport()->installEventFilter(this);
316 }
317
318
319 #if (!defined HAVE_SALOME) && (defined WIN32)
320 bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
321 {
322   switch (theEvent->type()) {
323     case QEvent::Enter:
324       if (!myIsSelected)
325         setStyleSheet(myPreSelectionStyle);
326       break;
327     case QEvent::Leave:
328       if (!myIsSelected)
329         setStyleSheet(myNeutralStyle);
330       break;
331   }
332   return QLabel::event(theEvent);
333 }
334 #endif
335
336 bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
337 {
338   if (theObj == myTreeView->viewport()) {
339     if (theEvent->type() == QEvent::MouseButtonRelease)
340       unselect();
341   }
342   return QLabel::eventFilter(theObj, theEvent);
343 }
344
345 static bool MYClearing = false;
346 void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
347 {
348   MYClearing = true;
349   myIsSelected = true;
350   setStyleSheet(mySelectionStyle);
351   // We can not block signals because on
352   // clear selection the View state will not be updated
353   myTreeView->clearSelection();
354   QLabel::mouseReleaseEvent(e);
355   MYClearing = false;
356 }
357
358 void XGUI_ActiveDocLbl::unselect()
359 {
360   if (!MYClearing) {
361     myIsSelected = false;
362     setStyleSheet(myNeutralStyle);
363   }
364 }
365
366
367 //********************************************************************
368 //********************************************************************
369 //********************************************************************
370 XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
371     : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
372 {
373   QVBoxLayout* aLayout = new QVBoxLayout(this);
374   ModuleBase_Tools::zeroMargins(aLayout);
375   aLayout->setSpacing(0);
376
377   QWidget* aLabelWgt = new QWidget(this);
378   aLabelWgt->setAutoFillBackground(true);
379
380   aLayout->addWidget(aLabelWgt);
381   QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
382   ModuleBase_Tools::zeroMargins(aLabelLay);
383   aLabelLay->setSpacing(0);
384
385   QLabel* aLbl = new QLabel(aLabelWgt);
386   aLbl->setPixmap(QPixmap(":pictures/assembly.png"));
387   aLbl->setMargin(2);
388   // Do not paint background of the label (in order to show icon)
389   aLbl->setAutoFillBackground(false);
390
391   aLabelLay->addWidget(aLbl);
392
393   SessionPtr aMgr = ModelAPI_Session::get();
394   DocumentPtr aDoc = aMgr->moduleDocument();
395
396   myActiveDocLbl = new XGUI_ActiveDocLbl(tr("Part set"), aLabelWgt);
397 //  myActiveDocLbl->setReadOnly(true);
398 //  myActiveDocLbl->setFrame(false);
399   myActiveDocLbl->setContextMenuPolicy(Qt::CustomContextMenu);
400
401   aLabelLay->addWidget(myActiveDocLbl);
402   aLabelLay->setStretch(1, 1);
403
404   myTreeView = new XGUI_DataTree(this);
405   myTreeView->setFrameShape(QFrame::NoFrame);
406   aLayout->addWidget(myTreeView);
407
408   QPalette aTreePalet = myTreeView->palette();
409   QColor aTreeBack = aTreePalet.color(QPalette::Base);
410
411   QPalette aPalet;
412   aPalet.setColor(QPalette::Base, aTreeBack);
413   aPalet.setColor(QPalette::Window, aTreeBack);
414   aLabelWgt->setPalette(aPalet);
415
416   myDocModel = new XGUI_DataModel(this);
417   connect(myDocModel, SIGNAL(modelAboutToBeReset()), SLOT(onBeforeReset()));
418   connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
419
420   connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
421           SLOT(onContextMenuRequested(QContextMenuEvent*)));
422 }
423
424 //***************************************************
425 XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
426 {
427 }
428
429 void XGUI_ObjectsBrowser::setXMLReader(Config_DataModelReader* theReader)
430 {
431   myDocModel->setXMLReader(theReader);
432   myTreeView->setModel(myDocModel);
433
434   // It has to be done after setting of model
435   myActiveDocLbl->setTreeView(myTreeView);
436
437   QItemSelectionModel* aSelMod = myTreeView->selectionModel();
438   connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
439           this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
440 }
441
442 //***************************************************
443 void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
444 {
445   QModelIndexList aIndexes;
446   QObjectPtrList aSelectedData = selectedObjects(&aIndexes);
447   bool toEnable = false;
448
449   if (aSelectedData.size() == 1) {
450     QModelIndex aSelected = myTreeView->indexAt(theEvent->pos());
451     if (!aIndexes.contains(aSelected))
452       return; // menu is called on non selected item
453
454     Qt::ItemFlags aFlags = dataModel()->flags(aIndexes.first());
455     toEnable = ((aFlags & Qt::ItemIsEditable) != 0);
456   }
457   foreach(QAction* aCmd, actions()) {
458     aCmd->setEnabled(toEnable);
459   }
460   emit contextMenuRequested(theEvent);
461 }
462
463 //***************************************************
464 void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
465 {
466   myTreeView->selectionModel()->clearSelection();
467   //Empty feature pointer means that selected root document
468   foreach(QAction* aCmd, actions()) {
469     aCmd->setEnabled(true);
470   }
471   QContextMenuEvent aEvent(QContextMenuEvent::Mouse, thePnt, myActiveDocLbl->mapToGlobal(thePnt));
472   emit contextMenuRequested(&aEvent);
473 }
474
475 //***************************************************
476 void XGUI_ObjectsBrowser::onEditItem()
477 {
478   QObjectPtrList aSelectedData = selectedObjects();
479   if (aSelectedData.size() > 0) {
480     ObjectPtr anObject = aSelectedData.first();
481     if (anObject.get()) {  // Selection happens in TreeView
482       // check whether the object can be renamed. There should not be parts which are not loaded
483       std::set<FeaturePtr> aFeatures;
484       aFeatures.insert(ModelAPI_Feature::feature(anObject));
485       if (!XGUI_Tools::canRemoveOrRename((QWidget*)parent(), aFeatures))
486         return;
487
488       // Find index which corresponds the feature
489       QModelIndex aIndex;
490       foreach(QModelIndex aIdx, selectedIndexes()) {
491         ObjectPtr aFea = dataModel()->object(aIdx);
492         if (dataModel()->object(aIdx)->isSame(anObject)) {
493           aIndex = aIdx;
494           break;
495         }
496       }
497       if (aIndex.isValid()) {
498         myTreeView->setCurrentIndex(aIndex);
499         myTreeView->edit(aIndex);
500       }
501       return;
502     }
503   }
504 }
505
506 //***************************************************
507 QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
508 {
509   QModelIndexList aIndexes;
510   QModelIndex aIndex;
511   for (int i = 0; i < myDocModel->rowCount(theParent); i++) {
512     aIndex = myDocModel->index(i, 0, theParent);
513     if (myDocModel->hasChildren(aIndex)) {
514       if (myTreeView->isExpanded(aIndex)) {
515         aIndexes.append(aIndex);
516         QModelIndexList aSubIndexes = expandedItems(aIndex);
517         if (!aSubIndexes.isEmpty())
518           aIndexes.append(aSubIndexes);
519       }
520     }
521   }
522   return aIndexes;
523 }
524
525 //***************************************************
526 void XGUI_ObjectsBrowser::rebuildDataTree()
527 {
528   myDocModel->rebuildDataTree();
529   update();
530 }
531
532 //***************************************************
533 void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
534 {
535   QList<QModelIndex> theIndexes;
536   QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
537   aSelectModel->clear();
538
539   foreach(ObjectPtr aFeature, theObjects)
540   {
541     QModelIndex aIndex = myDocModel->objectIndex(aFeature);
542     if (aIndex.isValid()) {
543       aSelectModel->select(aIndex, QItemSelectionModel::Select);
544     }
545   }
546 }
547
548 //***************************************************
549 void XGUI_ObjectsBrowser::clearContent()
550 {
551   myTreeView->clear();
552 }
553
554 //***************************************************
555 void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
556                                        const QItemSelection& theDeselected)
557 {
558   onSelectionChanged();
559 }
560
561 //***************************************************
562 void XGUI_ObjectsBrowser::onSelectionChanged()
563 {
564   emit selectionChanged();
565 }
566
567 //***************************************************
568 QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const
569 {
570   QObjectPtrList aList;
571   QModelIndexList aIndexes = selectedIndexes();
572   XGUI_DataModel* aModel = dataModel();
573   QModelIndexList::const_iterator aIt;
574   for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
575     if ((*aIt).column() == 1) {
576       ObjectPtr aObject = aModel->object(*aIt);
577       if (aObject) {
578         aList.append(aObject);
579         if (theIndexes)
580           theIndexes->append(*aIt);
581       }
582     }
583   }
584   return aList;
585 }
586
587 void XGUI_ObjectsBrowser::onBeforeReset()
588 {
589   myExpandedItems = expandedItems();
590 }
591
592 void XGUI_ObjectsBrowser::onAfterModelReset()
593 {
594   foreach(QModelIndex aIndex, myExpandedItems) {
595     myTreeView->setExpanded(aIndex, true);
596   }
597 }
598
599 std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
600 {
601   std::list<bool> aStates;
602   XGUI_DataModel* aModel = dataModel();
603   QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
604   int aNbChild = aModel->rowCount(aRootIdx);
605   for (int i = 0; i < aNbChild; i++) {
606     QModelIndex aIdx = aModel->index(i, 1, aRootIdx);
607     aStates.push_back(myTreeView->isExpanded(aIdx));
608   }
609   return aStates;
610 }
611
612 void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates)
613 {
614   if (theStates.size() == 0)
615     return;
616   XGUI_DataModel* aModel = dataModel();
617   QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
618   int aNbChild = aModel->rowCount(aRootIdx);
619
620   std::list<bool>::const_iterator aIt;
621   int i = 0;
622   for (aIt = theStates.cbegin(); aIt != theStates.cend(); aIt++, i++) {
623     if (i >= aNbChild )
624       break;
625     QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
626     myTreeView->setExpanded(aIdx, (*aIt));
627   }
628 }
629
630 void XGUI_ObjectsBrowser::updateAllIndexes(int theColumn, const QModelIndex& theParent)
631 {
632   int aNb = myDocModel->rowCount(theParent);
633   for (int i = 0; i < aNb; i++) {
634     QModelIndex aIdx = myDocModel->index(i, theColumn, theParent);
635     if (aIdx.isValid()) {
636       myTreeView->update(aIdx);
637       updateAllIndexes(theColumn, aIdx);
638     }
639   }
640 }