예제 #1
0
// "chessx.eco.txt" -> "chessx.eco", "chessx.gtm", "chessx.txt"
bool compileAsciiEcoFile(const QString& filenameIn, QString filenameOut, QString gtmFile)
{
    // Read in the ECO data
    if(!parseAsciiEcoData(filenameIn))
    {
        return false;
    }

    filenameOut = QFileInfo(filenameIn).absolutePath() + QDir::separator() + filenameOut;
    gtmFile = QFileInfo(filenameIn).absolutePath() + QDir::separator() + gtmFile;

    // Write out the main ECO file
    QFile file(filenameOut);
    file.open(QIODevice::WriteOnly);
    QDataStream sout(&file);
    sout << COMPILED_ECO_FILE_ID;
    sout << ecoPositions;
    file.close();

    // Write out the GTM (guess-the-move) ECO file
    QFile gfile(gtmFile);
    gfile.open(QIODevice::WriteOnly);
    QDataStream gout(&gfile);
    gout << COMPILED_GUESS_FILE_ID;
    gout << gtmPositions;
    gfile.close();

    ecoPositions.clear();
    gtmPositions.clear();

    return true;
}
예제 #2
0
void XbelTree::AddTU()
{
    QDomElement *fold = new QDomElement();
    CreateHeaderFolder(fold, QString::fromUtf8("Устройство телеуправления"), TU);
    QMap<QString, QString> properties;
    properties["name"] = "address";
    AddBookmarkNode(fold, QString::fromUtf8("адрес"), "0x01", &properties);
    properties["name"] = "comport";
    AddBookmarkNode(fold, QString::fromUtf8("компорт"), "2", &properties);
    properties["name"] = "begin_TU";
    properties["ico"] = ":/images/code.png";
    AddBookmarkNode(fold, QString::fromUtf8("адресное пространство ТУ - начало"), "0x0000", &properties);
    properties["name"] = "end_TU";
    properties["ico"] = ":/images/code.png";
    AddBookmarkNode(fold, QString::fromUtf8("адресное пространство ТУ - окончание"), "0x0009", &properties);
    properties.clear();
    properties["name"] = "proto";
    properties["variants"] = "MODBUS|DCON";
    AddBookmarkNode(fold, QString::fromUtf8("протокол"), "MODBUS", &properties);
    properties.clear();
    properties["name"] = "tic";
    properties["ico"] = ":/images/cycle.png";
    AddBookmarkNode(fold, QString::fromUtf8("Время удержания реле(DCON)"), "10", &properties);
    Reset();
    emit(MessageToStatusBar(QString::fromUtf8("Добавлено устройство ТУ")));
}
예제 #3
0
/**
 * @short Clears config vars
 * @author Rene Schmidt <*****@*****.**>
 * @version 0.1
 */
