File indexing completed on 2024-04-14 05:44:26
0001 /* 0002 * SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 **/ 0006 0007 #include "singlecontainerwidget.h" 0008 0009 #include "concwidget.h" 0010 0011 SingleContainerWidget::SingleContainerWidget(RegExpEditorWindow *editorWindow, QWidget *parent) 0012 : RegExpWidget(editorWindow, parent) 0013 { 0014 } 0015 0016 bool SingleContainerWidget::updateSelection(bool parentSelected) 0017 { 0018 bool changed = RegExpWidget::updateSelection(parentSelected); 0019 changed = _child->updateSelection(_isSelected) && changed; 0020 if (changed) { 0021 repaint(); 0022 } 0023 0024 return changed; 0025 } 0026 0027 bool SingleContainerWidget::hasSelection() const 0028 { 0029 return _isSelected || _child->hasSelection(); 0030 } 0031 0032 void SingleContainerWidget::clearSelection() 0033 { 0034 _isSelected = false; 0035 _child->clearSelection(); 0036 } 0037 0038 void SingleContainerWidget::deleteSelection() 0039 { 0040 _child->deleteSelection(); 0041 update(); 0042 } 0043 0044 void SingleContainerWidget::applyRegExpToSelection(RegExpType type) 0045 { 0046 _child->applyRegExpToSelection(type); 0047 } 0048 0049 RegExp *SingleContainerWidget::selection() const 0050 { 0051 if (isSelected()) { 0052 return regExp(); 0053 } else { 0054 return _child->selection(); 0055 } 0056 } 0057 0058 bool SingleContainerWidget::validateSelection() const 0059 { 0060 return _child->validateSelection(); 0061 } 0062 0063 QRect SingleContainerWidget::selectionRect() const 0064 { 0065 if (_isSelected) { 0066 return QRect(mapToGlobal(QPoint(0, 0)), size()); 0067 } else { 0068 return _child->selectionRect(); 0069 } 0070 } 0071 0072 RegExpWidget *SingleContainerWidget::widgetUnderPoint(QPointF globalPos, bool justVisibleWidgets) 0073 { 0074 RegExpWidget *wid = _child->widgetUnderPoint(globalPos, justVisibleWidgets); 0075 if (wid) { 0076 return wid; 0077 } else { 0078 // The child didn't contain the point, then lets see if this widget 0079 // itself does. 0080 return RegExpWidget::widgetUnderPoint(globalPos, justVisibleWidgets); 0081 } 0082 } 0083 0084 RegExpWidget *SingleContainerWidget::findWidgetToEdit(QPointF globalPos) 0085 { 0086 RegExpWidget *wid = _child->findWidgetToEdit(globalPos); 0087 if (wid) { 0088 return wid; 0089 } else if (QRectF(mapToGlobal(QPointF(0, 0)), size()).contains(globalPos)) { 0090 return this; 0091 } else { 0092 return nullptr; 0093 } 0094 } 0095 0096 void SingleContainerWidget::setConcChild(ConcWidget *conc) 0097 { 0098 delete _child; 0099 _child = conc; 0100 } 0101 0102 void SingleContainerWidget::selectWidget(bool sel) 0103 { 0104 RegExpWidget::selectWidget(sel); 0105 _child->selectWidget(sel); 0106 update(); 0107 } 0108 0109 void SingleContainerWidget::updateAll() 0110 { 0111 _child->updateAll(); 0112 RegExpWidget::updateAll(); 0113 } 0114 0115 void SingleContainerWidget::updateCursorRecursively() 0116 { 0117 _child->updateCursorRecursively(); 0118 updateCursorShape(); 0119 } 0120 0121 #include "moc_singlecontainerwidget.cpp"