Beispiel #1
0
bool Widgets::comboBox(QWidget *parent, const QString& title, const QString& text, const QStringList& args,
		       const QString& defaultEntry, QString &result)
{
  KDialog dlg( parent );
  kapp->setTopWidget( &dlg );
  dlg.setCaption( title );
  dlg.setButtons( KDialog::Ok|KDialog::Cancel );
  dlg.setModal( true );
  dlg.setDefaultButton( KDialog::Ok );

  KVBox* vbox = new KVBox( &dlg );
  dlg.setMainWidget( vbox );

  QLabel label (vbox);
  label.setText (text);
  KComboBox combo (vbox);
  combo.insertItems (0, args);
  combo.setCurrentIndex( combo.findText( defaultEntry ) );

  handleXGeometry(&dlg);

  bool retcode = (dlg.exec() == QDialog::Accepted);

  if (retcode)
    result = combo.currentText();

  return retcode;
}
void KisInputModeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    KComboBox *combo = qobject_cast<KComboBox *>(editor);
    Q_ASSERT(combo);

    int i = combo->findText(d->action->shortcutIndexes().key(index.data(Qt::EditRole).toUInt()));
    combo->setCurrentIndex(i);
}
void TracksDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
    if (!comboBox)
        return;
    const int pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly);
    comboBox->setCurrentIndex(pos);
}
Beispiel #4
0
void ConditionalDialog::init(KCConditional const & tmp, int numCondition)
{
    kDebug() << "Adding" << numCondition;
    KComboBox * cb  = 0;
    KComboBox * sb  = 0;
    KLineEdit * kl1 = 0;
    KLineEdit * kl2 = 0;
    QString value;
    KCMap *const map = m_selection->activeSheet()->map();
    KCValueConverter *const converter = map->converter();

    switch (numCondition) {
    case 0:
        cb  = m_dlg->m_condition_1;
        sb  = m_dlg->m_style_1;
        kl1 = m_dlg->m_firstValue_1;
        kl2 = m_dlg->m_secondValue_1;
        break;
    case 1:
        cb  = m_dlg->m_condition_2;
        sb  = m_dlg->m_style_2;
        kl1 = m_dlg->m_firstValue_2;
        kl2 = m_dlg->m_secondValue_2;
        break;
    case 2:
        cb  = m_dlg->m_condition_3;
        sb  = m_dlg->m_style_3;
        kl1 = m_dlg->m_firstValue_3;
        kl2 = m_dlg->m_secondValue_3;
        break;
    default:
        return;
    }

    if (!tmp.styleName.isEmpty()) {
        sb->setCurrentIndex(sb->findText(tmp.styleName));
        sb->setEnabled(true);
    }

    switch (tmp.cond) {
    case KCConditional::None :
    case KCConditional::IsTrueFormula: // was unhandled
        break;

    case KCConditional::Equal :
        cb->setCurrentIndex(1);
        break;

    case KCConditional::Superior :
        cb->setCurrentIndex(2);
        break;

    case KCConditional::Inferior :
        cb->setCurrentIndex(3);
        break;

    case KCConditional::SuperiorEqual :
        cb->setCurrentIndex(4);
        break;

    case KCConditional::InferiorEqual :
        cb->setCurrentIndex(5);
        break;

    case KCConditional::Between :
        cb->setCurrentIndex(6);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;

    case KCConditional::Different :
        cb->setCurrentIndex(7);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;
    case KCConditional::DifferentTo :
        cb->setCurrentIndex(8);
        break;
    }

    if (tmp.cond != KCConditional::None) {
        kl1->setEnabled(true);
        kl1->setText(converter->asString(tmp.value1).asString());
    }
}