summaryrefslogtreecommitdiffstats
path: root/kompare/komparepart/komparesplitter.cpp
blob: 64f3d51851120fa0b2edcd3f6c8333c2ad2d2f56 (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
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
/***************************************************************************
                                komparesplitter.cpp  -  description
                                -------------------
        begin                   : Wed Jan 14 2004
        copyright               : (C) 2004 by Jeff Snyder
        email                   : jeff@caffeinated.me.uk
****************************************************************************/

/***************************************************************************
**
**   This program is free software; you can redistribute it and/or modify
**   it under the terms of the GNU General Public License as published by
**   the Free Software Foundation; either version 2 of the License, or
**   (at your option) any later version.
**
***************************************************************************/

#include "komparesplitter.h"

#include <tqstyle.h>
#include <tqstring.h>
#include <tqtimer.h>

#include <kdebug.h>
#include <tdeapplication.h>
#include <tdeglobalsettings.h>

#include "diffmodel.h"
#include "difference.h"
#include "viewsettings.h"
#include "kompare_part.h"
#include "komparelistview.h"
#include "kompareconnectwidget.h"

using namespace Diff2;

KompareSplitter::KompareSplitter( ViewSettings *settings, TQWidget * parent,
                                  const char *name) :
	TQSplitter(TQt::Horizontal, parent, name ),
	m_settings( settings )
{
	TQFrame *scrollFrame = new TQFrame( parent, "scrollFrame" );
	reparent( scrollFrame, *(new TQPoint()), false );

	// Set up the scrollFrame
	scrollFrame->setFrameStyle( TQFrame::NoFrame | TQFrame::Plain );
	scrollFrame->setLineWidth(scrollFrame->style().pixelMetric(TQStyle::PM_DefaultFrameWidth));
	TQGridLayout *pairlayout = new TQGridLayout(scrollFrame, 2, 2, 0);
	m_vScroll = new TQScrollBar( TQt::Vertical, scrollFrame );
	pairlayout->addWidget( m_vScroll, 0, 1 );
	m_hScroll = new TQScrollBar( TQt::Horizontal, scrollFrame );
	pairlayout->addWidget( m_hScroll, 1, 0 );

	new KompareListViewFrame(true, m_settings, this, "source");
	new KompareListViewFrame(false, m_settings, this, "destination");
	pairlayout->addWidget( this, 0, 0 );

	// set up our looks
	setFrameStyle( TQFrame::StyledPanel | TQFrame::Sunken );
	setLineWidth( style().pixelMetric( TQStyle::PM_DefaultFrameWidth ) );

	setHandleWidth(50);
	setChildrenCollapsible( false );
	setFrameStyle( TQFrame::NoFrame );
	setSizePolicy( TQSizePolicy (TQSizePolicy::Ignored, TQSizePolicy::Ignored ));
	setOpaqueResize( true );
	setFocusPolicy( TQWidget::WheelFocus );

	connect( this, TQ_SIGNAL(configChanged()), TQ_SLOT(slotConfigChanged()) );
	connect( this, TQ_SIGNAL(configChanged()), TQ_SLOT(slotDelayedRepaintHandles()) );
	connect( this, TQ_SIGNAL(configChanged()), TQ_SLOT(slotDelayedUpdateScrollBars()) );
	
	// scrolling
	connect( m_vScroll, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(scrollToId(int)) );
	connect( m_vScroll, TQ_SIGNAL(sliderMoved(int)),  TQ_SLOT(scrollToId(int)) );
	connect( m_hScroll, TQ_SIGNAL(valueChanged(int)), TQ_SIGNAL(setXOffset(int)) );
	connect( m_hScroll, TQ_SIGNAL(sliderMoved(int)),  TQ_SIGNAL(setXOffset(int)) );

	m_scrollTimer=new TQTimer();
	restartTimer = false;
	connect (m_scrollTimer, TQ_SIGNAL(timeout()), TQ_SLOT(timerTimeout()) );

	// we need to receive childEvents now so that d->list is ready for when
	// slotSetSelection(...) arrives
	kapp->sendPostedEvents(this, TQEvent::ChildInserted);

	// init stuff
	slotUpdateScrollBars();
}

KompareSplitter::~KompareSplitter(){}

/*
    Inserts the widget \a w at the end (or at the beginning if \a
    prepend is TRUE) of the splitter's list of widgets.

    It is the responsibility of the caller to make sure that \a w is
    not already in the splitter and to call recalcId() if needed. (If
    \a prepend is TRUE, then recalcId() is very probably needed.)
*/

TQSplitterLayoutStruct *KompareSplitter::addWidget( KompareListViewFrame *w, bool prepend )
{
	/* This function is *not* a good place to make connections to and from
	 * the KompareListView. Make them in the KompareListViewFrame constructor
	 * instad - that way the connections get made upon creation, not upon the
	 * next processing of the event queue. */

	TQSplitterLayoutStruct *s;
	KompareConnectWidgetFrame *newHandle = 0;
	if ( d->list.count() > 0 ) {
		s = new TQSplitterLayoutStruct;
		s->resizeMode = KeepSize;
		TQString tmp = "qt_splithandle_";
		tmp += w->name();
		KompareListView *lw = 
			((KompareListViewFrame*)(prepend?w:d->list.last()->wid))->view();
		KompareListView *rw = 
			((KompareListViewFrame*)(prepend?d->list.first()->wid:w))->view();
		newHandle = new KompareConnectWidgetFrame(lw, rw, m_settings, this, tmp.latin1());
		s->wid = newHandle;
		newHandle->setId( d->list.count() );
		s->isHandle = TRUE;
		s->sizer = pick( newHandle->sizeHint() );
		if ( prepend )
		    d->list.prepend( s );
		else
		    d->list.append( s );
	}
	s = new TQSplitterLayoutStruct;
	s->resizeMode = DefaultResizeMode;
	s->wid = w;
	s->isHandle = FALSE;
	if ( prepend ) d->list.prepend( s );
	else d->list.append( s );
	if ( newHandle && isVisible() )
		newHandle->show(); // will trigger sending of post events
	return s;
}


/*!
    Tells the splitter that the child widget described by \a c has
    been inserted or removed.
*/

void KompareSplitter::childEvent( TQChildEvent *c )
{
    if ( c->type() == TQEvent::ChildInserted ) {
		if ( !c->child()->isWidgetType() )
			return;

		if ( ((TQWidget*)c->child())->testWFlags( WType_TopLevel ) )
			return;

		TQSplitterLayoutStruct *s = d->list.first();
		while ( s ) {
			if ( s->wid == c->child() )
				return;
			s = d->list.next();
		}
		addWidget( (KompareListViewFrame*)c->child() );
		recalc( isVisible() );
    } else if ( c->type() == TQEvent::ChildRemoved ) {
		TQSplitterLayoutStruct *prev = 0;
		if ( d->list.count() > 1 )
			prev = d->list.at( 1 );  // yes, this is correct
		TQSplitterLayoutStruct *curr = d->list.first();
		while ( curr ) {
			if ( curr->wid == c->child() ) {
			d->list.removeRef( curr );
			if ( prev && prev->isHandle ) {
				TQWidget *w = prev->wid;
				d->list.removeRef( prev );
				delete w; // will call childEvent()
			}
			recalcId();
			doResize();
			return;
			}
			prev = curr;
			curr = d->list.next();
		}
	}
}

// This is from a private qt header (kernel/qlayoutengine_p.h). sorry.
TQSize qSmartMinSize( TQWidget *w );

static TQPoint toggle( TQWidget *w, TQPoint pos )
{
    TQSize minS = qSmartMinSize( w );
    return -pos - TQPoint( minS.width(), minS.height() );
}

static bool isCollapsed( TQWidget *w )
{
    return w->x() < 0 || w->y() < 0;
}

static TQPoint topLeft( TQWidget *w )
{
    if ( isCollapsed(w) ) {
        return toggle( w, w->pos() );
    } else {
        return w->pos();
    }
}

static TQPoint bottomRight( TQWidget *w )
{
    if ( isCollapsed(w) ) {
        return toggle( w, w->pos() ) - TQPoint( 1, 1 );
    } else {
        return w->geometry().bottomRight();
    }
}

void KompareSplitter::moveSplitter( TQCOORD p, int id )
{
	TQSplitterLayoutStruct *s = d->list.at( id );
	int farMin;
	int min;
	int max;
	int farMax;
	p = adjustPos( p, id, &farMin, &min, &max, &farMax );
	int oldP = pick( s->wid->pos() );
	int* poss = new int[d->list.count()];
	int* ws = new int[d->list.count()];
	TQWidget *w = 0;
	bool upLeft;
	if ( TQApplication::reverseLayout() && orient ==TQt::Horizontal ) {
		int q = p + s->wid->width();
		doMove( FALSE, q, id - 1, -1, (p > max), poss, ws );
		doMove( TRUE, q, id, -1, (p < min), poss, ws );
		upLeft = (q > oldP);
	} else {
		doMove( FALSE, p, id, +1, (p > max), poss, ws );
		doMove( TRUE, p, id - 1, +1, (p < min), poss, ws );
		upLeft = (p < oldP);
	}
	if ( upLeft ) {
		int count = d->list.count();
		for ( int id = 0; id < count; ++id ) {
			w = d->list.at( id )->wid;
			if( !w->isHidden() )
				setGeo( w, poss[id], ws[id], TRUE );
		}
	} else {
		for ( int id = d->list.count() - 1; id >= 0; --id ) {
			w = d->list.at( id )->wid;
			if( !w->isHidden() )
				setGeo( w, poss[id], ws[id], TRUE );
		}
	}
	storeSizes();
}

void KompareSplitter::doMove( bool backwards, int pos, int id, int delta,
                        bool mayCollapse, int* positions, int* widths )
{
	TQSplitterLayoutStruct *s;
	TQWidget *w;
	for ( ; id >= 0 && id < (int)d->list.count();
			id = backwards ? id - delta : id + delta ) {
		s = d->list.at( id );
		w = s->wid;
		if ( w->isHidden() ) {
			mayCollapse = TRUE;
		} else {
			if ( s->isHandle ) {
				int dd = s->getSizer( orient );
				int nextPos = backwards ? pos - dd : pos + dd;
				positions[id] = pos;
				widths[id] = dd;
				pos = nextPos;
			} else {
				int dd = backwards ? pos - pick( topLeft(w) )
				                   : pick( bottomRight(w) ) - pos + 1;
				if ( dd > 0 || (!isCollapsed(w) && !mayCollapse) ) {
					dd = TQMAX( pick(qSmartMinSize(w)),
					           TQMIN(dd, pick(w->maximumSize())) );
				} else {
					dd = 0;
				}
				positions[id] = backwards ? pos - dd : pos;
				widths[id] = dd;
				pos = backwards ? pos - dd : pos + dd;
				mayCollapse = TRUE;
			}
		}
	}
}

void KompareSplitter::slotSetSelection( const DiffModel* model, const Difference* diff )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if ( curr->isHandle )
			((KompareConnectWidgetFrame*)
				curr->wid)->wid()->slotSetSelection( model, diff );
		else
		{
			((KompareListViewFrame*)
				curr->wid)->view()->slotSetSelection( model, diff );
			((KompareListViewFrame*)
				curr->wid)->slotSetModel( model );
		}
	}
	slotDelayedRepaintHandles();
	slotDelayedUpdateScrollBars();
}

