void QGeoMapReplyNokia::networkFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError)
        return;

    QVariant fromCache = m_reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
    setCached(fromCache.toBool());

    if (!isCached()) {
        QAbstractNetworkCache *cache = m_reply->manager()->cache();
        if (cache) {
            QNetworkCacheMetaData metaData = cache->metaData(m_reply->url());
            QDateTime exp = QDateTime::currentDateTime();
            exp = exp.addDays(14);
            metaData.setExpirationDate(exp);
            cache->updateMetaData(metaData);
        }
    }

    setMapImageData(m_reply->readAll());
    setMapImageFormat("PNG");
    setFinished(true);

    m_reply->deleteLater();
    m_reply = 0;
}
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile)
{
    setMapImageData(tile->img());
    setMapImageFormat(tile->format());
    setFinished(true);
    setCached(true);
    tile->deleteLater();
}
Beispiel #3
0
/**
 * Aim. (shows the right hand sprite and weapon holding)
 */ 
void BattleUnit::aim(bool aiming)
{
	if (aiming)
		_status = STATUS_AIMING;
	else
		_status = STATUS_STANDING;

	setCached(false);
}
Beispiel #4
0
DrawingItem::~DrawingItem()
{
    _drawing.signal_item_deleted.emit(this);
    //if (!_children.empty()) {
    //    g_warning("Removing item with children");
    //}

    // remove from the set of cached items and delete cache
    setCached(false, true);
    if (_has_cache_iterator) {
        _drawing._candidate_items.erase(_cache_iterator);
    }
    // remove this item from parent's children list
    // due to the effect of clearChildren(), this only happens for the top-level deleted item
    if (_parent) {
        _markForRendering();
    }

    switch (_child_type) {
    case CHILD_NORMAL: {
        ChildrenList::iterator ithis = _parent->_children.iterator_to(*this);
        _parent->_children.erase(ithis);
        } break;
    case CHILD_CLIP:
        // we cannot call setClip(NULL) or setMask(NULL),
        // because that would be an endless loop
        _parent->_clip = NULL;
        break;
    case CHILD_MASK:
        _parent->_mask = NULL;
        break;
    case CHILD_ROOT:
        _drawing._root = NULL;
        break;
    case CHILD_FILL_PATTERN:
        _parent->_fill_pattern = NULL;
        break;
    case CHILD_STROKE_PATTERN:
        _parent->_stroke_pattern = NULL;
        break;
    default: ;
    }

    if (_parent) {
        _parent->_markForUpdate(STATE_ALL, false);
    }
    clearChildren();
    delete _transform;
    delete _stroke_pattern;
    delete _fill_pattern;
    delete _clip;
    delete _mask;
    delete _filter;
    if(_style)
        sp_style_unref(_style);
}
Beispiel #5
0
void MlCache::setCachedSlices(const std::string & name)
{
	openEntry(name);
	HBase * p = getNamedEntry(name);
	int nf = p->numChildren();
	unsigned csize = entrySize(name);
	for(int i = 0; i < nf; i++) {
		if(p->isChildData(i))
			setCached(name, p->getChildName(i), csize);
	}
	
	closeEntry(name);
}
Beispiel #6
0
/**
 * Returns the soldier's amount of bravery.
 * @return Bravery.
 */
void BattleUnit::keepFalling()
{
	_fallPhase++;
	if (_fallPhase == 3)
	{
		_fallPhase = 2;
		if (_health == 0)
			_status = STATUS_DEAD;
		else
			_status = STATUS_UNCONSCIOUS;
	}
	setCached(false);
}
vector<float>& KernelCache::getRow(int i)
{
  //cout << "gettingRow " << i << endl;
  if (isCached(i)) {
    //cout << "cached" << endl;
    // remove pattern i from its current position in the list
    lru.erase(lruPtr[i]);
  }
  else {
    //cout << "numCached: " << numCached << endl;
    if (numCached >= numCacheable) {  // need to erase something
      //cout << "erasing..." << endl;
      int elementToErase = lru.back();
      setCached(elementToErase, false);
      rowPtr[i] = rowPtr[elementToErase];
      lru.pop_back();
    }
    else {
      // create the new row:
      //cout << "creating row..." << endl;
      rowPtr[i] = numCached;
      rows[numCached] = vector<float>(length);
      ++numCached;
    }
    setCached(i, true);
    for (int j = 0; j < length; j++) {
      rows[rowPtr[i]][j] = data->kernel->eval(data, i, j, data);
    }
  }
  lru.insert(lru.begin(), i);
  lruPtr[i] = lru.begin();
  //cout << "finished get row" << endl;

  vector<float> &retval = rows[rowPtr[i]];
  return retval;
}
//-----------------------------------------------------------------------------
void
QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
    if (!_reply) {
        return;
    }
    if (error != QNetworkReply::OperationCanceledError) {
        qWarning() << "Fetch tile error:" << _reply->errorString();
    }
    _reply->deleteLater();
    _reply = 0;
    if(!_badTile.size()) {
        QFile b(":/res/notile.png");
        if(b.open(QFile::ReadOnly))
            _badTile = b.readAll();
    }
    setMapImageData(_badTile);
    setMapImageFormat("png");
    setFinished(true);
    setCached(false);
}
Beispiel #9
0
QGeoMapReplyOsm::QGeoMapReplyOsm(QNetworkReply *reply, const QGeoTiledMapRequest &request, QObject *parent)
        : QGeoTiledMapReply(request, parent),
        m_reply(reply)
{
    m_reply->setParent(this);
    QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute);
    setCached(fromCache.toBool());

    connect(m_reply,
            SIGNAL(finished()),
            this,
            SLOT(networkFinished()));

    connect(m_reply,
            SIGNAL(error(QNetworkReply::NetworkError)),
            this,
            SLOT(networkError(QNetworkReply::NetworkError)));
    connect(m_reply,
            SIGNAL(destroyed()),
            this,
            SLOT(replyDestroyed()));
}
//-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent)
    : QGeoTiledMapReply(spec, parent)
    , _reply(NULL)
    , _request(request)
    , _networkManager(networkManager)
{
    if(_request.url().isEmpty()) {
        if(!_badMapBox.size()) {
            QFile b(":/res/notile.png");
            if(b.open(QFile::ReadOnly))
                _badMapBox = b.readAll();
        }
        setMapImageData(_badMapBox);
        setMapImageFormat("png");
        setFinished(true);
        setCached(false);
    } else {
        QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom());
        connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply);
        connect(task, &QGCMapTask::error, this, &QGeoTiledMapReplyQGC::cacheError);
        getQGCMapEngine()->addTask(task);
    }
}
Beispiel #11
0
/**
 * Kneel down and spend TUs.
 * @flag to kneel or to stand up
 */
void BattleUnit::kneel(bool kneeled)
{
	_kneeled = kneeled;
	setCached(false);
}
Beispiel #12
0
/**
 * Returns the soldier's amount of bravery.
 * @return Bravery.
 */
void BattleUnit::startFalling()
{
	_status = STATUS_FALLING;
	_fallPhase = 0;
	setCached(false);
}