Exemple #1
0
void ComboStatutPaymentDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     Q_UNUSED(index);
     QComboBox * combo = static_cast<QComboBox*>(editor);
     combo->setEditable(true);
     combo->addItem(tr(NO_VALIDATED));
     combo->addItem(tr(VALIDATED));
     combo->addItem(tr(RECORDED));
}
Exemple #2
0
bool Ruler::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
	bool result = PaletteItem::collectExtraInfo(parent, family, prop, value, swappingEnabled, returnProp, returnValue, returnWidget);

	if (prop.compare("width", Qt::CaseInsensitive) == 0) {
		returnProp = tr("width");

		int units = m_modelPart->localProp("width").toString().contains("cm") ? IndexCm : IndexIn;
		QLineEdit * e1 = new QLineEdit();
		QDoubleValidator * validator = new QDoubleValidator(e1);
		validator->setRange(1.0, 20 * ((units == IndexCm) ? 2.54 : 1), 2);
		validator->setNotation(QDoubleValidator::StandardNotation);
		e1->setValidator(validator);
		e1->setEnabled(swappingEnabled);
		QString temp = m_modelPart->localProp("width").toString();
		temp.chop(2);
		e1->setText(temp);
		e1->setObjectName("infoViewLineEdit");	
        e1->setMaximumWidth(80);

		m_widthEditor = e1;
		m_widthValidator = validator;

		QComboBox * comboBox = new QComboBox(parent);
		comboBox->setEditable(false);
		comboBox->setEnabled(swappingEnabled);
		comboBox->addItem("cm");
		comboBox->addItem("in");
		comboBox->setCurrentIndex(units);
		m_unitsEditor = comboBox;
		comboBox->setObjectName("infoViewComboBox");	
        comboBox->setMinimumWidth(60);


		QHBoxLayout * hboxLayout = new QHBoxLayout();
		hboxLayout->setAlignment(Qt::AlignLeft);
		hboxLayout->setContentsMargins(0, 0, 0, 0);
		hboxLayout->setSpacing(0);
		hboxLayout->setMargin(0);


		hboxLayout->addWidget(e1);
		hboxLayout->addWidget(comboBox);

		QFrame * frame = new QFrame();
		frame->setLayout(hboxLayout);
		frame->setObjectName("infoViewPartFrame");

		connect(e1, SIGNAL(editingFinished()), this, SLOT(widthEntry()));
		connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(unitsEntry(const QString &)));

        returnValue = temp + QString::number(units);
		returnWidget = frame;

		return true;
	}
