Beispiel #1
0
ConstraintTable::ConstraintTable(QWidget * parent, ConstraintCanvas * c)
    : Q3Table(c->elements.count(), 4, parent)
{
    setSorting(true);
    setSelectionMode(NoSelection);
    setRowMovingEnabled(FALSE);

    horizontalHeader()->setLabel(0, TR("visible"));
    horizontalHeader()->setLabel(1, " ");
    horizontalHeader()->setLabel(2, TR("element"));
    horizontalHeader()->setLabel(3, TR("constraint"));
    setColumnStretchable(0, FALSE);
    setColumnStretchable(1, FALSE);

    int row;
    bool v = c->indicate_visible;
    Q3ValueList<BrowserNode *> & hv = c->hidden_visible;
    BrowserNodeList & elts = c->elements;
    BrowserNode * bn;
    QString yes = TR("  yes");
    QString empty;

    elts.sort();

    for (bn = elts.first(), row = 0; bn != 0; bn = elts.next(), row += 1) {
        if ((v) ? hv.findIndex(bn) != -1 : hv.findIndex(bn) == -1)
            setText(row, 0, yes);

        setPixmap(row, 1, *(bn->pixmap(0)));

        TableItem * ti;

        ti = new TableItem(this, Q3TableItem::Never, bn->full_name(TRUE));
        ti->setReplaceable(FALSE);
        setItem(row, 2, ti);

        QString s = toUnicode(bn->constraint());
        int n = s.count('\n');

        ti = new TableItem(this, Q3TableItem::Never, s);
        ti->setReplaceable(FALSE);
        setItem(row, 3, ti);

        if (n != 0) {
            // note : adjustRow(row) does nothing
            setRowHeight(row, rowHeight(row) * (n + 1));
        }
    }

    adjustColumn(0);
    adjustColumn(1);
    setColumnStretchable(2, TRUE);
    setColumnStretchable(3, TRUE);

    connect(this, SIGNAL(pressed(int, int, int, const QPoint &)),
            this, SLOT(button_pressed(int, int, int, const QPoint &)));
}
Beispiel #2
0
KeyValuesTable::KeyValuesTable(HaveKeyValueData * hv, QWidget * parent, bool isReadOnly)
    : StringTable(((hv == 0) ? 0 : hv->get_n_keys()) + ((isReadOnly) ? 0 : 1),
                  (isReadOnly) ? 2 : 3, parent, isReadOnly)
{
    horizontalHeader()->setLabel(0, TR("Key"));
    horizontalHeader()->setLabel(1, TR("Value"));

    if (!isReadOnly)
        horizontalHeader()->setLabel(2, TR("do"));

    int index;
    int sup = 0;
    if(hv)
        sup = hv->get_n_keys();

    if (isReadOnly)
    {
        for (index = 0; index < sup; index += 1)
        {
            TableItem * ti;

            ti = new TableItem(this, Q3TableItem::Never,
                               toUnicode(hv->get_key(index)));
            ti->setReplaceable(FALSE);
            setItem(index, 0, ti);

            QString s = toUnicode(hv->get_value(index));
            int n = s.count('\n');

            ti = new TableItem(this, Q3TableItem::Never, s);
            ti->setReplaceable(FALSE);
            setItem(index, 1, ti);

            if (n != 0)
            {
                // note : adjustRow(index) does nothing
                setRowHeight(index, rowHeight(index) * (n + 1));
            }
        }
    }
    else
    {
        props.setAutoDelete(TRUE);

        QStringList items;

        for (index = 0; index < sup; index += 1) {
            QString k = toUnicode(hv->get_key(index));
            QString v = toUnicode(hv->get_value(index));
            QStringList * psl = props[k];

            setText(index, 0, k);

            if (psl != 0)
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));

            if ((k.contains(':') == 2) &&
                    ProfiledStereotypes::enumerated(k, items)) {
                psl = new QStringList(items);
                props.insert(k, psl);
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));
            }
            else
                setItem(index, 1, new MLinesItem(this, v));

            setText(index, 2, QString());
            setRowStretchable(index, TRUE);
        }

        setText(index, 0, QString());
        setItem(index, 1, new MLinesItem(this, QString()));
        setText(index, 2, QString());
        setRowStretchable(index, TRUE);
    }

    horizontalHeader()->setResizeEnabled(TRUE, 0);  //setColumnStretchable (0, TRUE);
    setColumnStretchable(1, TRUE);

    if (! isReadOnly) {
        adjustColumn(2);
        setColumnStretchable(2, FALSE);
    }
}
Beispiel #3
0
void KeyValuesTable::updateThisFromNode(HaveKeyValueData *hv, bool isReadOnly)
{

    if (!isReadOnly)
    {
        if(numCols() == 2)
            insertColumns(2);
        horizontalHeader()->setLabel(2, TR("do"));
    }
    else
    {
        if(numCols() == 3)
            removeColumn(2);
    }

    int index;
    int sup = 0;
    if(hv)
        sup = hv->get_n_keys();
    int rowCount = numRows();
    for (index = rowCount - 1; index > sup; index -= 1)
        removeRow(index);

    if (isReadOnly)
    {
        for (index = 0; index < sup; index += 1)
        {
            TableItem * tiKey = nullptr;
            TableItem * tiValue = nullptr;
            QString s = toUnicode(hv->get_value(index));
            int n = s.count('\n');

            if(index == numRows() || numRows() == 0)
            {
                tiKey = new TableItem(this, Q3TableItem::Never,
                                      toUnicode(hv->get_key(index)));
                tiValue = new TableItem(this, Q3TableItem::Never, s);
                setItem(index, 0, tiKey);
                setItem(index, 1, tiValue);
            }
            else
            {
                tiKey = dynamic_cast<TableItem*>(item(index, 0));
                tiKey->setText(hv->get_key(index));
                tiValue = dynamic_cast<TableItem*>(item(index, 1));
                tiValue->setText(s);
            }
            tiKey->setReplaceable(FALSE);
            tiValue->setReplaceable(FALSE);


            if (n != 0)
            {
                // note : adjustRow(index) does nothing
                setRowHeight(index, rowHeight(index) * (n + 1));
            }
        }
    }
    else
    {
        props.setAutoDelete(TRUE);

        QStringList items;

        for (index = 0; index < sup; index += 1)
        {
            QString k = toUnicode(hv->get_key(index));
            QString v = toUnicode(hv->get_value(index));
            QStringList * psl = props[k];

            setText(index, 0, k);

            if (psl != 0)
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));

            if ((k.contains(':') == 2) &&
                    ProfiledStereotypes::enumerated(k, items)) {
                psl = new QStringList(items);
                props.insert(k, psl);
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));
            }
            else
                setItem(index, 1, new MLinesItem(this, v));

            setText(index, 2, QString());
            setRowStretchable(index, TRUE);
        }

        if(index == numRows())
            insertRows(numRows());
        setText(index, 0, QString());
        setItem(index, 1, new MLinesItem(this, QString()));
        setText(index, 2, QString());
        setRowStretchable(index, TRUE);
    }

    horizontalHeader()->setResizeEnabled(TRUE, 0);  //setColumnStretchable (0, TRUE);
    setColumnStretchable(1, TRUE);

    if (! isReadOnly) {
        adjustColumn(2);
        setColumnStretchable(2, FALSE);
    }



}