void KompareSplitter::slotSetSelection( const Difference* diff )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( curr->isHandle )
			((KompareConnectWidgetFrame*)
				curr->wid)->wid()->slotSetSelection( diff );
		else
			((KompareListViewFrame*)
				curr->wid)->view()->slotSetSelection( diff );
	slotDelayedRepaintHandles();
	slotDelayedUpdateScrollBars();
}

void KompareSplitter::slotApplyDifference( bool apply )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			((KompareListViewFrame*)
				curr->wid)->view()->slotApplyDifference( apply );
	slotDelayedRepaintHandles();
}

void KompareSplitter::slotApplyAllDifferences( bool apply )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			((KompareListViewFrame*)
				curr->wid)->view()->slotApplyAllDifferences( apply );
	slotDelayedRepaintHandles();
	scrollToId( scrollTo ); // FIXME!
}

void KompareSplitter::slotApplyDifference( const Difference* diff, bool apply )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			((KompareListViewFrame*)
				curr->wid)->view()->slotApplyDifference( diff, apply );
	slotDelayedRepaintHandles();
}

void KompareSplitter::slotDifferenceClicked( const Difference* diff )
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			((KompareListViewFrame*)
				curr->wid)->view()->setSelectedDifference( diff, false );
	emit selectionChanged( diff );
}