Exemple #3
0
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	QComboBox *comboDelegate = new QComboBox(parent);
	comboDelegate->setModel(model);
	comboDelegate->setEditable(true);
	comboDelegate->setAutoCompletion(true);
	comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
	comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion);
	return comboDelegate;
}
Exemple #4
0
QWidget *ComboPayeursDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                           const QModelIndex &index) const
{
    Q_UNUSED(option);
    Q_UNUSED(index);
    QComboBox * combo = new QComboBox(parent);
    combo->setEditable(true);
    combo->setInsertPolicy(QComboBox::InsertAtTop);
    return combo;
}
static
QComboBox *controlParamComboBox (
	synthv1_controls::Type ctype, QWidget *pParent )
{
	QComboBox *pComboBox = new QComboBox(pParent);

	synthv1widget_controls::Names map;

	int iParamMin = 0;
	int iParamMax = iParamMin;

	switch(ctype) {
	case synthv1_controls::CC:
		iParamMin = 0;
		iParamMax = 128;
		map = synthv1widget_controls::controllerNames();
		break;
	case synthv1_controls::RPN:
		map = synthv1widget_controls::rpnNames();
		break;
	case synthv1_controls::NRPN:
		map = synthv1widget_controls::nrpnNames();
		break;
	case synthv1_controls::CC14:
		iParamMin = 1;
		iParamMax = 32;
		map = synthv1widget_controls::control14Names();
		// Fall thru...
	default:
		break;
	}

	const bool bEditable = (iParamMin >= iParamMax);
	pComboBox->setEditable(bEditable);
	pComboBox->setInsertPolicy(QComboBox::NoInsert);

	const QString sMask("%1 - %2");
	if (bEditable) {
		synthv1widget_controls::Names::ConstIterator iter
			= map.constBegin();
		const synthv1widget_controls::Names::ConstIterator& iter_end
			= map.constEnd();
		for ( ; iter != iter_end; ++iter) {
			const unsigned short param = iter.key();
			pComboBox->addItem(sMask.arg(param).arg(iter.value()), int(param));
		}
	} else {
		for (int iParam = iParamMin; iParam < iParamMax; ++iParam) {
			const unsigned short param = iParam;
			pComboBox->addItem(sMask.arg(param).arg(map.value(param)), iParam);
		}
	}

	return pComboBox;
}
QWidget *EventsWindow::createTagsInput()
{
    QComboBox *tagInput = new QComboBox;
    tagInput->setEditable(true);
    tagInput->setInsertPolicy(QComboBox::NoInsert);
#if QT_VERSION >= 0x040700
    tagInput->lineEdit()->setPlaceholderText(tr("Type or select a tag to filter"));
#endif

    return tagInput;
}
Exemple #7
0
//! [10]
QComboBox *Window::createComboBox(const QString &text)
{
    QComboBox *comboBox = new QComboBox;
    comboBox->setEditable(true);
    comboBox->addItem(text);
    comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    comboBox->setMinimumContentsLength(3);
#endif
    return comboBox;
}
Exemple #8
0
QWidget* SettingsDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    if (index.data().type() == QVariant::Color) {
        QComboBox* comboBox = new QComboBox(parent);
        comboBox->addItems(svgColorNames());
        comboBox->setEditable(true);
        int i = 0;
        foreach (const QString& color, svgColorNames())
            comboBox->setItemData(i++, QColor(color), Qt::DecorationRole);
        return comboBox;
    } else if (index.data().type() == QVariant::Font) {
Exemple #9
0
    void testMoveTab()
    {
        // Test inspired by #170470 and #177036 (title messup).
        // Then expanded to include the problem of #159295 (focus loss).
        QWidget topLevel;
        QComboBox* combo = new QComboBox(&topLevel);
        combo->setEditable(true);
        KTabWidget* w = new KTabWidget(&topLevel);
        w->setAutomaticResizeTabs(true);
        w->resize(300, 400);
        QResizeEvent e(w->size(), QSize());
        QApplication::sendEvent(w, &e);
        QString prefix = "This is a long prefix for the tab title. ";
        KLineEdit* lineEdits[4];
        for (int i = 0; i < 4; ++i) {
            QWidget* page = new QWidget;
            page->setObjectName(QString::number(i));
            lineEdits[i] = new KLineEdit(page); // a widget that can take focus
            lineEdits[i]->setObjectName("LineEdit"+QString::number(i));
            w->insertTab(i, page, prefix+QString::number(i));
            //kDebug() << i << w->tabText(i);
        }
        topLevel.show();
        // Necessary after show(), otherwise topLevel.focusWidget() returns NULL
        QApplication::setActiveWindow(&topLevel);

        // Make sure the tab order is so that the combo gets focus after this tab
        QWidget::setTabOrder(lineEdits[0], combo->lineEdit());
        QWidget::setTabOrder(combo->lineEdit(), lineEdits[1]);

        w->setCurrentIndex(0);
        lineEdits[0]->setFocus();
        QCOMPARE(topLevel.focusWidget()->objectName(), lineEdits[0]->objectName());
        QVERIFY(lineEdits[0]->isVisible());

        w->moveTab(0,3);
        //for (int i = 0; i < 4; ++i)
            //kDebug() << i << w->tabText(i);
        QCOMPARE(w->tabText(0), QString(prefix+QString::number(1)));
        QCOMPARE(w->tabText(1), QString(prefix+QString::number(2)));
        QCOMPARE(w->tabText(2), QString(prefix+QString::number(3)));
        QCOMPARE(w->tabText(3), QString(prefix+QString::number(0)));

        // Did the focus switch to the lineEdit, due to removeTab+insertTab? Whoops.
        QCOMPARE(topLevel.focusWidget()->objectName(), lineEdits[0]->objectName());

        w->moveTab(3,0);
        QCOMPARE(topLevel.focusWidget()->objectName(), lineEdits[0]->objectName());
        for (int i = 0; i < 4; ++i) {
            //kDebug() << i << w->tabText(i);
            QCOMPARE(w->tabText(i), QString(prefix+QString::number(i)));
        }
     }
Exemple #10
0
QWidget *ComboBoxItemDelegate::createEditor(QWidget *parent,
                                            const QStyleOptionViewItem &option,
                                            const QModelIndex &index) const {
    Q_UNUSED(option);
    Q_UNUSED(index);

    QComboBox *combo = new QComboBox(parent);
    combo->setEditable(true);
    combo->addItems(data->items);

    return combo;
}
QWidget *OBSPropertiesView::AddList(obs_property_t prop)
{
	const char       *name  = obs_property_name(prop);
	QComboBox        *combo = new QComboBox();
	obs_combo_type   type   = obs_property_list_type(prop);
	obs_combo_format format = obs_property_list_format(prop);
	size_t           count  = obs_property_list_item_count(prop);
	int              idx    = -1;

	for (size_t i = 0; i < count; i++)
		AddComboItem(combo, prop, format, i);

	if (type == OBS_COMBO_TYPE_EDITABLE)
		combo->setEditable(true);

	if (format == OBS_COMBO_FORMAT_INT) {
		int    val       = (int)obs_data_getint(settings, name);
		string valString = to_string(val);
		idx              = combo->findData(QT_UTF8(valString.c_str()));

	} else if (format == OBS_COMBO_FORMAT_FLOAT) {
		double val       = obs_data_getdouble(settings, name);
		string valString = to_string(val);
		idx              = combo->findData(QT_UTF8(valString.c_str()));

	} else if (format == OBS_COMBO_FORMAT_STRING) {
		const char *val  = obs_data_getstring(settings, name);

		if (type == OBS_COMBO_TYPE_EDITABLE)
			combo->lineEdit()->setText(val);
		else
			idx      = combo->findData(QT_UTF8(val));
	}

	if (type == OBS_COMBO_TYPE_EDITABLE)
		return NewWidget(prop, combo,
				SIGNAL(editTextChanged(const QString &)));

	if (idx != -1)
		combo->setCurrentIndex(idx);

	WidgetInfo *info = new WidgetInfo(this, prop, combo);
	connect(combo, SIGNAL(currentIndexChanged(int)), info,
				SLOT(ControlChanged()));
	children.push_back(std::move(unique_ptr<WidgetInfo>(info)));

	/* trigger a settings update if the index was not found */
	if (idx == -1)
		info->ControlChanged();

	return combo;
}
QWidget* ComboBoxItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
	const QModelIndex& index) const
{
	Q_UNUSED(option);
	Q_UNUSED(index);

	QComboBox* editor = new QComboBox(parent);
	editor->setModel(m_model);
	editor->setEditable(m_editable);
	editor->setInsertPolicy(QComboBox::NoInsert);

	return editor;
}
Exemple #13
0
void EspressoPWscfConfig::setPDir (QString path) {
    if (path.isEmpty()) path = "/home/iazzi/projects/espresso-5.0/upf_files";
    QDir dir(path);
    for (int i=0;i<m_species.count();i++) {
        QString sym = m_species[i];
        if (m_speciesWidget->findChild<QComboBox*>(sym)) continue;
        QComboBox *editor = new QComboBox;
        editor->setEditable(false);
        editor->addItems(dir.entryList(QStringList(sym+".*")));
        editor->setObjectName(sym);
        m_speciesLayout->addRow(sym, editor);
    }
}
Exemple #14
0
void ComboPayDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     Q_UNUSED(index);
     QComboBox * combo = static_cast<QComboBox*>(editor);
     combo->setEditable(true);
     //QModelIndex indexin = index;
     QHash<int,QString>::const_iterator it;
     for (it = m_hash.begin(); it != m_hash.end(); ++it)
     {
         QString item = QString::number(it.key())+":"+it.value();
         combo->addItem(item);
         }
}
Exemple #15
0
//-----------------------------------------------------------------------------
// Function: PortsDelegate::createSelectorWithVHDLStandardLibraries()
//-----------------------------------------------------------------------------
QWidget* PortsDelegate::createSelectorWithVHDLStandardLibraries(QWidget* parent) const
{
    QComboBox* combo = new QComboBox(parent);
    combo->setEditable(true);
    combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);

    for (unsigned int i = 0;i < VhdlGeneral::VHDL_TYPEDEF_COUNT; ++i)
    {
        combo->addItem(VhdlGeneral::VHDL_TYPE_DEFINITIONS[i]);
    }

    return combo;
}
Exemple #16
0
void ComboSitesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     Q_UNUSED(index);
     QComboBox * combo = static_cast<QComboBox*>(editor);
     combo->setEditable(true);
     //QModelIndex indexin = index;
     QMap<QString,QString>::const_iterator it;
     for (it = m_mapSites.begin(); it != m_mapSites.end(); ++it)
     {
         QString item = it.value();
         combo->addItem(item);
         }
}
void WebDialogProvider::init(const QString &lbl, WebDialogProvider::Type type)
{
    QVBoxLayout *vbox = new QVBoxLayout(this);

    label = new QLabel(lbl, this);
    vbox->addWidget(label);
    vbox->addStretch(1);

    switch (type)
    {
    case WebDialogProvider::LineEdit:
        input = new QLineEdit(this);
        break;
    case WebDialogProvider::SpinBox:
        input = new QSpinBox(this);
        break;
    case WebDialogProvider::DoubleSpinBox:
        input = new QDoubleSpinBox(this);
        break;
    case WebDialogProvider::ComboBox:
    case WebDialogProvider::EditableComboBox:
    {
        QComboBox *combo = new QComboBox(this);
        if (type == WebDialogProvider::EditableComboBox)
        {
            combo->setEditable(true);
        }
        input = combo;
    }
    break;
    }
    vbox->addWidget(input);
    vbox->addStretch(1);

#ifndef QT_NO_SHORTCUT
    label->setBuddy(input);
#endif

    QDialogButtonBox *buttonBox =
        new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this);
    buttonBox->setObjectName(QLatin1String("qt_inputdlg_buttonbox"));
    QPushButton *okButton =
        static_cast<QPushButton *> (buttonBox->addButton(QDialogButtonBox::Ok));
    okButton->setDefault(true);
    vbox->addWidget(buttonBox);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
