Exemplo n.º 1
0
void InfoPane::createLabels(const QString& title, const QString& value, const int num_cols, int& x, int& y)
{
	QLabel* labelTitle = new QLabel(title, this);
	labelTitle->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
	labelTitle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);

	QPalette palette = labelTitle->palette();
	QColor f = palette.color(QPalette::Foreground);
	f.setAlpha(128);
	palette.setColor(QPalette::Foreground, f);
	labelTitle->setPalette(palette);

	gridLayout().addWidget(labelTitle, y, x, 1, 1);

	QLabel* labelValue = new QLabel(value, this);
	labelValue->setTextInteractionFlags(Qt::TextBrowserInteraction);
	labelValue->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
	gridLayout().addWidget(labelValue, y, x + 1, 1, 1);

	x += 2;

	if (x % num_cols == 0)
	{
		x = 0;
		y++;
	}
}
void HashPopulateWidget::addRow(QGridLayout *layout) {
	if(layout == NULL) {
		layout = gridLayout();
	}

	if(m_lastLabel) {
		disconnect(m_lastLabel,SIGNAL(editingFinished()),this,SLOT(lastRowEditionCompleted()));
	}

	if(m_lastValue) {
		disconnect(m_lastValue,SIGNAL(editingFinished()),this,SLOT(lastRowEditionCompleted()));
	}

    int ix = layout->rowCount();

	m_lastLabel = new HashLineEdit(QObject::tr("a label"),true,this);
	layout->addWidget(m_lastLabel,ix,0);
	connect(m_lastLabel,SIGNAL(editingFinished()),this,SLOT(lastRowEditionCompleted()));

	m_lastValue = new HashLineEdit(QObject::tr("a value"),true,this);
	layout->addWidget(m_lastValue,ix,1,1,2);
	connect(m_lastValue,SIGNAL(editingFinished()),this,SLOT(lastRowEditionCompleted()));
    if (m_keysOnly) m_lastValue->hide();

	emit editionStarted();
}
void HashPopulateWidget::lastRowEditionCompleted() {
	if(	m_lastLabel && !m_lastLabel->text().isEmpty() && m_lastLabel->hasChanged()) {
		if(m_lastLabel->text().isEmpty() && m_lastValue->text().isEmpty()) {
			// removeRow() ?;
		} else {
			HashRemoveButton *button = createRemoveButton(m_lastLabel, m_lastValue);
            for (int i = 0; i < gridLayout()->rowCount(); i++) {
                HashLineEdit * label = lineEditAt(i, 0);
                if (m_lastLabel == label) {
                    gridLayout()->addWidget(button,i,3);
                    break;
                }
            }
			addRow();
		}
	}
}
Exemplo n.º 4
0
int InfoPane::createHeader(const QString& title, const int num_cols)
{
	int y = 0;

	QLabel* label = new QLabel(title, this);
	QFont font;
	font.setBold(true);
	font.setWeight(75);
	label->setFont(font);
	label->setAlignment(Qt::AlignCenter);
	gridLayout().addWidget(label, y++, 0, 1, num_cols);

	QFrame* line = new QFrame(this);
	line->setFrameShape(QFrame::HLine);
	line->setFrameShadow(QFrame::Sunken);
	gridLayout().addWidget(line, y++, 0, 1, num_cols);

	return y;
}
Exemplo n.º 5
0
int ParameterDialog::exec() {
  parameter_model_ = new ParameterModel(int(name_parameter_map_.size()), 2, this);

  QStringList headerLabels;
  headerLabels.push_back("Variable Name");
  headerLabels.push_back("Variable Value");
  parameter_model_->setHorizontalHeaderLabels(headerLabels);

  QTableView tableView(this);
  tableView.setModel(parameter_model_);

  size_t currentRow = 0;
  for (std::map<std::string, Parameter*>::iterator it = name_parameter_map_.begin(); it != name_parameter_map_.end(); ++it) {
    QModelIndex name = parameter_model_->index(int(currentRow), 0, QModelIndex());
    parameter_model_->setData(name, QVariant(it->first.c_str()));

    QModelIndex value = parameter_model_->index(int(currentRow), 1, QModelIndex());
    std::pair<QVariant, int> model_data = it->second->toModelData();
    parameter_model_->setData(value, model_data.first, model_data.second);

    currentRow++;
  }

  tableView.setItemDelegate(new ParameterDelegate(name_parameter_map_));

  tableView.horizontalHeader()->setStretchLastSection(true);
  tableView.horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
  tableView.setShowGrid(true);
  tableView.verticalHeader()->hide();
  tableView.setSelectionBehavior(QAbstractItemView::SelectRows);
  tableView.resizeColumnsToContents();

  int totlen = tableView.columnWidth(0) + tableView.columnWidth(1) + frameSize().width();
  setMinimumWidth(totlen);

  QPushButton* pushButtonReset = new QPushButton("Reset", this);
  QPushButton* pushButtonApply = new QPushButton("Apply", this);
  QPushButton* pushButtonCancel = new QPushButton("Cancel", this);
  pushButtonApply->setDefault(true);

  connect(pushButtonReset, SIGNAL(clicked()), this, SLOT(reset()));
  connect(pushButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
  connect(pushButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));

  QGridLayout gridLayout(this);
  gridLayout.addWidget(&tableView, 0, 0, 1, 3);
  gridLayout.addWidget(pushButtonReset, 1, 0);
  gridLayout.addWidget(pushButtonApply, 1, 1);
  gridLayout.addWidget(pushButtonCancel, 1, 2);
  setLayout(&gridLayout);

  int result = QDialog::exec();

  return result;
}
Exemplo n.º 6
0
ExtraToolBar::ExtraToolBar(Qt::Orientation orientation, QWidget *parent)
    : GridWidget(parent),
      m_orientation(orientation)
{
    m_iconSize = 20;

    switch(m_orientation) {
        case Qt::Horizontal:
            setFixedHeight(m_iconSize);
            gridLayout()->setAlignment(Qt::AlignLeft);
            break;

        case Qt::Vertical:
            setFixedWidth(m_iconSize);
            gridLayout()->setAlignment(Qt::AlignTop);
            break;
    }

    gridLayout()->setSpacing(3);
}
Exemplo n.º 7
0
void GridLayoutModule::call(GraphAttributes &AG)
{
	const Graph &G = AG.constGraph();

	// compute grid layout
	GridLayout gridLayout(G);
	doCall(G,gridLayout,m_gridBoundingBox);

	// transform grid layout to real layout
	mapGridLayout(G,gridLayout,AG);
}
Exemplo n.º 8
0
void PlanarGridLayoutModule::callFixEmbed(GraphAttributes &AG, adjEntry adjExternal)
{
	const Graph &G = AG.constGraph();

	// compute grid layout
	GridLayout gridLayout(G);
	if (!handleTrivial(G, gridLayout, m_gridBoundingBox)) {
		doCall(G, adjExternal, gridLayout, m_gridBoundingBox, true);
	}

	// transform grid layout to real layout
	mapGridLayout(G,gridLayout,AG);
}
const QHash<QString,QString> &HashPopulateWidget::hash() {
	static QHash<QString,QString> theHash;

	theHash.clear();
	for(int i=1 /*i==0 is title*/; i < gridLayout()->rowCount() /*last one is always an empty one*/; i++) {
		QString label;
		HashLineEdit *labelEdit = lineEditAt(i,0);
		if(labelEdit) {
			label = labelEdit->textIfSetted();
		}

		QString value;
		HashLineEdit *valueEdit = lineEditAt(i,1);
		if(valueEdit) {
			value = valueEdit->textIfSetted();
		}

		if(!label.isEmpty() /*&& !value.isEmpty()*/) {
			theHash.insert(label, value);
		}
	}
	return theHash;
}
Exemplo n.º 10
0
HashLineEdit* HashPopulateWidget::lineEditAt(int row, int col) {
	QLayoutItem *litem = gridLayout()->itemAtPosition(row,col);
	return litem ? qobject_cast<HashLineEdit*>(litem->widget()) : NULL;
}
Exemplo n.º 11
0
void KisGmicSettingsWidget::createSettingsWidget(ROLE role)
{

    QList<Parameter *> parameters = m_commandDefinition->m_parameters;

    if (parameters.size() == 0)
    {
        dbgPlugins << "No parameters!";
        return;
    }

    QGridLayout * gridLayout(0);
    if (role == CreateRole)
    {
        gridLayout = new QGridLayout(this);
    }

    int row = 0;
    for (int i = 0; i < parameters.size();i++)
    {
        Parameter * p = parameters.at(i);
        dbgPlugins << "Processing: " << qPrintable(p->typeName()) << " " << qPrintable(p->toString());
        switch (p->m_type)
        {
            case Parameter::INT_P:
            {
                IntParameter * intParam = static_cast<IntParameter *>(p);
                KisSliderSpinBox * spinBox(0);
                if (role == CreateRole)
                {
                    spinBox = new KisSliderSpinBox;
                    spinBox->setMinimum(intParam->m_minValue);
                    spinBox->setMaximum(intParam->m_maxValue);

                    // map widget to parameter index
                    m_widgetToParameterIndexMapper[spinBox] = i;
                    mapParameterWidget(intParam, spinBox);

                    // TODO: check if it should update preview!!!, only then recompute preview
                    connect(spinBox, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(setIntValue(int)));

                    gridLayout->addWidget(new QLabel(intParam->name()), row, 0);
                    gridLayout->addWidget(spinBox, row, 1, 1, 3);

                    row++;
                }
                else if (role == LoadRole)
                {
                    spinBox = qobject_cast<KisSliderSpinBox *>(widget(intParam));
                }

                if (spinBox)
                {
                    spinBox->setValue(intParam->m_value);
                }
                else
                {
                    dbgPlugins << "Widget not available; Role: " << role << p->m_type;
                }
                break;
            }
            case Parameter::FLOAT_P:
            {
                FloatParameter * floatParam = static_cast<FloatParameter *>(p);

                KisDoubleSliderSpinBox * spinBox(0);
                if (role == CreateRole)
                {
                    spinBox = new KisDoubleSliderSpinBox;
                    // TODO: check if 2 decimals is correct
                    spinBox->setRange(floatParam->m_minValue, floatParam->m_maxValue, 2);

                    m_widgetToParameterIndexMapper[spinBox] = i;
                    mapParameterWidget(floatParam, spinBox);

                    connect(spinBox, SIGNAL(valueChanged(qreal)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(spinBox, SIGNAL(valueChanged(qreal)), this, SLOT(setFloatValue(qreal)));

                    gridLayout->addWidget(new QLabel(floatParam->name()), row, 0);
                    gridLayout->addWidget(spinBox, row, 1, 1, 3);
                    row++;
                }
                else if (role == LoadRole)
                {
                    spinBox = qobject_cast<KisDoubleSliderSpinBox *>(widget(floatParam));
                }

                if (spinBox)
                {
                    spinBox->setValue(floatParam->m_value);
                }
                else
                {
                    dbgPlugins << "Widget not available; Role: " << role << " TYPE " <<p->m_type;
                }
                break;
            }
            case Parameter::CHOICE_P:
            {
                ChoiceParameter * choiceParam = static_cast<ChoiceParameter *>(p);

                QComboBox * combo(0);
                if (role == CreateRole)
                {
                    combo = new QComboBox;
                    QStringListModel *model = new QStringListModel();
                    model->setStringList(choiceParam->m_choices);
                    combo->setModel(model);

                    m_widgetToParameterIndexMapper[combo] = i;
                    mapParameterWidget(choiceParam, combo);

                    connect(combo, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setChoiceIndex(int)));

                    gridLayout->addWidget(new QLabel(choiceParam->name()), row, 0);
                    gridLayout->addWidget(combo, row, 1, 1, 3);
                    row++;
                }
                else if (role == LoadRole)