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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
#include <tqstring.h>
#include <tqpushbutton.h>
#include <tqlayout.h>
#include <tqhbox.h>
#include <tqtimer.h>
#include <tdeaboutdata.h>
#include <tdecmdlineargs.h>
#include <tdeapplication.h>
#include <kdebug.h>
#include <kdialog.h>
#include <klocale.h>
#include <klineedit.h>
#include <kglobalsettings.h>
#include <tdecompletionbox.h>
#include "klineedittest.h"
KLineEditTest::KLineEditTest (TQWidget* widget, const char* name )
:TQWidget( widget, name )
{
TQVBoxLayout* layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
TQStringList list;
list << "Tree" << "Suuupa" << "Stroustrup" << "Stone" << "Slick"
<< "Slashdot" << "Send" << "Peables" << "Mankind" << "Ocean"
<< "Chips" << "Computer" << "Sandworm" << "Sandstorm" << "Chops";
list.sort();
m_lineedit = new KLineEdit( this, "klineedittest" );
m_lineedit->completionObject()->setItems( list );
m_lineedit->setFixedSize(500,30);
m_lineedit->setEnableSqueezedText( true );
connect( m_lineedit, TQT_SIGNAL( returnPressed() ), TQT_SLOT( slotReturnPressed() ) );
connect( m_lineedit, TQT_SIGNAL( returnPressed(const TQString&) ),
TQT_SLOT( slotReturnPressed(const TQString&) ) );
TQHBox *hbox = new TQHBox (this);
m_btnExit = new TQPushButton( "E&xit", hbox );
m_btnExit->setFixedSize(100,30);
connect( m_btnExit, TQT_SIGNAL( clicked() ), TQT_SLOT( quitApp() ) );
m_btnReadOnly = new TQPushButton( "&Read Only", hbox );
m_btnReadOnly->setToggleButton (true);
m_btnReadOnly->setFixedSize(100,30);
connect( m_btnReadOnly, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotReadOnly(bool) ) );
m_btnEnable = new TQPushButton( "Dis&able", hbox );
m_btnEnable->setToggleButton (true);
m_btnEnable->setFixedSize(100,30);
connect( m_btnEnable, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotEnable(bool) ) );
m_btnHide = new TQPushButton( "Hi&de", hbox );
m_btnHide->setFixedSize(100,30);
connect( m_btnHide, TQT_SIGNAL( clicked() ), TQT_SLOT( slotHide() ) );
layout->addWidget( m_lineedit );
layout->addWidget( hbox );
setCaption( "KLineEdit Unit Test" );
}
KLineEditTest::~KLineEditTest()
{
}
void KLineEditTest::quitApp()
{
kapp->closeAllWindows();
}
void KLineEditTest::show()
{
if (m_lineedit->isHidden())
m_lineedit->show();
m_btnHide->setEnabled( true );
TQWidget::show();
}
void KLineEditTest::slotReturnPressed()
{
kdDebug() << "Return pressed" << endl;
}
void KLineEditTest::slotReturnPressed( const TQString& text )
{
kdDebug() << "Return pressed: " << text << endl;
}
void KLineEditTest::resultOutput( const TQString& text )
{
kdDebug() << "KlineEditTest Debug: " << text << endl;
}
void KLineEditTest::slotReadOnly( bool ro )
{
m_lineedit->setReadOnly (ro);
TQString text = (ro) ? "&Read Write" : "&Read Only";
m_btnReadOnly->setText (text);
}
void KLineEditTest::slotEnable (bool enable)
{
m_lineedit->setEnabled (!enable);
TQString text = (enable) ? "En&able":"Dis&able";
m_btnEnable->setText (text);
}
void KLineEditTest::slotHide()
{
m_lineedit->hide();
m_btnHide->setEnabled( false );
m_lineedit->setText( "My dog ate the homework, whaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaa! I want my mommy!" );
TQTimer::singleShot( 1000, this, TQT_SLOT(show()) );
}
int main ( int argc, char **argv)
{
TDEAboutData aboutData( "klineedittest", "klineedittest", "1.0" );
TDECmdLineArgs::init(argc, argv, &aboutData);
TDEApplication::addCmdLineOptions();
TDEApplication a;
KLineEditTest *t = new KLineEditTest();
//t->lineEdit()->setTrapReturnKey( true );
//t->lineEdit()->completionBox()->setTabHandling( false );
t->lineEdit()->setEnableSqueezedText( true );
t->lineEdit()->setText ("This is a really really really really really really "
"really really long line because I am a talkative fool!");
a.setMainWidget(t);
t->show();
return a.exec();
}
#include "klineedittest.moc"
|