/// ///returns an identifying path from a widget /// QString getWidgetPath(QObject* o) { assert ( o ); //get the object path QString opath; if ( o->isWidgetType() ) { QWidget *w = dynamic_cast<QWidget*> ( o ); if ( w->objectName() == "" ) w->setObjectName ( getWidgetName ( w ) ); opath = w->objectName(); while ( w->parent() != NULL ) { w = dynamic_cast<QWidget*> ( w->parent() ); if ( w->objectName() == "" ) w->setObjectName ( getWidgetName ( w ) ); opath = w->objectName() + "/" + opath; } } return opath; }
void MainWindow::_addDockWidgets() { if(!_updatePending) return ; for(size_t ii = 0 ; ii < _dockWidgets.size() ; ii++) { QWidget* widget = _dockWidgets[ii] ; Q_ASSERT(widget) ; if (widget->parent() != 0) return; QDockWidget* dockWidget = qobject_cast<QDockWidget*>(widget); if(!dockWidget) { dockWidget = new QDockWidget(this); dockWidget->setWidget(widget); } Qt::DockWidgetArea area = Qt::LeftDockWidgetArea; // = 0x1 // area values are 0x1, 0x2, 0x4, 0x8 while(!dockWidget->isAreaAllowed(area) && area <= 0x8) area=(Qt::DockWidgetArea)((int)area<<1); if (!(area&Qt::AllDockWidgetAreas)) { qDebug("%s",tr("No usable DockArea found for %1, using left one.").arg( dockWidget->windowTitle()).toAscii().constData()); area = Qt::LeftDockWidgetArea; } QMainWindow::addDockWidget(area, dockWidget); Q_ASSERT(widget->parent() != 0); Q_ASSERT(dockWidget->parent() != 0); } _updatePending = false ; }
void QwtPlot::updateTabOrder() { if ( d_data->canvas->focusPolicy() == Qt::NoFocus ) return; if ( d_data->legend.isNull() || d_data->layout->legendPosition() == ExternalLegend || d_data->legend->legendItems().count() == 0 ) { return; } // Depending on the position of the legend the // tab order will be changed that the canvas is // next to the last legend item, or before // the first one. const bool canvasFirst = d_data->layout->legendPosition() == QwtPlot::BottomLegend || d_data->layout->legendPosition() == QwtPlot::RightLegend; QWidget *previous = NULL; QWidget *w = d_data->canvas; while ( ( w = w->nextInFocusChain() ) != d_data->canvas ) { bool isLegendItem = false; if ( w->focusPolicy() != Qt::NoFocus && w->parent() && w->parent() == d_data->legend->contentsWidget() ) { isLegendItem = true; } if ( canvasFirst ) { if ( isLegendItem ) break; previous = w; } else { if ( isLegendItem ) previous = w; else { if ( previous ) break; } } } if ( previous && previous != d_data->canvas ) setTabOrder( previous, d_data->canvas ); }
QToolBar* ToolViewToolBarTest::fetchToolBarFor(Sublime::View* view) { QWidget* toolWidget = view->widget(); const char* loc = "fetchToolBarFor"; Q_ASSERT_X(toolWidget, loc, "Tool refuses to create widget (null)."); Q_ASSERT(toolWidget->parent()); QMainWindow* toolWin = dynamic_cast<QMainWindow*>(toolWidget->parent()); Q_ASSERT_X(toolWin, loc, "Tool widget's parent is not a QMainWindow."); QList<QToolBar*> toolBars = toolWin->findChildren<QToolBar*>(); int barCount = toolBars.count(); char* failMsg = qstrdup(QString("Expected to find a toolbar but found %1").arg(barCount).toLatin1().data()); Q_ASSERT_X(barCount == 1, loc, failMsg); return toolBars.at(0); }
bool KviMainWindow::focusNextPrevChild(bool next) { QWidget * w = focusWidget(); if(w) { if(w->focusPolicy() == Qt::StrongFocus)return false; if(w->parent()) { QVariant v = w->parent()->property("KviProperty_ChildFocusOwner"); if(v.isValid())return false; // Do NOT change the focus widget! } } return KviTalMainWindow::focusNextPrevChild(next); }
/*! Returns the associated widget's parent object, which is either the parent widget, or qApp for top-level widgets. */ QObject *QAccessibleWidget::parentObject() const { QWidget *w = widget(); if (!w || w->isWindow() || !w->parentWidget()) return qApp; return w->parent(); }
void GridLayout::doLayout() { bool needMove, needReparent; if ( !prepareLayout( needMove, needReparent ) ) return; QDesignerGridLayout *layout = (QDesignerGridLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::Grid ); if ( !grid ) buildGrid(); QWidget* w; int r, c, rs, cs; for ( w = widgets.first(); w; w = widgets.next() ) { if ( grid->locateWidget( w, r, c, rs, cs) ) { if ( needReparent && w->parent() != layoutBase ) w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE ); if ( rs * cs == 1 ) { layout->addWidget( w, r, c, w->inherits( "Spacer" ) ? ( (Spacer*)w )->alignment() : 0 ); } else { layout->addMultiCellWidget( w, r, r+rs-1, c, c+cs-1, w->inherits( "Spacer" ) ? ( (Spacer*)w )->alignment() : 0 ); } w->show(); } else { qWarning("ooops, widget '%s' does not fit in layout", w->name() ); } } finishLayout( needMove, layout ); }
void tst_QScriptEngineDebugger::widget() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); #endif QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); QList<QScriptEngineDebugger::DebuggerWidget> widgets; widgets << QScriptEngineDebugger::ConsoleWidget << QScriptEngineDebugger::StackWidget << QScriptEngineDebugger::ScriptsWidget << QScriptEngineDebugger::LocalsWidget << QScriptEngineDebugger::CodeWidget << QScriptEngineDebugger::CodeFinderWidget << QScriptEngineDebugger::BreakpointsWidget << QScriptEngineDebugger::DebugOutputWidget << QScriptEngineDebugger::ErrorLogWidget; QList<QWidget*> lst; for (int i = 0; i < widgets.size(); ++i) { QScriptEngineDebugger::DebuggerWidget dw = widgets.at(i); QWidget *wid = debugger.widget(dw); QVERIFY(wid != 0); QCOMPARE(wid, debugger.widget(dw)); QVERIFY(lst.indexOf(wid) == -1); lst.append(wid); QCOMPARE(static_cast<QWidget *>(wid->parent()), (QWidget*)0); } }
void QwtPlotAbstractCanvas::drawCanvas( QPainter *painter ) { QWidget *w = canvasWidget(); painter->save(); if ( !d_data->styleSheet.borderPath.isEmpty() ) { painter->setClipPath( d_data->styleSheet.borderPath, Qt::IntersectClip ); } else { if ( borderRadius() > 0.0 ) { const QRect frameRect = w->property( "frameRect" ).toRect(); painter->setClipPath( borderPath2( frameRect ), Qt::IntersectClip ); } else { painter->setClipRect( w->contentsRect(), Qt::IntersectClip ); } } QwtPlot *plot = qobject_cast< QwtPlot *>( w->parent() ); if ( plot ) plot->drawCanvas( painter ); painter->restore(); }
bool KviWindow::focusNextPrevChild(bool bNext) { QWidget * pWidget = focusWidget(); if(pWidget) { if(pWidget->focusPolicy() == Qt::StrongFocus) return false; if(pWidget->parent()) { if(pWidget->parent()->metaObject()->indexOfProperty("KviProperty_ChildFocusOwner") == -1) return false; // Do NOT change the focus widget! } } return QWidget::focusNextPrevChild(bNext); }
bool QtDNDTabBar::event(QEvent* event) { QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event); if (mouseEvent) { QWidget* childAtPoint = window()->childAt(mapTo(window(), mouseEvent->pos())); QtDNDTabBar* underMouse = dynamic_cast<QtDNDTabBar*>(childAtPoint); if (!underMouse && childAtPoint) { underMouse = dynamic_cast<QtDNDTabBar*>(childAtPoint->parent()); } if (!underMouse && currentIndex() >= 0) { // detach and drag // stop move event QMouseEvent* finishMoveEvent = new QMouseEvent (QEvent::MouseMove, mouseEvent->pos (), Qt::NoButton, Qt::NoButton, Qt::NoModifier); QTabBar::event(finishMoveEvent); delete finishMoveEvent; finishMoveEvent = NULL; // start drag QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; // distinguish tab-reordering drops from other ones mimeData->setData("action", "application/tab-detach") ; drag->setMimeData(mimeData); // set drag image QRect rect = tabRect( currentIndex() ); #if QT_VERSION >= 0x050000 QPixmap pixmap = grab(rect); #else QPixmap pixmap = QPixmap::grabWidget(this, rect); #endif QPixmap targetPixmap (pixmap.size ()); QPainter painter (&targetPixmap); painter.setOpacity(0.9); painter.drawPixmap(0,0, pixmap); painter.end (); drag->setPixmap (targetPixmap); drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height())); dragIndex = currentIndex(); dragText = tabText(dragIndex); dragWidget = dynamic_cast<QTabWidget*>(parent())->widget(dragIndex); assert(dragWidget); dynamic_cast<QTabWidget*>(parent())->removeTab(currentIndex()); Qt::DropAction dropAction = drag->exec(); if (dropAction == Qt::IgnoreAction) { // aborted drag, put tab back in place // disable event handling during the insert for the tab to prevent infinite recursion (stack overflow) dragWidget->blockSignals(true); dynamic_cast<QTabWidget*>(parent())->insertTab(dragIndex, dragWidget, dragText); dragWidget->blockSignals(false); } return true; } } return QTabBar::event(event); }
void IdealController::addView(Qt::DockWidgetArea area, View* view) { IdealDockWidget *dock = new IdealDockWidget(this, m_mainWindow); // dock object name is used to store toolview settings QString dockObjectName = view->document()->title(); // support different configuration for same docks opened in different areas if (m_mainWindow->area()) dockObjectName += '_' + m_mainWindow->area()->objectName(); dock->setObjectName(dockObjectName); KAcceleratorManager::setNoAccel(dock); QWidget *w = view->widget(dock); if (w->parent() == 0) { /* Could happen when we're moving the widget from one IdealDockWidget to another. See moveView below. In this case, we need to reparent the widget. */ w->setParent(dock); } QList<QAction *> toolBarActions = view->toolBarActions(); if (toolBarActions.isEmpty()) { dock->setWidget(w); } else { QMainWindow *toolView = new QMainWindow(); QToolBar *toolBar = new QToolBar(toolView); int iconSize = m_mainWindow->style()->pixelMetric(QStyle::PM_SmallIconSize); toolBar->setIconSize(QSize(iconSize, iconSize)); toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); toolBar->setWindowTitle(i18n("%1 Tool Bar", w->windowTitle())); toolBar->setFloatable(false); toolBar->setMovable(false); toolBar->addActions(toolBarActions); toolView->setCentralWidget(w); toolView->addToolBar(toolBar); dock->setWidget(toolView); } dock->setWindowTitle(view->widget()->windowTitle()); dock->setWindowIcon(view->widget()->windowIcon()); dock->setFocusProxy(dock->widget()); if (IdealButtonBarWidget* bar = barForDockArea(area)) { QAction* action = bar->addWidget( view->document()->title(), dock, static_cast<MainWindow*>(parent())->area(), view); m_dockwidget_to_action[dock] = m_view_to_action[view] = action; m_docks->addAction(action); connect(dock, &IdealDockWidget::closeRequested, action, &QAction::toggle); } connect(dock, &IdealDockWidget::dockLocationChanged, this, &IdealController::dockLocationChanged); dock->hide(); docks.insert(dock); }
void VBoxLogSearchPanel::hideEvent (QHideEvent *aEvent) { QWidget *focus = QApplication::focusWidget(); if (focus && focus->parent() == this) focusNextPrevChild (true); QWidget::hideEvent (aEvent); }
bool HelpViewer::showHelpFor(const QObject* object) { if (object == 0) return false; HashMap<const QObject*, String>::Iterator to_find; QObject* object2 = (QObject*) object; QWidget* widget = dynamic_cast<QWidget*>(object2); if (widget && widget->parent() != 0) { QToolBar* tb = dynamic_cast<QToolBar*>(widget->parent()); if (tb != 0) { QList<QAction *> acs = widget->actions(); if (acs.size() == 1) { to_find = docu_entries_.find(*acs.begin()); if (to_find != docu_entries_.end()) { showHelp((*to_find).second); return true; } } } } while (object2 != 0) { to_find = docu_entries_.find(object2); if (to_find != docu_entries_.end()) break; object2 = object2->parent(); } if (object2 == 0) { setStatusbarText(tr("No documentation for this widget available!"), true); return false; } showHelp((*to_find).second); return true; }
void UISettingsDialog::showEvent(QShowEvent *pEvent) { /* Base-class processing: */ QIMainDialog::showEvent(pEvent); /* One may think that QWidget::polish() is the right place to do things * below, but apparently, by the time when QWidget::polish() is called, * the widget style & layout are not fully done, at least the minimum * size hint is not properly calculated. Since this is sometimes necessary, * we provide our own "polish" implementation. */ if (m_fPolished) return; m_fPolished = true; int iMinWidth = m_pSelector->minWidth(); #ifdef Q_WS_MAC /* Remove all title bar buttons (Buggy Qt): */ ::darwinSetHidesAllTitleButtons(this); /* Set all size policies to ignored: */ for (int i = 0; i < m_pStack->count(); ++i) m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored); /* Activate every single page to get the optimal size: */ for (int i = m_pStack->count() - 1; i >= 0; --i) { m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); /* Prevent this widgets to go in the Small/Mini size state which is * available on Mac OS X. Not sure why this happens but this seems to help * against. */ QList <QWidget*> list = m_pStack->widget(i)->findChildren<QWidget*>(); for (int a = 0; a < list.size(); ++a) { QWidget *w = list.at(a); if (w->parent() == m_pStack->widget(i)) w->setFixedHeight(w->sizeHint().height()); } m_pStack->setCurrentIndex(i); /* Now make sure the layout is freshly calculated. */ layout()->activate(); QSize s = minimumSize(); if (iMinWidth > s.width()) s.setWidth(iMinWidth); m_sizeList.insert(0, s); m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored); } sltCategoryChanged(m_pSelector->currentId()); #else /* Q_WS_MAC */ /* Resize to the minimum possible size: */ QSize s = minimumSize(); if (iMinWidth > s.width()) s.setWidth(iMinWidth); resize(s); #endif /* Q_WS_MAC */ }
void QwtPlot::updateTabOrder() { // Depending on the position of the legend the // tab order will be changed that the canvas is // next to the last legend item, or directly before // the first one. The following code seems much too // complicated but is there a better implementation ? if ( d_canvas->focusPolicy() == QWidget::NoFocus || focusData() == NULL ) return; // move the cursor to the canvas for ( int i = 0; i < focusData()->count(); i++ ) { if ( focusData()->next() == d_canvas ) break; } const bool canvasFirst = d_layout->legendPosition() == QwtPlot::Bottom || d_layout->legendPosition() == QwtPlot::Right; for ( int j = 0; j < focusData()->count(); j++ ) { QWidget *w = canvasFirst ? focusData()->next() : focusData()->prev(); if ( w->focusPolicy() != QWidget::NoFocus && w->parent() && w->parent() == d_legend->contentsWidget() ) { if ( canvasFirst ) { do // go back to last non legend item { w = focusData()->prev(); // before the first legend item } while ( w->focusPolicy() == QWidget::NoFocus ); } if ( w != d_canvas ) setTabOrder(w, d_canvas); break; } } }
EdgeWidgetLayoutBox::EdgeWidgetLayoutBox(QWidget* parent, EdgeWidgetBoxLayout::Orientation orientation, const char* name ) : QFrame( parent, name ) { QWidget * edgeWidget = this; while (edgeWidget && (!dynamic_cast<EdgeWidget *>(edgeWidget))) edgeWidget = dynamic_cast<QWidget *>(edgeWidget->parent()); _layout = new EdgeWidgetBoxLayout(this, (EdgeWidget *)edgeWidget, orientation, name); _layout->setAutoAdd(true); }
void BitcoinAmountField::setValid(bool valid) { QWidget* parent = (QWidget*)this->parent(); if (parent && parent->parent() && parent->parent()->inherits("SendCoinsEntry")) { ; } else { amount->setStyleSheet((valid) ? "" : "background-color: #f88;"); return; } QString qss = SC_QSS_TOOLTIP_DEFAULT; qss += "QDoubleSpinBox {border: none;"; qss += (valid) ? "background-color: #fff;" : "background-color: #f88;"; qss += (fHasTriAngle) ? "background-image: url(:/resources/res/images/bg_triangle_right.png); background-position: left center; background-repeat: no-repeat; padding: 0px 20px; font-size: 12px;" : ""; qss += "}"; qss += "QDoubleSpinBox::up-button {width: 15px; margin: 2px 5px 0 0; border-image: url(" + QString(SC_ICON_PATH_DEFAULT) + "bg_btn_up.png); border: none;}"; qss += "QDoubleSpinBox::down-button {width: 15px; margin: 0 5px 2px 0; border-image: url(" + QString(SC_ICON_PATH_DEFAULT) + "bg_btn_down.png); border: none;}"; amount->setStyleSheet(qss); }
CopasiSlider* SliderDialog::findCopasiSliderAtPosition(const QPoint& p) { QWidget* pWidget = childAt(p); CopasiSlider* pSlider = NULL; while (pWidget && pWidget != this && !pSlider) { pSlider = dynamic_cast<CopasiSlider*>(pWidget); pWidget = (QWidget*)pWidget->parent(); } return pSlider; }
//---------------------------------------------------------------------------- QRect ctkHostedAppPlaceholderWidget::getAbsolutePosition() { QWidget* current = this; int x = 0; int y = 0; do { x = x + current->x(); y = y + current->y(); current = dynamic_cast<QWidget*>(current->parent()); } while (current); return QRect(x,y,width(),height()); }
void PaletteTree::DraggableElement::mousePressEvent(QMouseEvent *event) { QWidget *atMouse = childAt(event->pos()); if (!atMouse || atMouse == this) { return; } DraggableElement *child = dynamic_cast<DraggableElement *>(atMouse->parent()); if (!child) { child = dynamic_cast<DraggableElement *>(atMouse); } if (!child) { return; } Q_ASSERT(child->id().idSize() == 3); // it should be element type // new element's ID is being generated here // may this epic event should take place in some more appropriate place Id elementId(child->id(), QUuid::createUuid().toString()); QByteArray itemData; bool isFromLogicalModel = false; QDataStream stream(&itemData, QIODevice::WriteOnly); stream << elementId.toString(); // uuid stream << Id::rootId().toString(); // pathToItem stream << QString("(" + child->text() + ")"); stream << QPointF(0, 0); stream << isFromLogicalModel; QMimeData *mimeData = new QMimeData; mimeData->setData("application/x-real-uml-data", itemData); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); QPixmap p = child->icon().pixmap(96, 96); if (!p.isNull()) { drag->setPixmap(child->icon().pixmap(96, 96)); } if (drag->start(Qt::CopyAction | Qt::MoveAction) == Qt::MoveAction) { child->close(); } else { child->show(); } }
void UXInfoPlugin::processEvent(QObject *obj, QEvent *e) { QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e); QWidget *widget = dynamic_cast<QWidget*>(obj); QPoint pos; if (mouseEvent && widget && mouseEvent->type() == QMouseEvent::MouseButtonPress) { pos = widget->pos(); for (; widget; widget = dynamic_cast<QWidget*>(widget->parent())) { pos += widget->pos(); } UXInfo::reportMouseClick(mouseEvent->pos() + pos); } }
// Returns a groupbox prefix for widgets that are owned by a groupbox QString TestLabel::groupBoxName() const { QWidget *parent = q; QGroupBox *gb; QString ret; do { parent = qobject_cast<QWidget*>(parent->parent()); gb = qobject_cast<QGroupBox*>(parent); if (gb && !gb->title().isEmpty()) ret += gb->title() + "/"; } while (parent); ret.chop(1); return ret; }
void MainWindow::_addOverlayWidgets() { if(!_updatePending) return; for(size_t ii = 0 ; ii < _overlayWidgets.size() ; ii++) { QWidget* widget = _overlayWidgets[ii]; Q_ASSERT(widget); if (widget->parent() != 0) return; widget->setParent( _viewStack->getCurrentViewer() ); // widget->resize( _viewStack->size() ); widget->setPalette( Qt::transparent ); widget->setAttribute( Qt::WA_TransparentForMouseEvents ); widget->show(); } }
void LdapConfigWidget::setFeatures( LdapConfigWidget::WinFlags features ) { d->mFeatures = features; // First delete all the child widgets. // FIXME: I hope it's correct QList<QObject*> ch = children(); const int numberOfChild( ch.count() ); for ( int i = 0; i < numberOfChild; ++i ) { QWidget *widget = dynamic_cast<QWidget*>( ch[ i ] ); if ( widget && widget->parent() == this ) { delete ( widget ); } } // Re-create child widgets according to the new flags d->initWidget(); }
void ControlSingleton::showDialog(Gui::TaskView::TaskDialog *dlg) { // only one dialog at a time assert(!ActiveDialog || ActiveDialog==dlg); Gui::DockWnd::CombiView* pcCombiView = qobject_cast<Gui::DockWnd::CombiView*> (Gui::DockWindowManager::instance()->getDockWindow("Combo View")); // should return the pointer to combo view if (pcCombiView) { pcCombiView->showDialog(dlg); // make sure that the combo view is shown QDockWidget* dw = qobject_cast<QDockWidget*>(pcCombiView->parentWidget()); if (dw) { dw->setVisible(true); dw->toggleViewAction()->setVisible(true); dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); } if (ActiveDialog == dlg) return; // dialog is already defined ActiveDialog = dlg; connect(dlg, SIGNAL(destroyed()), this, SLOT(closedDialog())); } // not all workbenches have the combo view enabled else if (!_taskPanel) { QDockWidget* dw = new QDockWidget(); dw->setWindowTitle(tr("Task panel")); dw->setFeatures(QDockWidget::DockWidgetMovable); _taskPanel = new Gui::TaskView::TaskView(dw); dw->setWidget(_taskPanel); _taskPanel->showDialog(dlg); getMainWindow()->addDockWidget(Qt::LeftDockWidgetArea, dw); connect(dlg, SIGNAL(destroyed()), dw, SLOT(deleteLater())); // if we have the normal tree view available then just tabify with it QWidget* treeView = Gui::DockWindowManager::instance()->getDockWindow("Tree view"); QDockWidget* par = treeView ? qobject_cast<QDockWidget*>(treeView->parent()) : 0; if (par && par->isVisible()) { getMainWindow()->tabifyDockWidget(par, dw); qApp->processEvents(); // make sure that the task panel is tabified now dw->show(); dw->raise(); } } }
void HierarchyList::objectClicked( QListViewItem *i ) { if ( !i ) return; QWidget *w = findWidget( i ); if ( !w ) return; if ( formWindow == w ) { if ( deselect ) formWindow->clearSelection( false ); formWindow->emitShowProperties( formWindow ); return; } if ( !formWindow->widgets()->find( w ) ) { if ( w->parent() && w->parent()->inherits( "QWidgetStack" ) && w->parent()->parent() && ( w->parent()->parent()->inherits( "QTabWidget" ) || w->parent()->parent()->inherits( "QWizard" ) ) ) { if ( w->parent()->parent()->inherits( "QTabWidget" ) ) ( (QTabWidget*)w->parent()->parent() )->showPage( w ); else ( (QDesignerWizard*)w->parent()->parent() )->setCurrentPage( ( (QDesignerWizard*)w->parent()->parent() )->pageNum( w ) ); w = (QWidget*)w->parent()->parent(); formWindow->emitUpdateProperties( formWindow->currentWidget() ); } else { return; } } if ( deselect ) formWindow->clearSelection( false ); if ( w->isVisibleTo( formWindow ) ) formWindow->selectWidget( w, true ); }
void ExpandingWidgetModel::placeExpandingWidget(const QModelIndex& idx_) { QModelIndex idx(firstColumn(idx_)); QWidget* w = 0; if( m_expandingWidgets.contains(idx) ) w = m_expandingWidgets[idx]; if( w && isExpanded(idx) ) { if( !idx.isValid() ) return; QRect rect = treeView()->visualRect(idx); if( !rect.isValid() || rect.bottom() < 0 || rect.top() >= treeView()->height() ) { //The item is currently not visible w->hide(); return; } QModelIndex rightMostIndex = idx; QModelIndex tempIndex = idx; while( (tempIndex = rightMostIndex.sibling(rightMostIndex.row(), rightMostIndex.column()+1)).isValid() ) rightMostIndex = tempIndex; QRect rightMostRect = treeView()->visualRect(rightMostIndex); //Find out the basic height of the row rect.setLeft( rect.left() + 20 ); rect.setRight( rightMostRect.right() - 5 ); //These offsets must match exactly those used in KateCompletionDeleage::sizeHint() rect.setTop( rect.top() + basicRowHeight(idx) + 5 ); rect.setHeight( w->height() ); if( w->parent() != treeView()->viewport() || w->geometry() != rect || !w->isVisible() ) { w->setParent( treeView()->viewport() ); w->setGeometry(rect); w->show(); } } }
void VerticalLayout::doLayout() { bool needMove, needReparent; if ( !prepareLayout( needMove, needReparent ) ) return; QVBoxLayout *layout = (QVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox ); for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needReparent && w->parent() != layoutBase ) w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE ); if ( qstrcmp( w->className(), "Spacer" ) == 0 ) layout->addWidget( w, 0, ( (Spacer*)w )->alignment() ); else layout->addWidget( w ); w->show(); } finishLayout( needMove, layout ); }
QWidget * KSimWidgetList::getActiveWidget() { QWidget * activeWidget = (QWidget *)0; QWidget * currentWidget = widgetList.getFirst(); while (currentWidget) { if (currentWidget->parent()->inherits("KSimEditor")) { KSimEditor * editor = (KSimEditor*)(widgetList.getFirst()->parent()); if (editor->getDoc()->getActiveEditor() == editor) { activeWidget = currentWidget; break; } } currentWidget = widgetList.next(); }; return activeWidget; }