Exemplo n.º 1
0
void KoCursorPrivate::setAutoHideCursor( QWidget *w, bool enable, bool customEventFilter )
{
    if ( !w || !enabled )
        return;

    QWidget* viewport = 0;
    QAbstractScrollArea * sv = qobject_cast<QAbstractScrollArea *>( w );
    if ( sv )
        viewport = sv->viewport();

    if ( enable )
    {
        if ( m_eventFilters.contains( w ) )
            return;
        KoCursorPrivateAutoHideEventFilter* filter = new KoCursorPrivateAutoHideEventFilter( w );
        m_eventFilters.insert( w, filter );
        if (viewport) {
            m_eventFilters.insert( viewport, filter );
            connect(viewport, SIGNAL(destroyed(QObject*)), this, SLOT(slotViewportDestroyed(QObject*)));
        }
        if ( !customEventFilter ) {
            w->installEventFilter( filter ); // for key events
            if (viewport)
                viewport->installEventFilter( filter ); // for mouse events
        }
        connect( w, SIGNAL(destroyed(QObject*)),
                 this, SLOT(slotWidgetDestroyed(QObject*)) );
    }
    else
    {
Exemplo n.º 2
0
void ItemDelegate::setIndexWidget(const QModelIndex &index, ItemWidget *w)
{
    reset(&m_cache[index.row()], w);
    if (w == NULL)
        return;

    QWidget *ww = w->widget();

    if (!m_antialiasing) {
        QFont f = ww->font();
        f.setStyleStrategy(QFont::NoAntialias);
        ww->setFont(f);
        foreach (QWidget *child, ww->findChildren<QWidget *>("item_child"))
            child->setFont(f);
    }

    // Try to get proper size by showing item momentarily.
    ww->show();
    w->updateSize(m_maxSize, m_idealWidth);
    ww->hide();

    ww->installEventFilter(this);

    w->setCurrent(m_view->currentIndex() == index);

    emit rowSizeChanged();
}
Exemplo n.º 3
0
HistoryCompleter::HistoryCompleter(QObject *parent)
    : QCompleter(parent)
    , d_ptr(new HistoryCompleterPrivate(this))
{
    // make an assumption to allow pressing of the down
    // key, before the first model run:
    // parent is likely the lineedit
    QWidget *p = qobject_cast<QWidget *>(parent);
    if (p) {
        p->installEventFilter(d_ptr->model);
        QString objectName = p->objectName();
        if (objectName.isEmpty())
            return;
        d_ptr->model->list = d_ptr->model->settings->value(objectName).toStringList();
    }

    QLineEdit *l = qobject_cast<QLineEdit *>(parent);
    if (l && d_ptr->model->list.count())
        l->setText(d_ptr->model->list.at(0));

    setModel(d_ptr->model);
    HistoryLineDelegate *delegate = new HistoryLineDelegate;
    HistoryLineView *view = new HistoryLineView(d_ptr, delegate->pixmap.width());
    setPopup(view);
    view->setItemDelegate(delegate);
}
QWidget * EventFilterDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
    QWidget* out = QItemDelegate::createEditor(parent,option,index);
    if(filter)
    out->installEventFilter(filter);
    return out;
};
Exemplo n.º 5
0
void QWSEmbedWidgetPrivate::updateWindow()
{
    Q_Q(QWSEmbedWidget);

    QWidget *win = q->window();
    if (win == window)
        return;

    if (window) {
        window->removeEventFilter(q);
        QWSEmbedCommand command;
        command.setData(windowId, embeddedId, QWSEmbedEvent::StopEmbed);
        QWSDisplay::instance()->d->sendCommand(command);
    }

    window = win;
    if (!window)
        return;
    windowId = window->winId();

    QWSEmbedCommand command;
    command.setData(windowId, embeddedId, QWSEmbedEvent::StartEmbed);
    QWSDisplay::instance()->d->sendCommand(command);
    window->installEventFilter(q);
    q->installEventFilter(q);
}
Exemplo n.º 6
0
void VPropertyFormWidget::buildEditor(VProperty* property, QFormLayout* formLayout, Property type)
{
    // Add property (no child properties)
    // Create the editor (if it doesn't work, create empty widget)
    QWidget* tmpEditor = property->createEditor(this, QStyleOptionViewItem(), nullptr);
    if (!tmpEditor)
    {
        tmpEditor = new QWidget(this);
    }

    // set tooltip and whats this
    tmpEditor->setToolTip(property->getDescription());
    tmpEditor->setWhatsThis(property->getDescription());

    // Install event filter
    tmpEditor->installEventFilter(this);

    // Set the editor data
    property->setEditorData(tmpEditor);

    // add new row
    if (type == Property::Complex)
    {
        QString name = "<b>"+property->getName()+"</b>";
        formLayout->addRow(name, tmpEditor);
    }
    else
    {
        formLayout->addRow(property->getName(), tmpEditor);
    }

    d_ptr->EditorWidgets.append(VPropertyFormWidgetPrivate::SEditorWidget(tmpEditor));
}
Exemplo n.º 7
0
/*! create editor for tree widget item
*/
QWidget *
CQPropertyDelegate::
createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
  QTreeWidgetItem *item = getModelItem(index);
  assert(item);

  CQPropertyDelegate *th = const_cast<CQPropertyDelegate *>(this);

  QWidget *w = 0;

  if (CQPropertyItem::isType(item->type())) {
    CQPropertyItem *item1 = dynamic_cast<CQPropertyItem *>(item);
    assert(item1);

    if (index.column() == 1)
      w = item1->createEditor(parent);
  }
  else
    assert(false);

  if (w) {
    w->updateGeometry();

    if (w->layout())
      w->layout()->invalidate();

    //w->setFixedSize(sizeHint(option, index));

    w->installEventFilter(th);
  }

  return w;
}
Exemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent),
    _positionShift(QPoint(0,0)),
    _toolBar(new QToolBar(this)),
    _iconLable(new QLabel(this))
{
    setObjectName("MainWindow");
    setWindowFlags(Qt::FramelessWindowHint);
    setContextMenuPolicy(Qt::NoContextMenu);
    setMouseTracking(true);

    QMainWindow::addToolBar(Qt::TopToolBarArea, _toolBar);
    _toolBar->setObjectName("MenuToolBar");
    _toolBar->setMovable(false);
    _toolBar->setContextMenuPolicy(Qt::NoContextMenu);

    QWidget *spacerWidget = new QWidget(_toolBar);
    spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    _toolBar->addWidget(_iconLable);
    _spacerAction = _toolBar->addWidget(spacerWidget);

    _toolBar->installEventFilter(this);
    spacerWidget->installEventFilter(this);

    //TODO: Зафигачить механизм загрузки всего стиля от css до иконок основных кнопочек (крестик закрытия)
    QAction *closeAction = _toolBar->addAction(QIcon(":/icons/cross_grey.png"), QString::null);

//    setIcon(QIcon(":/icons/cross_grey.png"));
    loadStyleSheet(":/css/dark_theme.css");

    resize(700, 500);

    connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
}
Exemplo n.º 9
0
MonthView::MonthView(QWidget *parent, const QCategoryFilter& c, QSet<QPimSource> set)
    : QCalendarWidget(parent)
{
    setObjectName("monthview");

    setVerticalHeaderFormat(NoVerticalHeader);
    setFirstDayOfWeek( Qtopia::weekStartsOnMonday() ? Qt::Monday : Qt::Sunday );

    QDate start = QDate::currentDate();
    start.setYMD(start.year(), start.month(), 1);
    QDate end = start.addDays(start.daysInMonth() - 1);

    model = new QOccurrenceModel(QDateTime(start, QTime(0, 0, 0)), QDateTime(end.addDays(1), QTime(0, 0)), this);
    if (set.count() > 0)
        model->setVisibleSources(set);
    model->setCategoryFilter(c);

    connect(model, SIGNAL(modelReset()), this, SLOT(resetFormatsSoon()));
    connect(this, SIGNAL(currentPageChanged(int,int)), this, SLOT(updateModelRange(int,int)));

    // Since we don't know if we'll get a model reset from the model
    // at startup, force a timer
    dirtyTimer = new QTimer();
    dirtyTimer->setSingleShot(true);
    dirtyTimer->setInterval(0);
    connect(dirtyTimer, SIGNAL(timeout()), this, SLOT(resetFormats()));

    resetFormatsSoon();

    // XXX find the QCalendarView class so we can handle Key_Back properly :/
    // [this comes from qtopiaapplication.cpp]
    QWidget *table = findChild<QWidget*>("qt_calendar_calendarview");
    if (table)
        table->installEventFilter(this);
}
Exemplo n.º 10
0
void TransparentTop::transparentChanged()
{
#ifdef WIN32
    if (bCanTransparent){
        QWidget *p = static_cast<QWidget*>(parent());
        if (*useTransparent){
            if (!m_bUseTransparent){
                SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
                SetLayeredWindowAttributes(p->winId(), p->colorGroup().background().rgb(), 255, LWA_ALPHA);
                if (p->isVisible())
                    RedrawWindow(p->winId(), NULL, NULL, RDW_UPDATENOW);
                p->installEventFilter(this);
                m_bUseTransparent = true;
            }
        }else{
            if (m_bUseTransparent){
                SetWindowLongW(p->winId(), GWL_EXSTYLE, GetWindowLongW(p->winId(), GWL_EXSTYLE) & ~WS_EX_LAYERED);
                p->removeEventFilter(this);
                m_bUseTransparent = false;
            }
        }
    }
#endif
    setTransparent();
}
Exemplo n.º 11
0
void TransparentPlugin::setState()
{
    QWidget *main = getMainWindow();
    if (main == NULL)
        return;
#ifdef WIN32
    if (timer == NULL){
        timer = new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
        main->installEventFilter(this);
        SetWindowLongW(main->winId(), GWL_EXSTYLE, GetWindowLongW(main->winId(), GWL_EXSTYLE) | WS_EX_LAYERED);
        SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), 0, LWA_ALPHA);
        RedrawWindow(main->winId(), NULL, NULL, RDW_UPDATENOW);
        main->setMouseTracking(true);
        m_bActive = main->isActiveWindow();
        m_bState  = !m_bActive;
    }
    bool bNewState = m_bActive || m_bHaveMouse;
    if (bNewState == m_bState){
        BYTE d = (BYTE)(bNewState ? 255 : QMIN((100 - getTransparency()) * 256 / 100, 255));
        SetLayeredWindowAttributes(main->winId(), main->colorGroup().background().rgb(), d, LWA_ALPHA);
        return;
    }
    m_bState = bNewState;
    startTime = GetTickCount();
    timer->start(10);
