summaryrefslogtreecommitdiffstats
path: root/tools/designer/examples/multiclip/multiclip.ui.h
blob: a2b0b0cf76e940c688bd9fb0745a959ea885d84b (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
void MulticlipForm::addClipping()
{
    TQString text = currentLineEdit->text();
    if ( ! text.isEmpty() ) {
	lengthLCDNumber->display( (int)text.length() );
	int i = 0;
	for ( ; i < (int)clippingsListBox->count(); i++ ) {
	    if ( clippingsListBox->text( i ) == text ) {
		i = -1; // Do not add duplicates
		break;
	    }
	}
	if ( i != -1 )
	    clippingsListBox->insertItem( text, 0 );
    }
}

void MulticlipForm::dataChanged()
{
    TQString text;
    text = cb->text();
    clippingChanged( text );
    if ( autoCheckBox->isChecked() )
	addClipping();
}

void MulticlipForm::deleteClipping()
{
    clippingChanged( "" );
    clippingsListBox->removeItem( clippingsListBox->currentItem() );
}

void MulticlipForm::init()
{
    lengthLCDNumber->setBackgroundColor( darkBlue );
    currentLineEdit->setFocus();

    cb = qApp->clipboard();
    connect( cb, SIGNAL( dataChanged() ), SLOT( dataChanged() ) );
    if ( cb->supportsSelection() )
	connect( cb, SIGNAL( selectionChanged() ), SLOT( selectionChanged() ) );

    dataChanged();
}

void MulticlipForm::selectionChanged()
{
    cb->setSelectionMode( TRUE );
    dataChanged();
    cb->setSelectionMode( FALSE );
}

void MulticlipForm::copyPrevious()
{
    if ( clippingsListBox->currentItem() != -1 ) {
	cb->setText( clippingsListBox->currentText() );
	if ( cb->supportsSelection() ) {
	    cb->setSelectionMode( TRUE );
	    cb->setText( clippingsListBox->currentText() );
	    cb->setSelectionMode( FALSE );
	}
    }
}

void MulticlipForm::clippingChanged( const TQString & clipping )
{
    currentLineEdit->setText( clipping );
    lengthLCDNumber->display( (int)clipping.length() );
}