Пример #1
0
KexiComboBoxTableEdit::KexiComboBoxTableEdit(KexiDB::TableViewColumn &column, QWidget *parent)
        : KexiComboBoxBase()
        , KexiInputTableEdit(column, parent)
        , d(new Private())
{
    m_setVisibleValueOnSetValueInternal = true;
    m_reinstantiatePopupOnShow = true; // needed because re-opening of the popup fails for unknown reason
    d->button = new KexiComboBoxDropDownButton(parentWidget() /*usually a viewport*/);
    d->button->hide();
    d->button->setFocusPolicy(Qt::NoFocus);
    connect(d->button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));

    connect(m_lineedit, SIGNAL(textChanged(QString)), this, SLOT(slotLineEditTextChanged(QString)));

    m_rightMarginWhenFocused = this->column()->isReadOnly() ? 0 : d->button->width();
    m_rightMarginWhenFocused -= RIGHT_MARGIN_DELTA;
    updateLineEditStyleSheet();
    m_rightMarginWhenFocused += RIGHT_MARGIN_DELTA;
}
KexiComboBoxTableEdit::KexiComboBoxTableEdit(KexiDB::TableViewColumn &column, QWidget *parent)
        : KexiComboBoxBase()
        , KexiInputTableEdit(column, parent)
        , d(new Private())
{
    m_setVisibleValueOnSetValueInternal = true;
    d->button = new KexiComboBoxDropDownButton(parentWidget() /*usually a viewport*/);
    d->button->hide();
    d->button->setFocusPolicy(Qt::NoFocus);
    connect(d->button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));

    connect(m_lineedit, SIGNAL(textChanged(QString)), this, SLOT(slotLineEditTextChanged(QString)));

// m_lineedit = new QLineEdit(this, "lineedit");
// m_lineedit->setFrame(false);
// m_lineedit->setFrameStyle( QFrame::Plain | QFrame::Box );
// m_lineedit->setLineWidth( 1 );
// if (f.isNumericType()) {
//  m_lineedit->setAlignment(AlignRight);
// }
// setView( m_lineedit );

// layout->addWidget(m_view);
// m_combo->setEditable( true );
// m_combo->clear();
// m_combo->insertStringList(f.enumHints());
// QStringList::ConstIterator it, end( f.enumHints().constEnd() );
// for ( it = f.enumHints().constBegin(); it != end; ++it) {
//  if(!hints.at(i).isEmpty())
//   m_combo->insertItem(hints.at(i));
// }

//js: TODO
//js static_cast<KComboBox*>(m_view)->insertStringList(list);
//js static_cast<KComboBox*>(m_view)->setCurrentItem(static_cast<int>(t));
}