int ExactnessConfigurator::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: addCurrentValue(); break;
        case 1: removeCurrentValue(); break;
        case 2: updateValueFromItem((*reinterpret_cast< QTableWidgetItem*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Example #2
0
ExactnessConfigurator::ExactnessConfigurator(QWidget *parent) :QWidget(parent)
{
    #ifdef K_DEBUG
           TINIT;
    #endif

    QBoxLayout *mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);

    QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom);
    QLabel *label = new QLabel(tr("Smoothness"));
    label->setAlignment(Qt::AlignHCenter); 
    layout->addWidget(label);
    m_exactness = new QDoubleSpinBox();

    //m_exactness->setValue(4.0);
    m_exactness->setDecimals(2);
    m_exactness->setSingleStep(0.1);
    m_exactness->setMaximum(100);
    layout->addWidget(m_exactness);

    mainLayout->addLayout(layout);

    QLabel *previews = new QLabel(tr("My Values:"));
    previews->setAlignment(Qt::AlignHCenter);
    mainLayout->addWidget(previews);

    m_table = new QTableWidget(3, 3);
    connect(m_table, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(updateValueFromItem(QTableWidgetItem *)));

    m_table->setSelectionMode(QAbstractItemView::SingleSelection);
    m_table->horizontalHeader()->hide();
    m_table->verticalHeader()->hide();

    for (int row = 0; row < m_table->rowCount(); row++) {
         m_table->verticalHeader()->resizeSection(row, 15);

         for (int col = 0; col < m_table->columnCount(); col++) {
              QTableWidgetItem *newItem = new QTableWidgetItem;
              m_table->setItem(row, col, newItem);
         }
    }

    m_table->setItemSelected(m_table->item(0,0), true); 
    m_table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    m_table->setMaximumHeight(22*m_table->rowCount() + 3);
    m_table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
    m_table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

    mainLayout->addWidget(m_table);

    QBoxLayout *buttonLayout = new QBoxLayout(QBoxLayout::LeftToRight);

    TImageButton *add = new TImageButton(QIcon(kAppProp->themeDir() + "/"  + "icons/plus_sign.png"),22, 0, false);
    connect(add, SIGNAL(clicked()), this, SLOT(addCurrentValue()));
    buttonLayout->addWidget(add);

    TImageButton *del = new TImageButton(QIcon(kAppProp->themeDir() + "/"  + "icons/minus_sign.png"), 22, 0, false);
    connect(del, SIGNAL(clicked()), this, SLOT(removeCurrentValue()));
    buttonLayout->addWidget(del);

    mainLayout->addLayout(buttonLayout);
    mainLayout->addStretch(2);

    TCONFIG->beginGroup("BrushTool");
    double smoothness = TCONFIG->value("Smoothness", -1).toDouble();

    if (smoothness > 0) 
        m_exactness->setValue(smoothness);
    else
        m_exactness->setValue(4.0);
}