Exemplo n.º 1
0
	void clear(){
		resourceUrl->clear();
		resourceEncodeQueryItems->clear();
		acceptType->clear();
		refererUrl->clear();
		refererEncodeQueryItems->clear();
		vaild = true;
	}
Exemplo n.º 2
0
// Get a resource's map data
void ResourceTable::getResourceMap(QHash<QString, qint32> &hashMap, QHash<qint32, Resource> &resourceMap, qint32 noteLid) {
    NoteTable ntable(db);
    QString noteGuid = ntable.getGuid(noteLid);
    NSqlQuery query(db);
    qint32 prevLid = -1;
    db->lockForRead();
    query.prepare("Select key, data, lid from datastore where lid in (select lid from datastore where key=:key2 and data=:noteLid) order by lid");
    query.bindValue(":key2", RESOURCE_NOTE_LID);
    query.bindValue(":noteLid", noteLid);
    query.exec();
    hashMap.clear();
    resourceMap.clear();
    Resource *r = NULL;
    QString hash;
    while (query.next()) {
        qint32 lid = query.value(2).toInt();

        // Peek at the next record to see if we are at the end
        // If this is the last result set, we force a save of the
        // record
        if (!query.next()) {
            prevLid = lid;
            lid = -1;
        }
        query.previous();

        // If these don't match, we need to save the current
        // record we are building.
        if (prevLid != lid) {
            if (prevLid > 0) {
                if (hash != "") {
                    hashMap.insert(hash, prevLid);
                    if (r == NULL)
                        r = new Resource();
                    if (!r->noteGuid.isSet()) {
                        r->noteGuid = noteGuid;
                    }
                    resourceMap.insert(prevLid, *r);
                    delete r;
                }
            }
            r = new Resource();
            prevLid = lid;
            hash = "";
        }
        qint32 key = query.value(0).toInt();
        if (key == RESOURCE_DATA_HASH) {
            hash = query.value(1).toString();
        }
        mapResource(query, *r);
    }
    db->unlock();
    query.finish();

    if (r != NULL)
        delete r;
}
void Ut_NotificationPreviewPresenter::cleanup()
{
    homeWindows.clear();
    homeWindowVisible.clear();
    qDeleteAll(notificationManagerNotification);
    notificationManagerNotification.clear();
    notificationManagerCloseNotificationIds.clear();
    gQmLocksStub->stubReset();
    gQmDisplayStateStub->stubReset();
}
 ~medCompositeParameterPrivate()
 {
     variants.clear();
     QHashIterator<QString, QWidget*> i(widgets);
     while (i.hasNext())
     {
         i.next();
         delete i.value();
     }
     widgets.clear();
 }
Exemplo n.º 5
0
bool shutdownScripts()
{
	timers.clear();
	bindings.clear();
	internalNamespace.clear();
	while (!scripts.isEmpty())
	{
		delete scripts.takeFirst();
	}
	return true;
}
Exemplo n.º 6
0
void ScriptsModel::rebuildTree() {
    for (int i = _treeNodes.size() - 1; i >= 0; i--) {
        if (_treeNodes.at(i)->getType() == TREE_NODE_TYPE_FOLDER) {
            delete _treeNodes.at(i);
            _treeNodes.removeAt(i);
        }
    }
    QHash<QString, TreeNodeFolder*> folders;
    for (int i = 0; i < _treeNodes.size(); i++) {
        TreeNodeBase* node = _treeNodes.at(i);
        if (node->getType() == TREE_NODE_TYPE_SCRIPT) {
            TreeNodeScript* script = static_cast<TreeNodeScript*>(node);
            TreeNodeFolder* parent = NULL;
            QString hash;
            QStringList pathList = script->getLocalPath().split(tr("/"));
            pathList.removeLast();
            QStringList::const_iterator pathIterator;
            for (pathIterator = pathList.constBegin(); pathIterator != pathList.constEnd(); ++pathIterator) {
                hash.append(*pathIterator + "/");
                if (!folders.contains(hash)) {
                    folders[hash] = new TreeNodeFolder(*pathIterator, parent);
                }
                parent = folders[hash];
            }
            script->setParent(parent);
        }
    }
    QHash<QString, TreeNodeFolder*>::const_iterator folderIterator;
    for (folderIterator = folders.constBegin(); folderIterator != folders.constEnd(); ++folderIterator) {
        _treeNodes.append(*folderIterator);
    }
    folders.clear();
}
Exemplo n.º 7
0
    void commit() {
        // update all documents

        // remove previous instances
        if ( indexPresent() ) {
            for ( QHash<Node, lucene::document::Document*>::iterator it = documentCache.begin();
                  it != documentCache.end(); ++it ) {
                lucene::document::Document* doc = it.value();
                if ( const TCHAR* id = doc->get( idFieldName().data() ) ) { // this check is only for testing, it should NEVER fail
                    lucene::index::Term* idTerm = _CLNEW lucene::index::Term( idFieldName().data(), id );
                    getIndexReader()->deleteDocuments( idTerm );
                    _CLDECDELETE( idTerm );
                }
            }
        }

        // add the updated ones
        for ( QHash<Node, lucene::document::Document*>::iterator it = documentCache.begin();
              it != documentCache.end(); ++it ) {
            lucene::document::Document* doc = it.value();
            // never add empty docs
            if ( !docEmpty( doc ) ) {
                getIndexWriter()->addDocument( doc );
            }
            _CLDELETE( doc );
        }

        documentCache.clear();
    }
