Exemplo n.º 1
0
bool
ResizableMessageBox::event(QEvent *e)
{
    bool result = QMessageBox::event(e);

    //QMessageBox::event in this case will call setFixedSize on the dialog frame, making it not resizable by the user
    if ( (e->type() == QEvent::LayoutRequest) || (e->type() == QEvent::Resize) ) {
        setMinimumHeight(0);
        setMaximumHeight(QWIDGETSIZE_MAX);
        setMinimumWidth(0);
        setMaximumWidth(QWIDGETSIZE_MAX);
        setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

        // make the detailed text expanding
        QTextEdit *textEdit = findChild<QTextEdit *>();

        if (textEdit) {
            textEdit->setMinimumHeight(0);
            textEdit->setMaximumHeight(QWIDGETSIZE_MAX);
            textEdit->setMinimumWidth(0);
            textEdit->setMaximumWidth(QWIDGETSIZE_MAX);
            textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        }
    }

    return result;
}
Exemplo n.º 2
0
void UBMessagesDialog::setMessages(const QList<QString> messages)
{
    mMessages = messages;

    if (mMessages.count())
    {        
        QVBoxLayout *messagesLayout = new QVBoxLayout(this);
        foreach (QString message, mMessages)
        {
            QTextEdit *messageBox = new QTextEdit(this);
            messageBox->setMinimumHeight(55);
            messageBox->setReadOnly(true);
            messageBox->setFocusPolicy(Qt::NoFocus);
            messageBox->setText(message);
            messagesLayout->addWidget(messageBox);
        }
Exemplo n.º 3
0
QString QtopiaInputDialog::getMultiLineText(QWidget *parent, const QString &title, const QString &label,
                                            QtopiaApplication::InputMethodHint hint, const QString &hintParam,
                                            const QString &text, bool *ok)
{
    QTextEdit *te = new QTextEdit;
    QtopiaApplication::setInputMethodHint(te, hint, hintParam);
    te->setPlainText(text);
    te->setFocus();
    te->selectAll();
    te->setMinimumHeight(100);

    QtopiaInputDialog dlg(parent, title, label, te);

    QString result;
    bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
    if (ok)
        *ok = accepted;
    if (accepted)
        result = te->toPlainText();

    return result;
}
Exemplo n.º 4
0
void SqlItemView::setModel(QAbstractItemModel * model)
{
	m_model = model;
	QSqlQueryModel * t = qobject_cast<QSqlQueryModel *>(model);
	if (!t)  { return; }
	QSqlRecord rec(t->record());

	if (scrollWidget->widget())
	{
		delete scrollWidget->takeWidget();
	}

	QWidget * layoutWidget = new QWidget(scrollWidget);
	m_gridLayout = new QGridLayout(layoutWidget);
	QString tmp("%1:");

	for (int i = 0; i < rec.count(); ++i)
	{
		m_gridLayout->addWidget(
			new QLabel(tmp.arg(rec.fieldName(i)), layoutWidget), i, 0);
		QTextEdit * w = new QTextEdit(layoutWidget);
		w->setReadOnly(false);
		w->setAcceptRichText(false);
		int mh = QFontMetrics(w->currentFont()).lineSpacing();
		w->setMinimumHeight(mh);
		w->setSizePolicy(QSizePolicy::Expanding,
                         QSizePolicy::MinimumExpanding);
		m_gridLayout->addWidget(w, i, 1);
		m_gridLayout->setRowMinimumHeight(i, mh);
		connect(w, SIGNAL(textChanged()),
				this, SLOT(textChanged()));
	}
	scrollWidget->setWidget(layoutWidget);

	m_count = rec.count();
}
Exemplo n.º 5
0
//-----------------------------------------------------------------------------
// Function: ParameterDelegate::createEditor()
//-----------------------------------------------------------------------------
QWidget* ParameterDelegate::createEditor(QWidget* parent, QStyleOptionViewItem const& option, 
    QModelIndex const& index ) const
{
    if (index.column() == nameColumn())
    {
        QWidget* editor = QStyledItemDelegate::createEditor(parent, option, index);
        
        QLineEdit* lineEditor = qobject_cast<QLineEdit*>(editor);

        if (lineEditor)
        {
            lineEditor->setValidator(new NameValidator(lineEditor));
        }

        return editor;
    }

    if (index.column() == choiceColumn()) 
    {
        return createChoiceSelector(parent);
    }
    else if (index.column() == formatColumn()) 
    {
        return createFormatSelector(parent);
    }
    else if (index.column() == resolveColumn())
    {
        return createResolveSelector(parent);
    }
    else if (index.column() == usageCountColumn())
    {
        QModelIndex valueIdIndex = index.sibling(index.row(), idColumn());
        QString targetId = valueIdIndex.data(Qt::DisplayRole).toString();
        emit(openReferenceTree(targetId));

        return 0;
    }
    
    else if (index.column() == valueColumn() && valueIsArray(index))
    {
        ArrayView* editor = new ArrayView(parent);

        QScrollArea* scrollingWidget = new QScrollArea(parent);
        scrollingWidget->setWidgetResizable(true);
        scrollingWidget->setWidget(editor);

        scrollingWidget->parent()->installEventFilter(editor);

        return scrollingWidget;
    }

    else if (isIndexForValueUsingChoice(index)) 
    {
        return createEnumerationSelector(parent, index);
    }
    else if (index.column() == descriptionColumn())
    {
        QTextEdit* editor = new QTextEdit(parent);
        editor->setMinimumHeight(120);
        return editor;
    }
    else
    {
        return ChoiceCreatorDelegate::createEditor(parent, option, index);
    }
}
Exemplo n.º 6
0
//----------------------------------------------------------------------------
void DynamicEditor::setupTabs(QDomDocument *elmerDefs, const QString &Section, int ID)
{
  // Clear:
  //-------
  this->ID = ID;

  hash.clear();

  QLayout *layout = this->layout();
  if(layout != NULL) {
    QLayoutItem *item;
    while((item = layout->takeAt(0)) != 0)
      delete item;
    if(tabWidget != NULL) {
      tabWidget->clear();
      delete tabWidget;
    }
    delete layout;
  }

  // Get root element of elmerDefs:
  //-------------------------------
  root = elmerDefs->documentElement();

  tabWidget = new QTabWidget;
  //tabWidget->setTabShape(QTabWidget::Triangular);
  tabWidget->setUsesScrollButtons(true);
  tabWidget->setElideMode(Qt::ElideNone);
  all_stuff = root.firstChildElement("ALL");
  element = root.firstChildElement("PDE");

  tabs = 0;

  while(!element.isNull()) {

    name = element.firstChildElement("Name");

    QGridLayout *grid = new QGridLayout;

    int params = 0;

    for( int iter=0; iter<2; iter++ )
    {
      if ( iter==0 ) {
        if ( name.text().trimmed() == "General" ) continue;
        section = all_stuff.firstChildElement(Section);
      } else  {
        section = element.firstChildElement(Section);
      }

      param = section.firstChildElement("Parameter");
      
      // ML: Added argument "Parameter" for nextSiblingElement(), 5. August 2010:
      for( ; !param.isNull(); param=param.nextSiblingElement("Parameter"), params++ ) {

        // label
        QString widget_type = param.attribute("Widget","Edit");
        QString widget_enabled = param.attribute("Enabled","True");
        QString widget_visible = param.attribute("Visible","True");
        QString paramType = param.firstChildElement("Type").text().trimmed();
        QString labelName = param.firstChildElement("Name").text().trimmed();
        QString sifName   = param.firstChildElement("SifName").text().trimmed();
        if ( sifName == "" ) sifName = labelName;
        QString paramDefault = param.firstChildElement("DefaultValue").text().trimmed();
        QString whatis    = param.firstChildElement("Whatis").text().trimmed();
        QString statusTip = param.firstChildElement("StatusTip").text().trimmed();
        QString fullName  = "/"+name.text().trimmed()+"/"+Section+"/"+labelName+"/"+QString::number(ID);
        h.widget = NULL;

        if ( widget_type == "Edit" ) {
          DynLineEdit *edit = new DynLineEdit;
          h.widget = edit->lineEdit;
          edit->lineEdit->setText(paramDefault);
          edit->name = fullName;
          connect(edit->lineEdit, SIGNAL(returnPressed()),
		  edit, SLOT(editSlot()));
          connect(edit->lineEdit, SIGNAL(textChanged(QString)),
		  this, SLOT(textChangedSlot(QString)));

        } else if (widget_type == "TextEdit") {
	  QTextEdit *textEdit = new QTextEdit;
	  // set height to 5..8 lines of current font:
	  QFont currentFont = textEdit->currentFont();
	  QFontMetrics fontMetrics(currentFont);
	  int fontHeight = fontMetrics.height();
	  textEdit->setMinimumHeight(5*fontHeight);
	  textEdit->setMaximumHeight(8*fontHeight);
	  h.widget = textEdit;

	} else if ( widget_type == "Combo" ) {
          QComboBox *combo = new QComboBox;
          h.widget = combo;

          // combo->setObjectName(labelName);  // removed 30. sept. 2008, ML
          int count = 0, active=0;

          QDomElement item = param.firstChildElement("Item");
          for( ; !item.isNull(); item=item.nextSiblingElement("Item") ) {
            QString itemType = item.attribute( "Type", "" );
            if ( itemType == "Active" ) active=count;
            QDomElement itemName = item.firstChildElement("Name");
            combo->insertItem(count++,itemName.text().trimmed() );
          } 
          combo->setCurrentIndex(active);
          // connect(combo, SIGNAL(activated(QString)), this, SLOT(comboSlot(QString)));
	  connect(combo, SIGNAL(currentIndexChanged(QString)), this, SLOT(comboSlot(QString)));

        } else if ( widget_type == "CheckBox" ) {
          QCheckBox *l = new QCheckBox;
          h.widget = l;

          l->setText("");
          l->setChecked(false);
          if ( paramDefault == "True" ) l->setChecked(true);
          connect(l, SIGNAL(stateChanged(int)), this, SLOT(lSlot(int)));

        } else if ( widget_type == "Label" ) {
          QLabel *label = new QLabel;
          QFont font;
          font.setBold(true);
          font.setUnderline(true);
          label->setFont(font);
          label->setText(labelName);
          h.widget = label;
        }

        if ( h.widget ) {
          h.widget->setWhatsThis(whatis);
          h.widget->setStatusTip(statusTip);
          h.widget->setProperty( "dom address",fullName);
          h.elem = param;

          if ( widget_enabled == "False" ) h.widget->setEnabled(false);

	  if(widget_type != "TextEdit") h.widget->setFixedHeight(18);

	  if(widget_type == "TextEdit") {
            QLabel *textEditLabel = new QLabel;
            textEditLabel->setText(labelName);
            h.label = textEditLabel;
	    grid->addWidget(h.widget, params, 0, 1, 2);

            if ( widget_visible == "False" ) {
              h.label->hide();
              h.widget->hide();
            }

	  } else if ( widget_type != "Label" ) {
            QLabel *label = new QLabel;
            label->setText(labelName);
            h.label = label;
            grid->addWidget(h.label,  params, 0);
            grid->addWidget(h.widget, params, 1);

            if ( widget_visible == "False" ) {
              h.label->hide();
              h.widget->hide();
            }
          } else {
            h.label = NULL;
            grid->addWidget(h.widget, params, 0);
          }
          hash[fullName] = h;
        }
      }
    }
void PlotDataFitFunctionWidget::initialize() {

    QProcessorWidget::initialize();
    QGridLayout* mainLayout = new QGridLayout(this);
    QLabel* label = new QLabel(this);
    label->setText(QString(tr("Fitting Function",0)));
    label->setAlignment(Qt::AlignHCenter);
    QFont font = label->font();
    font.setBold(true);
    font.setPointSize(14);
    label->setFont(font);
    mainLayout->addWidget(label,0,0,1,3);
    widgetVector_.push_back(label);
    label = new QLabel(this);
    label->setText(QString(tr("Function:",0)));
    label->setFixedWidth(100);
    mainLayout->addWidget(label,1,0,1,1);
    widgetVector_.push_back(label);
    QTextEdit* textedit = new QTextEdit(QString(tr("No FitFunction Selected",0)),this);
    textedit->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    textedit->setReadOnly(true);
    textedit->setMaximumHeight(200);
    textedit->setMinimumHeight(20);
    mainLayout->addWidget(textedit,1,1,1,2);
    widgetVector_.push_back(textedit);
    label = new QLabel(this);
    label->setText(QString(tr("Fittingcolumn:",0)));
    label->setFixedWidth(100);
    mainLayout->addWidget(label,2,0,1,1);
    widgetVector_.push_back(label);
    label = new QLabel(this);
    label->setText(QString(tr("Column-Value",0)));
    mainLayout->addWidget(label,2,1,1,1);
    widgetVector_.push_back(label);
    label = new QLabel(this);
    label->setText(QString(tr("MSE:",0)));
    label->setFixedWidth(100);
    mainLayout->addWidget(label,3,0,1,1);
    widgetVector_.push_back(label);
    label = new QLabel(this);
    label->setText(QString(tr("MSE-Value",0)));
    mainLayout->addWidget(label,3,1,1,1);
    widgetVector_.push_back(label);

    delete proxyModel_;
    proxyModel_ = new PlotDataExtendedTableModel(NULL, std::vector<std::pair<int,std::string> >(0), this);
    table_ = new ExtendedTable(this);

    table_->setModel(proxyModel_);
    table_->setSortingEnabled(false);
    table_->verticalHeader()->hide();
    table_->resizeColumnsToContents();
    table_->setMinimumHeight(150);
    mainLayout->addWidget(table_, 4, 0, 1, 3);
    table_->setContextMenuPolicy(Qt::CustomContextMenu);
    table_->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);

    QObject::connect(table_,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(tableContextMenu(const QPoint&)));
    QObject::connect(table_->horizontalHeader(),SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(tableContextMenu(const QPoint&)));

    setLayout(mainLayout);

    for (size_t i = 1; i < widgetVector_.size(); ++i) {
        widgetVector_[i]->setVisible(false);
    }

    //show();

    initialized_ = true;
}