#else
    if (!top) {
        top = new TransparentTop(main, getTransparency());
        connect(top,SIGNAL(destroyed()),this,SLOT(topDestroyed()));
    }
    top->setTransparent(getTransparency());
#endif
}
Exemplo n.º 12
0
void QWhatsThis::add( QWidget * widget, const QPixmap & icon,
		      const char * title, const char * text,
		      bool deepCopy )
{
    QWhatsThisPrivate::setUpWhatsThis();
    QWhatsThisPrivate::Item * i = wt->dict->find( (void *)widget );
    if ( i )
	remove( widget );

    i = new QWhatsThisPrivate::Item;
    i->dc = deepCopy;
    if ( deepCopy ) {
	i->s = new char[ qstrlen(text) + 1 ];
	qstrcpy( i->s, text );
	if ( title ) {
	    i->t = new char[ qstrlen(text) + 1 ];
	    qstrcpy( i->t, text );
	}
    } else {
	i->s = (char*)text;
	i->t = (char*)title;
    }
    i->pm = icon;
    wt->dict->insert( (void *)widget, i );
    QWidget * tlw = widget->topLevelWidget();
    if ( !wt->tlw->find( (void *)tlw ) ) {
	wt->tlw->insert( (void *)tlw, tlw );
	tlw->installEventFilter( wt );
    }
}
Exemplo n.º 13
0
void ToolBar::actionEvent(QActionEvent *event)
{
    QToolBar::actionEvent(event);
    if (event->type() == QEvent::ActionAdded)
        if (event->action()) {
            QWidget *widget = widgetForAction(event->action());
            if (widget)
                widget->installEventFilter(this);
        }
}
Exemplo n.º 14
0
 inline void flipEventFilters(QAbstractItemDelegate *oldDelegate,
                              QAbstractItemDelegate *newDelegate)
 {
     for (QList<WidgetMapper>::const_iterator it = widgetMap.cbegin(), end = widgetMap.cend(); it != end; ++it) {
         QWidget *w = it->widget;
         if (!w)
             continue;
         w->removeEventFilter(oldDelegate);
         w->installEventFilter(newDelegate);
     }
 }
