Exemple #1
0
Drawbar::Drawbar(QWidget* parent)
   : Slider(parent)
      {
      _sliderColor = Qt::darkGray;
      setOrientation(Qt::Vertical);
      setInvertedAppearance(true);
      setRange(0.0, 8.0);
      setLineStep(1.0);
      setPageStep(1.0);
      setInteger(true);
      }
Exemple #2
0
void MemoryView::resizeEvent(QResizeEvent *event)
{
	if(m_updating)
		return;

	CodeEdit::resizeEvent(event);

	const int yPos = verticalScrollBar()->value();

	if(!m_memory.size())
		return;

	m_updating = true;

	const int contentWidth = viewport()->width() - m_gutter->prefferedWidth();
	int cellCount = contentWidth / fontMetrics().width("         ");

	if(cellCount * fontMetrics().width("         ") + fontMetrics().width("       ") <= contentWidth)
		cellCount += 1;

	setLineStep(cellCount + 1);

	QString content;
	int j = 0;
	for(int i = 0; i < m_memory.size(); ++i) {
		content += QString::number(m_memory[i]).rightJustified(8, ' ');

		++j;

		if(j > cellCount) {
			content += "\n";
			j = 0;
		} else {
			content += " ";
		}
	}

	if(content.endsWith("\n"))
		content.chop(1);

	if(toPlainText() != content) {
		clear();
		setPlainText(content);
	}

	verticalScrollBar()->setValue(yPos);

	m_updating = false;
}
Slider::Slider( QWidget *parent, const char *name,Qt::WFlags flag)
       :VtlWidget( parent, name, flag)
{
    resize(100,40);

    slider = new QSlider(this);
    slider->setOrientation(Qt::Horizontal);
    slider->setGeometry(10,10,80,20);
    slider->setMinValue(-32768);
    slider->show();

    orientation = Qt::Horizontal;
    direction = LeftToRight;
    minValue = 0;
    maxValue = 100;
    value = 0;
    tracking = Disabled;
    tickmarks = 0;
    tickInterval = 10;
    lineStep = 10;
    pageStep = 10;
    mainColor = Qt::white;
    tickmarksColor = Qt::black;
    precision = 1;

    setTickmarks (tickmarks);
    setTickInterval (tickInterval);
    setTracking (tracking);
    setDirection(direction);
    setLineStep(lineStep);
    setPageStep(pageStep);
    setMainColor(mainColor);
    setTickmarksColor(tickmarksColor);

    setNewMask();

    MDIRef = NULL;

    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
    connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(setNewMask()));
}
bool QDial::qt_property( int id, int f, QVariant* v)
{
    switch ( id - staticMetaObject()->propertyOffset() ) {
    case 0: switch( f ) {
	case 0: setTracking(v->asBool()); break;
	case 1: *v = QVariant( this->tracking(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 1: switch( f ) {
	case 0: setWrapping(v->asBool()); break;
	case 1: *v = QVariant( this->wrapping(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 2: switch( f ) {
	case 1: *v = QVariant( this->notchSize() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 3: switch( f ) {
	case 0: setNotchTarget(v->asDouble()); break;
	case 1: *v = QVariant( this->notchTarget() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 4: switch( f ) {
	case 0: setNotchesVisible(v->asBool()); break;
	case 1: *v = QVariant( this->notchesVisible(), 0 ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 5: switch( f ) {
	case 0: setMinValue(v->asInt()); break;
	case 1: *v = QVariant( this->minValue() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 6: switch( f ) {
	case 0: setMaxValue(v->asInt()); break;
	case 1: *v = QVariant( this->maxValue() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 7: switch( f ) {
	case 0: setLineStep(v->asInt()); break;
	case 1: *v = QVariant( this->lineStep() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 8: switch( f ) {
	case 0: setPageStep(v->asInt()); break;
	case 1: *v = QVariant( this->pageStep() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    case 9: switch( f ) {
	case 0: setValue(v->asInt()); break;
	case 1: *v = QVariant( this->value() ); break;
	case 3: case 4: case 5: break;
	default: return FALSE;
    } break;
    default:
	return QWidget::qt_property( id, f, v );
    }
    return TRUE;
}
bool Slider::onPropertyChanged(const QString& name, const QVariant& val)
{
    
    if ( VtlWidget::onPropertyChanged(name, val) )
      return TRUE;

    VtlActionHandler* actHandler = ((VtlWindow*)this->parentWidget())->actionHandler();  

    if (name == (QString) "PROCNAME") {
      processName = val.toString();
    }  
    else if (name == (QString) "ORIENTATION") {
           actHandler->setProperty(this, name, QVariant(orientation), val);
           setOrientation(val.toInt());
    }
    else if (name == (QString) "MINVALUE") {
           actHandler->setProperty(this, name, QVariant(minValue), val);
           setMinValue(val.toDouble());
    }
    else if (name == (QString) "MAXVALUE") {
           actHandler->setProperty(this, name, QVariant(maxValue), val);
           setMaxValue(val.toDouble());
    }
    else if (name == (QString) "DIRECTION") {
           actHandler->setProperty(this, name, QVariant(direction), val);
           setDirection(val.toInt());
    }
    else if (name == (QString )"SOURCER") {
      if ( val.toString() != "None" ) {
        _sourcer = SourcerConnector<VtlWidget>::change (this, _sourcer, val.toString() );
      }
      else 
        _sourcer = 0;
    }
    else if (name == (QString) "TRACKING") {
           actHandler->setProperty(this, name, QVariant(tracking), val);
           setTracking(val.toInt());
    }
    else if (name == (QString) "TICKMARKS") {
           actHandler->setProperty(this, name, QVariant(tickmarks), val);
           setTickmarks(val.toInt());
    }
    else if (name == (QString) "TICKINTERVAL") {
           actHandler->setProperty(this, name, QVariant(tickInterval), val);
           setTickInterval(val.toInt());
    }
    else if (name == (QString) "LINESTEP") {
           actHandler->setProperty(this, name, QVariant(lineStep), val);
           setLineStep(val.toDouble());
    }
    else if (name == (QString) "PAGESTEP") {
           actHandler->setProperty(this, name, QVariant(pageStep), val);
           setPageStep(val.toInt());
    }
    else if (name == (QString) "MAIN_COLOR") {
           actHandler->setProperty(this, name, QVariant(mainColor), val);
           setMainColor(val.toColor());
    }
    else if (name == (QString) "TICKMARKS_COLOR") {
           actHandler->setProperty(this, name, QVariant(tickmarksColor), val);
           setTickmarksColor(val.toColor());
    }
    else if (name == (QString) "PRECISION") {
           actHandler->setProperty(this, name, QVariant(precision), val);
           setPrecision(val.toInt());
    }

    repaint();
    return TRUE;
}