summaryrefslogtreecommitdiffstats
path: root/src/kvirc/ui/kvi_customtoolbar.cpp
blob: b4201299fa24032c280f67ae5f651dca986cdb90 (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
//=============================================================================
//
//   File : kvi_customtoolbar.cpp
//   Created on Sun 21 Nov 2004 05:28:57 by Szymon Stefanek
//
//   This file is part of the KVIrc IRC Client distribution
//   Copyright (C) 2004 Szymon Stefanek <pragma at kvirc dot net>
//
//   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 opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#define __KVIRC__

#include "kvi_customtoolbar.h"
#include "kvi_frame.h"
#include "kvi_locale.h"
#include "kvi_app.h"
#include "kvi_actionmanager.h"
#include "kvi_customtoolbardescriptor.h"

#include <tqcursor.h>
#include "kvi_tal_popupmenu.h"
#include <tqlayout.h>
#include <tqpixmap.h>
#include <tqcursor.h>
#include <tqtoolbutton.h>
#include <tqpainter.h>
#include <tqstyle.h>

#ifdef COMPILE_USE_QT4
	#include <tqevent.h>
	#include <tq3dragobject.h>
	
	#define TQDragObject Q3DragObject
	#define TQTextDrag Q3TextDrag
	#define TQIconDrag Q3IconDrag
	
	#include <tqstyleoption.h>
#else
	#include <tqobjectlist.h>
	#include <tqdragobject.h>
#endif



KviCustomToolBarSeparator::KviCustomToolBarSeparator(KviCustomToolBar *pParent,const char * name)
: TQWidget(pParent,name)
{
	m_pToolBar = pParent;
	setBackgroundMode(pParent->backgroundMode());
	setBackgroundOrigin(ParentOrigin);
	setSizePolicy(TQSizePolicy(TQSizePolicy::Minimum,TQSizePolicy::Minimum));
}

TQSize KviCustomToolBarSeparator::sizeHint() const
{
#ifdef COMPILE_USE_QT4
	TQStyleOption opt;
	opt.initFrom(this);
	int extent = style()->pixelMetric(TQStyle::PM_ToolBarSeparatorExtent,&opt,this);
#else
	int extent = style().pixelMetric(TQStyle::PM_DockWindowSeparatorExtent,this);
#endif
	if(m_pToolBar->orientation() == Qt::Horizontal)return TQSize(extent,0);
	else return TQSize(0,extent);
}

void KviCustomToolBarSeparator::paintEvent(TQPaintEvent *)
{
	TQPainter p(this);
#ifdef COMPILE_USE_QT4
	TQStyleOption opt;
	opt.initFrom(this);
	style()->drawPrimitive(TQStyle::PE_Q3DockWindowSeparator,&opt,&p,this);
#else
	TQStyle::SFlags flags = TQStyle::Style_Default;
	if(m_pToolBar->orientation() == Qt::Horizontal)flags |= TQStyle::Style_Horizontal;
	style().tqdrawPrimitive(TQStyle::PE_DockWindowSeparator,&p,rect(),colorGroup(),flags);
#endif
}


KviCustomToolBar::KviCustomToolBar(KviCustomToolBarDescriptor * d,const TQString &label,TQT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam)
: KviToolBar(label,dock,bNewLine,nam)
{
	m_pDescriptor = d;
	m_pMovedChild = 0;
	m_pDraggedChild = 0;
	m_pFilteredChildren = 0;
	setAcceptDrops(true);
	connect(KviActionManager::instance(),TQT_SIGNAL(beginCustomizeToolBars()),this,TQT_SLOT(beginCustomize()));
	connect(KviActionManager::instance(),TQT_SIGNAL(endCustomizeToolBars()),this,TQT_SLOT(endCustomize()));
	setMinimumSize(20,20);
	d->registerToolBar(this);
	if(KviActionManager::customizingToolBars())
		beginCustomize(); // because we will not get the signal
}

KviCustomToolBar::~KviCustomToolBar()
{
	if(KviActionManager::customizingToolBars())
		syncDescriptor(); // because we will not get endCustomize()
	m_pDescriptor->unregisterToolBar(this);
	if(KviActionManager::customizingToolBars())
	{
		if(KviActionManager::currentToolBar() == this)
			KviActionManager::instance()->setCurrentToolBar(0);
	}
	if(m_pFilteredChildren)delete m_pFilteredChildren;
}

void KviCustomToolBar::paintEvent(TQPaintEvent * e)
{
	KviToolBar::paintEvent(e);
	if(KviActionManager::customizingToolBars() && (KviActionManager::currentToolBar() == this))
	{
		TQPainter p(this);
		p.setPen(TQt::red);
		p.drawRect(0,0,width(),height());
	}
}

void KviCustomToolBar::filteredChildDestroyed()
{
	if(!m_pFilteredChildren)return;
	const TQObject * o = TQT_TQOBJECT(const_cast<TQT_BASE_OBJECT_NAME*>(sender()));
	m_pFilteredChildren->remove((void *)o);
}

void KviCustomToolBar::filterChild(TQObject * o)
{
	bool * b = new bool(((TQWidget *)o)->isEnabled());
	if(m_pFilteredChildren)
		m_pFilteredChildren->insert(o,b);
	if(!*b)((TQWidget *)o)->setEnabled(true);
	o->installEventFilter(this);
	connect(o,TQT_SIGNAL(destroyed()),this,TQT_SLOT(filteredChildDestroyed()));
}

void KviCustomToolBar::unfilterChild(TQObject * o)
{
	if(m_pFilteredChildren)
	{
		bool * b = m_pFilteredChildren->find(o);
		if(b)
		{
			if(!*b)((TQWidget *)o)->setEnabled(false);
			o->removeEventFilter(this);
			disconnect(o,TQT_SIGNAL(destroyed()),this,TQT_SLOT(filteredChildDestroyed()));
		}
	}
}

void KviCustomToolBar::beginCustomize()
{
	if(m_pFilteredChildren)delete m_pFilteredChildren;
	m_pFilteredChildren = new KviPointerHashTable<void *,bool>;
	m_pFilteredChildren->setAutoDelete(true);
	// filter the events for all the children
#ifdef COMPILE_USE_QT4
	TQPtrList<TQObject*> l = children();
	for(TQPtrList<TQObject*>::Iterator it = l.begin();it != l.end();++it)
	{
		if((*it)->isWidgetType())
			filterChild(*it);
	}
#else
	const TQObjectList l = childrenListObject();
	TQObjectListIterator it(l);
	while(TQObject * o = it.current())
	{
		if(o->isWidgetType())
			filterChild(o);
		++it;
	}
#endif
}

void KviCustomToolBar::endCustomize()
{
	// stop filtering events
#ifdef COMPILE_USE_QT4
	TQPtrList<TQObject*> l = children();
	for(TQPtrList<TQObject*>::Iterator it = l.begin();it != l.end();++it)
	{
		if((*it)->isWidgetType())
			unfilterChild(*it);
	}
#else
	const TQObjectList l = childrenListObject();
	TQObjectListIterator it(l);
	while(TQObject * o = it.current())
	{
		if(o->isWidgetType())
			unfilterChild(o);
		++it;
	}
#endif
	// FIXME: We SHOULD MAKE SURE that the children are re-enabled...
	// this could be done by calling setEnabled(isEnabled()) on each action ?
	if(m_pFilteredChildren)
	{
		delete m_pFilteredChildren;
		m_pFilteredChildren = 0;
	}
	syncDescriptor();
}

void KviCustomToolBar::syncDescriptor()
{
	// store the item order in the descriptor
	TQBoxLayout * lay = boxLayout();
	TQLayoutIterator iter = lay->iterator();
	TQLayoutItem * i;
	m_pDescriptor->actions()->clear();
	while((i = iter.current()))
	{
		if(TQWidget * w = i->widget())
			m_pDescriptor->actions()->append(new TQString(w->name()));
		++iter;
	}
}

void KviCustomToolBar::childEvent(TQChildEvent *e)
{
	if(KviActionManager::customizingToolBars())
	{
		// this is useful for droppped and dragged-out children
		if(e->type() == TQEvent::ChildInserted)
		{
			if(e->child()->isWidgetType())
				filterChild(TQT_TQOBJECT(e->child()));
			goto done;
		}
		
		if(e->type() == TQEvent::ChildRemoved)
		{
			if(e->child()->isWidgetType())
				unfilterChild(TQT_TQOBJECT(e->child()));
			goto done;
		}
	}
done:
	KviToolBar::childEvent(e);
}

void KviCustomToolBar::dragEnterEvent(TQDragEnterEvent *e)
{
	if(!KviActionManager::customizingToolBars())return;
	KviActionManager::instance()->setCurrentToolBar(this);
	TQString text;
	if(TQTextDrag::decode(e,text))
	{
		if(!text.isEmpty())
		{
			KviAction * a = KviActionManager::instance()->getAction(text);
			if(a)
			{
				e->accept(true);
				int idx = dropIndexAt(mapFromGlobal(TQCursor::pos()),0,0);
				m_pDraggedChild = a->addToCustomToolBar(this);
#ifdef COMPILE_USE_QT4
				TQWidget * pWidgetToMove = widgetAt(idx);
				bool bDone = false;
				TQAction * a;
				if(pWidgetToMove)
				{
					a = actionForWidget(pWidgetToMove);
					if(a)
					{
						bDone = true;
						a = insertWidget(a,m_pDraggedChild);
					}
				}
				if(!bDone)
					a = addWidget(m_pDraggedChild);
				a->setVisible(true);
#else
				boxLayout()->remove(m_pDraggedChild); // in case it was already added
				boxLayout()->insertWidget(idx,m_pDraggedChild);
#ifdef COMPILE_TDE_SUPPORT
				// bleah ://///
				insertWidget(-1,m_pDraggedChild->sizeHint().width(),m_pDraggedChild,idx);
#endif
#endif
				TQEvent ev(TQEvent::LayoutHint);
				TQApplication::sendEvent(this,&ev);
			} else e->accept(false);
		} else e->accept(false);
	} else e->accept(false);
}

void KviCustomToolBar::dragMoveEvent(TQDragMoveEvent *e)
{
	if(!m_pDraggedChild)return;
	drag(m_pDraggedChild,mapFromGlobal(TQCursor::pos()));
}

void KviCustomToolBar::dragLeaveEvent(TQDragLeaveEvent *e)
{
	if(m_pDraggedChild)
	{
		if(m_pFilteredChildren)
			m_pFilteredChildren->remove(m_pDraggedChild); // just to be sure
		delete m_pDraggedChild;
		m_pDraggedChild = 0;
	}
}

void KviCustomToolBar::dropEvent(TQDropEvent *e)
{
	if(!m_pDraggedChild)return;
	m_pDraggedChild = 0;
	e->accept();
	// nuthin :)
}

int KviCustomToolBar::dropIndexAt(const TQPoint &pnt,TQWidget * exclude,int * excludeIdx)
{
	// find the widget at the current poisition
	// treating exclude as if it was going to be removed
	// find also the exclude index if needed
#ifdef COMPILE_USE_QT4
	TQLayout * l = layout();
#else
	TQBoxLayout * l = boxLayout();
#endif
	TQLayoutItem * i = 0;
	if(excludeIdx)*excludeIdx = -1;
	int idx = 0;

	if(!l)return 0;
	TQLayoutIterator it = l->iterator();
	
	// find the children with minimum distance
	int iMinDistIdx = -1;
	TQWidget * pMinDistW = 0;
	unsigned int uMinDist = 0xffffffff;
	int iExcludeIdx = -1;
	TQPoint pntExclude;
	TQWidget * w = 0;

	while((i = it.current()))
	{
		if((w = i->widget()))
		{
			if(uMinDist != 0)
			{
				int iRight = w->x() + w->width();
				int iBottom = w->y() + w->height();
				if((pnt.x() >= w->x()) && (pnt.y() >= w->y()) && (pnt.x() <= iRight) && (pnt.y() <= iBottom))
				{
					// inside the widget
					// distance 0
					pMinDistW = w;
					iMinDistIdx = idx;
					uMinDist = 0;
				} else {
					// outside the widget
					// compute the distance
					unsigned int uXDist = (pnt.x() < w->x()) ? (w->x() - pnt.x()) : (pnt.x() > iRight ? (pnt.x() - iRight) : 0);
					unsigned int uYDist = (pnt.y() < w->y()) ? (w->y() - pnt.y()) : (pnt.y() > iBottom ? (pnt.y() - iBottom) : 0);
					if((uXDist < 8192) && (uYDist < 8192))
					{
						// it is in reasonable rect
						unsigned int uDist = (uXDist * uXDist) + (uYDist * uYDist);
						if(uDist < uMinDist)
						{
							// min distance for now
							uMinDist = uDist;
							pMinDistW = w;
							iMinDistIdx = idx;
						}
					} // else the user has a really HUUUGE screen
				}
			} // else the minimum distance widget has already been found
			if(w == exclude)
			{
				iExcludeIdx = idx;
				pntExclude = w->pos();
			}
		}
		idx++;
		++it;
	}
	
	if(!pMinDistW)
	{
		// ops.. not found at all (empty toolbar or really far from any button)
		if(orientation() == Qt::Horizontal)
		{
			if(pnt.x() < (width() / 2))iMinDistIdx = 0; // insert at position 0
			else iMinDistIdx = idx;
			// else insert at the last position found
		} else {
			if(pnt.y() < (height() / 2))iMinDistIdx = 0; // insert at position 0
			else iMinDistIdx = idx;
			// else insert at the last position found
		}
	} else {
		// got it, check for the exclude idx
		if((iExcludeIdx == -1) || (iExcludeIdx != iMinDistIdx))
		{
			// would not put it over exclude idx
			// check if we have to stay on right or left of the widget found
			if(orientation() == Qt::Horizontal)
			{
				if(pnt.x() > (pMinDistW->x() + (pMinDistW->width() / 2)))
					iMinDistIdx++; // need to put it on the right
			} else {
				if(pnt.y() > (pMinDistW->y() + (pMinDistW->height() / 2)))
					iMinDistIdx++; // need to put it below
			}
		}
		
		// ok , check again (we might have moved exactly over exclude idx now!)
		if((iExcludeIdx != -1) && (iExcludeIdx != iMinDistIdx))
		{
			// got the exclude idx by the way and wouldn't put exactly over it
			// check if exclude idx is "before" the current possible insert position
			// if it is , then lower down the index by one
			if(orientation() == Qt::Horizontal)
			{
				if(pnt.x() > pntExclude.x())
					iMinDistIdx--; // removing exclude will move everything one step back
			} else {
				if(pnt.y() > pntExclude.y())
					iMinDistIdx--; // removing exclude will move everything one step back
			}
		}
	}

	if(iMinDistIdx < 0)iMinDistIdx = 0;
	if(excludeIdx)*excludeIdx = iExcludeIdx;

	return iMinDistIdx;

}

#ifdef COMPILE_USE_QT4
TQWidget * KviCustomToolBar::widgetAt(int index)
{
	TQLayout * l = layout();
	if(!l)
		return NULL;
	TQLayoutItem * it = l->itemAt(index);
	if(!it)
		return NULL;
	return it->widget();
}

TQAction * KviCustomToolBar::actionForWidget(TQWidget * pWidget)
{
	return actionAt(pWidget->x() + 1,pWidget->y() + 1);
}

#endif

void KviCustomToolBar::drag(TQWidget * child,const TQPoint &pnt)
{
	int me = -1;
	int idx = dropIndexAt(pnt,child,&me);
	tqDebug("DROP INDEX IS %d, ME IS %d",idx,me);
	if(idx == me)
		return; // would move over itself
#ifdef COMPILE_USE_QT4
	TQWidget * pWidgetToMove = widgetAt(idx > me ? idx-1 : idx);
	tqDebug("SEARCHING FOR WIDGET TO MOVE AT %d AND FOUND %x (ME=%x)",idx > me ? idx-1 : idx,pWidgetToMove,child);
	if(pWidgetToMove == child)
		return; // hmmm
	bool bDone = false;
	TQAction * pMyOwnAction = actionForWidget(child);
	if(!pMyOwnAction)
		return;
	TQAction * a;
	removeAction(pMyOwnAction);
	if(pWidgetToMove)
	{
		a = actionForWidget(pWidgetToMove);
		if(a)
		{
			tqDebug("AND GOT ACTION FOR THAT WIDGET");

			bDone = true;
			a = insertWidget(a,child);
		}
	} else {
		addAction(a);
	}
	if(!bDone)
		a = addWidget(child);
	a->setVisible(true);
#else
	boxLayout()->remove(child);
	boxLayout()->insertWidget(idx,child);
#ifdef COMPILE_TDE_SUPPORT
	// bleah ://///
	insertWidget(-1,child->width(),child,idx);
#endif
#endif
	TQEvent ev(TQEvent::LayoutHint);
	TQApplication::sendEvent(this,&ev);
}

void KviCustomToolBar::mousePressEvent(TQMouseEvent * e)
{
	if(KviActionManager::customizingToolBars())
		KviActionManager::instance()->setCurrentToolBar(this);
	KviToolBar::mousePressEvent(e);
}

bool KviCustomToolBar::eventFilter(TQObject *o,TQEvent *e)
{
	if(!KviActionManager::customizingToolBars())goto unhandled; // anything here is done when customizing only
	if(e->type() == TQEvent::Enter)
	{
		if(m_pMovedChild)return true; // kill it while moving other children
	}
	if(e->type() == TQEvent::Leave)
	{
		if(m_pMovedChild)return true; // kill it while moving other children
	}
	if(e->type() == TQEvent::MouseButtonPress)
	{
		KviActionManager::instance()->setCurrentToolBar(this);
		TQMouseEvent * ev = (TQMouseEvent *)e;
		if(ev->button() & Qt::LeftButton)
		{
			if(o->isWidgetType())
			{
				if(!(
					o->inherits("KviTalPopupMenu") ||
					o->inherits("TQToolBarHandle") ||
					o->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ||
					o->inherits("TQDockWindowResizeHandle") ||
					o->inherits("TQToolBarExtensionWidget")
					))
				{
					m_pMovedChild = (TQWidget *)o;
					// allow resizing of children
					// FIXME: do it only if the child is really resizable
					if(m_pMovedChild->width() > 20) // might be an applet
					{
						if(ev->pos().x() > (m_pMovedChild->width() - 4))
						{
							m_pMovedChild = 0;
							goto unhandled; // let the applet handle the event it
						}
					}
					g_pApp->setOverrideCursor(TQt::sizeAllCursor);
					return true;
				}
			}
		}
		goto unhandled;
	}
	if(e->type() == TQEvent::MouseButtonRelease)
	{
		if(m_pMovedChild)
		{
			g_pApp->restoreOverrideCursor();
			m_pMovedChild = 0;
			return true;
		}
		goto unhandled;
	}
	if(e->type() == TQEvent::MouseMove)
	{
		if(m_pMovedChild)
		{
			TQMouseEvent * ev = (TQMouseEvent *)e;

			TQPoint pnt = mapFromGlobal(m_pMovedChild->mapToGlobal(ev->pos()));
			if((pnt.y() < 0) || (pnt.y() > height()) || (pnt.x() < 0) || (pnt.x() > width()))
			{
				// drag out!
// FIXME: This is screwed up in TQt4.... :/
#ifdef COMPILE_USE_QT4
				TQDrag * d = new TQDrag(this);
				TQMimeData * m = new TQMimeData();
				m->setText(m_pMovedChild->name());
				d->setMimeData(m);
#else
				TQDragObject * d = new TQTextDrag(m_pMovedChild->name(),this);
#endif
				KviAction * act = KviActionManager::instance()->getAction(m_pMovedChild->name());
				if(act)
				{
					TQPixmap * pixie = act->bigIcon();
#ifdef COMPILE_USE_QT4
					if(pixie)
					{
						d->setPixmap(*pixie);
						d->setHotSpot(TQPoint(3,3));
					}
#else
					if(pixie)d->setPixmap(*pixie,TQPoint(3,3));
#endif
				}
				//d->setPixmap(TQPixmap::grabWidget(m_pMovedChild),TQPoint(m_pMovedChild->width() / 2,m_pMovedChild->height() / 2));
				// throw it somewhere else for now
				if(m_pFilteredChildren)
					unfilterChild(TQT_TQOBJECT(m_pMovedChild));
#ifdef COMPILE_USE_QT4
				TQAction * pActionForMovedChild = actionForWidget(m_pMovedChild);
				if(pActionForMovedChild)
					pActionForMovedChild->setVisible(false);
				m_pMovedChild->hide();
#else
				m_pMovedChild->hide();
				m_pMovedChild->reparent(g_pFrame,TQPoint(-1000,-1000),false);
#endif
				TQEvent ev(TQEvent::LayoutHint);
				TQApplication::sendEvent(this,&ev);
#ifdef COMPILE_USE_QT4
				if(!d->exec(TQt::MoveAction) != TQt::MoveAction)
#else
				if(!d->dragMove())
#endif
				{
					// the user has probably failed to remove the action from the toolbar
					// flash the trashcan in the customize toolbars dialog
					KviActionManager::instance()->emitRemoveActionsHintRequest();
					// will filter it as ChildInserted
#ifndef COMPILE_USE_QT4
					m_pMovedChild->reparent(this,TQPoint(0,0),false);
#endif
#ifdef COMPILE_USE_QT4
					TQAction * pActionForMovedChild = actionForWidget(m_pMovedChild);
					if(pActionForMovedChild)
						pActionForMovedChild->setVisible(false);
#else
					boxLayout()->insertWidget(0,m_pMovedChild);
					m_pMovedChild->show();
#ifdef COMPILE_TDE_SUPPORT
					// bleah ://///
					insertWidget(-1,m_pMovedChild->width(),m_pMovedChild,0);
#endif
#endif
					TQEvent ev(TQEvent::LayoutHint);
					TQApplication::sendEvent(this,&ev);
				} else {
					TQApplication::sendPostedEvents(m_pMovedChild,0);
					m_pMovedChild->deleteLater();
					m_pMovedChild = 0;
				}
				return true;
			}

			drag(m_pMovedChild,pnt);
			return true;
		}
		goto unhandled;
	}
unhandled:
	return KviToolBar::eventFilter(o,e);
}