void KompareSplitter::slotConfigChanged()
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() ) {
		if ( !curr->isHandle )
		{
			((KompareListViewFrame*)
				curr->wid)->view()->setSpaces( m_settings->m_tabToNumberOfSpaces );
			((KompareListViewFrame*)
				curr->wid)->view()->setFont( m_settings->m_font );
			((KompareListViewFrame*)
				curr->wid)->view()->update();
		}
	}
}

void KompareSplitter::slotDelayedRepaintHandles()
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		 if ( curr->isHandle )
			((KompareConnectWidgetFrame*)curr->wid)->wid()->slotDelayedRepaint();
}

void KompareSplitter::repaintHandles()
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( curr->isHandle )
			((KompareConnectWidgetFrame*)curr->wid)->wid()->repaint();
}

// Scrolling stuff
/*
 * limit updating to once every 50 msec with a qtimer
 * FIXME: i'm a nasty hack
 */

void KompareSplitter::wheelEvent( TQWheelEvent* e )
{
	// scroll lines...
	if ( e->orientation() == TQt::Vertical )
	{
		if ( e->state() & TQt::ControlButton )
			if ( e->delta() < 0 ) // scroll down one page
				m_vScroll->addPage();
			else // scroll up one page
				m_vScroll->subtractPage();
		else
			if ( e->delta() < 0 ) // scroll down
				m_vScroll->addLine();
			else // scroll up
				m_vScroll->subtractLine();
	}
	else
	{
		if ( e->state() & TQt::ControlButton )
			if ( e->delta() < 0 ) // scroll right one page
				m_hScroll->addPage();
			else // scroll left one page
				m_hScroll->subtractPage();
		else
			if ( e->delta() < 0 ) // scroll to the right
				m_hScroll->addLine();
			else // scroll to the left
				m_hScroll->subtractLine();
	}
	e->accept();
	repaintHandles();
}