static void fill(Counter &counter, const typename Counter::Container &container, bool fragmented)
{
    qint64 allocated = 0;
    QHash<void *, int> allocations;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            int amount = fragmented ? j : i;
            allocated += amount;
            counter.request(amount);
            void *alloc = malloc(amount);
            allocations.insertMulti(alloc, amount);
            counter.obtain(reinterpret_cast<quintptr>(alloc));
            QCOMPARE(counter.currentTotal(), allocated);
        }
    }

    QCOMPARE(allocated, 99 * 50 * 100);
    QCOMPARE(counter.currentTotal(), allocated);
    QCOMPARE(sum(container), allocated);

    for (auto it = allocations.begin(), end = allocations.end(); it != end; ++it) {
        free(it.key());
        counter.release(reinterpret_cast<quintptr>(it.key()));
        allocated -= it.value();
        QCOMPARE(counter.currentTotal(), allocated);
    }

    allocations.clear();

    QCOMPARE(allocated, 0);
    QCOMPARE(counter.currentTotal(), 0);
    QCOMPARE(sum(container), 0);
}
Exemplo n.º 9
0
bool Cz1::init(void)				// initialize
{
//    if (!fp_log) fp_log=fopen("z1.log","wt");	// Open log file
//    pCPU->logsw = true;
#ifndef QT_NO_DEBUG
//    pCPU->logsw = true;

#endif
    initExtension();
    CpcXXXX::init();

//    for(int i = 0; i < 0x10000; i++) mem[i] = i & 0xff;

    pHD66108->init();

    i80l188ebcpu->eoi = 0x8000;
    io_b8 = timer0Control = timer2Control = 0;

    intPulseId = pTIMER->initTP(240);

    lastIntPulse = false;

    pCENTCONNECTOR = new Cconnector(this,36,1,Cconnector::Centronics_36,"Parrallel Connector",false,QPoint(715,50));
    publish(pCENTCONNECTOR);
    pSIOCONNECTOR = new Cconnector(this,9,2,Cconnector::DB_25,"Serial Connector",false,QPoint(0,50));
    publish(pSIOCONNECTOR);
    pSERIALCONNECTOR = new Cconnector(this,3,3,Cconnector::Jack,"Serial Jack Connector",false,QPoint(0,20));
    publish(pSERIALCONNECTOR);

//    pUART->init();
//    pUART->pTIMER = pTIMER;

    pCENT->init();
    pCENT->setBufferSize(10);

    QHash<int,QString> lbl;
    lbl.clear();
    lbl[1] = "STROBE";
    lbl[2] = "D1";
    lbl[3] = "D2";
    lbl[4] = "D3";
    lbl[5] = "D4";
    lbl[6] = "D5";
    lbl[7] = "D6";
    lbl[8] = "D7";
    lbl[9] = "D8";
    lbl[10]= "ACK";
    lbl[11]= "BUSY";
    lbl[31]= "INIT";
    lbl[32]= "ERROR";
    QHash<int,QString> lbl_serial;
    lbl_serial.clear();
    lbl_serial[1] = "RXD";
    lbl_serial[2] = "TXD";
    WatchPoint.remove(this);
    WatchPoint.add(&pCENTCONNECTOR_value,64,36,this,"Centronic 36pins connector",lbl);
    WatchPoint.add(&pSERIALCONNECTOR_value,64,3,this,"Synchronous serial connector",lbl_serial);

    return true;
}
Exemplo n.º 10
0
void Ut_USBModeSelector::cleanup()
{
    delete usbModeSelector;
    qQuickViews.clear();
    qWindowVisible.clear();
    gNotificationManagerStub->stubReset();
}
Exemplo n.º 11
0
void iV_FreeImageFile(IMAGEFILE *imageFile)
{
	// so when we get here, it is time to redo everything. will clean this up later. TODO.
	files.clear();
	images.clear();
	delete imageFile;
}
Exemplo n.º 12
0
void QgsHttpRequestHandler::imageColors( QHash<QRgb, int>& colors, const QImage& image )
{
  colors.clear();
  int width = image.width();
  int height = image.height();

  const QRgb* currentScanLine = nullptr;
  QHash<QRgb, int>::iterator colorIt;
  for ( int i = 0; i < height; ++i )
  {
    currentScanLine = ( const QRgb* )( image.scanLine( i ) );
    for ( int j = 0; j < width; ++j )
    {
      colorIt = colors.find( currentScanLine[j] );
      if ( colorIt == colors.end() )
      {
        colors.insert( currentScanLine[j], 1 );
      }
      else
      {
        colorIt.value()++;
      }
    }
  }
}
Exemplo n.º 13
0
void tst_QScriptValueIterator::iterateString()
{
    QScriptEngine engine;
    QScriptValue str = QScriptValue(&engine, QString::fromLatin1("ciao"));
    QVERIFY(str.isString());
    QScriptValue obj = str.toObject();
    QVERIFY(obj.property("length").isNumber());
    int length = obj.property("length").toInt32();
    QCOMPARE(length, 4);

    QScriptValueIterator it(obj);
    QHash<QString, QScriptValue> stringProperties;
    bool iteratedThruLength = false;

    while (it.hasNext()) {
        it.next();
        const QString name = it.name();

        if (name == QString::fromLatin1("length")) {
            QVERIFY(it.value().isNumber());
            QCOMPARE(it.value().toInt32(), length);
            QCOMPARE(it.flags(), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration | QScriptValue::Undeletable);
            QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
            iteratedThruLength = true;
            continue;
        }

        QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration.");
        stringProperties.insert(name, it.value());
        QCOMPARE(it.flags(), obj.propertyFlags(name));
        QVERIFY(it.value().strictlyEquals(obj.property(name)));
    }

    QVERIFY(iteratedThruLength);
    QCOMPARE(stringProperties.size(), length);

    // And going backwards
    iteratedThruLength = false;
    stringProperties.clear();
    it.toBack();

    while (it.hasPrevious()) {
        it.previous();
        const QString name = it.name();

        if (name == QString::fromLatin1("length")) {
            QVERIFY(it.value().isNumber());
            QCOMPARE(it.value().toInt32(), length);
            QCOMPARE(it.flags(), QScriptValue::ReadOnly | QScriptValue::SkipInEnumeration | QScriptValue::Undeletable);
            QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration.");
            iteratedThruLength = true;
            continue;
        }

        QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration.");
        stringProperties.insert(name, it.value());
        QCOMPARE(it.flags(), obj.propertyFlags(name));
        QVERIFY(it.value().strictlyEquals(obj.property(name)));
    }
}
Exemplo n.º 14
0
//******************************************************************************************
//function: doQuery
//params: const QString &lpzQuery
//return: QJsonArray
//Description:
//******************************************************************************************
QJsonArray WSClient::doQuery( const QString &lpzQuery )
{
    if (!this->getCheckLogin()) {
        throw WSClientException( this->jsLoginError );
    }

    QHash<QString, QString> params;
    params.insert("query", lpzQuery);

    QJsonObject response = Get("query", params);
    params.clear();

    if ( !response.isEmpty() ) {
        QVariantMap map_json  = response.toVariantMap();
        QVariant success      = map_json.value("success");

        if ( success.toBool() ) {
            return response.value("result").toArray();
        }
        else {
            QJsonObject error = response.value("error").toObject();
            throw WSClientException( error );
        }
    }
    throw WSClientException( jsNoData );
}
Exemplo n.º 15
0
//******************************************************************************************
//function: doSetRelated
//params: const QString &relate_this_id, const QString &with_this_ids
//return: QJsonObject
//Description:
//Set relation between records.
//param relate_this_id string ID of record we want to related other records with
//param with_this_ids string/array either a string with one unique ID or an array of IDs to relate to the first parameter
//******************************************************************************************
QJsonObject WSClient::doSetRelated(const QString &relate_this_id, const QString &with_these_ids)
{
    if (!this->getCheckLogin()) {
        throw WSClientException( this->jsLoginError );
    }

    QHash<QString, QString> params;
    params.insert("relate_this_id", relate_this_id);
    params.insert("with_these_ids", with_these_ids);

    qDebug() << params;

    QJsonObject response = Post("SetRelation", params);
    params.clear();

    if ( !response.isEmpty() ) {
        QVariantMap map_json  = response.toVariantMap();
        QVariant success      = map_json.value("success");

        if ( success.toBool() ) {
            return response.value("result").toObject();
        }
        else {
            QJsonObject error = response.value("error").toObject();
            throw WSClientException( error );
        }
    }
    throw WSClientException( jsNoData );
}
Exemplo n.º 16
0
    inline void serialize_vc6(Archive &ar, QHash<K,T> &t, const unsigned int)
    {
        typedef typename QHash<K,T>::iterator Iterator;
        typedef typename QHash<K,T>::key_type Key;
        typedef typename QHash<K,T>::mapped_type Value;

        if (ar.isRead())
        {
          t.clear();
          boost::uint32_t count = 0;
          ar & count;

          for (boost::uint32_t i=0; i<count; i++)
          {
            Key key;
            ar & key;
            Value value;
            ar & value;
            t.insert(key, value);
          }
        }
        else if (ar.isWrite())
        {
          boost::uint32_t count = static_cast<boost::uint32_t>(t.size());
          ar & count;
          Iterator it = t.begin();
          for (boost::uint32_t i=0; i<count; i++)
          {
            ar & it.key();
            ar & it.value();
            it++;
          }
        }
    }