void KLAid::_clearConfig()
{
  _pCount = 0;
  mapIdx = 0;
  iTitles.clear();
  iTexts.clear();
}
예제 #4
0
void Ut_VolumeControl::cleanup()
{
    delete volumeControl;
    acquireCalled = false;
    releaseCalled = false;
    qTimerStartCounts.clear();
    qTimerStopCounts.clear();
    disconnect(SIGNAL(timeout()));
}
예제 #5
0
void XbelTree::AddMQ() {
    QDomElement *fold = new QDomElement();
    CreateHeaderFolder(fold, QString::fromUtf8("Счетчик электроэнергии Меркурий"), MERQURY);
    QMap<QString, QString> properties;
    properties["name"] = "address";
    AddBookmarkNode(fold, QString::fromUtf8("адрес"), "0x01", &properties);
    properties["name"] = "comport";
    AddBookmarkNode(fold, QString::fromUtf8("компорт"), "2", &properties);
    properties["name"] = "cycle";
    AddBookmarkNode(fold, QString::fromUtf8("цикл опроса"), "3000", &properties);
    properties["name"] = "mqpassword";
    AddBookmarkNode(fold, QString::fromUtf8("пароль"), "000000", &properties);
    QString characteristics[23][5] = {
        {QString::fromUtf8("Напряжения"),                   "U",  "potential",  "folder",   ""},
        {QString::fromUtf8("Напряжение фазы A"),            "UA", "potential",  "clicked",  ":/images/U.png"},
        {QString::fromUtf8("Напряжение фазы B"),            "UB", "potential",  "clicked",  ":/images/U.png"},
        {QString::fromUtf8("Напряжение фазы C"),            "UC", "potential",  "clicked",  ":/images/U.png"},
        {QString::fromUtf8("Токи"),                         "I",  "current",    "folder",   ""},
        {QString::fromUtf8("Ток фазы A"),                   "IA", "current",    "clicked",  ":/images/I.png"},
        {QString::fromUtf8("Ток фазы B"),                   "IB", "current",    "clicked",  ":/images/I.png"},
        {QString::fromUtf8("Ток фазы C"),                   "IC", "current",    "clicked",  ":/images/I.png"},
        {QString::fromUtf8("Активные мощности"),            "P",  "power-A",    "folder",   ""},
        {QString::fromUtf8("Активная мощность фазы A"),     "PA", "power-A",    "clicked",  ":/images/P.png"},
        {QString::fromUtf8("Активная мощность фазы B"),     "PB", "power-A",    "clicked",  ":/images/P.png"},
        {QString::fromUtf8("Активная мощность фазы C"),     "PC", "power-A",    "clicked",  ":/images/P.png"},
        {QString::fromUtf8("Суммарная активная мощность"),  "SP", "power-A",    "clicked",  ":/images/P.png"},
        {QString::fromUtf8("Реактивные мощности"),          "Q",  "power-Q",    "folder",   ""},
        {QString::fromUtf8("Реактивная мощность фазы A"),   "QA", "power-Q",    "clicked",  ":/images/Q.png"},
        {QString::fromUtf8("Реактивная мощность фазы B"),   "QB", "power-Q",    "clicked",  ":/images/Q.png"},
        {QString::fromUtf8("Реактивная мощность фазы C"),   "QC", "power-Q",    "clicked",  ":/images/Q.png"},
        {QString::fromUtf8("Суммарная реактивная мощность"),"SQ", "power-Q",    "clicked",  ":/images/Q.png"},
        {QString::fromUtf8("Полные мощности"),              "S",  "power-S",    "folder",   ""},
        {QString::fromUtf8("Полная мощность фазы A"),       "SA", "power-S",    "clicked",  ":/images/S.png"},
        {QString::fromUtf8("Полная мощность фазы B"),       "SB", "power-S",    "clicked",  ":/images/S.png"},
        {QString::fromUtf8("Полная мощность фазы C"),       "SC", "power-S",    "clicked",  ":/images/S.png"},
        {QString::fromUtf8("Суммарная полная мощность"),    "SS", "power-S",    "clicked",  ":/images/S.png"},
    };
    QDomElement folder;
    for(int i=0; i<23; i++) {
        if( characteristics[i][3] == "folder" ) {
            properties.clear();
            properties["name"] = characteristics[i][2];
            folder = AddFolderNode(fold, characteristics[i][0], &properties);
        }
        else {
            properties.clear();
            properties["name"] = characteristics[i][2];
            properties["property"] = characteristics[i][3];
            properties["phase"] = characteristics[i][1];
            properties["ico"] = characteristics[i][4];
            AddBookmarkNode(&folder, characteristics[i][0], "", &properties);
        }
    }
    Reset();
    emit(MessageToStatusBar(QString::fromUtf8("Добавлено устройство Меркурий")));
}
예제 #6
0
void FrameReader::ReadStream()
{
	Openchunk *invoice = qobject_cast<Openchunk *>(sender());
  if (!invoice) {
		return;
	}
	if (!invoice->validpng) {
		QMessageBox::warning(0, tr("Error on reader."),tr("Error say:%1").arg(invoice->error()));
	return;
	}
	////////qDebug() << "### valid image...say .." << invoice->error();
	//////qDebug() << "### valid image...say .." << invoice->validpng;
	QMap<int,APNGFRAME> framlist = invoice->list();
	QMap<int,APNGFRAME> readylist;
	readylist.clear();
	if (QThread::currentThread() == qApp->thread()) {
     qDebug() << "### can paint .." << framlist.size();
	   QMapIterator<int,APNGFRAME> i(framlist);
		 int rec = -1;
         while (i.hasNext()) {
                i.next();
					       APNGFRAME one = i.value();
					     if (one.item.isNull()) {
					       QImage tmpe;
					       QImage Pvidi(one.maxframe.width(),one.maxframe.height(),QImage::Format_ARGB32);
					       if (tmpe.loadFromData(one.dimg)) {
								 QPainter p(&Pvidi);
								 p.setRenderHint(QPainter::Antialiasing, true);
								 p.setBrush(one.bg);
								 p.drawRect(one.maxframe);
								 p.drawImage(one.point,tmpe);
								 p.end();
								 one.item = Pvidi;
								 ///////qDebug() << "### isNull() out theard .." << one.item.isNull();
								 readylist.insert(rec++,one);
								 }
							 }
				 }
  }
	if (readylist.size() > 0 ) {
		movie = readylist;
		framlist.clear();
	} else {
		movie = framlist;
	}
	if (movie.size() < 1) {
	buffer->LoadFile(qfile); /* stay on buffer to save  */
	} else {
		current = 0;
		running = true;
		ValidApng = true;
		disconnect(this);
		NextFrame();
	}
}
예제 #7
0
QList<QVariantMap > HsMenuClientPrivate::getList(const QVariantMap &queryPreference)
{
    QList<QVariantMap> list;
    QMap<QString, QVariant> map = queryPreference;
    
    map.remove(hsItemName);
    map.remove(hsItemDescription);
    
    CaQuery query;
    // define query
    query.setFlagsOn(VisibleEntryFlag);
    query.setEntryRoles(ItemEntryRole);
    query.setEntryTypeNames(QStringList(Hs::templatedApplicationTypeName));
    
    
    // add atributes to caquery
    QMapIterator<QString, QVariant> k(map);
    while (k.hasNext()) {
        k.next();
        query.setAttribute(k.key(),k.value().toString());
    }  
    QList< QSharedPointer<CaEntry> > entries = CaService::instance()->getEntries(query);
    map.clear();
    if (entries.count()) {
        QMap<QString, QString> attrMap;
        QMapIterator<QString, QString> k(attrMap);
        //walk trought entrys and extract keys into map
        for (int i = 0; i < entries.count(); ++i) {
            map[hsItemId] = entries.at(i)->id();
            map[hsItemName] = entries.at(i)->text();
            map[hsItemDescription] = entries.at(i)->description();
            CaIconDescription iconDesc = entries.at(i)->iconDescription();
            map[hsIconFileName] = iconDesc.filename();
            map[hsIconName] = iconDesc.skinId();
            map[hsIconApplicationId] = iconDesc.applicationId();
            
            // extract entry atributes
            attrMap = entries.at(i)->attributes();
            QMapIterator<QString, QString> k(attrMap);
            // insert entrys attr into map
            while (k.hasNext()) {
                k.next();
                map.insert(k.key(),k.value());
            }
            list.append(map); //append entry map to list
            // clean used maps
            map.clear();
            attrMap.clear();
        }
    }
    return list;
}
예제 #8
0
파일: main.cpp 프로젝트: MarcSky/parserQt
void parser(const QByteArray &text) {
    QStringList systemWords;
    systemWords << "mainpassword" << "login";
    QStringList localWords;
    localWords << "password" << "login" << "email";
    QList<QByteArray> s = text.split('\n');
    bool systemFlag = true;
    bool systemCounter = false;
    bool localFlag = false;
    bool localCounter = false;
    QMap<QString, QString> localMap;
    QMap<QString, QString> systemMap;
    QList< QMap<QString, QString> > systemList;
    QList< QMap<QString, QString> > sitesList;
    int i = 0;
    while(i < s.size() - 1) {
        QList<QByteArray> l;
        l.append(s[i].split(':'));
        QString key = QString(l.at(0));
        QString value = QString(l.at(1));
        if(systemFlag) {
            if(!systemCounter) {
                QString local = "";
                foreach(local, systemWords) {
                    if(local == key && key != QString("system")) systemMap[key] = value;
                }
                if(value == QString("end")) systemCounter = true;
            }
            if( !systemMap.isEmpty() && systemCounter) {
                systemList.append(systemMap);
                systemMap.clear();
                systemCounter = false;
            }
        }
        if (localFlag) {
            if(!localCounter) {
                QString local = "";
                if(value == QString("start")) localMap["site"] = key;
                foreach(local, localWords) {
                    if(local == key && value != QString("end") && value!=QString("start")) {
                        localMap[key] = value;
                    }
                }
                if(value == QString("end")) localCounter = true;
            }
            if(!localMap.isEmpty() && localCounter) {
                sitesList.append(localMap);
                localMap.clear();
                localCounter = false;
            }
        }
예제 #9
0
bool QgsComposerTable::calculateMaxColumnWidths( QMap<int, double>& maxWidthMap, const QList<QgsAttributeMap>& attributeMaps ) const
{
  maxWidthMap.clear();
  QList<QgsComposerTableColumn*>::const_iterator columnIt = mColumns.constBegin();

  int col = 0;
  for ( ; columnIt != mColumns.constEnd(); ++columnIt )
  {
    maxWidthMap.insert( col, textWidthMillimeters( mHeaderFont, ( *columnIt )->heading() ) );
    col++;
  }

  //go through all the attributes and adapt the max width values
  QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.constBegin();

  double currentAttributeTextWidth;

  for ( ; attIt != attributeMaps.constEnd(); ++attIt )
  {
    QgsAttributeMap::const_iterator attIt2 = attIt->constBegin();
    for ( ; attIt2 != attIt->constEnd(); ++attIt2 )
    {
      currentAttributeTextWidth = textWidthMillimeters( mContentFont, attIt2.value().toString() );
      if ( currentAttributeTextWidth > maxWidthMap[ attIt2.key()] )
      {
        maxWidthMap[ attIt2.key()] = currentAttributeTextWidth;
      }
    }
  }
  return true;
}
예제 #10
0
/*!
 * Modifies the detail definitions. The default detail definitions are
 * queried from QContactManagerEngine::schemaDefinitions and then modified
 * with this function in the transform leaf classes.
 *
 * \a definitions The detail definitions to modify.
 * \a contactType The contact type the definitions apply for.
 */
void CntTransformOrganisation::detailDefinitions(QMap<QString, QContactDetailDefinition> &definitions, const QString& contactType) const
{
    Q_UNUSED(contactType);

    if(definitions.contains(QContactOrganization::DefinitionName)) {
        QContactDetailDefinition d = definitions.value(QContactOrganization::DefinitionName);
        QMap<QString, QContactDetailFieldDefinition> fields = d.fields();
        QContactDetailFieldDefinition f;

        // Not all fields are supported, replace:
        fields.clear();
        f.setDataType(QVariant::String);
        f.setAllowableValues(QVariantList());
        fields.insert(QContactOrganization::FieldName, f);
        fields.insert(QContactOrganization::FieldTitle, f);
        fields.insert(QContactOrganization::FieldAssistantName, f);
        f.setDataType(QVariant::StringList);
        fields.insert(QContactOrganization::FieldDepartment, f);

        d.setFields(fields);

        // Replace original definitions
        definitions.insert(d.name(), d);
    }
}
예제 #11
0
void MagicTowerLoader::loadSavedGame(const QString& directoryName, const QString& saveName)
{
    scene->reset();
    loadMap(directoryName + "/" + saveName + ".mtsavedmap.ini");
    QFile extraFile(directoryName + "/" + saveName + ".mtsavedextra.ini");
    extraFile.open(QFile::ReadOnly);
    QTextStream extraFileStream(&extraFile);
    QString className;
    QMap<QString, QString> parameters;
    for(;;)
    {
        QString str = extraFileStream.readLine();
        str = str.trimmed();
        if(extraFileStream.atEnd() || (str.startsWith("[")&&str.endsWith("]")))
        {
            if(className.size()>0)
            {
                if(className == "Character")
                {
                    QString map = parameters["map"];
                    int x = parameters["x"].toInt();
                    int y = parameters["y"].toInt();
                    scene->setObjectAt(map,"character",x,y,getPreset<MagicTowerCharacter>("warrior")->clone());
                    MagicTowerCharacter* character = dynamic_cast<MagicTowerCharacter*>(
                                scene->getObjectAt(map,"character",x,y));
                    if(character!=NULL)
                    {
                        QMap<QString, QString>::const_iterator i = parameters.begin();
                        while (i != parameters.end())
                        {
                            if(i.key()=="x"||i.key()=="y"||i.key()=="map")
                            {
                                i++;
                                continue;
                            }
                            character->setGameProperty(i.key(),i.value().toInt());
                            i++;
                        }
                        scene->setActiveCharacter(character);
                    }
                }
                parameters.clear();
            }
            str[0] = QChar(' ');
            str[str.size()-1] = QChar(' ');
            str = str.trimmed();
            className = str;
        }
        else if(str.size()>0)
        {
            QStringList lineParts = str.split("=");
            if(lineParts.size()==2)
            {
                parameters[lineParts[0].trimmed()] = lineParts[1].trimmed();
            }
        }
        if(extraFileStream.atEnd()) break;
    }
    extraFile.close();
}
void FacebookContactsDatabasePrivate::createUpdatedEntries(const QMap<QString, QMap<QString, QVariant> > &input,
                                                           const QString &primary,
                                                           QMap<QString, QVariantList> &entries)
{
    entries.clear();

    // Check if we have the same data
    QStringList keys;
    foreach (const QVariantMap &inputEntry, input) {
        // TODO: instead of return, we should only insert entries that "works" to
        // the list.
        if (inputEntry.isEmpty()) {
            return;
        }

        if (keys.isEmpty()) {
            keys = inputEntry.keys();
        } else if (inputEntry.keys() != keys) {
            return;
        }
    }

    foreach (const QString &key, keys) {
        entries.insert(key, QVariantList());
    }
예제 #13
0
void TimeStamp::resetRepository()
{
	registry.clear();
	TZFile tzf;tzf.setName("UTC");
	registry.insert("UTC",tzf);
	setDefaultZone(defaultzone);
}
예제 #14
0
void LairTool::commitToTemplate() {
    if (currentTemplate == NULL)
        return;

    currentTemplate->setSpawnLimit(ui->spinBox->value());

    QMap<QString, uint32>* mobiles = currentTemplate->getMobiles();
    mobiles->clear();

    for (int i = 0; i < ui->listWidget_mobiles->count(); ++i) {
        QListWidgetItem* item = ui->listWidget_mobiles->item(i);

        QString data = item->text();

        QString mobile = data.section('\t', 0, 0);
        QString level = data.section('\t', 1, 1);

        mobiles->insert(mobile, level.toInt());
    }

    commitBuildings(ui->listWidget_veryEasy, LairTemplate::VERYEASY);
    commitBuildings(ui->listWidget_easy, LairTemplate::EASY);
    commitBuildings(ui->listWidget_Medium, LairTemplate::MEDIUM);
    commitBuildings(ui->listWidget_Hard, LairTemplate::HARD);
    commitBuildings(ui->listWidget_veryHard, LairTemplate::VERYHARD);
}
예제 #15
0
// +-----------------------------------------------------------
bool f3::LogControl::getAppLogData(QMap<QString, QtMsgType> &mAppLogData) const
{
	// Try to lock the shared memory
	if(!m_pSharedMemory->lock())
		return false;

	// Read the map from the shared memory
	QBuffer oBuffer;
	QDataStream oStream(&oBuffer);

	oBuffer.setData((char *) m_pSharedMemory->constData(), m_pSharedMemory->size());
	oBuffer.open(QBuffer::ReadOnly);
	
	QMap<QString, int> mApps;
	oStream >> mApps;

	// Unlock the shared memory before returning
	m_pSharedMemory->unlock();

	mAppLogData.clear();
	QMap<QString, int>::iterator it;
	for(it = mApps.begin(); it != mApps.end(); ++it)
		mAppLogData.insert(it.key(), (QtMsgType) (it.value() - 1));

	return true;
}
예제 #16
0
void getCookie(const QByteArray &input,QMap<QString,QString> &output)
{
    output.clear();
    QString s=QString::fromLatin1(input,input.size());
    QRegExp m("(\r\n|\n){2,}");
    int itemp=m.indexIn(s);
    if(itemp >=0)
    {
        s=s.left(itemp);
    }
    QStringList slist=s.split(QRegExp("\r\n|\n"));
    QRegExp m1("Set-Cookie:\\s+(.*)=(.*);");
    m1.setMinimal(true);
    int c=slist.count();
    for(int i=0;i<c;i++)
    {
        if((itemp=m1.indexIn(slist[i]))>=0)
        {
            output.insert(m1.cap(1),m1.cap(2));
//            qDebug()<<m1.cap(1)<<m1.cap(2)<<m1.cap(3)<<m1.cap(4);
        }
    }


}
예제 #17
0
void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) {
  Q_UNUSED(col)
  KstObjectItem *koi = static_cast<KstObjectItem*>(i);
  KstBaseCurve *c;

  if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
    KPopupMenu *m = new KPopupMenu(this);

    m->setTitle(koi->text(0));

    int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
    //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti());

    if (koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
      id = m->insertItem(i18n("&Make Curve..."), koi, SLOT(makeCurve()));
    } else if ((c = dynamic_cast<KstBaseCurve*>(koi->dataObject().data()))) {
      KPopupMenu *addMenu = new KPopupMenu(this);
      KPopupMenu *removeMenu = new KPopupMenu(this);
      PlotMap.clear();
      id = 100;
      bool haveAdd = false, haveRemove = false;
      for (KstPlot *p = KST::plotList.first(); p; p = KST::plotList.next()) {
        if (!p->Curves.contains(c)) {
          addMenu->insertItem(p->tagName(), koi, SLOT(addToPlot(int)), 0, id);
          haveAdd = true;
        } else {
예제 #18
0
void FontMap::Clear(void)
{
    m_FontMap.clear();

    //FIXME: remove
    globalFontMap.clear();
}
void tst_QOrganizerItemDetailDefinition::testEmpty()
{
    QOrganizerItemDetailDefinition def;

    QVERIFY(def.isEmpty());

    def.setName("Name");
    QVERIFY(!def.isEmpty());
    def.setName(QString());
    QVERIFY(def.isEmpty());
    QMap<QString, QOrganizerItemDetailFieldDefinition> fields;
    QOrganizerItemDetailFieldDefinition f;
    f.setDataType(QVariant::String);
    fields.insert("Field", f);
    def.setFields(fields);
    QVERIFY(!def.isEmpty());

    def.setName("Name");
    QVERIFY(!def.isEmpty());

    fields.clear();
    def.setFields(fields);
    QVERIFY(!def.isEmpty());

    def.setName(QString());
    QVERIFY(def.isEmpty());
}
예제 #20
0
int commandtool::df(QMap<QString, dfentry> &entries)
{
    entries.clear();
    QString result;
    QStringList args;
    int r = exec("df", args, result);
    if (r != 0)
    {
        util::log(QString("execute df error %d").arg(r));
        return r;
    }
    QStringList ps = result.split('\n',QString::SkipEmptyParts);
    foreach (const QString& string, ps)
    {
        QStringList fields = string.split(' ',QString::SkipEmptyParts);
        if (fields.size() < 6)
            continue;

        dfentry entry;
        entry.dev = fields.at(0);
        entry.used = fields.at(2).toULongLong()*1024;
        entry.avail = fields.at(3).toULongLong()*1024;
        entry.mountpoint =fields.at(5);
        entries[entry.dev]= entry;
    }
예제 #21
0
void QThreadStorageData::finish(void **p)
{
    QMap<int, void *> *tls = reinterpret_cast<QMap<int, void *> *>(p);
    if (!tls || tls->isEmpty() || !mutex())
        return; // nothing to do

    DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());

    QMap<int, void *>::iterator it = tls->begin();
    while (it != tls->end()) {
        int id = it.key();
        void *q = it.value();
        it.value() = 0;
        ++it;

        if (!q) {
            // data already deleted
            continue;
        }

        mutex()->lock();
        void (*destructor)(void *) = destructors()->value(id);
        mutex()->unlock();

        if (!destructor) {
            if (QThread::currentThread())
                qWarning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed",
                         QThread::currentThread(), id);
            continue;
        }
        destructor(q);
    }
    tls->clear();
}
bool PLCMainPipePlugin::PLCGetDeviceLinkRate(const QString &DeviceMACAddress, QMap<QString, QPair<qint16, qint16> > &DeviceLinkRateTable) const
{
    API_REF_GUARD(&m_refCount, &m_refCountMutex, &m_refCountCdt, false);

    if(!IsMacAddrValid(DeviceMACAddress)) {
        return false;
    }
    QString normalDevMac = NormalizeValidMacAddrFormat(DeviceMACAddress);

    PLC_DeviceLinkRateTable devLinkRateTable;
    int devLinkRateNumber = 0;
    BYTE deviceMac[PLC_MAC_ADDRESS_SIZE];
    QString devMac;
    QPair<qint16, qint16> linkRatePair;

    if(PLC_GET_SUCCESS == m_plcDriverExecutive->PLCGetDeviceLinkRate(PLCDeviceMacAddrFromString(normalDevMac, deviceMac),
            &devLinkRateNumber, &devLinkRateTable)) {
        DeviceLinkRateTable.clear();

        for(int idx = 0 ; idx < devLinkRateNumber ; ++idx) {
            devMac = PLCDeviceMacAddr2String(devLinkRateTable.PLC_DeviceMACAddr[idx]);
            linkRatePair.first = devLinkRateTable.PLC_DeviceTXRate[idx];
            linkRatePair.second = devLinkRateTable.PLC_DeviceRXRate[idx];
            DeviceLinkRateTable[devMac] = linkRatePair;
        }//for

        return true;
    }//if

    return false;
}
예제 #23
0
///////////////////////////////////////////////// Public Functions /////////////////////////////////////////////
//
//	Function to extract the input data from the QLineEdit's in the dialog and put it into
//	a QMap<QString,QVariant>.  The QMap is sent to this function as a reference and is modified by the function.
void VPNAgentDialog::createDict(QMap<QString,QVariant>& r_map)
{
	// Initialize the map
	r_map.clear();
	
	// Create the dict entries
	if (! ui.lineEdit_username->text().isEmpty() ) 
		r_map["Username"] = ui.lineEdit_username->text();
	
	if (! ui.lineEdit_password->text().isEmpty() )
		r_map["Password"] = ui.lineEdit_password->text();	
	
	if (! ui.lineEdit_host->text().isEmpty() )
		r_map["Host"] = ui.lineEdit_host->text();
	
	if (! ui.lineEdit_name->text().isEmpty() )
		r_map["Name"] = ui.lineEdit_name->text();
	
	if (! ui.lineEdit_cacert->text().isEmpty() )
		r_map["OpenConnect.CaCert"] = ui.lineEdit_cacert->text();
	
	if (! ui.lineEdit_cookie->text().isEmpty() )
		r_map["OpenConnect.Cookie"] = ui.lineEdit_cookie->text();
	
	if (! ui.lineEdit_servercert->text().isEmpty() )
		r_map["OpenConnect.ServerCert"] = ui.lineEdit_servercert->text();
		
	if (! ui.lineEdit_vpnhost->text().isEmpty() )
		r_map["OpenConnect.VPNHost"] = ui.lineEdit_vpnhost->text();	
	
	if (ui.checkBox_savecredentials->isEnabled() )
		r_map["SaveCredentials"] =  ui.checkBox_savecredentials->isChecked();
		
	return;
}
QMap<QString, QString> ControlClient::_parsecmd(QString cmdstr) {
    QMap<QString, QString> cmdmap;
    cmdmap.clear();
    QString cmdrasp = cmdstr.remove(_raspcmd_prefix).trimmed();
    QStringList paralist = cmdrasp.split("-");

    QString cmdopt;
    foreach (cmdopt, paralist) {
        if(cmdopt.startsWith("w ", Qt::CaseInsensitive)) {
            cmdmap["width"] = _parsepara(cmdopt);
        }
        if(cmdopt.startsWith("h ", Qt::CaseInsensitive)) {
            cmdmap["height"] = _parsepara(cmdopt);
            qDebug() << cmdopt;
        }

        if(cmdopt.startsWith("b ", Qt::CaseInsensitive)) {
            cmdmap["bitrate"] = _parsepara(cmdopt);
        }
        if(cmdopt.startsWith("fps ", Qt::CaseInsensitive)) {
            cmdmap["fps"] = _parsepara(cmdopt);
        }
        if(cmdopt.startsWith("br ", Qt::CaseInsensitive)) {
            cmdmap["brightness"] = _parsepara(cmdopt);
        }
    }
    qDebug() << cmdmap;
    return cmdmap;
}
예제 #25
0
extern "C" void qtns_shutdown()
{
    if (clients.count() > 0) {
        QMap<QtNPInstance *, QX11EmbedWidget *>::iterator it = clients.begin();
        while (it != clients.end()) {
            delete it.value();
            ++it;
        }
        clients.clear();
    }

    if (!ownsqapp)
        return;

    // check if qApp still runs widgets (in other DLLs)
    QWidgetList widgets = qApp->allWidgets();
    int count = widgets.count();
    for (int w = 0; w < widgets.count(); ++w) {
        // ignore all Qt generated widgets
        QWidget *widget = widgets.at(w);
        if (widget->windowFlags() & Qt::Desktop)
            count--;
    }
    if (count) // qApp still used
        return;

    delete qApp;
    ownsqapp = false;
}
void
DataArrayModel::clearSelectedCellLabels()
{
    beginResetModel();
    selectedCellLabels.clear();
    endResetModel();
}
예제 #27
0
void neuron_branch_tip_count(V3DLONG &n_branch, V3DLONG &n_tip, const vector<V_NeuronSWC> & segment_list)
{
	QMap <V_NeuronSWC_coord, V_NeuronSWC_unit> map;
	map.clear();

	for (V3DLONG i=0; i<segment_list.size(); i++)
	{
		const V_NeuronSWC & seg = segment_list.at(i);
		for (V3DLONG j=0; j<seg.row.size(); j++)
		{
			V_NeuronSWC_unit node = seg.row.at(j);
			V_NeuronSWC_coord key = node;
			map.insertMulti(key, node);
		}
	}

	n_branch = 0;
	n_tip = 2*segment_list.size();

	QList <V_NeuronSWC_coord> keys = map.uniqueKeys();
	for (V3DLONG i=0; i<keys.size(); i++)
	{
		V_NeuronSWC_coord key = keys.at(i);
		int nkey = map.count(key);
		if (nkey >= 3)
		{
			n_branch ++;
		}
		if (nkey >= 2)
		{
			n_tip -= nkey;
		}
	}
}
예제 #28
0
    void ConfigurationScreens::prepareScreens(QMap<int, OutputScreen *> & screens) {
        BackendConfiguration * config = BackendConfigurations::self()->activeBackendConfiguration();
        if (! config) {
            return;
        }

        if (config->name() == "external") {
            screens.clear();
            return;
        }

        QMap<int, QRect> layout = config->realLayout();
        for (QMap<int, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
            if (screens.contains(i.key())) {
                screens[i.key()]->_setGeom(i.value());
            } else {
                OutputScreen * screen = new OutputScreen(this);
                screen->_setId(i.key());
                screen->_setGeom(i.value());
                screens.insert(screen->id(), screen);
            }
        }

        for (QMap<int, OutputScreen *>::iterator i = screens.begin(); i != screens.end();) {
            if (! layout.contains(i.key())) {
                i = screens.erase(i);
            } else {
                ++i;
            }
        }
    }
예제 #29
0
bool FacultyController::saveAStudent()
{
    long ID = _ui->IDBox->text().toLong();
    QMap<QString, int> temp;
    if(_facultyObj->isMajor(ID))
    {
        for(int i = 0; i < _ui->MajorScoreList->rowCount(); ++i)
        {
            auto item = _ui->MajorScoreList->item(i, 0);
            if(item)
                temp[item->text()] = _ui->MajorScoreList->item(i, 1)->text().toInt();
        }
        _facultyObj->saveAStudentScores(ID, true, temp);
    }
    else if(_facultyObj->isMinor(ID))
    {
        temp.clear();
        for(int i = 0; i < _ui->MinorScoreList->rowCount(); ++i)
        {
            auto item = _ui->MinorScoreList->item(i, 0);
            if(item)
                temp[item->text()] = _ui->MinorScoreList->item(i, 1)->text().toInt();
        }
        _facultyObj->saveAStudentScores(ID, false, temp);
    }
    return true;
}
예제 #30
0
파일: shared.cpp 프로젝트: andrew-bibb/cmst
//
//  Function to extract the data from a QDBusArgument that contains a map.
//  Some of the arrayElements can contain a QDBusArgument as the object
//  instead of a primitive (string, bool, int, etc.). This function
//  will extract the data from the QDBusArgument and write it into a map.
//
//  Return value a bool, true on success, false otherwise.
//  The map is sent by reference (called r_map here) and is modified by this function.
//  r_var is a constant reference to the QDBusArgument.
//
bool shared::extractMapData(QMap<QString,QVariant>& r_map, const QVariant& r_var)
{
  //  make sure we can convert the QVariant into a QDBusArgument
  if (! r_var.canConvert<QDBusArgument>() ) return false;
  const QDBusArgument qdba =  r_var.value<QDBusArgument>();

  // make sure the QDBusArgument holds a map
  if (qdba.currentType() != QDBusArgument::MapType ) return false;

  // iterate over the QDBusArgument pulling map keys and values out
    r_map.clear();
    qdba.beginMap();

    while ( ! qdba.atEnd() ) {
      QString key;
      QVariant value;
      qdba.beginMapEntry();
      qdba >> key >> value;
      qdba.endMapEntry();
      r_map.insert(key, value);
    } // while

    qdba.endMap();
    return true;
}