blob: 7f179cefd37373969e807493af52717489157f75 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename slots use TQt Designer which will
** update this file, preserving your code. Create an init() slot in place of
** a constructor, and a destroy() slot in place of a destructor.
*****************************************************************************/
#include <tqheader.h>
#include <tqapplication.h>
void ListEditor::init()
{
listview->header()->hide();
listview->setSorting( -1 );
listview->setDefaultRenameAction( TQListView::Accept );
}
void ListEditor::setList( const TQStringList &l )
{
TQListViewItem *i = 0;
for ( TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it ) {
i = new TQListViewItem( listview, i );
i->setText( 0, *it );
i->setRenameEnabled( 0, TRUE );
}
}
void ListEditor::addItem()
{
TQListViewItem *i = new TQListViewItem( listview, listview->lastItem() );
i->setRenameEnabled( 0, TRUE );
tqApp->processEvents();
i->startRename( 0 );
}
void ListEditor::renamed( TQListViewItem *i )
{
if ( i && i->text( 0 ).isEmpty() )
i->startRename( 0 );
}
void ListEditor::removeItems()
{
TQListViewItemIterator it( listview );
TQListViewItem *i = 0;
while ( ( i = it.current() ) ) {
++it;
if ( i->isSelected() )
delete i;
}
}
TQStringList ListEditor::items()
{
TQStringList l;
TQListViewItemIterator it( listview );
TQListViewItem *i = 0;
while ( ( i = it.current() ) ) {
++it;
if ( !i->text( 0 ).isEmpty() )
l << i->text( 0 );
}
return l;
}
void ListEditor::renameItem()
{
TQListViewItem *i = listview->currentItem();
if ( i )
i->startRename( 0 );
}
|