Exemplo n.º 17
0
//******************************************************************************************
//function: doRetrieve
//params: const QString id
//return: QJsonObject
//Description:
//******************************************************************************************
QJsonObject WSClient::doRetrieve(const QString id)
{
    if (!this->getCheckLogin()) {
        throw WSClientException( this->jsLoginError );
    }

    QHash<QString, QString> params;
    params.insert("id", id);

    QJsonObject response = Get("retrieve", params);
    params.clear();

    if ( !response.isEmpty() ) {
        QVariantMap map_json  = response.toVariantMap();
        QVariant success      = map_json.value("success");

        if ( success.toBool() ) {
            return response.value("result").toObject();
        }
        else {
            QJsonObject error = response.value("error").toObject();
            throw WSClientException( error );
        }
    }

    return response;
}
Exemplo n.º 18
0
void ExtendedDialog::saveConfig()
{
    assert( currentTab() == AUDIO_TAB || currentTab() == VIDEO_TAB );
    QHash<QString, QVariant> *hashConfig = &m_hashConfigs[currentTab()];

    for( QHash<QString, QVariant>::iterator i = hashConfig->begin();
         i != hashConfig->end(); ++i )
    {
        QVariant &value = i.value();
        switch( static_cast<QMetaType::Type>(value.type()) )
        {
            case QMetaType::QString:
                config_PutPsz( p_intf, qtu(i.key()), qtu(value.toString()) );
                break;
            case QMetaType::Int:
                config_PutInt( p_intf, qtu(i.key()), value.toInt() ) ;
                break;
            case QMetaType::Double:
            case QMetaType::Float:
                config_PutFloat( p_intf, qtu(i.key()), value.toFloat() ) ;
                break;
            default:
                vlc_assert_unreachable();
        }
    }
    config_SaveConfigFile( p_intf );
    hashConfig->clear();
    m_applyButton->setEnabled( false );
}
Exemplo n.º 19
0
    void refreshLayerMovementAbilities()
    {
        layerMeta.clear();
        if (layers.count() == 0)
            return;
        for(int i = 0; i < layers.count(); ++i)
        {
            const KisNodeSP layer = layers.at(i);
            LayerModelMetaInfo ability;

            if (i > 0)
                ability.canMoveUp = true;

            if (i < layers.count() - 1)
                ability.canMoveDown = true;

            KisNodeSP parent = layer;
            while(parent)
            {
                ++ability.depth;
                parent = parent->parent();
            }

            if (ability.depth > 1)
                ability.canMoveLeft = true;

            if (i < layers.count() - 1 && qobject_cast<const KisGroupLayer*>(layers.at(i + 1).constData()))
                ability.canMoveRight = true;

            layerMeta[layer] = ability;
        }
    }