void KompareSplitter::keyPressEvent( TQKeyEvent* e )
{
	//keyboard scrolling
	switch ( e->key() ) {
	case Key_Right:
	case Key_L:
		m_hScroll->addLine();
		break;
	case Key_Left:
	case Key_H:
		m_hScroll->subtractLine();
		break;
	case Key_Up:
	case Key_K:
		m_vScroll->subtractLine();
		break;
	case Key_Down:
	case Key_J:
		m_vScroll->addLine();
		break;
	case Key_PageDown:
		m_vScroll->addPage();
		break;
	case Key_PageUp:
		m_vScroll->subtractPage();
		break;
	}
	e->accept();
	repaintHandles();
}

void KompareSplitter::timerTimeout()
{
	if ( restartTimer )
		restartTimer = false;
	else
		m_scrollTimer->stop();

	slotDelayedRepaintHandles();	

	emit scrollViewsToId( scrollTo );
}

void KompareSplitter::scrollToId( int id )
{
	scrollTo = id;

	if( restartTimer )
		return;

	if( m_scrollTimer->isActive() )
	{
		restartTimer = true;
	}
	else
	{
		emit scrollViewsToId( id );
		slotDelayedRepaintHandles();
		m_scrollTimer->start(30, false);
	}
}

void KompareSplitter::slotDelayedUpdateScrollBars()
{
	TQTimer::singleShot( 0, this, TQ_SLOT( slotUpdateScrollBars() ) );
}

void KompareSplitter::slotUpdateScrollBars()
{
	int m_scrollDistance = m_settings->m_scrollNoOfLines * lineSpacing();
	int m_pageSize = pageSize();

	if( needVScrollBar() )
	{
		m_vScroll->show();

		m_vScroll->blockSignals( true );
		m_vScroll->setRange( minVScrollId(), 
		                     maxVScrollId() );
		m_vScroll->setValue( scrollId() );
		m_vScroll->setSteps( m_scrollDistance, m_pageSize );
		m_vScroll->blockSignals( false );
	}
	else
	{
		m_vScroll->hide();
	}

	if( needHScrollBar() )
	{
		m_hScroll->show();
		m_hScroll->blockSignals( true );
		m_hScroll->setRange( 0, maxHScrollId() );
		m_hScroll->setValue( maxContentsX() );
		m_hScroll->setSteps( 10, minVisibleWidth() - 10 );
		m_hScroll->blockSignals( false );
	}
	else
	{
		m_hScroll->hide();
	}
}

