Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_SubShapeSelectorWdg.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
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.
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 email : webmaster.salome@opencascade.com
18 //
19
20 // File   : StdMeshersGUI_SubShapeSelectorWdg.cxx
21 // Author : Open CASCADE S.A.S. (dmv)
22 // SMESH includes
23 //
24 #include "StdMeshersGUI_SubShapeSelectorWdg.h"
25
26 // SMESH Includes
27 #include "SMESH_Type.h"
28 #include "SMESHGUI_MeshUtils.h"
29 #include "SMESH_Actor.h"
30 #include "SMESH_PreviewActorsCollection.h"
31 #include "SMESH_ActorUtils.h"
32 #include "SMESHGUI_GroupUtils.h"
33 #include "SMESH_Gen_i.hxx"
34 #include "SMESHGUI_GEOMGenUtils.h"
35 #include "SMESH_LogicalFilter.hxx"
36
37 // SVTK Includes
38 #include <SVTK_ViewWindow.h>
39 #include <SVTK_ViewModel.h>
40 #include <SVTK_ViewWindow.h>
41 #include <SVTK_Selector.h>
42
43 // SALOME GUI includes
44 #include <SALOME_ListIO.hxx>
45 #include <LightApp_SelectionMgr.h>
46 #include <SALOME_ListIteratorOfListIO.hxx>
47
48 // SUIT Includes
49 #include <SUIT_ResourceMgr.h>
50
51 // GEOM Includes
52 #include <GEOMBase.h>
53 #include <GEOM_TypeFilter.h>
54 #include <GEOM_CompoundFilter.h>
55
56 // Qt includes
57 #include <QPushButton>
58 #include <QGridLayout>
59 #include <QListWidget>
60 #include <QCheckBox>
61 #include <QLineEdit>
62
63 // OCCT includes
64 #include <TColStd_MapOfInteger.hxx>
65 #include <TColStd_IndexedMapOfInteger.hxx>
66 #include <TopoDS_Shape.hxx>
67 #include <TopExp.hxx>
68 #include <TopExp_Explorer.hxx>
69 #include <StdSelect_TypeOfEdge.hxx>
70
71 // SALOME KERNEL includes
72 #include <SALOMEDS_SObject.hxx>
73
74
75 #define SPACING 6
76 #define MARGIN 0
77
78 //================================================================================
79 /*!
80  *  Constructor
81  */
82 //================================================================================
83
84 StdMeshersGUI_SubShapeSelectorWdg
85 ::StdMeshersGUI_SubShapeSelectorWdg( QWidget * parent, TopAbs_ShapeEnum aSubShType ): 
86   QWidget( parent ),
87   myPreviewActor( 0 ),
88   myMaxSize( -1 )
89 {
90   QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
91
92   QGridLayout* edgesLayout = new QGridLayout( this );
93   edgesLayout->setMargin( MARGIN );
94   edgesLayout->setSpacing( SPACING );
95   
96   myListWidget   = new QListWidget( this );
97   myAddButton    = new QPushButton( tr( "SMESH_BUT_ADD" ),    this );
98   myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this );      
99   myInfoLabel    = new QLabel( this );
100   myPrevButton   = new QPushButton( "<<", this );
101   myNextButton   = new QPushButton( ">>", this );
102   myListWidget->setSelectionMode( QListWidget::ExtendedSelection );
103
104   edgesLayout->addWidget(myListWidget,   0, 0, 3, 3);
105   edgesLayout->addWidget(myAddButton,    0, 3);
106   edgesLayout->addWidget(myRemoveButton, 1, 3);
107   edgesLayout->addWidget(myInfoLabel,    3, 0, 1, 3);
108   edgesLayout->addWidget(myPrevButton,   4, 0);
109   edgesLayout->addWidget(myNextButton,   4, 2);
110
111   edgesLayout->setRowStretch(2, 5);
112   edgesLayout->setColumnStretch(1, 5);
113
114   myListWidget->setMinimumWidth(300);
115   myInfoLabel->setMinimumWidth(300);
116   myInfoLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
117   myInfoLabel->setAlignment(Qt::AlignCenter);
118
119   mySubShType = aSubShType;
120
121   init();
122 }
123
124 //================================================================================
125 /*!
126  *  Destructor
127  */
128 //================================================================================
129
130 StdMeshersGUI_SubShapeSelectorWdg::~StdMeshersGUI_SubShapeSelectorWdg()
131 {
132   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
133     if ( myPreviewActor ) {
134       myPreviewActor->RemoveFromRender( myRenderer );
135       aViewWindow->Repaint();
136
137       delete myPreviewActor;
138       myPreviewActor = 0;
139     }
140   }
141   myEntry = "";
142   myParamValue = "";
143   myMainShape.Nullify();
144
145   if ( mySelectionMgr && myFilter )
146     mySelectionMgr->removeFilter( myFilter );
147   delete myFilter; myFilter=0;
148
149   SUIT_SelectionFilter* filter;
150   foreach( filter, myGeomFilters )
151     delete filter;
152 }
153
154 //================================================================================
155 /*!
156  *  Create a layout, initialize fields
157  */
158 //================================================================================
159
160 void StdMeshersGUI_SubShapeSelectorWdg::init()
161 {
162   myParamValue = "";
163   myIsNotCorrected = true; // to dont call the GetCorrectedValue method twice
164   myListOfIDs.clear();
165   mySelectedIDs.clear();
166
167   myAddButton->setEnabled( false );
168   myRemoveButton->setEnabled( false );
169
170   mySMESHGUI     = SMESHGUI::GetSMESHGUI();
171   mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
172   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
173
174   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
175     aViewWindow->SetSelectionMode( ActorSelection );
176
177   myFilter=0;
178   //setFilter();
179
180   connect( myAddButton,    SIGNAL(clicked()), SLOT(onAdd()));
181   connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove()));
182   connect( myPrevButton,   SIGNAL(clicked()), SLOT(onPrevious()));
183   connect( myNextButton,   SIGNAL(clicked()), SLOT(onNext()));
184   
185   connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
186   connect( myListWidget,   SIGNAL(itemSelectionChanged()),    this, SLOT(onListSelectionChanged()));
187
188   updateState();
189 }
190
191 //================================================================================
192 /*!
193  * \brief Install filters to select sub-shapes of mySubShType or their groups
194  */
195 //================================================================================
196
197 void StdMeshersGUI_SubShapeSelectorWdg::setFilter()
198 {
199   SalomeApp_Study* study = mySMESHGUI->activeStudy();
200   GEOM_TypeFilter* typeFilter = new GEOM_TypeFilter(study, mySubShType, /*isShapeType=*/true );
201   GEOM_CompoundFilter* gpoupFilter = new GEOM_CompoundFilter(study);
202   gpoupFilter->addSubType( mySubShType );
203   myGeomFilters.append( typeFilter );
204   myGeomFilters.append( gpoupFilter );
205   myFilter = new SMESH_LogicalFilter( myGeomFilters, SMESH_LogicalFilter::LO_OR );
206   mySelectionMgr->installFilter( myFilter );
207 }
208
209 //================================================================================
210 /*!
211  *  Create a layout, initialize fields
212  */
213 //================================================================================
214
215 void StdMeshersGUI_SubShapeSelectorWdg::showPreview( bool visible)
216 {
217   if ( !myPreviewActor )
218     return;
219
220   if ( myIsShown != visible ) {
221     myPreviewActor->SetShown( visible );
222     
223     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
224       aViewWindow->Repaint();
225
226     myIsShown = visible;
227   }
228 }
229
230 //=================================================================================
231 // function : SelectionIntoArgument()
232 // purpose  : Called when selection as changed or other case
233 //=================================================================================
234 void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
235 {
236   if ( !myPreviewActor )
237     return;
238
239   mySelectedIDs.clear();
240
241   // get selected mesh
242   SALOME_ListIO aList;
243   mySelectionMgr->selectedObjects( aList );
244   int nbSel = aList.Extent();
245
246   if (nbSel > 0) {
247     SALOME_ListIteratorOfListIO anIt (aList);
248     
249     for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects
250       Handle(SALOME_InteractiveObject) IO = anIt.Value();
251       
252       GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() );  
253       if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study
254         GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape();
255         QString aFatherEntry = "";
256         QString aMainFatherEntry = "";
257         TopoDS_Shape shape;
258         if ( !CORBA::is_nil( aGeomFatherObj ) ) {
259           // Get Main Shape
260           GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry );
261           if ( !CORBA::is_nil( aGeomMain ) && aGeomMain->GetType() == 37 ) {  // Main Shape is a Group
262             GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape();
263             if ( !CORBA::is_nil( aMainFatherObj ) )
264               aMainFatherEntry = aMainFatherObj->GetStudyEntry();
265           }
266           aFatherEntry = aGeomFatherObj->GetStudyEntry();
267         }
268         
269         if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) )
270         {
271           if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object
272             GEOMBase::GetShape(aGeomObj, shape); 
273             if ( !shape.IsNull() ) {
274               TopExp_Explorer exp( shape, mySubShType );
275               for ( ; exp.More(); exp.Next() ) {
276                 int index = myPreviewActor->GetIndexByShape( exp.Current() );
277                 if ( index ) {
278                   mySelectedIDs.append( index );
279                   myPreviewActor->HighlightID( index );
280                 }
281               }
282             }
283           } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/  ) {
284             GEOMBase::GetShape(aGeomObj, shape); 
285             if ( !shape.IsNull() && shape.ShapeType() == mySubShType ) {
286               int index = myPreviewActor->GetIndexByShape( shape );
287               if ( index ) {
288                 mySelectedIDs.append( index );
289                 myPreviewActor->HighlightID( index );
290               }
291             }
292           }
293         }
294       } else { // Selected Actor from Actor Collection
295         QString anEntry = IO->getEntry();
296         QString str = "_";
297         int index = anEntry.lastIndexOf( str );
298         anEntry.remove(0, index+1);
299         int ind = anEntry.toInt();
300         if ( ind )
301           mySelectedIDs.append( ind );
302       }
303     }
304   }
305   // update add button
306   myAddButton->setEnabled( ( myListWidget->count() < myMaxSize || myMaxSize == -1 ) && mySelectedIDs.size() > 0 && ( mySelectedIDs.size() <= myMaxSize || myMaxSize == -1 ) );
307
308   //Connect Selected Ids in viewer and dialog's Ids list
309   bool signalsBlocked = myListWidget->blockSignals( true );
310   myListWidget->clearSelection();
311   if ( mySelectedIDs.size() > 0 ) {
312     for (int i = 0; i < mySelectedIDs.size(); i++) {
313       QString anID = QString(" %1").arg( mySelectedIDs.at(i) );
314       QList<QListWidgetItem*> anItems = myListWidget->findItems ( anID, Qt::MatchExactly );
315       QListWidgetItem* item;
316       foreach(item, anItems)
317         item->setSelected(true);
318     }
319   }
320   myListWidget->blockSignals( signalsBlocked );
321 }
322
323 //=================================================================================
324 // function : onAdd()
325 // purpose  : Called when Add Button Clicked
326 //=================================================================================
327 void StdMeshersGUI_SubShapeSelectorWdg::onAdd()
328 {
329   if ( mySelectedIDs.size() < 1 )
330     return;
331
332   myListWidget->blockSignals( true );
333   for (int i = 0; i < mySelectedIDs.size() && (myMaxSize == -1 || myListOfIDs.size() < myMaxSize); i++) {
334     if ( myListOfIDs.indexOf( mySelectedIDs.at(i) ) == -1 ) {
335       QString anID = QString(" %1").arg( mySelectedIDs.at(i) );
336
337       QListWidgetItem* anItem = new QListWidgetItem( anID, myListWidget );
338       anItem->setSelected(true);
339       
340       myListOfIDs.append( mySelectedIDs.at(i) );
341     }
342   }
343   onListSelectionChanged();
344   myListWidget->blockSignals( false );
345   myAddButton->setEnabled( myMaxSize == -1 || myListOfIDs.size() < myMaxSize );
346 }
347          
348 //=================================================================================
349 // function : onRemove()
350 // purpose  : Called when Remove Button Clicked
351 //=================================================================================
352 void StdMeshersGUI_SubShapeSelectorWdg::onRemove()
353 {
354   if ( myListWidget->count() < 1 )
355     return;
356
357   myListWidget->blockSignals( true );
358   QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
359   QListWidgetItem* item;
360   foreach(item, selItems) {
361     QString idStr = item->text();
362     int id = idStr.toInt();
363
364     int index = myListOfIDs.indexOf( id );
365     myListOfIDs.removeAt( index );
366     delete item;
367   }
368
369   onListSelectionChanged();
370   myListWidget->blockSignals( false );
371   
372   myAddButton->setEnabled( true );
373 }
374
375 void StdMeshersGUI_SubShapeSelectorWdg::onPrevious()
376 {
377   if ( myPreviewActor ) {
378     myPreviewActor->previous();
379     myListWidget->clearSelection();
380     updateButtons();
381     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
382       aViewWindow->Repaint();
383   }
384 }
385
386 void StdMeshersGUI_SubShapeSelectorWdg::onNext()
387 {
388   if ( myPreviewActor ) {
389     myPreviewActor->next();
390     myListWidget->clearSelection();
391     updateButtons();
392     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
393       aViewWindow->Repaint();
394   }
395 }
396
397 //=================================================================================
398 // function : onListSelectionChanged()
399 // purpose  : Called when selection in element list is changed
400 //=================================================================================
401 void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
402 {
403   if ( !myPreviewActor )
404     return;
405
406   mySelectionMgr->clearSelected();
407   TColStd_MapOfInteger aIndexes;
408   QList<QListWidgetItem*> selItems = myListWidget->selectedItems();
409   QListWidgetItem* anItem;
410   foreach(anItem, selItems)
411     myPreviewActor->HighlightID( anItem->text().toInt() );
412
413   // update remove button
414   myRemoveButton->setEnabled( selItems.size() > 0 );
415 }
416
417 //=================================================================================
418 // function : setGeomShape
419 // purpose  : Called to set geometry whose sub-shapes are selected
420 //================================================================================
421 void StdMeshersGUI_SubShapeSelectorWdg::SetGeomShapeEntry( const QString& theEntry )
422 {
423   if ( theEntry != "") {
424     myParamValue = theEntry;
425     myEntry = theEntry;
426     myGeomShape = GetTopoDSByEntry( theEntry );
427     updateState();
428     myIsNotCorrected = true;
429   }
430 }
431
432 //=================================================================================
433 // function : updateState
434 // purpose  : update Widget state
435 //=================================================================================
436 void StdMeshersGUI_SubShapeSelectorWdg::updateState()
437 {
438   bool state = false;
439   if ( !myGeomShape.IsNull() )
440     state = true;
441   myInfoLabel->setVisible( false );
442   myPrevButton->setVisible( false );
443   myNextButton->setVisible( false );
444   
445   myListWidget->setEnabled( state );
446   myAddButton->setEnabled( mySelectedIDs.size() > 0 );
447   
448   if (state) {
449     myPreviewActor = new SMESH_PreviewActorsCollection();
450     myPreviewActor->SetSelector( mySelector );
451     myPreviewActor->Init( myGeomShape, mySubShType, myEntry );
452     myPreviewActor->SetShown( false );
453     myIsShown = false;
454     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) {
455       myRenderer = aViewWindow->getRenderer();
456       myPreviewActor->AddToRender( myRenderer );
457       aViewWindow->Repaint();
458     }
459     updateButtons();
460   }
461 }
462
463 //=================================================================================
464 // function : GetGeomObjectByEntry
465 // purpose  : Called to get GeomObject
466 //=================================================================================
467 GEOM::GEOM_Object_var StdMeshersGUI_SubShapeSelectorWdg::GetGeomObjectByEntry( const QString& theEntry )
468 {
469   GEOM::GEOM_Object_var aGeomObj;
470   SALOMEDS::Study_var aStudy = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
471   if (aStudy != 0) {
472     SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( theEntry.toLatin1().data() );
473     SALOMEDS::GenericAttribute_var anAttr;
474
475     if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
476       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
477       CORBA::String_var aVal = anIOR->Value();
478       CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
479       aGeomObj = GEOM::GEOM_Object::_narrow(obj);
480     }
481   }
482   return aGeomObj;
483 }
484
485 //=================================================================================
486 // function : setObjectByEntry
487 // purpose  : Called to get GeomObject
488 //=================================================================================
489 TopoDS_Shape StdMeshersGUI_SubShapeSelectorWdg::GetTopoDSByEntry( const QString& theEntry )
490 {
491   TopoDS_Shape shape;
492   GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( theEntry );
493   GEOMBase::GetShape(aGeomObj, shape);
494   return shape;
495 }
496
497 //=================================================================================
498 // function : GetListOfIds
499 // purpose  : Called to get the list of SubShapes IDs
500 //=================================================================================
501 SMESH::long_array_var StdMeshersGUI_SubShapeSelectorWdg::GetListOfIDs()
502 {
503   SMESH::long_array_var anArray = new SMESH::long_array;
504
505   if ( myMainEntry != "" && myIsNotCorrected )
506     myListOfIDs = GetCorrectedListOfIDs( true );
507
508   int size = myListOfIDs.size();
509   anArray->length( size );
510   if ( size ) {
511     for (int i = 0; i < size; i++) {
512         anArray[i] = myListOfIDs.at(i);
513     }
514   }
515   return anArray;
516 }
517
518 //=================================================================================
519 // function : SetListOfIds
520 // purpose  : Called to set the list of SubShapes IDs
521 //=================================================================================
522 void StdMeshersGUI_SubShapeSelectorWdg::SetListOfIDs( SMESH::long_array_var theIds)
523 {
524   mySelectedIDs.clear();
525   myListOfIDs.clear();
526   int size = theIds->length();
527   for ( int i = 0; i < size; i++ )
528     mySelectedIDs.append( theIds[ i ] );
529
530   mySelectedIDs = GetCorrectedListOfIDs( false );
531   onAdd();
532 }
533
534 //=================================================================================
535 // function : SetMainShapeEntry
536 // purpose  : Called to set the Entry of main shape of the mesh
537 //=================================================================================
538 void StdMeshersGUI_SubShapeSelectorWdg::SetMainShapeEntry( const QString& theEntry )
539 {
540   myMainEntry = theEntry;
541   myMainShape = GetTopoDSByEntry( theEntry );
542   myIsNotCorrected = true;
543 }
544
545 //=================================================================================
546 // function : GetMainShapeEntry
547 // purpose  : Called to get the Main Object Entry
548 //=================================================================================
549 const char* StdMeshersGUI_SubShapeSelectorWdg::GetMainShapeEntry()
550 {
551   if ( myMainEntry == "")
552     return myEntry.toLatin1().data();
553
554   return myMainEntry.toLatin1().data();
555 }
556
557 //=================================================================================
558 // function : GetCorrectedListOfIds
559 // purpose  : Called to convert the list of IDs from sub-shape IDs to main shape IDs
560 //=================================================================================
561 QList<int> StdMeshersGUI_SubShapeSelectorWdg::GetCorrectedListOfIDs( bool fromSubshapeToMainshape )
562 {
563   if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) &&  fromSubshapeToMainshape )
564     return myListOfIDs;
565   else   if ( ( myMainShape.IsNull() || myGeomShape.IsNull() ) &&  !fromSubshapeToMainshape )
566     return mySelectedIDs;
567
568   QList<int> aList;
569   TopTools_IndexedMapOfShape   aGeomMap;
570   TopTools_IndexedMapOfShape   aMainMap;
571   TopExp::MapShapes(myGeomShape, aGeomMap);
572   TopExp::MapShapes(myMainShape, aMainMap);
573
574   if ( fromSubshapeToMainshape ) { // convert indexes from sub-shape to mainshape
575     int size = myListOfIDs.size();
576     for (int i = 0; i < size; i++) {
577       TopoDS_Shape aSubShape = aGeomMap.FindKey( myListOfIDs.at(i) );
578       int index = aMainMap.FindIndex( aSubShape );
579       aList.append( index );
580     }
581     myIsNotCorrected = false;
582   } else { // convert indexes from main shape to sub-shape
583     int size = mySelectedIDs.size();
584     for (int i = 0; i < size; i++) {
585       TopoDS_Shape aSubShape = aMainMap.FindKey( mySelectedIDs.at(i) );
586       int index = aGeomMap.FindIndex( aSubShape );
587       aList.append( index );
588     }
589   }
590
591   return aList;
592 }
593
594 void StdMeshersGUI_SubShapeSelectorWdg::updateButtons()
595 {
596   if ( myPreviewActor ) {
597     int total = myPreviewActor->count();
598     int chunk = myPreviewActor->currentChunk();
599     int chunkSize = myPreviewActor->chunkSize();
600     int imin = chunk*chunkSize+1;
601     int imax = std::min((chunk+1)*chunkSize, total);
602     bool vis = imax > 0 && total > chunkSize;
603     myInfoLabel->setVisible( vis );
604     myPrevButton->setVisible( vis );
605     myNextButton->setVisible( vis );
606     myInfoLabel->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg(imin).arg(imax).arg(total) );
607     myPrevButton->setEnabled( myPreviewActor->hasPrevious() );
608     myNextButton->setEnabled( myPreviewActor->hasNext() );
609   }
610 }