QWidget* RuleDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    Q_UNUSED(option)

    QWidget *editor = new QWidget(parent);
    KLineEdit *ruleLineEdit = new KLineEdit(editor);
    ruleLineEdit->setToolTip(i18n("Expression"));

    KComboBox *matchComboBox = new KComboBox(editor);
    matchComboBox->setToolTip(i18n("Match Mode"));
    matchComboBox->addItem(i18n("Ignore"));
    matchComboBox->addItem(i18n("Regular expression"));
    matchComboBox->addItem(i18n("Partial match"));
    matchComboBox->addItem(i18n("Exact match"));

    QCheckBox *requiredCheckBox = new QCheckBox(editor);
    requiredCheckBox->setToolTip(i18n("Required"));

    QHBoxLayout *layout = new QHBoxLayout(editor);
    layout->addWidget(ruleLineEdit);
    layout->addWidget(matchComboBox);
    layout->addWidget(requiredCheckBox);
    layout->setMargin(0);

    setEditorData(editor, index);

    return editor;
}
Пример #2
0
void PartDetailsDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    QLabel * label = dynamic_cast<QLabel*>(editor);
    if(label && index.isValid()){
        int column = index.column();
        QString text;
        if(column==PartsSqlTableModel::ColumnCreateDate){
            QDateTime date = index.data(Qt::EditRole).toDateTime();
            QLocale locale;
            text = locale.toString(date, QLocale::ShortFormat);
        }
        else if(column==PartsSqlTableModel::ColumnActualStock || column==PartsSqlTableModel::ColumnMinStock){
            QVariant stockVar = index.data(Qt::EditRole);
            if(stockVar.isValid()){
                QVariant partUnitVar = index.model()->index(index.row(), PartsSqlTableModel::ColumnPartUnit).data();
                QString posfix = partUnitVar.isValid() ? partUnitVar.toString() : QString();
                text = QString("%1 %2").arg(stockVar.toInt()).arg(posfix);
            }            
        }
        else{
            text = index.data(Qt::DisplayRole).toString();
        }
        label->setText(text);
    }
    else {
        setEditorData(editor, index);
    }
}
Пример #3
0
void QItemDelegate_QtDShell::__override_setEditorData(QWidget*  editor0, const QModelIndex&  index1, bool static_call) const
{
    if (static_call) {
        QItemDelegate::setEditorData((QWidget* )editor0, (const QModelIndex& )index1);
    } else {
        setEditorData((QWidget* )editor0, (const QModelIndex& )index1);
    }
}
Пример #4
0
QWidget *ComboBoxDelegateModulation::createEditor(QWidget *parent, const QStyleOptionViewItem &/* option */, const QModelIndex &index) const
{
  QComboBox* comboBox = new QComboBox(parent);
  for(int i = 0; i < DockRxOpt::ModulationStrings.size(); ++i)
  {
      comboBox->addItem(DockRxOpt::ModulationStrings[i]);
  }
  setEditorData(comboBox, index);
  return comboBox;
}
Пример #5
0
void ExtensionListDelegate::paint(QPainter* pPainter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
   std::auto_ptr<ExtensionListItem> pWidget(new ExtensionListItem(false, mAllowEditing));
   setEditorData(pWidget.get(), index);
   pWidget->resize(option.rect.width(), option.rect.height());
   QRect pixMapRect;
   pixMapRect.setWidth(option.rect.width());
   pixMapRect.setHeight(option.rect.height());
   QPixmap pix = QPixmap::grabWidget(pWidget.get());
   pPainter->save();
   pPainter->drawPixmap(option.rect, pix);
   pPainter->setPen(QPen(option.palette.mid(), 1.0, Qt::DashLine));
   pPainter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
   pPainter->restore();
}
Пример #6
0
void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelIndex& index) const
{
    setEditorData (editor, index, false);
}
Пример #7
0
QSize ExtensionListDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
   std::auto_ptr<ExtensionListItem> pWidget(new ExtensionListItem(mAllowEditing, mAllowEditing));
   setEditorData(pWidget.get(), index);
   return pWidget->sizeHint();
}
void DhQAbstractItemDelegate::DvhsetEditorData(QWidget* x1, const QModelIndex& x2) const {
  return setEditorData(x1, x2);
}