Example #1
0
void
CQGroupBox::
updateEnabled()
{
  bool enabled = isEnabled();

  QObjectList childList = children();

  for (int i = 0; i < childList.size(); ++i) {
    QObject *o = childList.at(i);

    if (! o->isWidgetType()) continue;

    QWidget *w = static_cast<QWidget *>(o);

    if (isCheckable()) {
      if (isChecked()) {
//      if (! w->isEnabled()) {
//        if (! w->testAttribute(Qt::WA_ForceDisabled))
            w->setEnabled(true);
//      }
      }
      else {
//      if (w->isEnabled())
          w->setEnabled(false);
      }
    }
    else {
      w->setEnabled(enabled);
    }
  }
}
Example #2
0
CardView::CardView(Table table, QSqlRelationalTableModel &model, int row)
	:ui(new Ui::CardView),
	mTable(table),
	mModel(model),
	mRow(row),
	isInsert(row == -1)
{
	ui->setupUi(this);



	for (int i=0; i < mTable.colums().size(); ++i)
	{
		auto column = mTable.colums()[i];

		QWidget* widget = column.isForeingKey()
						? createForeingLinkItem(column, mModel.data(mModel.index(row, i)))
						: createSimpleItem(column.columnType(), mModel.data(mModel.index(row, i)));

		if(!isInsert && column.isPrimaryKey())
			widget->setEnabled(false);

		if(column.isAutoInc())
			widget->setEnabled(false);

		ui->formLayout->addRow(column.caption(), widget);
	}
}
void EnlightenedObjectsWidget::SetRowEnabled(int row, bool enabled)
{
  QWidget*   spinbox  = cellWidget(row, 1);
  QWidget*   checkbox = cellWidget(row, 2);

  if (spinbox)
    spinbox->setEnabled(enabled);
  if (checkbox)
    checkbox->setEnabled(enabled);

}
Example #4
0
int egx_button_enable_(egx_wnd_t hwnd,int enable)
{
	if(0 == hwnd){
		return -1;
	}
	QWidget *widget = (QWidget*)hwnd;
	if(enable){
		widget->setEnabled(true);
	}else{
		widget->setEnabled(false);		
	}
	return 0;
}
Example #5
0
// The following is used to change the displayed page on a QStackedWidget based
// on a radio box group. 
void InputDialog::toggleStack(QStackedWidget* stack, bool on, QString model) 
{
   QWidget* widget;
   if (on) {
      widget = stack->findChild<QWidget*>(model);
      Q_ASSERT(widget);
      widget->setEnabled(true);
      stack->setCurrentWidget(widget);
   }else {
      widget = stack->findChild<QWidget*>(model);
      if (widget) widget->setEnabled(false);
   }
}
Example #6
0
/** Redefined to display an editable area. */
void TabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
	int tabIndex = tabAt(event->pos());
	int c = currentIndex();
	if (-1 < tabIndex && tabIndex < count() && c == tabIndex) {
		QRect visualRect = tabRect(tabIndex);
		SettingsPrivate *settings = SettingsPrivate::instance();
		if (settings->isRectTabs()) {
			visualRect.setLeft(visualRect.left() + 1);
			visualRect.setRight(visualRect.right() - 1);
		} else {
			visualRect.setLeft(visualRect.left() + 3 + settings->tabsOverlappingLength() * 1.25 + height() / 2);
			visualRect.setRight(visualRect.right() - settings->tabsOverlappingLength());
		}
		visualRect.setTop(visualRect.top() + 1);

		// Disable close buttons in case of unfortunate click
		for (int t = 0; t < count(); t++) {
			QWidget *button = tabButton(t, QTabBar::RightSide);
			if (button && t != tabIndex) {
				button->setEnabled(false);
			}
		}

		// Feed the QLineEdit with current tab text
		lineEdit->setText(tabText(tabIndex));
		lineEdit->selectAll();
		lineEdit->setFocus();
		lineEdit->setGeometry(visualRect);
		lineEdit->setVisible(true);
		lineEdit->grabMouse();
	}
	QTabBar::mouseDoubleClickEvent(event);
}
Example #7
0
void UIStateHelper::updateData(UIStateHelperData *data)
{
	QMap<QWidget*, UIStates>::iterator it;
	for (it = data->mWidgets.begin(); it != data->mWidgets.end(); ++it) {
		QWidget *widget = it.key();
		UIStates states = it.value();

		if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE | UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
			bool visible = isWidgetVisible(widget);
			widget->setVisible(visible);

			if (!visible) {
				/* Reset progressbar */
				QProgressBar *progressBar = dynamic_cast<QProgressBar*>(widget);
				if (progressBar) {
					progressBar->setValue(0);
				}
			}
		}

		if (states & (UISTATE_LOADING_ENABLED | UISTATE_LOADING_DISABLED | UISTATE_ACTIVE_ENABLED | UISTATE_ACTIVE_DISABLED)) {
			widget->setEnabled(isWidgetEnabled(widget));
		}
	}
}
Example #8
0
void ToolBar::setEnabled(bool on)
{
    /*
      if(on){
      QWidget::setEnabled(on);
      } else {
      int n = hbox->count();
      for(int i=0; i < n; ++i){
      QLayoutItem* item = hbox->itemAt(i);
      QWidget* widget = item->widget();
      if(widget){
      widget->setEnabled(false);
      }
      handle->setEnabled(true);
      }
      }
    */
    int n = hbox->count();
    for(int i=0; i < n; ++i){
        QLayoutItem* item = hbox->itemAt(i);
        QWidget* widget = item->widget();
        if(widget){
            widget->setEnabled(on);
        }
        handle->setEnabled(true);
    }
}
QWidget *QgsAttributeTableDelegate::createEditor(
  QWidget *parent,
  const QStyleOptionViewItem &option,
  const QModelIndex &index ) const
{
  Q_UNUSED( option );
  QgsVectorLayer *vl = layer( index.model() );
  if ( !vl )
    return NULL;

  int fieldIdx = index.model()->data( index, QgsAttributeTableModel::FieldIndexRole ).toInt();

  QWidget *w = QgsAttributeEditor::createAttributeEditor( parent, 0, vl, fieldIdx, index.model()->data( index, Qt::EditRole ) );

  w->setAutoFillBackground( true );

  if ( parent )
  {
    QgsAttributeTableView *tv = dynamic_cast<QgsAttributeTableView *>( parent->parentWidget() );
    w->setMinimumWidth( tv->columnWidth( index.column() ) );

    if ( vl->editType( fieldIdx ) == QgsVectorLayer::FileName ||
         vl->editType( fieldIdx ) == QgsVectorLayer::Calendar )
    {
      QLineEdit *le = w->findChild<QLineEdit*>();
      le->adjustSize();
      w->setMinimumHeight( le->height()*2 ); // FIXME: there must be a better way to do this
    }
  }

  w->setEnabled( vl->fieldEditable( fieldIdx ) );

  return w;
}
KScanOption *KScanDevice::getGuiElement( const QByteArray& name, QWidget *parent,
					 const QString& desc,
					 const QString& tooltip )
{
   if( name.isEmpty() ) return(0);
   QWidget *w = 0;
   KScanOption *so = 0;

   QByteArray alias = aliasName( name );

   /* Check if already exists */
   so = getExistingGuiElement( name );

   if( so ) return( so );

   /* ...else create a new one */
   so = new KScanOption( alias );

   if( so->valid() && so->softwareSetable())
   {
      /** store new gui-elem in list of all gui-elements */
      gui_elements.append( so );

      w = so->createWidget( parent, desc, tooltip );
      if( w )
      {
	 connect( so,   SIGNAL( optionChanged( KScanOption* ) ),
		  this, SLOT(   slOptChanged( KScanOption* )));
	 w->setEnabled( so->active() );
      }
      else
      {
Example #11
0
void Demo::MainWindow::setupScriptActions(const QModelIndex& selection) {

    if (selection.parent() != mProject->itemParent(Project::ScriptItems)) return;

    auto scriptName = mProject->data(selection).toString();
    QStringList unmods;
    unmods << mProject->initScriptName() << mProject->drawScriptName();

    if (unmods.contains(scriptName)) {
        ADDACTION(Insert);
        ADDACTION(Open);
        ADDACTION(Save);
        ADDACTION(SaveAs);
        REMACTION(Rename);
        ADDACTION(Edit);
        ADDACTION(Compile);
        REMACTION(Delete);
        REMACTION(Reload);
        mUI->actionRename->setEnabled(false);
        mUI->actionDelete->setEnabled(false);
    } else {
        ADDACTION(Insert);
        ADDACTION(Open);
        ADDACTION(Save);
        ADDACTION(SaveAs);
        ADDACTION(Rename);
        ADDACTION(Edit);
        ADDACTION(Compile);
        ADDACTION(Delete);
        REMACTION(Reload);
        mUI->actionRename->setEnabled(true);
        mUI->actionDelete->setEnabled(true);
    }

    mUI->actionInsert->setEnabled(true);
    mUI->actionOpen->setEnabled(true);

    QWidget* widget = mProject->data(selection, Project::EditorRole).value<QWidget*>();
    if (mUI->editorsTabs->indexOf(widget) != -1) {
        mUI->editorsTabs->setCurrentWidget(widget);
    }
    CodeEditor* editor = qobject_cast<CodeEditor*>(widget);
    mUI->actionSave->setEnabled(editor->document()->isModified());

    QWidget* curr = mUI->editorsTabs->currentWidget();
    if (curr) {
        curr->setEnabled(curr == widget);
    }

    mUI->actionSaveAs->setEnabled(true);
    mUI->actionEdit->setEnabled(true);

    mUI->actionCompile->setDisabled(mUI->actionAutocompile->isChecked());

    mUI->actionReload->setEnabled(false);

    mUI->actionComplete->setEnabled(curr && curr == widget);

}
void QgsEditorWidgetWrapper::setEnabled( bool enabled )
{
  QWidget* wdg = widget();
  if ( wdg )
  {
    wdg->setEnabled( enabled );
  }
}
Example #13
0
void kOnlineTransferForm::showEditWidget(IonlineJobEdit* widget)
{
  Q_CHECK_PTR(widget);

  QWidget* oldWidget = ui->creditTransferEdit->takeWidget();
  if (oldWidget != 0) { // This is true at the first call of showEditWidget() and if there are no widgets.
    oldWidget->setEnabled(false);
    disconnect(oldWidget, SIGNAL(readOnlyChanged(bool)), this, SLOT(setJobReadOnly(bool)));
  }
Example #14
0
/*!\reimp */
void QGroupBox::childEvent(QChildEvent *c)
{
    Q_D(QGroupBox);
    if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType())
        return;
    QWidget *w = (QWidget*)c->child();
    if (d->checkable) {
        if (d->checked) {
            if (!w->testAttribute(Qt::WA_ForceDisabled))
                w->setEnabled(true);
        } else {
            if (w->isEnabled()) {
                w->setEnabled(false);
                w->setAttribute(Qt::WA_ForceDisabled, false);
            }
        }
    }
}
Example #15
0
void MailFieldsWidget::showLayoutWidgets(QLayout* layout, bool show)
  {
  for(int i = 0; i < layout->count(); ++i)
    {
    QLayoutItem* li = layout->itemAt(i);
    QWidget* w = li->widget();
    w->setVisible(show);
    w->setEnabled(show);
    }
  }
void Launcher_page::enableWidget()
{
    QList<QObject *> list = scrollWidget->children();
    QWidget *w;
    for(int i = 1; i < list.count(); i++)
    {
        w = qobject_cast<QWidget *>(list.at(i));
        w->setEnabled(true);
    }
}
Example #17
0
void KRenameWindow::slotPluginEnabled()
{
    QTreeWidgetItem *selected = m_pagePlugins->listPlugins->currentItem();
    if (selected) {
        QWidget *w = m_pluginsWidgetHash[selected->text(0)];
        Plugin  *p = m_pluginsHash[selected->text(0)];

        p->setEnabled(m_pagePlugins->checkEnablePlugin->isChecked());
        w->setEnabled(p->alwaysEnabled() || m_pagePlugins->checkEnablePlugin->isChecked());
    }
}
Example #18
0
/*
  sets all children of the group box except the qt_groupbox_checkbox
  to either disabled/enabled
*/
void QGroupBoxPrivate::_q_setChildrenEnabled(bool b)
{
    Q_Q(QGroupBox);
    QObjectList childList = q->children();
    for (int i = 0; i < childList.size(); ++i) {
        QObject *o = childList.at(i);
        if (o->isWidgetType()) {
            QWidget *w = static_cast<QWidget *>(o);
            if (b) {
                if (!w->testAttribute(Qt::WA_ForceDisabled))
                    w->setEnabled(true);
            } else {
                if (w->isEnabled()) {
                    w->setEnabled(false);
                    w->setAttribute(Qt::WA_ForceDisabled, false);
                }
            }
        }
    }
}
Example #19
0
QWidget * Tab::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QWidget *tab = new QWidget(parent);
    tab->setEnabled(enabled);
    tab->setVisible(visible);
    tab->setStyleSheet(QString::fromStdString(style));
    LayoutWidget::createQtWidget(proxy, uiproxy, tab);
    setQWidget(tab);
    setProxy(proxy);
    return tab;
}
/* ---------------------------------------------------------------------------

   ------------------------------------------------------------------------- */
void KScanDevice::guiSetEnabled( const QByteArray& name, bool state )
{
    KScanOption *so = getExistingGuiElement( name );

    if( so )
    {
	QWidget *w = so->widget();

	if( w )
	    w->setEnabled( state );
    }
}
Example #21
0
/** Rename a tab. */
void TabBar::renameTab()
{
	this->setTabText(currentIndex(), lineEdit->text());
	emit tabRenamed(currentIndex(), tabText(currentIndex()));
	lineEdit->close();
	for (int t = 0; t < count(); t++) {
		QWidget *button = tabButton(t, QTabBar::RightSide);
		if (button) {
			button->setEnabled(true);
		}
	}
}
Example #22
0
QWidget * Group::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QWidget *groupBox = flat ?
        new QWidget(parent) :
        new QGroupBox(parent);
    groupBox->setEnabled(enabled);
    groupBox->setVisible(visible);
    groupBox->setStyleSheet(QString::fromStdString(style));
    LayoutWidget::createQtWidget(proxy, uiproxy, groupBox);
    setQWidget(groupBox);
    setProxy(proxy);
    return groupBox;
}
Example #23
0
void PropertyEditor::updateItemEditor(bool enable, int column, const QModelIndex& parent)
{
    QWidget* editor = indexWidget(parent);
    if (editor)
        editor->setEnabled(enable);

    int numRows = propertyModel->rowCount(parent);
    for (int i=0; i<numRows; i++) {
        QModelIndex item = propertyModel->index(i, column, parent);
        if (item.isValid()) {
            updateItemEditor(enable, column, item);
        }
    }
}
Example #24
0
void MOParametersWidget::updateEnabled()
{
    MOParameter* curParam;
    QWidget* curWidget;
    for(int i=0;i<_localParameters->size();i++)
    {
        curParam = _localParameters->at(i);
        curWidget = _mapValueWidgets.value(curParam,NULL);

        if(curWidget)
        {
            curWidget->setEnabled(_localParameters->shouldBeEnabled(curParam->name()));
        }
    }
}
/*!\reimp */
void QGroupBox::childEvent( QChildEvent *c )
{
    if ( !c->inserted() || !c->child()->isWidgetType() )
        return;
    QWidget *w = (QWidget*)c->child();
#ifndef QT_NO_CHECKBOX
    if ( d->checkbox ) {
        if ( w == d->checkbox )
            return;
        if ( d->checkbox->isChecked() ) {
            if ( !w->testWState( WState_ForceDisabled ) )
                w->setEnabled( TRUE );
        } else {
            if ( w->isEnabled() ) {
                w->setEnabled( FALSE );
                ((QGroupBox*)w)->clearWState( WState_ForceDisabled );
            }
        }
    }
#endif
    if ( !grid )
        return;
    insertWid( w );
}
Example #26
0
// Create new page (only in Tab widget or Stack widget)
QtWidgetObject* AtenTreeGuiDialog::addPage(TreeGuiWidget* widget, TreeGuiWidget* parentWidget, QString label)
{
	// Grab widget object...
	QtWidgetObject* wo = parentWidget->qtWidgetObject();
	if (wo == NULL)
	{
		printf("Internal Error: Can't add page to tabwidget since supplied tabwidget doesn't have an associated QtWidgetObject.\n");
		return NULL;
	}

	// Create new page widget and layout
	QWidget* pageWidget = new QWidget(this);
	QGridLayout *layout = addLayout(pageWidget);

	// Create widget object to return
	QtWidgetObject* qtwo = widgetObjects_.add();
	qtwo->set(widget, pageWidget, NULL, layout);
	pageWidget->setEnabled(widget->enabled());
	pageWidget->setVisible(widget->visible());
	pageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

	// Cast parent widget into correct type, and add page
	if (parentWidget->type() == TreeGuiWidget::TabWidget)
	{
		// Cast QWidget in parentWidget into QTabWidget
		QTabWidget *tabs = static_cast<QTabWidget*>(wo->qWidget());
		if (!tabs)
		{
			printf("Internal Error: Couldn't cast QWidget into QTabWidget.\n");
			return NULL;
		}
		int id = tabs->addTab(pageWidget, label);
	}
	else if (parentWidget->type() == TreeGuiWidget::StackWidget)
	{
		// Cast QWidget in parentWidget into QStackedWidget
		QStackedWidget *stack = static_cast<QStackedWidget*>(wo->qWidget());
		if (!stack)
		{
			printf("Internal Error: Couldn't cast QWidget into QStackedWidget.\n");
			return NULL;
		}
		int id = stack->addWidget(pageWidget);
	}
	else printf("Internal Error: Tried to add a page into a widget type (%s) that doesn't support it.\n", TreeGuiWidget::widgetType(widget->type()));

	return qtwo;
}
Example #27
0
void UIStateHelper::updateData(UIStateHelperData *data)
{
	QMap<QWidget*, UIStates>::iterator it;
	for (it = data->mWidgets.begin(); it != data->mWidgets.end(); ++it) {
		QWidget *widget = it.key();
		UIStates states = it.value();

		if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE | UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
			widget->setVisible(isWidgetVisible(widget));
		}

		if (states & (UISTATE_LOADING_ENABLED | UISTATE_LOADING_DISABLED | UISTATE_ACTIVE_ENABLED | UISTATE_ACTIVE_DISABLED)) {
			widget->setEnabled(isWidgetEnabled(widget));
		}
	}
}
void Qtilities::CoreGui::DynamicSideWidgetWrapper::handleCurrentIndexChanged(const QString& text) {
    if (d->ignore_combo_box_changes)
        return;

    if (d->text_iface_map.contains(text)) {
        if (d->current_widget) {
            // TODO
//            for (int i = 0; i < d->viewer_actions.count(); ++i)
//                ui->toolBar->removeAction(d->viewer_actions.at(i));

            d->viewer_actions.clear();
            d->current_widget->setParent(0);

            // Check if we must delete the current widget:
            if (d->text_iface_map[text]->manageWidgets()) {
                delete d->current_widget;
            }
        }

        ISideViewerWidget* iface = d->text_iface_map[text];
        QWidget* widget = iface->produceWidget();
        if (widget) {
            // Check if the viewer widget needs to add actions to the toolbar:
            // TODO
//            IActionProvider* action_provider = d->text_iface_map[text]->actionProvider();
//            if (action_provider) {
//                if (action_provider->actions().count() > 0) {
//                    d->viewer_actions = action_provider->actions();
//                    ui->toolBar->addActions(d->viewer_actions);
//                }
//            }

            if (ui->centralwidget->layout())
                delete ui->centralwidget->layout();

            QHBoxLayout* layout = new QHBoxLayout(ui->centralwidget);
            layout->setMargin(0);
            layout->addWidget(widget);
            widget->show();
            widget->setEnabled(true);
            d->current_widget = widget;
            d->is_current_widget_managed = iface->manageWidgets();
            setObjectName(text);
            emit currentTextChanged(text);
        }
    }
}
Example #29
0
/*!
    Sets the page at \a index \a enabled. The corresponding
    page icon is also \a enabled.

    \sa isPageEnabled()
*/
void QxtConfigWidget::setPageEnabled(int index, bool enabled)
{
    QWidget* page = qxt_d().stack->widget(index);
    QTableWidgetItem* item = qxt_d().item(index);
    if (page && item)
    {
        page->setEnabled(enabled);
        if (enabled)
            item->setFlags(item->flags() | Qt::ItemIsEnabled);
        else
            item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
    }
    else
    {
        qWarning("QxtConfigWidget::setPageEnabled(): Unknown index");
    }
}
void ClangProjectSettingsWidget::syncOtherWidgetsToComboBox()
{
    const QStringList options = m_projectSettings.commandLineOptions();
    m_ui.delayedTemplateParseCheckBox->setChecked(
        options.contains(QLatin1String{ClangProjectSettings::DelayedTemplateParsing}));

    const bool isCustom = !m_projectSettings.useGlobalConfig();
    m_ui.delayedTemplateParseCheckBox->setEnabled(isCustom);

    for (int i = 0; i < m_ui.clangDiagnosticConfigsSelectionWidget->layout()->count(); ++i) {
        QWidget *widget = m_ui.clangDiagnosticConfigsSelectionWidget->layout()->itemAt(i)->widget();
        if (widget)
            widget->setEnabled(isCustom);
    }

    refreshDiagnosticConfigsWidgetFromSettings();
}