Exemplo n.º 1
0
bool SelectionModel::setData(int row, const QVariant &value, const QByteArray &role) {
    return setData(index(row), value, m_roles.key(role));
}
Exemplo n.º 2
0
void UBGraphicsProxyWidget::setUuid(const QUuid &pUuid)
{
    UBItem::setUuid(pUuid);
    setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
Exemplo n.º 3
0
/*!
  Initialize data with an array of samples.
  \param samples Vector of points
*/
void QwtPlotSpectroCurve::setSamples( const QVector<QwtPoint3D> &samples )
{
    setData( new QwtPoint3DSeriesData( samples ) );
}
Exemplo n.º 4
0
//--------------------------------Execute---------------------------------//
//this method performs the actions for the Return object, using the
//store as a parameter to access the inventory and alter accordingly
//it also uses the file stream to read in the information
//according to formatting specifications, setting it for this specified
//derived transaction class
bool Returnx::execute(ifstream& file, Store& st)
{
	int custIdx;
	file >> custIdx;
	Customer* cust = st.getCustomer(custIdx);
	//read the custtomer index and get the customer at that index
	//from the store, if the store doesn't have the customer at that
	//spot then the customer has not been created and we cannot do anything
	if (cust == NULL)
	{
		cout << "Invalid Customer ID. Transaction could not be executed.\n";
		//no need for clean up since Customer is still NULL
		return false;
	}
	else
	{
		char format;
		file >> format;
		//read in the format, the format is specified to only be DVDs
		if (format != 'D')
		{
			cout << "Invalid format. Transaction could not be executed.\n";
			//no need for clean up since Formaat is not dynamic
			return false;
		}
		else
		{
			char genre;
			file >> genre;
			//read in the genre and then use the stores movie factory
			//to create a temporary movie of this genre,
			//however, if the genre did not correspond to an appropriate
			//movie, return false
			Movie* tempMov = st.getMovieFact().createIt(genre);
			if (tempMov == NULL)
			{
				cout << "Invalid movie. Transaction could not be"
					<< "executed.\n";
				//no need for clean up since tempMov is still NULL
				return false;
			}
			else
			{
				//everything worked, now we try to set the data
				//from the format specifications of a return
				//movie, and if this didn't work, the movie was 
				//created so we must clean this up. otherwise, we try
				//to return the movie from the inventory
				if (!tempMov->readTrans(file))
				{
					delete tempMov;
					tempMov = NULL;
					return false;
				}
				else
				{
					if (!cust->returnMovie(tempMov))
					{
						cout << "Invalid movie. Transaction could not be "
							<< "executed.\n";
						delete tempMov;
						tempMov = NULL;

						return false;
					}
					else
					{
						Movie* mov;
						//use a movie locator and a movie return value
						//to try to return the movie from the stores
						//inventory, if the return couldn't occur
						//we must delete the temporary movie
						if (!st.getInventory().returnMovie(mov, tempMov))
						{
							//if we couldn't return we must clean up
							cout << "Invalid movie." <<
								"Transaction could not be "
								<< "executed.\n";
							delete tempMov;
							tempMov = NULL;

							return false;
						}
						else
						{
							//otherwise everything worked out perfectly
							//so the data is set and the customer
							//adds this transaction to his/her trans hist
							//and clean up our temp mov
							setData(cust, mov);
							//cust->returnMovie(mov);
							delete tempMov;
							tempMov = NULL;
							cust->addTransaction(this);
							return true;
						}
					}
				}
			}
		}
	}
}
Exemplo n.º 5
0
 //--------------------------------------------------------------------------
 void CClan::init( ClanData* pData )
 {
     setData(pData);
 }
uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id,
                                 const QString &app_icon, const QString &summary, const QString &body,
                                 const QStringList &actions, const QVariantMap &hints, int timeout)
{
    uint id = 0;
    id = replaces_id ? replaces_id : m_nextId++;

    QString appname_str = app_name;
    if (appname_str.isEmpty()) {
        appname_str = i18n("Unknown Application");
    }

    if (timeout == -1) {
        const int AVERAGE_WORD_LENGTH = 6;
        const int WORD_PER_MINUTE = 250;
        int count = summary.length() + body.length();
        timeout = 60000 * count / AVERAGE_WORD_LENGTH / WORD_PER_MINUTE;

        // Add two seconds for the user to notice the notification, and ensure
        // it last at least five seconds, otherwise all the user see is a
        // flash
        timeout = 2000 + qMax(timeout, 3000);
    }

    const QString source = QString("notification %1").arg(id);
    if (replaces_id) {
        Plasma::DataContainer *container = containerForSource(source);
        if (container && container->data()["expireTimeout"].toInt() != timeout) {
            int timerId = m_sourceTimers.value(source);
            killTimer(timerId);
            m_sourceTimers.remove(source);
            m_timeouts.remove(timerId);
        }
    }

    Plasma::DataEngine::Data notificationData;
    notificationData.insert("id", QString::number(id));
    notificationData.insert("appName", appname_str);
    notificationData.insert("appIcon", app_icon);
    notificationData.insert("summary", summary);
    notificationData.insert("body", body);
    notificationData.insert("actions", actions);
    notificationData.insert("expireTimeout", timeout);

    QImage image;
    if (hints.contains("image_data")) {
        QDBusArgument arg = hints["image_data"].value<QDBusArgument>();
        image = decodeNotificationSpecImageHint(arg);
    } else if (hints.contains("image_path")) {
        QString path = findImageForSpecImagePath(hints["image_path"].toString());
        if (!path.isEmpty()) {
            image.load(path);
        }
    } else if (hints.contains("icon_data")) {
        // This hint was in use in version 1.0 of the spec but has been
        // replaced by "image_data" in version 1.1. We need to support it for
        // users of the 1.0 version of the spec.
        QDBusArgument arg = hints["icon_data"].value<QDBusArgument>();
        image = decodeNotificationSpecImageHint(arg);
    }
    notificationData.insert("image", image);

    if (hints.contains("urgency")) {
        notificationData.insert("urgency", hints["urgency"].toInt());
    }

    setData(source, notificationData );

    if (timeout) {
        int timerId = startTimer(timeout);
        m_sourceTimers.insert(source, timerId);
        m_timeouts.insert(timerId, source);
    }

    return id;
}
bool FunctionCurve::loadData(int points, bool xLog10Scale)
{
    if (!points)
        points = dataSize();

	double *X = (double *)malloc(points*sizeof(double));
	if (!X){
		QMessageBox::critical(0, QObject::tr("QtiPlot - Memory Allocation Error"),
		QObject::tr("Not enough memory, operation aborted!"));
		return false;
	}
	double *Y = (double *)malloc(points*sizeof(double));
	if (!Y){
		QMessageBox::critical(0, QObject::tr("QtiPlot - Memory Allocation Error"),
		QObject::tr("Not enough memory, operation aborted!"));
		free(X);
		return false;
	}

	double step = (d_to - d_from)/(double)(points - 1.0);
	if (d_function_type == Normal){
		MyParser parser;
		double x = d_from;
		try {
			parser.DefineVar(d_variable.ascii(), &x);
			QMapIterator<QString, double> i(d_constants);
			while (i.hasNext()){
				i.next();
				parser.DefineConst(i.key().ascii(), i.value());
			}
			parser.SetExpr(d_formulas[0].ascii());

			int lastButOne = points - 1;
			try {
				double xl = x, xr;
				double y = parser.EvalRemoveSingularity(&x, false);
				bool wellDefinedFunction = true;
				if (!gsl_finite(y)){// try to find a first well defined point (might help for some not really bad functions)
					wellDefinedFunction = false;
					for (int i = 0; i < lastButOne; i++){
						xl = x;
						x += step;
						xr = x;
						y = parser.Eval();
						if (gsl_finite(y)){
							wellDefinedFunction = true;
							int iter = 0;
							double x0 = x, y0 = y;
							while(fabs(xr - xl)/step > 1e-15 && iter < points){
								x = 0.5*(xl + xr);
								y = parser.Eval();
								if (gsl_finite(y)){
									xr = x;
									x0 = x;
									y0 = y;
								} else
									xl = x;
								iter++;
							}
							d_from = x0;
							X[0] = x0;
							Y[0] = y0;
							step = (d_to - d_from)/(double)(lastButOne);
							break;
						}
					}
					if (!wellDefinedFunction){
						QMessageBox::critical(0, QObject::tr("QtiPlot"),
						QObject::tr("The function %1 is not defined in the specified interval!").arg(d_formulas[0]));
						free(X); free(Y);
						return false;
					}
				} else {
					X[0] = d_from;
					Y[0] = y;
				}
			} catch (MyParser::Pole) {}

			ScaleEngine *sc_engine = 0;
			if (plot())
				sc_engine = (ScaleEngine *)plot()->axisScaleEngine(xAxis());

			if (xLog10Scale || (d_from > 0 && d_to > 0 && sc_engine &&
				sc_engine->type() == ScaleTransformation::Log10)){
				step = log10(d_to/d_from)/(double)(points - 1);
				for (int i = 1; i < lastButOne; i++ ){
					x = d_from*pow(10, i*step);
					X[i] = x;
					try {
						Y[i] = parser.EvalRemoveSingularity(&x, false);
					} catch (MyParser::Pole){}
				}
			} else {
				for (int i = 1; i < lastButOne; i++ ){
					x += step;
					X[i] = x;
					try {
						Y[i] = parser.EvalRemoveSingularity(&x, false);
					} catch (MyParser::Pole){}
				}
			}
			//the last point might be outside the interval, therefore we calculate it separately at its precise value
			x = d_to;
			X[lastButOne] = x;
			try {
				Y[lastButOne] = parser.EvalRemoveSingularity(&x, false);
			} catch (MyParser::Pole){}
		} catch(mu::ParserError &e) {}
	} else if (d_function_type == Parametric || d_function_type == Polar) {
		QStringList aux = d_formulas;
		MyParser xparser;
		MyParser yparser;
		double par;
		if (d_function_type == Polar) {
			QString swap=aux[0];
			aux[0]="("+swap+")*cos("+aux[1]+")";
			aux[1]="("+swap+")*sin("+aux[1]+")";
		}

		try {
			QMapIterator<QString, double> i(d_constants);
			while (i.hasNext()){
				i.next();
				xparser.DefineConst(i.key().ascii(), i.value());
				yparser.DefineConst(i.key().ascii(), i.value());
			}

			xparser.DefineVar(d_variable.ascii(), &par);
			yparser.DefineVar(d_variable.ascii(), &par);
			xparser.SetExpr(aux[0].ascii());
			yparser.SetExpr(aux[1].ascii());
			par = d_from;
			for (int i = 0; i<points; i++ ){
				X[i] = xparser.Eval();
				Y[i] = yparser.Eval();
				par += step;
			}
		} catch(mu::ParserError &) {}
	}

	if (curveType() == QwtPlotCurve::Yfx)
		setData(X, Y, points);
	else
		setData(Y, X, points);
	free(X); free(Y);
	return true;
}
Exemplo n.º 8
0
/*!
  Assign a series of points

  setSamples() is just a wrapper for setData() without any additional
  value - beside that it is easier to find for the developer.

  \param data Data
  \warning The item takes ownership of the data object, deleting
           it when its not used anymore.
*/
void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
{
    setData( data );
}
Exemplo n.º 9
0
/*!
  \brief Initialize the data by pointing to memory blocks which 
         are not managed by QwtPlotCurve.

  setRawSamples is provided for efficiency. 
  It is important to keep the pointers
  during the lifetime of the underlying QwtCPointerData class.

  \param xData pointer to x data
  \param yData pointer to y data
  \param size size of x and y

  \sa QwtCPointerData
*/
void QwtPlotCurve::setRawSamples( 
    const double *xData, const double *yData, int size )
{
    setData( new QwtCPointerData( xData, yData, size ) );
}
Exemplo n.º 10
0
PropertyItemInt::PropertyItemInt( QString name, const QVariant &value, PropertyItem *parent )
:PropertyItem(name,parent) {
 setData(value);


}
Exemplo n.º 11
0
/*!
  Initialize data with an array of points.

  \param samples Vector of points
  \note QVector is implicitly shared
  \note QPolygonF is derived from QVector<QPointF>
*/
void QwtPlotCurve::setSamples( const QVector<QPointF> &samples )
{
    setData( new QwtPointSeriesData( samples ) );
}
Exemplo n.º 12
0
void
ModelWindow::setDirty()
{
    dirty = true;
    setData(false);
}
Exemplo n.º 13
0
void
ModelWindow::setBinWidthFromSlider()
{
    binWidthLineEdit->setText(QString("%1").arg(binWidthSlider->value()));
    setData(false);
}
Exemplo n.º 14
0
void Input::setRep(QMap<QString, QVariant> rep)
{
    setData(rep);
}
Exemplo n.º 15
0
QxtSqlPackage& QxtSqlPackage::operator= (const QxtSqlPackage & other)
{
    setData(other.data());
    return *this;
}
Exemplo n.º 16
0
/*!
  Set data by copying x- and y-values from specified memory blocks.
  Contrary to setRawSamples(), this function makes a 'deep copy' of
  the data.

  \param xData pointer to x values
  \param yData pointer to y values
  \param size size of xData and yData

  \sa QwtPointArrayData
*/
void QwtPlotCurve::setSamples( 
    const double *xData, const double *yData, int size )
{
    setData( new QwtPointArrayData( xData, yData, size ) );
}
Exemplo n.º 17
0
int QHexEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: currentAddressChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: currentSizeChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: dataChanged(); break;
        case 3: overwriteModeChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: setAddressWidth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 5: setAddressArea((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: setAsciiArea((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 7: setHighlighting((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QByteArray*>(_v) = data(); break;
        case 1: *reinterpret_cast< int*>(_v) = addressOffset(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = addressAreaColor(); break;
        case 3: *reinterpret_cast< QColor*>(_v) = highlightingColor(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = selectionColor(); break;
        case 5: *reinterpret_cast< bool*>(_v) = overwriteMode(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 7: *reinterpret_cast< QFont*>(_v) = font(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setData(*reinterpret_cast< QByteArray*>(_v)); break;
        case 1: setAddressOffset(*reinterpret_cast< int*>(_v)); break;
        case 2: setAddressAreaColor(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setHighlightingColor(*reinterpret_cast< QColor*>(_v)); break;
        case 4: setSelectionColor(*reinterpret_cast< QColor*>(_v)); break;
        case 5: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 6: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 7: setFont(*reinterpret_cast< QFont*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemplo n.º 18
0
/*!
  \brief Initialize data with x- and y-arrays (explicitly shared)

  \param xData x data
  \param yData y data

  \sa QwtPointArrayData
*/
void QwtPlotCurve::setSamples( const QVector<double> &xData,
    const QVector<double> &yData )
{
    setData( new QwtPointArrayData( xData, yData ) );
}
Exemplo n.º 19
0
void DataCurve::loadData()
{
  Plot *plot = static_cast<Plot *>(this->plot());
  Graph *g = static_cast<Graph *>(plot->parent());
  if (!g)
    return;

  int xcol = d_table->colIndex(d_x_column);
  int ycol = d_table->colIndex(title().text());

  if (xcol < 0 || ycol < 0){
    remove();
    return;
  }

  int r = abs(d_end_row - d_start_row) + 1;
  QVarLengthArray<double> X(r), Y(r);
  int xColType = d_table->columnType(xcol);
  int yColType = d_table->columnType(ycol);

  QStringList xLabels, yLabels;// store text labels

//  int xAxis = QwtPlot::xBottom;
//  if (d_type == Graph::HorizontalBars)
//    xAxis = QwtPlot::yLeft;

  QTime time0;
  QDateTime date0;
  QString date_time_fmt = d_table->columnFormat(xcol);
  if (xColType == Table::Time){
    for (int i = d_start_row; i <= d_end_row; i++ ){
      QString xval=d_table->text(i,xcol);
      if (!xval.isEmpty()){
        time0 = QTime::fromString (xval, date_time_fmt);
        if (time0.isValid())
          break;
      }
    }
  } else if (xColType == Table::Date){
    for (int i = d_start_row; i <= d_end_row; i++ ){
      QString xval=d_table->text(i,xcol);
      if (!xval.isEmpty()){
        date0 = QDateTime::fromString (xval, date_time_fmt);
        if (date0.isValid())
          break;
      }
    }
  }

  int size = 0;
  for (int i = d_start_row; i <= d_end_row; i++ ){
    QString xval = d_table->text(i,xcol);
    QString yval = d_table->text(i,ycol);
    if (!xval.isEmpty() && !yval.isEmpty()){
      bool valid_data = true;
      if (xColType == Table::Text){
        xLabels << xval;
        X[size] = (double)(size + 1);
      } else if (xColType == Table::Time){
        QTime time = QTime::fromString (xval, date_time_fmt);
        if (time.isValid())
          X[size]= time0.msecsTo (time);
      } else if (xColType == Table::Date){
        QDateTime d = QDateTime::fromString (xval, date_time_fmt);
        if (d.isValid())
          X[size] = (double) date0.secsTo(d);
      } else
        X[size] = plot->locale().toDouble(xval, &valid_data);

      if (yColType == Table::Text){
        yLabels << yval;
        Y[size] = (double)(size + 1);
      } else
        Y[size] = plot->locale().toDouble(yval, &valid_data);

      if (valid_data)
        size++;
    }
  }

  X.resize(size);
  Y.resize(size);

  // The code for calculating the waterfall offsets, that is here in QtiPlot, has been moved up to
  // PlotCurve so that MantidCurve can access it as well.
  if (g->isWaterfallPlot())
  {
    // Calculate the offsets
    computeWaterfallOffsets();
  }
  // End re-jigged waterfall offset code

  if (!size){
    remove();
    return;
  } else {
    if (d_type == Graph::HorizontalBars){
      setData(Y.data(), X.data(), size);
      foreach(DataCurve *c, d_error_bars)
        c->setData(Y.data(), X.data(), size);
    } else {
      setData(X.data(), Y.data(), size);
      foreach(DataCurve *c, d_error_bars)
        c->setData(X.data(), Y.data(), size);
    }

    if (xColType == Table::Text){
      if (d_type == Graph::HorizontalBars)
        g->setLabelsTextFormat(QwtPlot::yLeft, ScaleDraw::Text, d_x_column, xLabels);
      else
        g->setLabelsTextFormat(QwtPlot::xBottom, ScaleDraw::Text, d_x_column, xLabels);
    } else if (xColType == Table::Time || xColType == Table::Date){
      int axis = QwtPlot::xBottom;
      if (d_type == Graph::HorizontalBars)
        axis = QwtPlot::yLeft;
      ScaleDraw *old_sd = static_cast<ScaleDraw *>(plot->axisScaleDraw(axis));
      ScaleDraw *sd = new ScaleDraw(plot, old_sd);
      if (xColType == Table::Date)
        sd->setDateTimeOrigin(date0);
      else
        sd->setDateTimeOrigin(QDateTime(QDate::currentDate(), time0));
      plot->setAxisScaleDraw(axis, sd);
    }

    if (yColType == Table::Text)
      g->setLabelsTextFormat(QwtPlot::yLeft, ScaleDraw::Text, title().text(), yLabels);
  }

  if (!d_labels_list.isEmpty()){
    (static_cast<Graph*>(plot->parent()))->updatePlot();
    loadLabels();
  }
}
Exemplo n.º 20
0
void XLineEdit::setDataWidgetMap(XDataWidgetMapper* m)
{
  _mapper=m;
  m->addMapping(this, _fieldName, QByteArray("text"), QByteArray("defaultText"));
  connect(this, SIGNAL(textChanged(QString)), this, SLOT(setData(QString)));
}
Exemplo n.º 21
0
void ProcessingInstruction::setNodeValue(const String& nodeValue, ExceptionCode& ec)
{
    // NO_MODIFICATION_ALLOWED_ERR: taken care of by setData()
    setData(nodeValue, ec);
}
void QwtErrorPlotCurve::loadData()
{
	if (!d_master_curve)
		return;

    if (!plot())
        return;

	Table *mt = d_master_curve->table();
	if (!mt)
		return;

	int xcol = mt->colIndex(d_master_curve->xColumnName());
	int ycol = mt->colIndex(d_master_curve->title().text());
	int errcol = d_table->colIndex(title().text());
	if (xcol<0 || ycol<0 || errcol<0)
		return;

	int xColType = mt->columnType(xcol);
	int yColType = mt->columnType(ycol);

	d_start_row = d_master_curve->startRow();
	d_end_row = d_master_curve->endRow();
    int r = abs(d_end_row - d_start_row) + 1;
	QVector<double> X(r), Y(r), err(r);
    int data_size = 0;
    QLocale locale = d_table->locale();
	for (int i = d_start_row; i <= d_end_row; i++){
		QString xval = mt->text(i, xcol);
		QString yval = mt->text(i, ycol);
		QString errval = d_table->text(i, errcol);
		if (!xval.isEmpty() && !yval.isEmpty() && !errval.isEmpty()){
		    bool ok = true;
			if (xColType == Table::Text)
				X[data_size] = (double)(data_size + 1);
			else
				X[data_size] = locale.toDouble(xval, &ok);

			if (yColType == Table::Text)
				Y[data_size] = (double)(data_size + 1);
			else
				Y[data_size] = locale.toDouble(yval, &ok);

            if (!ok)
                continue;

			err[data_size] = locale.toDouble(errval, &ok);
			if (ok)
                data_size++;
		}
	}

	if (!data_size)
		remove();

    X.resize(data_size);
	Y.resize(data_size);
	err.resize(data_size);

	setData(X.data(), Y.data(), data_size);
	setErrors(err);
}
Exemplo n.º 23
0
void RecycledListItem::updateItemContents()
{
    AbstractViewItem::updateItemContents();    
    if (m_model && m_index.isValid())
        setData(m_model->data(m_index,Qt::DisplayRole), Qt::DisplayRole);
}
Exemplo n.º 24
0
/// setData() is re-implemented from QStandardItemModel to set the widget window title and icon for the Qt::DecorationRole and Qt::DisplayRole/Qt::EditRole
bool AMWindowPaneModel::setData(const QModelIndex &index, const QVariant &value, int role) {

	if(!index.isValid())
		return false;

	switch(role) {

	case Qt::DisplayRole:
	case Qt::EditRole:
		// alias items and heading items can have separate descriptions, but for normal items, the DisplayRole and EditRole should be the window title
		if(isAlias(index) || isHeading(index))
			return AMDragDropItemModel::setData(index, value, role);

		if(internalPane(index)) {
			internalPane(index)->setWindowTitle(value.toString());
			return true;
		}
		else
			return false;

		break;


	case Qt::DecorationRole:
		// alias items and heading items can have separate icons, but for normal items, the Decoration role should be the window icon
		if(isAlias(index) || isHeading(index))
			return AMDragDropItemModel::setData(index, value, role);

		if(internalPane(index)) {
			internalPane(index)->setWindowIcon(value.value<QIcon>());
			return true;
		}
		else
			return false;
		break;

	case AMWindowPaneModel::DockStateRole:
	{

		// docking an alias? dock the target instead.
		if(isAlias(index)) {
			QStandardItem* target = aliasTarget(index);
			if(target)
				return setData(target->index(), value, role);
			else
				return false;
		}

		bool nowDocked = value.toBool();
		bool wasDocked = isDocked(index);

		// set dock state like normal, but emit special signal dockStateChanged() if it's changing.
		if(AMDragDropItemModel::setData(index, value, role)) {

			QWidget* w = internalPane(index);

			if(wasDocked && !nowDocked)
				emit dockStateChanged(w, false, index.data(AMWindowPaneModel::UndockResizeRole).toBool());
			else if(!wasDocked && nowDocked)
				emit dockStateChanged(w, true, index.data(AMWindowPaneModel::UndockResizeRole).toBool());

			return true;
		}
		else
			return false;
		break;
	}
	case AMWindowPaneModel::UndockResizeRole:
		return AMDragDropItemModel::setData(index, value, role);
		break;

	case AMWindowPaneModel::IsVisibleRole:
	    if (AMDragDropItemModel::setData(index, value, role)) {
			QWidget *pane = internalPane(index);
			emit visibilityChanged(pane, value.toBool());
			return true;
	    } else {
			return false;
	    }

	    break;

	default:
		return AMDragDropItemModel::setData(index, value, role);
	}
}
Exemplo n.º 25
0
      // Method to store satellite data in this class' data map
   void SatDataReader::loadData(void)
      throw(FFStreamError, gpstk::StringUtils::StringException)
   {

         // Do this until end-of-file reached or something else happens
      while(1)
      {
         try
         {
            std::string line;

            formattedGetLine(line, true);

               // If line is too long, we throw an exception
            if (line.size()>255)
            {
               FFStreamError e("Line too long");
               GPSTK_THROW(e);
            }

               // Let's find and strip comments, wherever they are
            if( StringUtils::firstWord(line)[0] == '#' )
            {
               formattedGetLine(line, true);
            }

            std::string::size_type idx = line.find('#');
            if( !(idx == std::string::npos) )
            {
               line = line.substr(0, idx);
            }

               // We erase the header (first line)
            if( StringUtils::firstWord(line) == "Launch" )
            {
               formattedGetLine(line, true);
            }

               // Remove trailing and leading blanks
            line = StringUtils::strip(line);

               // Skip blank lines
            if (line.size()==0)
            {
               continue;
            }

               // Let's start to get data out of file
               // Launch date
            string ldate(StringUtils::stripFirstWord(line));
               // Deactivation date
            string ddate(StringUtils::stripFirstWord(line));
               // GPS number
            string gnumber(StringUtils::stripFirstWord(line));
               // PRN number
            string prn(StringUtils::stripFirstWord(line));
               // Block tipe
            string block(StringUtils::upperCase(
               StringUtils::stripFirstWord(line)));

               // Get satellite id. If it doesn't fit GPS or Glonass, it is
               // marked as unknown
            SatID sat(StringUtils::asInt(prn),SatID::systemUnknown);
               // Let's identify satellite system
            if(block[0] == 'I')
            {
               sat.system = SatID::systemGPS;
            }
            else
            { 
               if (block.substr(0, 3) == "GLO")
               {
                  sat.system = SatID::systemGlonass;
               }
            }

               // Declare the structure to store data
            SatDataReader::svData data;

            data.block = block;
            data.gpsNumber = StringUtils::asInt(gnumber);

               // Get launch date in a proper format
            if(ldate[0] != '0')
            {
                ldate = StringUtils::translate(ldate, "-", " ");
                scanTime(data.launchDate, ldate, "%Y %m %d");
            }

               // Get deactivation date in a proper format
            if(ddate[0] != '0')
            {
                ddate = StringUtils::translate(ddate, "-", " ");
                scanTime(data.deactivationDate, ddate, "%Y %m %d");
            }

            // It's not a good way!!! 
            data.launchDate.setTimeSystem(TimeSystem::Any);
            data.deactivationDate.setTimeSystem(TimeSystem::Any);

               // Insert data in data map
            setData(sat, data);

         }  // End of try block
         catch (EndOfFile& e)
         {
               // Close this data stream
            (*this).close();

            return;
         }
         catch (...)
         {
               // Close this data stream
            (*this).close();

            return;
         }

      } // End of while(1)

   }  // End of method 'SatDataReader::loadData()'
Exemplo n.º 26
0
Buffer &Buffer::operator=(const Buffer &copy)
{
    setData(copy.data, copy.len);
    return *this;
}
Exemplo n.º 27
0
void CharacterData::setNodeValue(const String& nodeValue, ExceptionCode& ec)
{
    setData(nodeValue, ec);
}
Exemplo n.º 28
0
/*!
Constructs a copy of \a other with \a parent.
*/
QxtSqlPackage::QxtSqlPackage(const QxtSqlPackage & other, QObject *parent) : QObject(parent)
{
    record = -1;

    setData(other.data());
}
Exemplo n.º 29
0
/*!
  Assign a series of samples
    
  setSamples() is just a wrapper for setData() without any additional
  value - beside that it is easier to find for the developer.
    
  \param data Data
  \warning The item takes ownership of the data object, deleting
           it when its not used anymore. 
*/
void QwtPlotSpectroCurve::setSamples(
    QwtSeriesData<QwtPoint3D> *data )
{
    setData( data );
}  
Exemplo n.º 30
0
UBMimeData::UBMimeData(const QList<UBMimeDataItem> &items)
    : QMimeData()
    , mItems(items)
{
    setData(UBApplication::mimeTypeUniboardPage, QByteArray());
}