Exemplo n.º 15
0
 inline void flipEventFilters(QAbstractItemDelegate *oldDelegate,
                              QAbstractItemDelegate *newDelegate)
 {
     for (int i = 0; i < widgetMap.count(); ++i) {
         QWidget *w = widgetMap.at(i).widget;
         if (!w)
             continue;
         w->removeEventFilter(oldDelegate);
         w->installEventFilter(newDelegate);
     }
 }
Exemplo n.º 16
0
QtWebDirectory::QtWebDirectory(QWidget * parent)
	: QtBrowser(parent) {

	QWidget * widget = (QWidget *) getWidget();

	CloseEventFilter * closeEventFilter = new CloseEventFilter(this, SLOT(CloseEventFilterSlot()));
	widget->installEventFilter(closeEventFilter);

	widget->resize(715, 569);
	LANGUAGE_CHANGE(widget);
	init();
}
Exemplo n.º 17
0
void AutoHideWidget::installFiliter(QObject *o){
    QObjectList children = o->children();
    for(int n=0;n < children.count();n++){
        if(children[n]->isWidgetType()){
            qDebug()<<"AutoHideWidget::installFilter:child name:"<<children[n]->objectName();
            QWidget *w = static_cast<QWidget*>(children[n]);
            w->setMouseTracking(true);
            w->installEventFilter(this);
            installFiliter(children[n]);
        }
    }
}
Exemplo n.º 18
0
int ExtendedTabWidget::addSubWindow(EditorInterface* window)
{
    QWidget *widget = window->widget();
    Q_ASSERT(widget != 0);

    int curr = currentIndex();
    int index = QTabWidget::insertTab(curr + 1, widget, window->icon(), tabTextFor(widget));
    widget->installEventFilter(this);
    widget->setAttribute(Qt::WA_DeleteOnClose, true);
    setCurrentWidget(widget);
    tabsUpdate();
    return index;
}
Exemplo n.º 19
0
void Configuration::findApplication(const QString &query)
{
    for (int i = (m_findApplicationUi.resultsLayout->count() - 1); i >= 0; --i)
    {
        m_findApplicationUi.resultsLayout->takeAt(i)->widget()->deleteLater();
        m_findApplicationUi.resultsLayout->removeItem(m_findApplicationUi.resultsLayout->itemAt(i));
    }

    if (query.length() < 3)
    {
        m_findApplicationDialog->adjustSize();

        return;
    }

    KService::List services = KServiceTypeTrader::self()->query("Application", QString("exist Exec and ( (exist Keywords and '%1' ~subin Keywords) or (exist GenericName and '%1' ~~ GenericName) or (exist Name and '%1' ~~ Name) )").arg(query));

    if (!services.isEmpty())
    {
        foreach (const KService::Ptr &service, services)
        {
            if (!service->noDisplay() && service->property("NotShowIn", QVariant::String) != "KDE")
            {
                Launcher* launcher = new Launcher(KUrl(service->entryPath()), m_applet);

                QWidget* entryWidget = new QWidget(static_cast<QWidget*>(parent()));
                QLabel* iconLabel = new QLabel(entryWidget);
                QLabel* textLabel = new QLabel(QString("%1<br /><small>%3</small>").arg(launcher->title()).arg(launcher->description()), entryWidget);

                iconLabel->setPixmap(launcher->icon().pixmap(32, 32));

                textLabel->setFixedSize(240, 40);

                QHBoxLayout* entryWidgetLayout = new QHBoxLayout(entryWidget);
                entryWidgetLayout->addWidget(iconLabel);
                entryWidgetLayout->addWidget(textLabel);
                entryWidgetLayout->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);

                entryWidget->setToolTip(QString("<b>%1</b><br /><i>%2</i>").arg(launcher->title()).arg(launcher->description()));
                entryWidget->setLayout(entryWidgetLayout);
                entryWidget->setFixedSize(300, 40);
                entryWidget->setObjectName(service->entryPath());
                entryWidget->installEventFilter(this);
                entryWidget->setCursor(QCursor(Qt::PointingHandCursor));

                m_findApplicationUi.resultsLayout->addWidget(entryWidget);

                delete launcher;
            }
        }
    }
