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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
|
/**********************************************************************
** Copyright (C) 2000-2001 Trolltech AS. All rights reserved.
**
** This file is part of TQt Designer.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact [email protected] if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <tqvariant.h> // HP-UX compiler needs this here
#include <tqlistview.h>
#include "workspace.h"
#include "formwindow.h"
#include "mainwindow.h"
#include "pixmapchooser.h"
#include "globaldefs.h"
#include "command.h"
#ifndef KOMMANDER
#include "project.h"
#include "pixmapcollection.h"
#include "sourcefile.h"
#include "sourceeditor.h"
#endif
#include "formfile.h"
#include <tqheader.h>
#include <tqfileinfo.h>
#include <tqapplication.h>
#include <tqpainter.h>
#include <tqpen.h>
#include <tqobjectlist.h>
#include <tqworkspace.h>
#include <tqpopupmenu.h>
#include <tqtextstream.h>
#include "qcompletionedit.h"
#include <kurldrag.h>
#include <klocale.h>
static const char * const folderxpm[]={
"16 16 6 1",
". c None",
"b c #ffff00",
"d c #000000",
"* c #999999",
"a c #cccccc",
"c c #ffffff",
"................",
"................",
"..*****.........",
".*ababa*........",
"*abababa******..",
"*cccccccccccc*d.",
"*cbababababab*d.",
"*cabababababa*d.",
"*cbababababab*d.",
"*cabababababa*d.",
"*cbababababab*d.",
"*cabababababa*d.",
"*cbababababab*d.",
"**************d.",
".dddddddddddddd.",
"................"};
static const char * const file_xpm[]={
"16 16 5 1",
". c #7f7f7f",
"# c None",
"c c #000000",
"b c #bfbfbf",
"a c #ffffff",
"################",
"..........######",
".aaaaaaaab.#####",
".aaaaaaaaba.####",
".aaaaaaaacccc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".aaaaaaaaaabc###",
".bbbbbbbbbbbc###",
"ccccccccccccc###"};
static TQPixmap *folderPixmap = 0;
static TQPixmap *filePixmap = 0;
static TQPixmap* formPixmap = 0;
#ifndef KOMMANDER
WorkspaceItem::WorkspaceItem( TQListView *parent, Project* p )
#else
WorkspaceItem::WorkspaceItem( TQListView *parent )
#endif
: TQListViewItem( parent )
{
init();
#ifndef KOMMANDER
project = p;
#endif
t = ProjectType;
setPixmap( 0, *folderPixmap );
setExpandable( false );
}
#ifndef KOMMANDER
WorkspaceItem::WorkspaceItem( TQListViewItem *parent, SourceFile* sf )
: TQListViewItem( parent )
{
init();
sourceFile = sf;
t = SourceFileType;
setPixmap( 0, *filePixmap );
}
#endif
WorkspaceItem::WorkspaceItem( TQListViewItem *parent, FormFile* ff, Type type )
: TQListViewItem( parent )
{
init();
formFile = ff;
t = type;
if ( type == FormFileType ) {
setPixmap( 0, *formPixmap );
TQObject::connect( ff, TQT_SIGNAL( somethingChanged(FormFile*) ), listView(), TQT_SLOT( update(FormFile*) ) );
#ifndef KOMMANDER
if ( formFile->supportsCodeFile() )
(void) new WorkspaceItem( this, formFile, FormSourceType );
} else if ( type == FormSourceType ) {
setPixmap( 0, *filePixmap );
#endif
}
}
WorkspaceItem::WorkspaceItem( TQListView *parent, FormFile* ff, Type type )
: TQListViewItem( parent )
{
init();
formFile = ff;
t = type;
if ( type == FormFileType ) {
setPixmap( 0, *formPixmap );
TQObject::connect( ff, TQT_SIGNAL( somethingChanged(FormFile*) ), listView(), TQT_SLOT( update(FormFile*) ) );
#ifndef KOMMANDER
if ( formFile->supportsCodeFile() )
(void) new WorkspaceItem( this, formFile, FormSourceType );
} else if ( type == FormSourceType ) {
setPixmap( 0, *filePixmap );
#endif
}
}
void WorkspaceItem::init()
{
autoOpen = false;
useOddColor = false;
#ifndef KOMMANDER
project = 0;
sourceFile = 0;
#endif
formFile = 0;
}
void WorkspaceItem::paintCell( TQPainter *p, const TQColorGroup &cg, int column, int width, int align )
{
TQColorGroup g( cg );
g.setColor( TQColorGroup::Base, backgroundColor() );
g.setColor( TQColorGroup::Foreground, TQt::black );
#ifndef KOMMANDER
if ( type() == FormSourceType && !formFile->hasFormCode() ) {
g.setColor( TQColorGroup::Text, listView()->palette().disabled().color( TQColorGroup::Text) );
g.setColor( TQColorGroup::HighlightedText, listView()->palette().disabled().color( TQColorGroup::Text) );
} else {
#endif
g.setColor( TQColorGroup::Text, TQt::black );
#ifndef KOMMANDER
}
#endif
p->save();
if ( isModified() ) {
TQFont f = p->font();
f.setBold( true );
p->setFont( f );
}
TQListViewItem::paintCell( p, g, column, width, align );
p->setPen( TQPen( cg.dark(), 1 ) );
if ( column == 0 )
p->drawLine( 0, 0, 0, height() - 1 );
if ( listView()->firstChild() != this ) {
if ( nextSibling() != itemBelow() && itemBelow()->depth() < depth() ) {
int d = depth() - itemBelow()->depth();
p->drawLine( -listView()->treeStepSize() * d, height() - 1, 0, height() - 1 );
}
}
p->drawLine( 0, height() - 1, width, height() - 1 );
p->drawLine( width - 1, 0, width - 1, height() );
p->restore();
}
TQString WorkspaceItem::text( int column ) const
{
if ( column != 0 )
return TQListViewItem::text( column );
switch( t ) {
#ifndef KOMMANDER
case ProjectType:
if ( project->isDummy() )
return i18n("<No Project>" );
return project->makeRelative( project->fileName() );
#endif
case FormFileType:
return formFile->formName() + ": " + formFile->fileName();
#ifndef KOMMANDER
case FormSourceType:
return formFile->codeFile();
case SourceFileType:
return sourceFile->fileName();
#endif
}
return TQString(); // shut up compiler
}
void WorkspaceItem::fillCompletionList( TQStringList& completion )
{
switch( t ) {
case ProjectType:
break;
case FormFileType:
completion += formFile->formName();
completion += formFile->fileName();
break;
#ifndef KOMMANDER
case FormSourceType:
completion += formFile->codeFile();
break;
case SourceFileType:
completion += sourceFile->fileName();
break;
#endif
}
}
bool WorkspaceItem::checkCompletion( const TQString& completion )
{
switch( t ) {
case ProjectType:
break;
case FormFileType:
return completion == formFile->formName()
|| completion == formFile->fileName();
#ifndef KOMMANDER
case FormSourceType:
return completion == formFile->codeFile();
case SourceFileType:
return completion == sourceFile->fileName();
#endif
}
return false;
}
bool WorkspaceItem::isModified() const
{
#ifndef KOMMANDER
switch( t ) {
case ProjectType:
return project->isModified();
case FormFileType:
return formFile->isModified( FormFile::WFormWindow );
case FormSourceType:
return formFile->isModified( FormFile::WFormCode );
case SourceFileType:
return sourceFile->isModified();
}
return false; // shut up compiler
#else
return formFile->isModified();
#endif
}
TQString WorkspaceItem::key( int column, bool ) const
{
TQString key = text( column );
if ( t == FormFileType )
key.prepend( "0" );
else
key.prepend( "a" );
return key;
}
TQColor WorkspaceItem::backgroundColor()
{
bool b = useOddColor;
if ( t == FormSourceType && parent() )
b = ( ( WorkspaceItem*)parent() )->useOddColor;
return b ? *backColor2 : *backColor1;
}
void WorkspaceItem::setOpen( bool b )
{
TQListViewItem::setOpen( b );
autoOpen = false;
}
void WorkspaceItem::setAutoOpen( bool b )
{
TQListViewItem::setOpen( b );
autoOpen = b;
}
Workspace::Workspace( TQWidget *parent, MainWindow *mw )
: TQListView( parent, 0, WStyle_Customize | WStyle_NormalBorder | WStyle_Title |
WStyle_Tool | WStyle_MinMax | WStyle_SysMenu ), mainWindow( mw ),
#ifndef KOMMANDER
project( 0 ), completionDirty( false )
#else
completionDirty( false )
#endif
{
init_colors();
setDefaultRenameAction( Accept );
blockNewForms = false;
bufferEdit = 0;
header()->setStretchEnabled( true );
header()->hide();
setSorting( 0 );
setResizePolicy( TQScrollView::Manual );
#ifndef KOMMANDER
setIcon( PixmapChooser::loadPixmap( "logo" ) );
#endif
TQPalette p( palette() );
p.setColor( TQColorGroup::Base, TQColor( *backColor2 ) );
(void)*selectedBack; // hack
setPalette( p );
addColumn( i18n("Files" ) );
setAllColumnsShowFocus( true );
connect( this, TQT_SIGNAL( mouseButtonClicked( int, TQListViewItem *, const TQPoint &, int ) ),
this, TQT_SLOT( itemClicked( int, TQListViewItem *, const TQPoint& ) ) ),
connect( this, TQT_SIGNAL( doubleClicked( TQListViewItem * ) ),
this, TQT_SLOT( itemDoubleClicked( TQListViewItem * ) ) ),
connect( this, TQT_SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint &, int ) ),
this, TQT_SLOT( rmbClicked( TQListViewItem *, const TQPoint& ) ) ),
setHScrollBarMode( AlwaysOff );
setVScrollBarMode( AlwaysOn );
viewport()->setAcceptDrops( true );
setAcceptDrops( true );
setColumnWidthMode( 1, Manual );
if ( !folderPixmap ) {
folderPixmap = new TQPixmap( folderxpm );
filePixmap = new TQPixmap( file_xpm );
formPixmap = new TQPixmap( PixmapChooser::loadPixmap( "form.xpm", PixmapChooser::Mini ) );
}
#ifdef KOMMANDER
makeConnections(mw);
#endif
}
#ifndef KOMMANDER
void Workspace::projectDestroyed( TQObject* o )
{
if ( o == project ) {
project = 0;
clear();
}
}
#endif
#ifndef KOMMANDER
void Workspace::setCurrentProject( Project *pro )
{
if ( project == pro )
return;
if ( project ) {
disconnect( project, TQT_SIGNAL( sourceFileAdded(SourceFile*) ), this, TQT_SLOT( sourceFileAdded(SourceFile*) ) );
disconnect( project, TQT_SIGNAL( sourceFileRemoved(SourceFile*) ), this, TQT_SLOT( sourceFileRemoved(SourceFile*) ) );
disconnect( project, TQT_SIGNAL( formFileAdded(FormFile*) ), this, TQT_SLOT( formFileAdded(FormFile*) ) );
disconnect( project, TQT_SIGNAL( formFileRemoved(FormFile*) ), this, TQT_SLOT( formFileRemoved(FormFile*) ) );
disconnect( project, TQT_SIGNAL( projectModified() ), this, TQT_SLOT( update() ) );
}
project = pro;
connect( project, TQT_SIGNAL( sourceFileAdded(SourceFile*) ), this, TQT_SLOT( sourceFileAdded(SourceFile*) ) );
connect( project, TQT_SIGNAL( sourceFileRemoved(SourceFile*) ), this, TQT_SLOT( sourceFileRemoved(SourceFile*) ) );
connect( project, TQT_SIGNAL( formFileAdded(FormFile*) ), this, TQT_SLOT( formFileAdded(FormFile*) ) );
connect( project, TQT_SIGNAL( formFileRemoved(FormFile*) ), this, TQT_SLOT( formFileRemoved(FormFile*) ) );
connect( project, TQT_SIGNAL( destroyed(TQObject*) ), this, TQT_SLOT( projectDestroyed(TQObject*) ) );
connect( project, TQT_SIGNAL( projectModified() ), this, TQT_SLOT( update() ) );
clear();
if ( bufferEdit )
bufferEdit->clear();
projectItem = new WorkspaceItem( this, project );
projectItem->setOpen( true );
for ( TQPtrListIterator<SourceFile> sources = project->sourceFiles();
sources.current(); ++sources ) {
SourceFile* f = sources.current();
(void) new WorkspaceItem( projectItem, f );
}
for ( TQPtrListIterator<FormFile> forms = project->formFiles();
forms.current(); ++forms ) {
FormFile* f = forms.current();
(void) new WorkspaceItem( projectItem, f );
}
updateColors();
completionDirty = true;
}
#endif
#ifdef KOMMANDER
void Workspace::makeConnections(MainWindow *)
{
// FIXME
}
#endif
#ifndef KOMMANDER
void Workspace::sourceFileAdded( SourceFile* sf )
{
(void) new WorkspaceItem( projectItem, sf );
Q_UNUSED(sf);
updateColors();
}
#endif
#ifndef KOMMANDER
void Workspace::sourceFileRemoved( SourceFile* sf )
{
delete findItem( sf );
updateColors();
}
#endif
void Workspace::formFileAdded( FormFile* ff )
{
#ifndef KOMMANDER
(void) new WorkspaceItem( projectItem, ff );
#else
(void) new WorkspaceItem( this, ff );
#endif
updateColors();
}
void Workspace::formFileRemoved( FormFile* ff )
{
delete findItem( ff );
updateColors();
}
void Workspace::update()
{
completionDirty = true;
triggerUpdate();
}
void Workspace::update( FormFile* ff )
{
TQListViewItem* i = findItem( ff );
if ( i ) {
i->repaint();
if ( (i = i->firstChild()) )
i->repaint();
}
}
void Workspace::activeFormChanged( FormWindow *fw )
{
WorkspaceItem *i = findItem( fw->formFile() );
if ( i ) {
setCurrentItem( i );
setSelected( i, true );
if ( !i->isOpen() )
i->setAutoOpen( true );
}
closeAutoOpenItems();
}
#ifndef KOMMANDER
void Workspace::activeEditorChanged( SourceEditor *se )
{
if ( !se->object() )
return;
if ( se->formWindow() ) {
WorkspaceItem *i = findItem( se->formWindow()->formFile() );
if ( i && i->firstChild() ) {
if ( !i->isOpen() )
i->setAutoOpen( true );
setCurrentItem( i->firstChild() );
setSelected( i->firstChild(), true );
}
} else {
WorkspaceItem *i = findItem( se->sourceFile() );
if ( i ) {
setCurrentItem( i );
setSelected( i, true );
}
}
closeAutoOpenItems();
}
#endif
WorkspaceItem *Workspace::findItem( FormFile* ff)
{
TQListViewItemIterator it( this );
for ( ; it.current(); ++it ) {
if ( ( (WorkspaceItem*)it.current() )->formFile == ff )
return (WorkspaceItem*)it.current();
}
return 0;
}
#ifndef KOMMANDER
WorkspaceItem *Workspace::findItem( SourceFile *sf )
{
TQListViewItemIterator it( this );
for ( ; it.current(); ++it ) {
if ( ( (WorkspaceItem*)it.current() )->sourceFile == sf )
return (WorkspaceItem*)it.current();
}
return 0;
}
#endif
void Workspace::closeAutoOpenItems()
{
TQListViewItemIterator it( this );
for ( ; it.current(); ++it ) {
WorkspaceItem* i = (WorkspaceItem*) it.current();
WorkspaceItem* ip = (WorkspaceItem*) i->parent();
if ( i->type() == WorkspaceItem::FormSourceType ) {
if ( !i->isSelected() && !ip->isSelected()
&& ip->isAutoOpen() ) {
ip->setAutoOpen( false );
}
}
}
}
void Workspace::closeEvent( TQCloseEvent *e )
{
e->accept();
}
void Workspace::itemDoubleClicked( TQListViewItem *i )
{
if ( ( (WorkspaceItem*)i)->type()== WorkspaceItem::ProjectType )
i->setOpen( true );
}
void Workspace::itemClicked( int button, TQListViewItem *i, const TQPoint& )
{
if ( !i || button != Qt::LeftButton )
return;
closeAutoOpenItems();
WorkspaceItem* wi = (WorkspaceItem*)i;
#ifndef KOMMANDER
if ( wi->type() == WorkspaceItem::SourceFileType )
mainWindow->editSource( wi->sourceFile );
switch( wi->type() ) {
case WorkspaceItem::ProjectType:
break; // ### TODO
case WorkspaceItem::FormFileType:
wi->formFile->showFormWindow();
break;
case WorkspaceItem::FormSourceType:
wi->formFile->showEditor();
break;
case WorkspaceItem::SourceFileType:
mainWindow->editSource( wi->sourceFile );
break;
}
#else
wi->formFile->showFormWindow();
#endif
}
void Workspace::contentsDropEvent( TQDropEvent *e )
{
if (!KURLDrag::canDecode(e))
{
e->ignore();
return;
}
KURL::List files;
KURLDrag::decode(e, files);
if (files.isEmpty())
return;
for (KURL::List::Iterator it = files.begin(); it != files.end(); ++it)
{
if (!(*it).isLocalFile())
continue;
TQString fn = (*it).path();
mainWindow->fileOpen(fn);
}
}
void Workspace::contentsDragEnterEvent( TQDragEnterEvent *e )
{
if ( !KURLDrag::canDecode( e ) )
e->ignore();
else
e->accept();
}
void Workspace::contentsDragMoveEvent( TQDragMoveEvent *e )
{
if ( !KURLDrag::canDecode( e ) )
e->ignore();
else
e->accept();
}
void Workspace::rmbClicked( TQListViewItem *i, const TQPoint& pos )
{
if ( !i )
return;
WorkspaceItem* wi = (WorkspaceItem*)i;
enum { OPEN_SOURCE, REMOVE_SOURCE, OPEN_FORM, REMOVE_FORM, OPEN_FORM_SOURCE };
TQPopupMenu menu( this );
switch ( wi->type() ) {
#ifndef KOMMANDER
case WorkspaceItem::SourceFileType:
menu.insertItem( i18n("&Open Source File..." ), OPEN_SOURCE );
menu.insertSeparator();
menu.insertItem( PixmapChooser::loadPixmap( "editcut" ),
i18n("&Remove Source File From Project" ), REMOVE_SOURCE );
break;
#endif
case WorkspaceItem::FormFileType:
menu.insertItem( i18n("&Open Form..." ), OPEN_FORM );
menu.insertSeparator();
menu.insertItem( PixmapChooser::loadPixmap( "editcut" ),
#ifndef KOMMANDER
i18n("&Remove Form From Project" ), REMOVE_FORM );
#else
i18n("&Remove Form" ), REMOVE_FORM );
#endif
break;
case WorkspaceItem::FormSourceType:
menu.insertItem( i18n("&Open Form Source..." ), OPEN_FORM_SOURCE );
menu.insertSeparator();
menu.insertItem( PixmapChooser::loadPixmap( "editcut" ),
#ifndef KOMMANDER
i18n("&Remove Form From Project" ), REMOVE_FORM );
#else
i18n("&Remove Form" ), REMOVE_FORM );
#endif
break;
#ifndef KOMMANDER
case WorkspaceItem::ProjectType:
MainWindow::self->popupProjectMenu( pos );
return;
#endif
default:
return;
}
switch ( menu.exec( pos ) ) {
#ifndef KOMMANDER
case REMOVE_SOURCE:
project->removeSourceFile( wi->sourceFile );
break;
#endif
case OPEN_SOURCE:
itemClicked( Qt::LeftButton, i, pos );
break;
#ifndef KOMMANDER
case REMOVE_FORM: // FIXME
project->removeFormFile( wi->formFile );
break;
#endif
case OPEN_FORM:
itemClicked( Qt::LeftButton, i, pos );
break;
case OPEN_FORM_SOURCE:
itemClicked( Qt::LeftButton, i, pos );
break;
default:
break;
}
}
bool Workspace::eventFilter( TQObject *o, TQEvent * e )
{
// Reggie, on what type of events do we have to execute updateBufferEdit()
if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(bufferEdit) && e->type() != TQEvent::ChildRemoved )
updateBufferEdit();
return TQListView::eventFilter( o, e );
}
void Workspace::setBufferEdit( QCompletionEdit *edit )
{
bufferEdit = edit;
connect( bufferEdit, TQT_SIGNAL( chosen( const TQString & ) ),
this, TQT_SLOT( bufferChosen( const TQString & ) ) );
bufferEdit->installEventFilter( this );
}
void Workspace::updateBufferEdit()
{
if ( !bufferEdit || !completionDirty )
return;
completionDirty = false;
#ifndef KOMMANDER
TQStringList completion = MainWindow::self->projectFileNames();
while ( it.current() ) {
( (WorkspaceItem*)it.current())->fillCompletionList( completion );
++it;
}
completion.sort();
bufferEdit->setCompletionList( completion );
#endif
}
void Workspace::bufferChosen( const TQString &buffer )
{
if ( bufferEdit )
bufferEdit->setText( "" );
#ifndef KOMMANDER
if ( MainWindow::self->projectFileNames().contains( buffer ) ) {
MainWindow::self->setCurrentProjectByFilename( buffer );
return;
}
#endif
TQListViewItemIterator it( this );
while ( it.current() ) {
if ( ( (WorkspaceItem*)it.current())->checkCompletion( buffer ) ) {
itemClicked( Qt::LeftButton, it.current(), TQPoint() );
break;
}
++it;
}
}
void Workspace::updateColors()
{
TQListViewItem* i = firstChild();
if ( i )
i = i->firstChild();
bool b = true;
while ( i ) {
WorkspaceItem* wi = ( WorkspaceItem*) i;
i = i->nextSibling();
wi->useOddColor = b;
b = !b;
}
}
#include "workspace.moc"
|