Exemplo n.º 20
0
bool shutdownScripts()
{
	for (int i = 0; i < scripts.size(); ++i)
	{
		QScriptEngine *engine = scripts.at(i);
		unregisterFunctions(engine);
	}
	timers.clear();
	bindings.clear();
	internalNamespace.clear();
	while (!scripts.isEmpty())
	{
		delete scripts.takeFirst();
	}
	return true;
}
Exemplo n.º 21
0
void Parser::ReleaseOfferMap(QHash<QString, ItemOffer *> &pOfferMap) {
    QHashIterator<QString, ItemOffer *> itOffer(pOfferMap);
    while (itOffer.hasNext()) {
        ItemOffer *pOffer = itOffer.next().value();
        delete pOffer;
    }
    pOfferMap.clear();
}
Exemplo n.º 22
0
void Parser::ReleaseGoodsMap(QHash<QString, Goods *> &pGoodsMap) {
    QHashIterator<QString, Goods *> itGoods(pGoodsMap);
    while (itGoods.hasNext()) {
        Goods *pGoods = itGoods.next().value();
        delete pGoods;
    }
    pGoodsMap.clear();
}
Exemplo n.º 23
0
bool Patient:: search(const QString &type, const QString &content,int serchType,const QString &table)
{
    static QHash<QString,QString> ser;
    emit startSearch();
    d->cDataInit();
    qDebug()<<"hans " << ser;
    qDebug()<<type;
    qDebug()<<content;
    qDebug()<<serchType;
    if(!serchType)
    {
        ser.clear();
        if(content.size() != 0)
        {
            //QString cmd = QString("select * from %1 where %2 LIKE '%3%' or %2 = '%3' ORDER BY id DESC").arg(table,type,content);
            if(type == "检查日期时间之后")
            {
                QString ttype = "检查日期时间";
                qDebug()<<QString("select * from %1 where %2 > '%3' ORDER BY id DESC").arg(table,ttype,content);
                this->setQuery(QString("select * from %1 where %2 > '%3' ORDER BY id DESC").arg(table,ttype,content));
            }
            else
            {
                this->setQuery(QString("select * from %1 where %2 LIKE '%3%'or %2 = '%3' ORDER BY id DESC").arg(table,type,content));
            }

        }
        else
        {
            this->setQuery(QString("select * from %1 ORDER BY id DESC ").arg(table));
        }
        ser[type] = content;
    }
    else
    {

        ser[type] = content;
        QHashIterator< QString ,QString> it(ser);
        QString cmd = "";
        while(it.hasNext())
        {

            it.next();
            //  qDebug()<< it.key() << it.value();
            cmd = QString("%1 and (%2 LIKE '%3%' or  %2 = '%3') ").arg(cmd,it.key(),it.value());
        }
        cmd = cmd.mid(4,-1);
        //cmd = " select * from Patient where (病人ID LIKE '2016%' or  病人ID = '2016')  and (姓名 LIKE '1%' or  姓名 = '1') ORDER BY id DESC";
        qDebug()<<cmd;
        //this->setQuery(cmd);
        this->setQuery(QString("select * from %1 where %2 ORDER BY id DESC").arg(table,cmd));
    }
    // emit layoutChanged();
    this->setCurrentPatientNum(rowCount());
    setSelectedPatientNum(0);
    updateCurrentPID();
    return true;
}
Exemplo n.º 24
0
static void osc_stop (void)
{
#ifdef CONFIG_DEBUG
	qDebug("osc_stop()");
#endif

	qDeleteAll(g_dssiEditors);
	g_dssiEditors.clear();
}
Exemplo n.º 25
0
// Load labels
bool loadLabels(const char *filename)
{
	if (!PHYSFS_exists(filename))
	{
		debug(LOG_SAVE, "No %s found -- use fallback method", filename);
		return false;
	}
	WzConfig ini(filename);
	if (ini.status() != QSettings::NoError)
	{
		debug(LOG_ERROR, "No label file %s", filename);
		return false;
	}
	labels.clear();
	QStringList list = ini.childGroups();
	for (int i = 0; i < list.size(); ++i)
	{
		ini.beginGroup(list[i]);
		labeltype p;
		QString label(ini.value("label").toString());
		if (labels.contains(label))
		{
			debug(LOG_ERROR, "Duplicate label found");
		}
		else if (list[i].startsWith("position"))
		{
			p.p1 = ini.vector2i("pos");
			p.p2 = p.p1;
			p.type = POSITION;
			p.player = -1;
			p.id = -1;
			labels.insert(label, p);
		}
		else if (list[i].startsWith("area"))
		{
			p.p1 = ini.vector2i("pos1");
			p.p2 = ini.vector2i("pos2");
			p.type = AREA;
			p.player = -1;
			p.id = -1;
			labels.insert(label, p);
		}
		else if (list[i].startsWith("object"))
		{
			p.id = ini.value("id").toInt();
			p.type = ini.value("type").toInt();
			p.player = ini.value("player").toInt();
			labels.insert(label, p);
		}
		else
		{
			debug(LOG_ERROR, "Misnamed group in %s", filename);
		}
		ini.endGroup();
	}
	return true;
}
Exemplo n.º 26
0
void FieldWidget::clearTeamData(RobotMap &team, QHash<uint, robot::Specs> &specsMap)
{
    specsMap.clear();

    // force redrawing robots
    foreach (Robot r, team) {
        delete r.id;
        delete r.robot;
    }
void IapAddTimer::removeAll()
{
    QHashIterator<QString, _IapAddTimer* > i(timers);
    while (i.hasNext()) {
	i.next();
	_IapAddTimer *t = i.value();
	delete t;
    }
    timers.clear();
}
Exemplo n.º 28
0
// Call this function when you want to clean up all animation data allocated to
// the memory.
void ResourceManager::clearAnimationCache()
{
    QHash<QString, AnimationModel*>::Iterator iter = sAnimationHash.begin();
    while(iter != sAnimationHash.end())
    {
        delete iter.value();
        iter++;
    }
    sAnimationHash.clear();
}
Exemplo n.º 29
0
// Load a theme into a resourceList.
void Global::loadTheme(QHash<QString, QString> &resourceList, QString theme) {
    resourceList.clear();
    if (theme.trimmed() == "")
        return;
    QFile systemTheme(fileManager.getProgramDirPath("theme.ini"));
    this->loadThemeFile(resourceList,systemTheme, theme);

    QFile userTheme(fileManager.getHomeDirPath("theme.ini"));
    this->loadThemeFile(resourceList, userTheme, theme);
}
Exemplo n.º 30
0
void ResourceManager::clearImageCache()
{
    QHash<QString, QImage*>::Iterator iter = sSourceImageHash.begin();
    while(iter != sSourceImageHash.end())
    {
        delete iter.value();
        iter++;
    }
    sSourceImageHash.clear();
}