示例#1
0
DisplayInfo DisplaySpeed::getData() {
	DisplayInfo info;

	// The pulse scanner knows the speeds.
	PulseScanner* scanner = ((CyclometerController*)context)->getPulseScanner();

	// Get and format the speeds to the appropriate digits.
	// Hooray pointer arithmetic!
	formatSpeed(scanner->currentSpeed(), info.val + 2, info.dp + 2);
	formatSpeed(scanner->averageSpeed(), info.val, info.dp);

	return info;
}
示例#2
0
//--------------------------------------------------------------
// set the speed
void SpeedUI::setSpeed(
  double speed)
{
  if (m_speed == speed)
    return;

  m_speed = speed;
  formatSpeed();
}
示例#3
0
//--------------------------------------------------------------
// set the units
void SpeedUI::setUnits(
  int units)
{
  if (m_units == units)
    return;

  m_units = units;

  formatSpeed();
  formatRange();
}
示例#4
0
QVariant TransferList::data (const QModelIndex & index, int role) const {
	if (role != Qt::DisplayRole) return QVariant();
	int r = index.row ();
	if (r < 0 || (size_t)r >= mOpIds.size()) {
		sf::Log (LogWarning) << LOGID << "Strange row " << r << std::endl;
		return QVariant ();
	}
	AsyncOpId id = mOpIds[r];
	assert (mTransfers.count(id) > 0);
	const TransferInfo & t = mTransfers.find(id)->second;
	int c = index.column ();
	switch (c) {
	case 0:
		return QVariant (qtString (sf::toString (t.uri)));
		break;
	case 1:
		return QVariant (qtString (t.filename));
		break;
	case 2:
		if (mOutgoing)
			return QVariant (qtString (t.receiver));
		else
			return QVariant (qtString (t.source));
	break;
	case 3:
		return QVariant (formatSize (t.size));
		break;
	case 4:
		return QVariant (((float)t.transferred / (float)t.size)); // [0 .. 1]
		break;
	case 5:{
		return QVariant (formatSpeed (t.speed));
		break;
	}
	case 6:{
		int seconds = (int) (t.size / t.speed);
		return QVariant (formatInterval (seconds));
		break;
	}
	case 7:
		if (t.state == sf::TransferInfo::ERROR){
			return QVariant ("Error: " + QString (toString (t.error)));
		}
		return QVariant (tr(toString (t.state)));
		break;
	}
	return QVariant ();
}