QWidget *ColoringRulesTreeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
{
    QWidget *w = NULL;

    QTreeWidgetItem *ti = tree_->topLevelItem(index.row());
    if (!ti) return NULL;

    switch (index.column()) {
    case name_col_:
    {
        SyntaxLineEdit *sle = new SyntaxLineEdit(parent);
        connect(sle, SIGNAL(textChanged(QString)), this, SLOT(ruleNameChanged(QString)));
        sle->setText(ti->text(name_col_));
        w = (QWidget*) sle;
    }
        break;

    case filter_col_:
    {
        DisplayFilterEdit *dfe = new DisplayFilterEdit(parent);
        // It's possible to have an invalid filter and an enabled OK button at this point.
        // We might want to add a local slot for checking the filter status.
        connect(dfe, SIGNAL(textChanged(QString)), dfe, SLOT(checkDisplayFilter(QString)));
        dfe->setText(ti->text(filter_col_));
        w = (QWidget*) dfe;
    }
        break;
    default:
        break;
    }

    return w;
}
QWidget *ColoringRulesTreeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    Q_UNUSED(option);
    QWidget *w = NULL;

    QTreeWidgetItem *ti = tree_->topLevelItem(index.row());
    if (!ti) return NULL;

    switch (index.column()) {
    case name_col_:
    {
        SyntaxLineEdit *sle = new SyntaxLineEdit(parent);
        connect(sle, SIGNAL(textChanged(QString)), this, SLOT(ruleNameChanged(QString)));
        sle->setText(ti->text(name_col_));
        w = (QWidget*) sle;
    }
        break;

    case filter_col_:
    {
        SyntaxLineEdit *dfe = new SyntaxLineEdit(parent);
        connect(dfe, SIGNAL(textChanged(QString)), dfe, SLOT(checkDisplayFilter(QString)));
        connect(dfe, SIGNAL(textChanged(QString)), this, SLOT(ruleFilterChanged(QString)));
        dfe->setText(ti->text(filter_col_));
        w = (QWidget*) dfe;
    }
        break;
    default:
        break;
    }

    return w;
}
Exemple #3
0
void
Rule::setRuleName(const QString &ruleName) {
    if (_ruleName != ruleName) {
        _ruleName = ruleName;
        emit ruleNameChanged();
    }
}
Exemple #4
0
void
Rule::_init() {
    connect(this,        SIGNAL(ruleNameChanged()),  this, SIGNAL(changed()));
    connect(this,        SIGNAL(ruleIdChanged()),    this, SIGNAL(changed()));
    connect(this,        SIGNAL(ruleActiveChanged()),    this, SIGNAL(changed()));
    connect(this,        SIGNAL(stopIfMatchedChanged()), this, SIGNAL(changed()));
    connect(&_condition, SIGNAL(changed()),          this, SIGNAL(conditionChanged()));
    connect(&_action,    SIGNAL(changed()),          this, SIGNAL(actionChanged()));
    connect(&_condition, SIGNAL(changed()), this, SIGNAL(changed()));
    connect(&_action,     SIGNAL(changed()),    this, SIGNAL(changed()));
//    connect(this,        SIGNAL(conditionChanged()), this, SIGNAL(changed()));
//    connect(this,        SIGNAL(actionChanged()),    this, SIGNAL(changed()));
}