Exemple #18
0
QWidget* QUDefaultDelegate::createEditor(
		QWidget *parent,
		const QStyleOptionViewItem &/*option*/,
		const QModelIndex &/*index*/) const
{
	QComboBox *editor = new QComboBox(parent);

	editor->addItems(QUAudioTagTask::availableSpecialSources());
	for(int i = 0; i < editor->count(); i++)
		editor->setItemData(i, Qt::darkGray, Qt::ForegroundRole);

	editor->setEditable(true);

	return editor;
}
void EntryEditorDialog::on_AddExpenseButton_clicked()
{
    //TODO refactor
    QHBoxLayout *newLayout = new QHBoxLayout();
    QComboBox *entryName = new QComboBox();
    newLayout->addWidget(entryName);
    entryName->setEditable(true);
    entryName->setMinimumWidth(150);
    newLayout->addStretch();
    QLineEdit *entryAmount = new QLineEdit();
    newLayout->addWidget(entryAmount);
    entryAmount->setMinimumWidth(100);
    entryAmount->setAlignment(Qt::AlignRight);

    ui->ExpenseEntryLayout->addLayout(newLayout);
}
Exemple #20
0
void ComboDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     QComboBox * combo = static_cast<QComboBox*>(editor);
     combo->setEditable(true);
     QModelIndex indexin = index;
     QHash<QString,QString> hashOfTokensInBlob = diversblobsList(m_table,indexin);
     QHash<QString,QString>::iterator it;
     if (index.column() == PayeursDiagrams::DIVERS_PAYEURS)
     {
         for (it = hashOfTokensInBlob.begin(); it != hashOfTokensInBlob.end(); ++it)
         {
             QString item = it.key()+":"+it.value();
             combo->addItem(item);
             }
         }
}
Exemple #21
0
QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	QComboBox *comboDelegate = new QComboBox(parent);
	comboDelegate->setModel(model);
	comboDelegate->setEditable(true);
	comboDelegate->setAutoCompletion(true);
	comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive);
	comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion);
	comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this)));
	connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString)));
	currCombo.comboEditor = comboDelegate;
	currCombo.currRow = index.row();
	currCombo.model = const_cast<QAbstractItemModel*>(index.model());
	return comboDelegate;
}
Exemple #22
0
QWidget* FieldTypeDelegate::createEditor(QWidget* pParent, const QStyleOptionViewItem& option,
        const QModelIndex& index) const
{
    if (index.isValid() == false)
    {
        return NULL;
    }

    QComboBox* pTypeCombo = new QComboBox(pParent);
    pTypeCombo->setEditable(false);
    pTypeCombo->addItem("int");
    pTypeCombo->addItem("double");
    pTypeCombo->addItem("string");

    return pTypeCombo;
}
Exemple #23
0
QWidget *IColDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & /* option */, const QModelIndex &index) const
{
    if( index.column() == 0 ){
	QComboBox *comboBox = new QComboBox(parent);
	
	sSet colsSet=_msc->getColsSet( _type, _name, _p );
	
	for( sSet::const_iterator p=colsSet.begin(); p != colsSet.end(); p++ ){
	    comboBox->addItem((*p).c_str());
	}
	comboBox->setEditable(true);
	comboBox->setAutoCompletion(true);

	return comboBox;
    }
    return NULL;
}
QString WebDialogProvider::getItem(QWidget *parent,
                                const QString &title, const QString &label,
                                const QStringList &list, int current, bool editable, bool *ok,
                                Qt::WindowFlags flags)
{
    QComboBox *combo = new QComboBox;
    combo->addItems(list);
    combo->setCurrentIndex(current);
    combo->setEditable(editable);
    WebDialogProvider dlg(title, label, parent, combo, flags);
    bool accepted = (dlg.exec() == QDialog::Accepted);
    if (ok)
    {
        *ok = accepted;
    }
    return combo->currentText();
}
void ExtensibleFileDialog::setEditableFilter(bool on)
{
  QLayout *main_layout = layout();
  if (!main_layout)
    return;

  for (int i = 0; i < main_layout->count(); i++){
    QLayoutItem *item = main_layout->itemAt(i);
    if (!item)
      continue;
    QComboBox *filterBox = qobject_cast<QComboBox*>(item->widget());
    if (filterBox){
      filterBox->setEditable(on);
      connect(filterBox, SIGNAL(editTextChanged(const QString &)),
          this, SIGNAL(filterSelected(const QString &)));
      return;
    }
  }
}
Exemple #26
0
void QuickEdit::TypeDelegateSetup()
{
    GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false);

    delegate->widgetCreator = [](QWidget* parent)
    {
        BrowserNodeList result;
        QStringList classes;
        BrowserClass::instances(result);
        result.full_names(classes);

        QStringList basics = GenerationSettings::basic_types();
        classes+=basics;
        QCompleter* completer = new QCompleter(classes, parent);
        completer->setCaseSensitivity(Qt::CaseSensitive);

        QComboBox* box = new QComboBox(parent);
        QStringListModel* model = new QStringListModel;
        model->setStringList(classes);
        box->setModel(model);
        box->setEditable(true);
        box->setCompleter(completer);
        return box;
    };

    delegate->dataAccessor = [](QWidget* editor, const QModelIndex& index)
    {
        QString value = index.model()->data(index, Qt::EditRole).toString();
        QComboBox* box = static_cast<QComboBox*>(editor);
        box->setCurrentText(value);
    };

    delegate->dataSetter = [](QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)
    {
        QComboBox* box = static_cast<QComboBox*>(editor);
        QString value = box->currentText();
        model->setData(index, value, Qt::EditRole);
    };

    ui->tvEditor->setItemDelegateForColumn(columns.indexOf("type"), delegate);
}
Exemple #27
0
QWidget *ComboBoxDelegate::createEditor(QWidget *parent,
		const QStyleOptionViewItem& option,
		const QModelIndex& index) const
{
	Position c = index.column();

	if (c >= 2) return QItemDelegate::createEditor(parent, option, index);

	QComboBox* editor = new QComboBox(parent);

	if (c == 0) editor->addItems(sl_modifier_);
	else 			 editor->addItems(sl_keys_);

	editor->setEditable(false);
	editor->setFrame(false);
	editor->setDuplicatesEnabled(false);

	editor->installEventFilter(const_cast<ComboBoxDelegate*>(this));
	editor->showPopup();
	return editor;
}
void Board::setupLoadImage(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget) 
{
    Q_UNUSED(returnValue);
    Q_UNUSED(value);
    Q_UNUSED(prop);
    Q_UNUSED(family);
    Q_UNUSED(parent);

	returnProp = tr("image file");

	QFrame * frame = new QFrame();
	frame->setObjectName("infoViewPartFrame");
	QVBoxLayout * vboxLayout = new QVBoxLayout();
	vboxLayout->setContentsMargins(0, 0, 0, 0);
	vboxLayout->setSpacing(0);
	vboxLayout->setMargin(0);

	QComboBox * comboBox = new QComboBox();
	comboBox->setObjectName("infoViewComboBox");
	comboBox->setEditable(false);
	comboBox->setEnabled(swappingEnabled);
	m_fileNameComboBox = comboBox;

	setFileNameItems();

	connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(fileNameEntry(const QString &)));

	QPushButton * button = new QPushButton (tr("load image file"));
	button->setObjectName("infoViewButton");
	connect(button, SIGNAL(pressed()), this, SLOT(prepLoadImage()));
	button->setEnabled(swappingEnabled);

	vboxLayout->addWidget(comboBox);
	vboxLayout->addWidget(button);

	frame->setLayout(vboxLayout);
	returnWidget = frame;

	returnProp = "";
}
    foreach(sqlb::FieldPtr f, fields)
    {
        QTreeWidgetItem *tbitem = new QTreeWidgetItem(ui->treeWidget);
        tbitem->setFlags(tbitem->flags() | Qt::ItemIsEditable);
        tbitem->setText(kName, f->name());
        QComboBox* typeBox = new QComboBox(ui->treeWidget);
        typeBox->setProperty("column", f->name());
        typeBox->setEditable(true);
        typeBox->addItems(sqlb::Field::Datatypes);
        int index = typeBox->findText(f->type(), Qt::MatchExactly);
        if(index == -1)
        {
            // non standard named type
            typeBox->addItem(f->type());
            index = typeBox->count() - 1;
        }
        typeBox->setCurrentIndex(index);
        connect(typeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTypes()));
        ui->treeWidget->setItemWidget(tbitem, kType, typeBox);

        tbitem->setCheckState(kNotNull, f->notnull() ? Qt::Checked : Qt::Unchecked);
        tbitem->setCheckState(kPrimaryKey, pk.contains(f) ? Qt::Checked : Qt::Unchecked);
        tbitem->setCheckState(kAutoIncrement, f->autoIncrement() ? Qt::Checked : Qt::Unchecked);
        tbitem->setCheckState(kUnique, f->unique() ? Qt::Checked : Qt::Unchecked);

        // For the default value check if it is surrounded by parentheses and if that's the case
        // add a '=' character before the entire string to match the input format we're expecting
        // from the user when using functions in the default value field.
        if(f->defaultValue().startsWith('(') && f->defaultValue().endsWith(')'))
            tbitem->setText(kDefault, "=" + f->defaultValue());
        else
            tbitem->setText(kDefault, f->defaultValue());

        tbitem->setText(kCheck, f->check());

        QSharedPointer<sqlb::ForeignKeyClause> fk = m_table.constraint(f, sqlb::Constraint::ForeignKeyConstraintType).dynamicCast<sqlb::ForeignKeyClause>();
        if(fk)
            tbitem->setText(kForeignKey, fk->toString());
        ui->treeWidget->addTopLevelItem(tbitem);
    }
QWidget * table_widget_delegate::createWidget(const QModelIndex &index, const QStyleOptionViewItem &option, 
	QWidget *parent) const
{
	column_data_ptr cd = _column_datas[index.column()];
	if (!cd){
		return 0;
	}

	switch (cd->type)
	{
	case WIDGET_CHECKBOX:
		return 0;
	case  WIDGET_COMBOBOX:
		{
			QComboBox *widget = new QComboBox(parent);
            widget->setEditable(true);
			switch (cd->data.type())
			{
			case QVariant::StringList:
				widget->addItems(cd->data.toStringList());
				break;
			case QVariant::Map:
				{
					QVariantMap map = cd->data.toMap();
					for (auto it = map.begin(); it != map.end(); ++it){
						widget->addItem(it.key(), it.value());
					}
				}
				break;
			default:
				break;
			}
			return widget;
		}
	default:
		break;
	}

	return 0;
}