Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** ui.h extension file, included from the uic-generated form implementation. 00003 ** 00004 ** If you wish to add, delete or rename slots use Qt Designer which will 00005 ** update this file, preserving your code. Create an init() slot in place of 00006 ** a constructor, and a destroy() slot in place of a destructor. 00007 *****************************************************************************/ 00008 00009 #include <qheader.h> 00010 #include <qapplication.h> 00011 00012 void ListEditor::init() 00013 { 00014 listview->header()->hide(); 00015 listview->setSorting( -1 ); 00016 listview->setDefaultRenameAction( QListView::Accept ); 00017 } 00018 00019 void ListEditor::setList( const QStringList &l ) 00020 { 00021 QListViewItem *i = 0; 00022 for ( QStringList::ConstIterator it = l.begin(); it != l.end(); ++it ) { 00023 i = new QListViewItem( listview, i ); 00024 i->setText( 0, *it ); 00025 i->setRenameEnabled( 0, TRUE ); 00026 } 00027 } 00028 00029 void ListEditor::addItem() 00030 { 00031 QListViewItem *i = new QListViewItem( listview, listview->lastItem() ); 00032 i->setRenameEnabled( 0, TRUE ); 00033 qApp->processEvents(); 00034 i->startRename( 0 ); 00035 } 00036 00037 void ListEditor::renamed( QListViewItem *i ) 00038 { 00039 if ( i && i->text( 0 ).isEmpty() ) 00040 i->startRename( 0 ); 00041 } 00042 00043 void ListEditor::removeItems() 00044 { 00045 QListViewItemIterator it( listview ); 00046 QListViewItem *i = 0; 00047 while ( ( i = it.current() ) ) { 00048 ++it; 00049 if ( i->isSelected() ) 00050 delete i; 00051 } 00052 } 00053 00054 QStringList ListEditor::items() 00055 { 00056 QStringList l; 00057 QListViewItemIterator it( listview ); 00058 QListViewItem *i = 0; 00059 while ( ( i = it.current() ) ) { 00060 ++it; 00061 if ( !i->text( 0 ).isEmpty() ) 00062 l << i->text( 0 ); 00063 } 00064 return l; 00065 } 00066 00067 void ListEditor::renameItem() 00068 { 00069 QListViewItem *i = listview->currentItem(); 00070 if ( i ) 00071 i->startRename( 0 ); 00072 }