Exemplo n.º 20
0
void AMWindowPaneModel::onRowsInserted(const QModelIndex &parent, int first, int last) {
	// for each item inserted: install event filter on the widget, and add to the widget lookup hash.
	for(int row=first; row<=last; row++) {
		QModelIndex i = index(row, 0, parent);

		if(!isAlias(i)) {
			QWidget* widget = internalPane(i);
			if(widget) {
				widget2item_.insert(widget, itemFromIndex(i));
				widget->installEventFilter(this);
			}
		}
	}
}
Exemplo n.º 21
0
void DockPlugin::init()
{
    if (dock)
        return;
    QWidget *main = getMainWindow();
    if (main == NULL)
        return;
    main->installEventFilter(this);
    dock = new DockWnd(this, "inactive", I18N_NOOP("Inactive"));
    connect(dock, SIGNAL(showPopup(QPoint)), this, SLOT(showPopup(QPoint)));
    connect(dock, SIGNAL(toggleWin()), this, SLOT(toggleWin()));
    connect(dock, SIGNAL(doubleClicked()), this, SLOT(doubleClicked()));
    bQuit = false;
}
Exemplo n.º 22
0
/*!
  \brief En/disable the panner

  When enabled is true an event filter is installed for
  the observed widget, otherwise the event filter is removed.

  \param on true or false
  \sa isEnabled(), eventFilter()
*/
void QwtPanner::setEnabled(bool on)
{
    if ( d_data->isEnabled != on ) {
        d_data->isEnabled = on;

        QWidget *w = parentWidget();
        if ( w ) {
            if ( d_data->isEnabled ) {
                w->installEventFilter(this);
            } else {
                w->removeEventFilter(this);
                hide();
            }
        }
    }
}
Exemplo n.º 23
0
/*!
  \brief En/disable the rescaler

  When enabled is true an event filter is installed for
  the canvas, otherwise the event filter is removed.

  \param on true or false
  \sa isEnabled(), eventFilter()
*/
void QwtPlotRescaler::setEnabled( bool on )
{
    if ( d_data->isEnabled != on )
    {
        d_data->isEnabled = on;

        QWidget *w = canvas();
        if ( w )
        {
            if ( d_data->isEnabled )
                w->installEventFilter( this );
            else
                w->removeEventFilter( this );
        }
    }
}
Exemplo n.º 24
0
void KRandrPassivePopup::startWatchingWidget( QWidget* widget_P )
    {
    static Atom wm_state = XInternAtom( QX11Info::display() , "WM_STATE", False );
    Window win = widget_P->winId();
    bool x11_events = false;
    for(;;)
	{
	Window root, parent;
	Window* children;
	unsigned int nchildren;
	XQueryTree( QX11Info::display(), win, &root, &parent, &children, &nchildren );
	if( children != NULL )
	    XFree( children );
	if( win == root ) // huh?
	    break;
	win = parent;
	
	QWidget* widget = QWidget::find( win );
	if( widget != NULL )
	    {
	    widget->installEventFilter( this );
	    watched_widgets.append( widget );
	    }
	else
	    {
	    XWindowAttributes attrs;
	    XGetWindowAttributes( QX11Info::display(), win, &attrs );
	    XSelectInput( QX11Info::display(), win, attrs.your_event_mask | StructureNotifyMask );
	    watched_windows.append( win );
	    x11_events = true;
	    }
	Atom type;
	int format;
	unsigned long nitems, after;
	unsigned char* data;
	if( XGetWindowProperty( QX11Info::display(), win, wm_state, 0, 0, False, AnyPropertyType,
	    &type, &format, &nitems, &after, &data ) == Success )
	    {
	    if( data != NULL )
		XFree( data );
	    if( type != None ) // toplevel window
		break;
	    }
	}
    if( x11_events )
	kapp->installX11EventFilter( this );
    }