void KompareSplitter::slotDelayedUpdateVScrollValue()
{
	TQTimer::singleShot( 0, this, TQ_SLOT( slotUpdateVScrollValue() ) );
}

void KompareSplitter::slotUpdateVScrollValue()
{
	m_vScroll->setValue( scrollId() );
}

/* FIXME: this should return the scrollId() from the listview containing the
 * /base/ of the diff. but there's bigger issues with that atm.
 */
 
int KompareSplitter::scrollId()
{
	TQSplitterLayoutStruct *curr = d->list.first();
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			return ((KompareListViewFrame*) curr->wid)->view()->scrollId();
	return minVScrollId();
}

int KompareSplitter::lineSpacing()
{
	TQSplitterLayoutStruct *curr = d->list.first();
	for ( curr = d->list.first(); curr; curr = d->list.next() )
		if ( !curr->isHandle )
			return ((KompareListViewFrame*)
				curr->wid)->view()->fontMetrics().lineSpacing();
	return 1;
}

int KompareSplitter::pageSize()
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if ( !curr->isHandle )
		{
			KompareListView *view = ((KompareListViewFrame*) curr->wid)->view();
			return view->visibleHeight() - TQStyle::PM_ScrollBarExtent;
		}
	}
	return 1;
}

bool KompareSplitter::needVScrollBar()
{
	TQSplitterLayoutStruct *curr;
	int pagesize = pageSize();
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if( !curr->isHandle )
		{
			KompareListView *view = ((KompareListViewFrame*) curr->wid)->view();
			if( view ->contentsHeight() > pagesize)
				return true;
		}
	}
	return false;
}

int KompareSplitter::minVScrollId()
{

	TQSplitterLayoutStruct *curr;
	int min = -1;
	int mSId;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if(!curr->isHandle) {
			KompareListView* view = ((KompareListViewFrame*)curr->wid)->view();
			mSId = view->minScrollId();
			if (mSId < min || min == -1) min = mSId;
		}
	}
	return ( min == -1 ) ? 0 : min;
}

int KompareSplitter::maxVScrollId()
{
	TQSplitterLayoutStruct *curr;
	int max = 0;
	int mSId;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if ( !curr->isHandle )
		{
			mSId = ((KompareListViewFrame*)curr->wid)->view()->maxScrollId();
			if ( mSId > max )
				max = mSId;
		}
	}
	return max;
}

bool KompareSplitter::needHScrollBar()
{
	TQSplitterLayoutStruct *curr;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if( !curr->isHandle )
		{
			KompareListView *view = ((KompareListViewFrame*) curr->wid)->view();
			if ( view->contentsWidth() > view->visibleWidth() )
				return true;
		}
	}
	return false;
}

int KompareSplitter::maxHScrollId()
{
	TQSplitterLayoutStruct *curr;
	int max = 0;
	int mHSId;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if( !curr->isHandle )
		{
			KompareListView *view = ((KompareListViewFrame*) curr->wid)->view();
			mHSId = view->contentsWidth() - view->visibleWidth();
			if ( mHSId > max )
				max = mHSId;
		}
	}
	return max;
}

int KompareSplitter::maxContentsX()
{
	TQSplitterLayoutStruct *curr;
	int max = 0;
	int mCX;
	for ( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if ( !curr->isHandle )
		{
			mCX = ((KompareListViewFrame*) curr->wid)->view()->contentsX();
			if ( mCX > max )
				max = mCX;
		}
	}
	return max;
}

int KompareSplitter::minVisibleWidth()
{
	// Why the hell do we want to know this?
	// ah yes, its because we use it to set the "page size" for horiz. scrolling.
	// despite the fact that *noone* has a pgright and pgleft key :P
	// But we do have mousewheels with horizontal scrolling functionality,
	// pressing shift and scrolling then goes left and right one page at the time
	TQSplitterLayoutStruct *curr;
	int min = -1;
	int vW;
	for( curr = d->list.first(); curr; curr = d->list.next() )
	{
		if ( !curr->isHandle ) {
			vW = ((KompareListViewFrame*)curr->wid)->view()->visibleWidth();
			if ( vW < min || min == -1 )
				min = vW;
		}
	}
	return ( min == -1 ) ? 0 : min;
}

#include "komparesplitter.moc"