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
|
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "widgetselection.h"
#include "formwindow.h"
#include "formwindowmanager.h"
// sdk
#include <QtDesigner/QDesignerFormEditorInterface>
#include <QtDesigner/QExtensionManager>
// shared
#include <qdesigner_command_p.h>
#include <qdesigner_propertycommand_p.h>
#include <layout_p.h>
#include <layoutinfo_p.h>
#include <formwindowbase_p.h>
#include <grid_p.h>
#include <QtGui/QMenu>
#include <QtGui/QWidget>
#include <QtGui/QMouseEvent>
#include <QtGui/QStylePainter>
#include <QtGui/QGridLayout>
#include <QtGui/QFormLayout>
#include <QtGui/QStyleOptionToolButton>
#include <QtGui/QApplication>
#include <QtCore/QVariant>
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
namespace qdesigner_internal {
enum { debugWidgetSelection = 0 };
// Return the layout the widget is in
template <class Layout>
static inline Layout *managedLayoutOf(const QDesignerFormEditorInterface *core,
QWidget *w,
const Layout * /* vs6dummy */ = 0)
{
if (QWidget *p = w->parentWidget())
if (QLayout *l = LayoutInfo::managedLayout(core, p))
return qobject_cast<Layout*>(l);
return 0;
}
// ----------- WidgetHandle
WidgetHandle::WidgetHandle(FormWindow *parent, WidgetHandle::Type t, WidgetSelection *s) :
InvisibleWidget(parent->formContainer()),
m_widget(0),
m_type(t),
m_formWindow( parent),
m_sel(s),
m_active(true)
{
setMouseTracking(false);
setAutoFillBackground(true);
setBackgroundRole(m_active ? QPalette::Text : QPalette::Dark);
setFixedSize(6, 6);
updateCursor();
}
void WidgetHandle::updateCursor()
{
#ifndef QT_NO_CURSOR
if (!m_active) {
setCursor(Qt::ArrowCursor);
return;
}
switch (m_type) {
case LeftTop:
setCursor(Qt::SizeFDiagCursor);
break;
case Top:
setCursor(Qt::SizeVerCursor);
break;
case RightTop:
setCursor(Qt::SizeBDiagCursor);
break;
case Right:
setCursor(Qt::SizeHorCursor);
break;
case RightBottom:
setCursor(Qt::SizeFDiagCursor);
break;
case Bottom:
setCursor(Qt::SizeVerCursor);
break;
case LeftBottom:
setCursor(Qt::SizeBDiagCursor);
break;
case Left:
setCursor(Qt::SizeHorCursor);
break;
default:
Q_ASSERT(0);
}
#endif
}
QDesignerFormEditorInterface *WidgetHandle::core() const
{
if (m_formWindow)
return m_formWindow->core();
return 0;
}
void WidgetHandle::setActive(bool a)
{
m_active = a;
setBackgroundRole(m_active ? QPalette::Text : QPalette::Dark);
updateCursor();
}
void WidgetHandle::setWidget(QWidget *w)
{
m_widget = w;
}
void WidgetHandle::paintEvent(QPaintEvent *)
{
QDesignerFormWindowManagerInterface *m = m_formWindow->core()->formWindowManager();
QStylePainter p(this);
if (m_formWindow->currentWidget() == m_widget) {
p.setPen(m->activeFormWindow() == m_formWindow ? Qt::blue : Qt::red);
p.drawRect(0, 0, width() - 1, height() - 1);
}
}
void WidgetHandle::mousePressEvent(QMouseEvent *e)
{
e->accept();
if (!m_formWindow->hasFeature(FormWindow::EditFeature))
return;
if (!(m_widget && e->button() == Qt::LeftButton))
return;
if (!(m_active))
return;
QWidget *container = m_widget->parentWidget();
m_origPressPos = container->mapFromGlobal(e->globalPos());
m_geom = m_origGeom = m_widget->geometry();
}
void WidgetHandle::mouseMoveEvent(QMouseEvent *e)
{
if (!(m_widget && m_active && e->buttons() & Qt::LeftButton))
return;
e->accept();
QWidget *container = m_widget->parentWidget();
const QPoint rp = container->mapFromGlobal(e->globalPos());
const QPoint d = rp - m_origPressPos;
const QRect pr = container->rect();
qdesigner_internal::Grid grid;
if (const qdesigner_internal::FormWindowBase *fwb = qobject_cast<const qdesigner_internal::FormWindowBase*>(m_formWindow))
grid = fwb->designerGrid();
switch (m_type) {
case LeftTop: {
if (rp.x() > pr.width() - 2 * width() || rp.y() > pr.height() - 2 * height())
return;
int w = m_origGeom.width() - d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
int h = m_origGeom.height() - d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
const int dx = m_widget->width() - w;
const int dy = m_widget->height() - h;
trySetGeometry(m_widget, m_widget->x() + dx, m_widget->y() + dy, w, h);
} break;
case Top: {
if (rp.y() > pr.height() - 2 * height())
return;
int h = m_origGeom.height() - d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
const int dy = m_widget->height() - h;
trySetGeometry(m_widget, m_widget->x(), m_widget->y() + dy, m_widget->width(), h);
} break;
case RightTop: {
if (rp.x() < 2 * width() || rp.y() > pr.height() - 2 * height())
return;
int h = m_origGeom.height() - d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
const int dy = m_widget->height() - h;
int w = m_origGeom.width() + d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
trySetGeometry(m_widget, m_widget->x(), m_widget->y() + dy, w, h);
} break;
case Right: {
if (rp.x() < 2 * width())
return;
int w = m_origGeom.width() + d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
tryResize(m_widget, w, m_widget->height());
} break;
case RightBottom: {
if (rp.x() < 2 * width() || rp.y() < 2 * height())
return;
int w = m_origGeom.width() + d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
int h = m_origGeom.height() + d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
tryResize(m_widget, w, h);
} break;
case Bottom: {
if (rp.y() < 2 * height())
return;
int h = m_origGeom.height() + d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
tryResize(m_widget, m_widget->width(), h);
} break;
case LeftBottom: {
if (rp.x() > pr.width() - 2 * width() || rp.y() < 2 * height())
return;
int w = m_origGeom.width() - d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
int h = m_origGeom.height() + d.y();
m_geom.setHeight(h);
h = grid.widgetHandleAdjustY(h);
int dx = m_widget->width() - w;
trySetGeometry(m_widget, m_widget->x() + dx, m_widget->y(), w, h);
} break;
case Left: {
if (rp.x() > pr.width() - 2 * width())
return;
int w = m_origGeom.width() - d.x();
m_geom.setWidth(w);
w = grid.widgetHandleAdjustX(w);
const int dx = m_widget->width() - w;
trySetGeometry(m_widget, m_widget->x() + dx, m_widget->y(), w, m_widget->height());
} break;
default: break;
} // end switch
m_sel->updateGeometry();
if (LayoutInfo::layoutType(m_formWindow->core(), m_widget) != LayoutInfo::NoLayout)
m_formWindow->updateChildSelections(m_widget);
}
void WidgetHandle::mouseReleaseEvent(QMouseEvent *e)
{
if (e->button() != Qt::LeftButton || !m_active)
return;
e->accept();
if (!m_formWindow->hasFeature(FormWindow::EditFeature))
return;
switch (WidgetSelection::widgetState(m_formWindow->core(), m_widget)) {
case WidgetSelection::UnlaidOut:
if (m_geom != m_widget->geometry()) {
SetPropertyCommand *cmd = new SetPropertyCommand(m_formWindow);
cmd->init(m_widget, QLatin1String("geometry"), m_widget->geometry());
cmd->setOldValue(m_origGeom);
m_formWindow->commandHistory()->push(cmd);
m_formWindow->emitSelectionChanged();
}
break;
case WidgetSelection::LaidOut:
break;
case WidgetSelection::ManagedGridLayout:
changeGridLayoutItemSpan();
break;
case WidgetSelection::ManagedFormLayout:
changeFormLayoutItemSpan();
break;
}
}
// Match the left/right widget handle mouse movements to form layout span-changing operations
static inline int formLayoutLeftHandleOperation(int dx, unsigned possibleOperations)
{
if (dx < 0) {
if (possibleOperations & ChangeFormLayoutItemRoleCommand::FieldToSpanning)
return ChangeFormLayoutItemRoleCommand::FieldToSpanning;
return 0;
}
if (possibleOperations & ChangeFormLayoutItemRoleCommand::SpanningToField)
return ChangeFormLayoutItemRoleCommand::SpanningToField;
return 0;
}
static inline int formLayoutRightHandleOperation(int dx, unsigned possibleOperations)
{
if (dx < 0) {
if (possibleOperations & ChangeFormLayoutItemRoleCommand::SpanningToLabel)
return ChangeFormLayoutItemRoleCommand::SpanningToLabel;
return 0;
}
if (possibleOperations & ChangeFormLayoutItemRoleCommand::LabelToSpanning)
return ChangeFormLayoutItemRoleCommand::LabelToSpanning;
return 0;
}
// Change form layout item horizontal span
void WidgetHandle::changeFormLayoutItemSpan()
{
QUndoCommand *cmd = 0;
// Figure out command according to the movement
const int dx = m_widget->geometry().center().x() - m_origGeom.center().x();
if (qAbs(dx) >= QApplication::startDragDistance()) {
int operation = 0;
if (const unsigned possibleOperations = ChangeFormLayoutItemRoleCommand::possibleOperations(m_formWindow->core(), m_widget)) {
switch (m_type) {
case WidgetHandle::Left:
operation = formLayoutLeftHandleOperation(dx, possibleOperations);
break;
case WidgetHandle::Right:
operation = formLayoutRightHandleOperation(dx, possibleOperations);
break;
default:
break;
}
if (operation) {
ChangeFormLayoutItemRoleCommand *fcmd = new ChangeFormLayoutItemRoleCommand(m_formWindow);
fcmd->init(m_widget, static_cast<ChangeFormLayoutItemRoleCommand::Operation>(operation));
cmd = fcmd;
}
}
}
if (cmd) {
m_formWindow->commandHistory()->push(cmd);
} else {
// Cancelled/Invalid. Restore the size of the widget.
if (QFormLayout *form = managedLayoutOf<QFormLayout>(m_formWindow->core(), m_widget)) {
form->invalidate();
form->activate();
m_formWindow->clearSelection(false);
m_formWindow->selectWidget(m_widget);
}
}
}
void WidgetHandle::changeGridLayoutItemSpan()
{
QDesignerLayoutDecorationExtension *deco = qt_extension<QDesignerLayoutDecorationExtension*>(core()->extensionManager(), m_widget->parentWidget());
if (!deco)
return;
QGridLayout *grid = managedLayoutOf<QGridLayout>(m_formWindow->core(), m_widget);
if (!grid)
return;
const int index = deco->indexOf(m_widget);
const QRect info = deco->itemInfo(index);
const int top = deco->findItemAt(info.top() - 1, info.left());
const int left = deco->findItemAt(info.top(), info.left() - 1);
const int bottom = deco->findItemAt(info.bottom() + 1, info.left());
const int right = deco->findItemAt(info.top(), info.right() + 1);
const QPoint pt = m_origGeom.center() - m_widget->geometry().center();
ChangeLayoutItemGeometry *cmd = 0;
switch (m_type) {
default:
break;
case WidgetHandle::Top: {
if (pt.y() < 0 && info.height() > 1) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y() + 1, info.x(), info.height() - 1, info.width());
} else if (pt.y() > 0 && top != -1 && grid->itemAt(top)->spacerItem()) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y() - 1, info.x(), info.height() + 1, info.width());
}
}
break;
case WidgetHandle::Left: {
if (pt.x() < 0 && info.width() > 1) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x() + 1, info.height(), info.width() - 1);
} else if (pt.x() > 0 && left != -1 && grid->itemAt(left)->spacerItem()) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x() - 1, info.height(), info.width() + 1);
}
}
break;
case WidgetHandle::Right: {
if (pt.x() > 0 && info.width() > 1) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x(), info.height(), info.width() - 1);
} else if (pt.x() < 0 && right != -1 && grid->itemAt(right)->spacerItem()) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x(), info.height(), info.width() + 1);
}
}
break;
case WidgetHandle::Bottom: {
if (pt.y() > 0 && info.width() > 1) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x(), info.height() - 1, info.width());
} else if (pt.y() < 0 && bottom != -1 && grid->itemAt(bottom)->spacerItem()) {
cmd = new ChangeLayoutItemGeometry(m_formWindow);
cmd->init(m_widget, info.y(), info.x(), info.height() + 1, info.width());
}
}
break;
}
if (cmd != 0) {
m_formWindow->commandHistory()->push(cmd);
} else {
grid->invalidate();
grid->activate();
m_formWindow->clearSelection(false);
m_formWindow->selectWidget(m_widget);
}
}
void WidgetHandle::trySetGeometry(QWidget *w, int x, int y, int width, int height)
{
if (!m_formWindow->hasFeature(FormWindow::EditFeature))
return;
int minw = w->minimumSize().width();
minw = qMax(minw, 2 * m_formWindow->grid().x());
int minh = w->minimumSize().height();
minh = qMax(minh, 2 * m_formWindow->grid().y());
if (qMax(minw, width) > w->maximumWidth() ||
qMax(minh, height) > w->maximumHeight())
return;
if (width < minw && x != w->x())
x -= minw - width;
if (height < minh && y != w->y())
y -= minh - height;
w->setGeometry(x, y, qMax(minw, width), qMax(minh, height));
}
void WidgetHandle::tryResize(QWidget *w, int width, int height)
{
int minw = w->minimumSize().width();
minw = qMax(minw, 16);
int minh = w->minimumSize().height();
minh = qMax(minh, 16);
w->resize(qMax(minw, width), qMax(minh, height));
}
// ------------------ WidgetSelection
WidgetSelection::WidgetState WidgetSelection::widgetState(const QDesignerFormEditorInterface *core, QWidget *w)
{
bool isManaged;
const LayoutInfo::Type lt = LayoutInfo::laidoutWidgetType(core, w, &isManaged);
if (lt == LayoutInfo::NoLayout)
return UnlaidOut;
if (!isManaged)
return LaidOut;
switch (lt) {
case LayoutInfo::Grid:
return ManagedGridLayout;
case LayoutInfo::Form:
return ManagedFormLayout;
default:
break;
}
return LaidOut;
}
WidgetSelection::WidgetSelection(FormWindow *parent) :
m_widget(0),
m_formWindow(parent)
{
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i)
m_handles[i] = new WidgetHandle(m_formWindow, static_cast<WidgetHandle::Type>(i), this);
hide();
}
void WidgetSelection::setWidget(QWidget *w)
{
if (m_widget != 0)
m_widget->removeEventFilter(this);
if (w == 0) {
hide();
m_widget = 0;
return;
}
m_widget = w;
m_widget->installEventFilter(this);
updateActive();
updateGeometry();
show();
}
void WidgetSelection::updateActive()
{
const WidgetState ws = widgetState(m_formWindow->core(), m_widget);
bool active[WidgetHandle::TypeCount];
qFill(active, active + WidgetHandle::TypeCount, false);
// Determine active handles
switch (ws) {
case UnlaidOut:
qFill(active, active + WidgetHandle::TypeCount, true);
break;
case ManagedGridLayout: // Grid: Allow changing span
active[WidgetHandle::Left] = active[WidgetHandle::Top] = active[WidgetHandle::Right] = active[WidgetHandle::Bottom] = true;
break;
case ManagedFormLayout: // Form: Allow changing column span
if (const unsigned operation = ChangeFormLayoutItemRoleCommand::possibleOperations(m_formWindow->core(), m_widget)) {
active[WidgetHandle::Left] = operation & (ChangeFormLayoutItemRoleCommand::SpanningToField|ChangeFormLayoutItemRoleCommand::FieldToSpanning);
active[WidgetHandle::Right] = operation & (ChangeFormLayoutItemRoleCommand::SpanningToLabel|ChangeFormLayoutItemRoleCommand::LabelToSpanning);
}
break;
default:
break;
}
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i)
if (WidgetHandle *h = m_handles[i]) {
h->setWidget(m_widget);
h->setActive(active[i]);
}
}
bool WidgetSelection::isUsed() const
{
return m_widget != 0;
}
void WidgetSelection::updateGeometry()
{
if (!m_widget || !m_widget->parentWidget())
return;
QPoint p = m_widget->parentWidget()->mapToGlobal(m_widget->pos());
p = m_formWindow->formContainer()->mapFromGlobal(p);
const QRect r(p, m_widget->size());
const int w = 6;
const int h = 6;
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i) {
WidgetHandle *hndl = m_handles[ i ];
if (!hndl)
continue;
switch (i) {
case WidgetHandle::LeftTop:
hndl->move(r.x() - w / 2, r.y() - h / 2);
break;
case WidgetHandle::Top:
hndl->move(r.x() + r.width() / 2 - w / 2, r.y() - h / 2);
break;
case WidgetHandle::RightTop:
hndl->move(r.x() + r.width() - w / 2, r.y() - h / 2);
break;
case WidgetHandle::Right:
hndl->move(r.x() + r.width() - w / 2, r.y() + r.height() / 2 - h / 2);
break;
case WidgetHandle::RightBottom:
hndl->move(r.x() + r.width() - w / 2, r.y() + r.height() - h / 2);
break;
case WidgetHandle::Bottom:
hndl->move(r.x() + r.width() / 2 - w / 2, r.y() + r.height() - h / 2);
break;
case WidgetHandle::LeftBottom:
hndl->move(r.x() - w / 2, r.y() + r.height() - h / 2);
break;
case WidgetHandle::Left:
hndl->move(r.x() - w / 2, r.y() + r.height() / 2 - h / 2);
break;
default:
break;
}
}
}
void WidgetSelection::hide()
{
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i) {
WidgetHandle *h = m_handles[ i ];
if (h)
h->hide();
}
}
void WidgetSelection::show()
{
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i) {
WidgetHandle *h = m_handles[ i ];
if (h) {
h->show();
h->raise();
}
}
}
void WidgetSelection::update()
{
for (int i = WidgetHandle::LeftTop; i < WidgetHandle::TypeCount; ++i) {
WidgetHandle *h = m_handles[ i ];
if (h)
h->update();
}
}
QWidget *WidgetSelection::widget() const
{
return m_widget;
}
QDesignerFormEditorInterface *WidgetSelection::core() const
{
if (m_formWindow)
return m_formWindow->core();
return 0;
}
bool WidgetSelection::eventFilter(QObject *object, QEvent *event)
{
if (object != widget())
return false;
switch (event->type()) {
default: break;
case QEvent::Move:
case QEvent::Resize:
updateGeometry();
break;
case QEvent::ZOrderChange:
show();
break;
} // end switch
return false;
}
}
QT_END_NAMESPACE
|