Exemplo n.º 25
0
bool QAquaFocusWidget::eventFilter(QObject * o, QEvent * e)
{
    if((e->type() == QEvent::ChildInserted || e->type() == QEvent::ChildRemoved) &&
	((QChildEvent*)e)->child() == this) {
	if(e->type() == QEvent::ChildRemoved)
	    o->removeEventFilter(this); //once we're removed, stop listening
	return TRUE; //block child events
    } else if(o == d) {
	switch (e->type()) {
	case QEvent::PaletteChange:
	    setPalette(d->palette());
	    break;
	case QEvent::Hide:
	    hide();
	    break;
	case QEvent::Show:
	    show();
	    break;
	case QEvent::Move: {
	    QPoint p(d->mapTo(parentWidget(), QPoint(0, 0)));
	    move(p.x() - focusOutset(), p.y() - focusOutset());
	    break;
	}
	case QEvent::Resize: {
	    QResizeEvent *re = (QResizeEvent*)e;
	    resize(re->size().width() + (focusOutset() * 2), 
		    re->size().height() + (focusOutset() * 2));
	    setMask(QRegion(rect()) - focusRegion());
	    break;
	}
	case QEvent::Reparent: {
	    QWidget *newp = FOCUS_WIDGET_PARENT(d);
	    QPoint p(d->mapTo(newp, QPoint(0, 0)));
	    newp->installEventFilter(this);
	    reparent(newp, p);
	    raise();
	    break; }
	default:
	    break;
	}
    } else if (QComboBox *combo = ::qt_cast<QComboBox *>(d)) {
        if (combo->lineEdit() == o && e->type() == QEvent::FocusOut)
            QApplication::sendEvent(combo, e);
    }
    return FALSE;
}
Exemplo n.º 26
0
void KFollowWindow::listenEvent( KWidget *w, ListenFlags flags )
{
	Q_D(KFollowWindow);
	if(w == NULL)
		return;

	if(flags.testFlag(targetVisible))
	{
		QObject::connect(w, SIGNAL(visibleChanged()), this, SLOT(on_visibleChanged()), Qt::QueuedConnection);
	}
	else
	{
		QObject::disconnect(w, SIGNAL(visibleChanged()), this, SLOT(on_visibleChanged()));
	}

	if(flags.testFlag(targetWindowEvent))
	{
		QWidget *viewport = w->viewport();
		viewport->installEventFilter(this);
	}
	else
	{
		QWidget *viewport = w->viewport();
		viewport->removeEventFilter(this);
	}

	if(flags.testFlag(targetEvent))
	{
		w->installEventFilter(this);
	}
	else
	{
		w->removeEventFilter(this);
	}

	if(flags.testFlag(targetScenePosition))
	{
		w->setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
		QObject::connect(w, SIGNAL(scenePosition(QPointF)), this, SLOT(on_scenePosition(QPointF)), Qt::QueuedConnection);
	}
	else
	{
		w->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
		QObject::disconnect(w, SIGNAL(scenePosition(QPointF)), this, SLOT(on_scenePosition(QPointF)));
	}
}
Exemplo n.º 27
0
QWidget *PropertyEditorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
	if(index.column() != 1)
		return 0;

	Property *prop = properties[index.data(Qt::UserRole).toInt()];
	PropertyManager *manager = prop->getManager();
	if(!manager) return 0;

	QWidget *editor = manager->createEditor(prop->getName(), prop->getValue(), parent);
	if(editor)
	{
		editor->setAutoFillBackground(true);
		editor->installEventFilter(const_cast<PropertyEditorDelegate *>(this));
	}
	return editor;
}
Exemplo n.º 28
0
void Spinner::updateAncestors()
{
    foreach (QWidget *w, m_ancestors)
        w->removeEventFilter(this);

    m_ancestors.clear();

    if (m_context == Overlay) {
        QWidget *w = this;
        while ((w = w->parentWidget())) {
            m_ancestors << w;
            w->installEventFilter(this);
            connect(w, &QObject::destroyed, this, &Spinner::updateAncestors);
        }
        updateGeometry();
    }
}
Exemplo n.º 29
0
QWidget *MTable::createBoxEditor( int row, int col ) const
{
    QWidget *e = 0;
    if ( col == 0 && ctype == ComboBox){

          e = new QComboBox( true, viewport(), "qt_editor_cb" );
          //e = new QComboBox( true, viewport(), "e" );
          ( ( QComboBox*)e )->setEditable( false );
          ( ( QComboBox*)e )->setDuplicatesEnabled ( false );

          QString strNoMed = "VACUUM";
          ( ( QComboBox*)e )->insertItem( strNoMed );

          QString str;
          for ( uint i = 0; i < itemList.size(); i++) {
            str = itemList[i].c_str();
            ( ( QComboBox*)e )->insertItem( str );
          }

           // only for non-editable combo boxes
          QString cellText = text( row, col );
          if ( !cellText.isEmpty() ){
             //Match of cellText with one combo box item resets current item
             ( ( QComboBox*)e )->setCurrentText( cellText );
              //this applies if no match
              if ( ( ( QComboBox*)e )->currentItem() == 0 )
	         ( ( QComboBox*)e )->insertItem( strNoMed, 0 );
          }

           // only for editable combo boxes
          //( ( QComboBox*)e )->setEditText( text( row, col ) );
          //( ( QComboBox*)e )->lineEdit()->setText( text( row, col ) );

     } else {
          //e = new QLineEdit( viewport() );
          e = new QLineEdit( viewport(), "qt_lineeditor" );
          if (validate)
           ((QLineEdit*)e)->setValidator(new QDoubleValidator(e));

          ( (QLineEdit*)e )->setFrame( FALSE );
          ( (QLineEdit*)e )->setText( text( row, col ) );
     }

    e->installEventFilter( this );
    return e;
}
Exemplo n.º 30
0
/*!
  \brief En/disable the picker

  When enabled is true an event filter is installed for
  the observed widget, otherwise the event filter is removed.

  \param enabled true or false
  \sa isEnabled(), eventFilter()
*/
void QwtPicker::setEnabled(bool enabled)
{
    if ( d_data->enabled != enabled )
    {
        d_data->enabled = enabled;

        QWidget *w = parentWidget();
        if ( w )
        {
            if ( enabled )
                w->installEventFilter(this);
            else
                w->removeEventFilter(this);
        }

        updateDisplay();
    }
}