ModelManagerDialog.ui.h

Go to the documentation of this file.
00001 /*!@file Qt/ModelManagerDialog.ui.h functions relating to model configuration
00002         dialog */
00003 
00004 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Qt/ModelManagerDialog.ui.h $
00005 // $Id: ModelManagerDialog.ui.h 7095 2006-09-01 18:07:02Z rjpeters $
00006 
00007 /****************************************************************************
00008 ** ui.h extension file, included from the uic-generated form implementation.
00009 **
00010 ** If you wish to add, delete or rename functions or slots use
00011 ** Qt Designer which will update this file, preserving your code. Create an
00012 ** init() function in place of a constructor, and a destroy() function in
00013 ** place of a destructor.
00014 *****************************************************************************/
00015 
00016 void ModelManagerDialog::init( ModelManager & manager )
00017 {
00018         mgr = &manager;
00019         pmap.clear();
00020         backupMap.clear();
00021         mgr->writeParamsTo( pmap );
00022         mgr->writeParamsTo( backupMap );
00023         listview->clear();
00024         listview->setDefaultRenameAction( QListView::Accept );
00025         QListViewItem *modelItem = new QListViewItem( listview, "model" );
00026         modelItem->setOpen( true );
00027         populate( pmap.getSubpmap( "model" ), modelItem );
00028         listview->triggerUpdate();
00029 }
00030 
00031 void ModelManagerDialog::populate( rutz::shared_ptr< ParamMap > pmp, QListViewItem *parent )
00032 {
00033         ParamMap::key_iterator kitr = pmp->keys_begin();
00034         while( kitr != pmp->keys_end() )
00035         {
00036                 QListViewItem *newItem = new QListViewItem( parent, *kitr, pmp->getStringParam( *kitr ) );
00037                 newItem->setOpen( true );
00038 
00039                 // if leaf, allow user to edit
00040                 if( pmp->isLeaf( *kitr ) )
00041                         newItem->setRenameEnabled( 1, true );
00042                 // otherwise, populate the submap
00043                 else
00044                         populate( pmp->getSubpmap( *kitr ), newItem );
00045 
00046                 ++kitr;
00047         }
00048 }
00049 
00050 
00051 void ModelManagerDialog::handleItemEdit( QListViewItem * item )
00052 {
00053         int depth = item->depth();
00054         int d = depth;
00055         std::vector< QString > maps( d + 1 );
00056         maps[d] = item->text( 0 );
00057         QListViewItem *parent = item->parent();
00058 
00059         // find path to list view item
00060         while( d > 0 )
00061         {
00062                 d = parent->depth();
00063                 maps[d] = parent->text( 0 );
00064                 parent = parent->parent();
00065         }
00066         rutz::shared_ptr< ParamMap > pm = pmap.getSubpmap( "model" );
00067         for( d = 1; d < depth; d++ )
00068         {
00069                 pm = pm->getSubpmap( maps[d].ascii() );
00070         }
00071 
00072         // edit the item
00073         pm->replaceStringParam( item->text( 0 ).ascii(), item->text( 1 ).ascii() );
00074 
00075         // update the model manager
00076         mgr->readParamsFrom( pmap );
00077         pmap.clear();
00078         mgr->writeParamsTo( pmap );
00079 
00080         // refresh the list view
00081         listview->clear();
00082         QListViewItem *modelItem = new QListViewItem( listview, "model" );
00083         modelItem->setOpen( true );
00084         populate( pmap.getSubpmap( "model" ), modelItem );
00085 
00086         // put the edited item back in focus
00087         QListViewItem *edited = listview->firstChild();
00088         for( d = 0; d <= depth; d++ )
00089         {
00090                 while( ( edited != 0 ) && ( edited->text( 0 ) != maps[d] ) )
00091                         edited = edited->nextSibling();
00092                 if( d < depth )
00093                         edited = edited->firstChild();
00094         }
00095         if( edited )
00096         {
00097                 listview->ensureItemVisible( edited );
00098                 listview->clearSelection();
00099                 edited->setSelected( true );
00100         }
00101         listview->triggerUpdate();
00102 }
00103 
00104 
00105 void ModelManagerDialog::handleWizardButton( void )
00106 {
00107         mmw.init( *mgr );
00108         mmw.show();
00109         close();
00110 }
00111 
00112 
00113 void ModelManagerDialog::handleApplyButton( void )
00114 {
00115         mgr->readParamsFrom( pmap );
00116         close();
00117 }
00118 
00119 
00120 
00121 void ModelManagerDialog::handleCancelButton( void )
00122 {
00123         mgr->readParamsFrom( backupMap );
00124         close();
00125 }
Generated on Sun May 8 08:05:33 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3