BorderDrawerInterface * BorderDrawersLoader::getDrawerFromSvg(QDomElement & drawerElement)
{
    QMap<QString,QString> properties;
    QDomNamedNodeMap attributes = drawerElement.attributes();
    for (int j = attributes.count()-1; j >= 0; --j)
    {
        QDomAttr attr = attributes.item(j).toAttr();
        if (attr.isNull())
            continue;
        properties.insert(attr.name(), attr.value());
    }
    QString drawerName = properties.take("name");
    if (!instance()->registeredDrawers().contains(drawerName))
        return 0;
    BorderDrawerInterface * drawer = getDrawerByName(drawerName);
    const QMetaObject * meta = drawer->metaObject();
    int count = meta->propertyCount();
    for (int i = 0; i < count; ++i)
    {
        QMetaProperty p = meta->property(i);
        QString value = properties.take(p.name());
        if (value.isEmpty())
            continue;
        p.write(drawer, QVariant(QByteArray::fromBase64(value.toAscii())));
    }
    return drawer;
}
Example #2
0
void CRouteGraph::ShowRoute(const QList<SRouteEntry>& Entrys)
{
	CUInt128 MaxDistance;
	uint64 StartTime = ULLONG_MAX;
	uint64 MaxTime = 0;

	// Nodes BEGIN
	QMap<CUInt128, CRouteNode*> Nodes = m_Nodes;
	foreach(const SRouteEntry& Entry, Entrys)
	{
		CRouteNode* Node = Nodes.take(Entry.ID);
		if(!Node)
		{
			ASSERT(!m_Nodes.contains(Entry.ID));
			Node = new CRouteNode();
			m_Nodes.insert(Entry.ID, Node);
			scene()->addItem(Node);
			Node->setScale(m_ScaleFactor);
		}

		Node->SetColor(Entry.Color);
		Node->setToolTip(Entry.Tipp);

		if(Entry.Distance > MaxDistance)
			MaxDistance = Entry.Distance;

		if(Entry.Time > MaxTime)
			MaxTime = Entry.Time;
		if(Entry.Time < StartTime)
			StartTime = Entry.Time;
	}
Example #3
0
// Fills in the various bits of information the tracker
// needs to keep around
void
MainWindow::setupTracker(Backend *newBug, QMap<QString, QString> info)
{
    newBug->setId(info["id"]);
    newBug->setName(info["name"]);
    newBug->setUsername(info["username"]);
    newBug->setPassword(info["password"]);
    newBug->setLastSync(info["last_sync"]);
    newBug->setVersion(info["version"]);
    if (!info["monitored_components"].isEmpty())
        newBug->setMonitorComponents(info["monitored_components"].split(","));
    connect(newBug, SIGNAL(bugsUpdated()),
            this, SLOT(bugsUpdated()));
    connect(newBug, SIGNAL(backendError(QString)),
            this, SLOT(backendError(QString)));

    // If this was called after the user used the Add Tracker window,
    // insert the data into the DB
    if (info["id"] == "-1")
    {
        info.take("id");
        info["auto_cache_comments"] = newBug->autoCacheComments();
        int tracker = SqlUtilities::simpleInsert("trackers", info);
        newBug->setId(QString("%1").arg(tracker));
        mSyncPosition = mBackendList.size() + 1;
        connect(newBug, SIGNAL(fieldsFound()),
                this, SLOT(fieldsChecked()));
        newBug->checkFields();
    }
    else
    {
        addTrackerToList(newBug, false);
    }
}
void AddJobDialog::loadTemplateList(void)
{
	ui->cbxTemplate->addItem(tr("<Default>"), QVariant::fromValue<const void*>(m_defaults));
	ui->cbxTemplate->setCurrentIndex(0);

	QMap<QString, OptionsModel*> templates = OptionsModel::loadAllTemplates(m_sysinfo);
	QStringList templateNames = templates.keys();
	templateNames.sort();

	for(QStringList::ConstIterator current = templateNames.constBegin(); current != templateNames.constEnd(); current++)
	{
		OptionsModel *currentTemplate = templates.take(*current);
		ui->cbxTemplate->addItem(*current, QVariant::fromValue<const void*>(currentTemplate));
		if(currentTemplate->equals(m_options))
		{
			ui->cbxTemplate->setCurrentIndex(ui->cbxTemplate->count() - 1);
		}
	}

	if((ui->cbxTemplate->currentIndex() == 0) && (!m_options->equals(m_defaults)))
	{
		qWarning("Not the default -> recently used!");
		ui->cbxTemplate->insertItem(1, tr("<Recently Used>"), QVariant::fromValue<const void*>(m_options));
		ui->cbxTemplate->setCurrentIndex(1);
	}
}
Example #5
0
 static gboolean qt_input_remove(guint handle) {
         int toReturn = 0;
         QPurpleIONotifier *tmp = notifierMap.take(handle);
         if (!tmp->defaultConstructed) {
                 toReturn = 1;
                 delete tmp; }
         return toReturn;
 }
Example #6
0
void VS_CC frameDoneCallback(void *userData, const VSFrameRef *f, int n, VSNodeRef *, const char *errorMsg) {
    completedFrames++;

    if (f) {
        reorderMap.insert(n, f);
        while (reorderMap.contains(outputFrames)) {
            const VSFrameRef *frame = reorderMap.take(outputFrames);
            if (!outputError) {
				if (y4m) {
					if (!fwrite("FRAME\n", 6, 1, outFile)) {
						errorMessage = "Error: fwrite() call failed";
						totalFrames = requestedFrames;
						outputError = true;
					}
				}

				if (!outputError) {
					const VSFormat *fi = vsapi->getFrameFormat(frame);
					for (int p = 0; p < fi->numPlanes; p++) {
						int stride = vsapi->getStride(frame, p);
						const uint8_t *readPtr = vsapi->getReadPtr(frame, p);
						int rowSize = vsapi->getFrameWidth(frame, p) * fi->bytesPerSample;
						int height = vsapi->getFrameHeight(frame, p);
						for (int y = 0; y < height; y++) {
							if (!fwrite(readPtr, rowSize, 1, outFile)) {
								errorMessage = "Error: fwrite() call failed";
								totalFrames = requestedFrames;
								outputError = true;
								p = 100; // break out of the outer loop
								break;
							}
							readPtr += stride;
						}
					}
				}
			}
            vsapi->freeFrame(frame);
            outputFrames++;
        }
    } else {
        outputError = true;
        totalFrames = requestedFrames;
        if (errorMsg)
            errorMessage = QString("Error: Failed to retrieve frame ") + n + QString(" with error: ") + QString::fromUtf8(errorMsg);
        else
            errorMessage = QString("Error: Failed to retrieve frame ") + n;
    }

    if (requestedFrames < totalFrames) {
        vsapi->getFrameAsync(requestedFrames, node, frameDoneCallback, NULL);
        requestedFrames++;
    }

    if (totalFrames == completedFrames) {
        QMutexLocker lock(&mutex);
        condition.wakeOne();
    }
}
Example #7
0
void MarksDB::addMark(QString email,int lessonId, int mark)
{
    if (!markMap.contains(email))
    {
        markMap.insert(email,QMap<int,int>());
    }
    QMap<int, int> map = markMap.take(email);
    if (!map.contains(lessonId))
    {
        map.insert(lessonId,mark);
    }
    else
    {
        map.take(lessonId);
        map.insert(lessonId,mark);
    }
    markMap.insert(email,map);
}
Example #8
0
    static gboolean qt_timer_remove(guint handle) {
            int toReturn = 0;
            QPurpleTimer *tmp = timerMap.take(handle);
            if (!tmp->defaultConstructed) { // we removed something
                    toReturn = 1;
                    delete tmp; }

            return toReturn;
    }
Example #9
0
bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods)
{
    Identifier id(nativeMods, nativeKey);
    if (!keyIDs.contains(id)) return false;

    EventHotKeyRef ref = keyRefs.take(keyIDs[id]);
    keyIDs.remove(id);
    return !UnregisterEventHotKey(ref);
}
Example #10
0
void tst_QMap::take()
{
    QMap<int, QString> map;

    map.insert(2, "zwei");
    map.insert(3, "drei");

    QVERIFY(map.take(3) == "drei");
    QVERIFY(!map.contains(3));
}
Example #11
0
/*!
 * \brief Universe::Remove Helper function
 * \param serverConnectionHandlerID the connection id of the server
 * \param clientID the client id on the current tab
 */
void Universe::Remove(uint64 serverConnectionHandlerID, anyID clientID)
{
    if (!(UniverseMap.contains(serverConnectionHandlerID)))
        return;

    QMap<anyID,TsVR*>* ConnectionHandlerUniverse = UniverseMap.value(serverConnectionHandlerID);
    if (!(ConnectionHandlerUniverse->contains(clientID)))
        return;

    delete ConnectionHandlerUniverse->take(clientID);
}
Example #12
0
void PersistantConfig::AddAndroidHosts()
{
  QMap<rdcstr, RemoteHost *> oldHosts;
  for(int i = RemoteHosts.count() - 1; i >= 0; i--)
  {
    if(RemoteHosts[i]->IsADB())
    {
      RemoteHost *host = RemoteHosts.takeAt(i);
      oldHosts[host->hostname] = host;
    }
  }

  QString androidSDKPath = QFile::exists(Android_SDKPath) ? QString(Android_SDKPath) : QString();

  SetConfigSetting("androidSDKPath", androidSDKPath);

  QString androidJDKPath = QFile::exists(Android_JDKPath) ? QString(Android_JDKPath) : QString();

  SetConfigSetting("androidJDKPath", androidJDKPath);

  SetConfigSetting("MaxConnectTimeout", QString::number(Android_MaxConnectTimeout));

  rdcstr androidHosts;
  RENDERDOC_EnumerateAndroidDevices(&androidHosts);
  for(const QString &hostName :
      QString(androidHosts).split(QLatin1Char(','), QString::SkipEmptyParts))
  {
    RemoteHost *host = NULL;

    if(oldHosts.contains(hostName))
      host = oldHosts.take(hostName);
    else
      host = new RemoteHost();

    host->hostname = hostName;
    rdcstr friendly;
    RENDERDOC_GetAndroidFriendlyName(hostName.toUtf8().data(), friendly);
    host->friendlyName = friendly;
    // Just a command to display in the GUI and allow Launch() to be called.
    host->runCommand = lit("Automatically handled");
    RemoteHosts.push_back(host);
  }

  // delete any leftovers
  QMapIterator<rdcstr, RemoteHost *> i(oldHosts);
  while(i.hasNext())
  {
    i.next();
    delete i.value();
  }
}
Example #13
0
/*!
 * \brief Universe::Remove Helper function
 * \param serverConnectionHandlerID the connection id of the server
 */
void Universe::Remove(uint64 serverConnectionHandlerID)
{
    if (!(UniverseMap.contains(serverConnectionHandlerID)))
        return;

    QMap<anyID,TsVR*>* ConnectionHandlerUniverse = UniverseMap.take(serverConnectionHandlerID);
    QMutableMapIterator<anyID,TsVR*> i(*ConnectionHandlerUniverse);
    while (i.hasNext())
    {
        i.next();
        delete ConnectionHandlerUniverse->take(i.key());
    }
    UniverseMap.remove(serverConnectionHandlerID);
}
Example #14
0
void set_write_handler(int fd, void (*cb)(void *opaque), void *opaque)
{
    if (gWriteNotifiers.contains(fd)) {
        QSocketNotifier *notifier = gWriteNotifiers.take(fd);
        notifier->setEnabled(false);
        delete notifier;
    }

    if (cb == nullptr) {
        return;
    }

    QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Write);
    QObject::connect(notifier, &QSocketNotifier::activated,
                     std::bind(cb, opaque) );
}
Example #15
0
void CP2PServers::SyncServers(const QVariantMap& Response)
{
	QMap<QString, SServer*> OldServers = m_Servers;

	foreach (const QVariant& vServer,Response["Servers"].toList())
	{
		QVariantMap Server = vServer.toMap();

		QString Url = Server["Url"].toString();

		SServer* pServer = OldServers.take(Url);
		if(!pServer)
		{
			pServer = new SServer();
			pServer->pItem = new QTreeWidgetItem();
			m_pServerTree->addTopLevelItem(pServer->pItem);

			pServer->pItem->setText(eUrl, Url);

			m_Servers.insert(Url, pServer);
		}

		QFont Font = pServer->pItem->font(eUrl);
		if(Font.bold() != Server["IsStatic"].toBool())
		{
			Font.setBold(Server["IsStatic"].toBool());
			pServer->pItem->setFont(eUrl, Font);
		}

		pServer->pItem->setText(eName, Server["Name"].toString());
		pServer->pItem->setData(eName, Qt::UserRole, Server["IsStatic"]);
		pServer->pItem->setText(eVersion, Server["Version"].toString());
		pServer->pItem->setText(eStatus, Server["Status"].toString());
		pServer->pItem->setData(eStatus, Qt::UserRole, Server["Status"]);
		pServer->pItem->setText(eUsers, Server["UserCount"].toString() + "(" + Server["LowIDCount"].toString() + ")/" + Server["UserLimit"].toString());
		pServer->pItem->setText(eFiles, Server["FileCount"].toString() + "|" + Server["HardLimit"].toString() + "(" + Server["SoftLimit"].toString() + ")");
		pServer->pItem->setText(eDescription, Server["Description"].toString());
	}

	foreach(SServer* pServer, OldServers)
	{
		m_Servers.remove(OldServers.key(pServer));
		delete pServer->pItem;
		delete pServer;
	}
Example #16
0
void set_branch( const QList< uint * > &touching, const BillonTpl< tlabel > *labelSkel, const BillonTpl< tlabelbranch > *labelBranch, 
                 QMap< tlabelbranch, tlabel > &NewLabelBranch, const QList< tlabel > &Labels, QMap< tlabel, QList<tlabel> > &edges ) {
	QList< uint * >::const_iterator iterVoxel = touching.begin(),
	                                iterVoxelEnd = touching.end() ;
	bool bDiscard ;
	QList< tlabelbranch > bridges ;
	while ( iterVoxel != iterVoxelEnd ) {
		tlabelbranch idBranch = (*labelBranch)( (*iterVoxel)[1], (*iterVoxel)[0], (*iterVoxel)[2] ) ;
		tlabel idComp = (*labelSkel)( (*iterVoxel)[1], (*iterVoxel)[0], (*iterVoxel)[2] ) ;
		bDiscard = false ;
		if ( !Labels.isEmpty() ) {
			bDiscard = ( !Labels.contains( idComp ) );
		}
		if ( !bDiscard ) {
			if ( !NewLabelBranch.contains( idBranch ) )
				NewLabelBranch.insert( idBranch, idComp ) ;
			else if (NewLabelBranch[idBranch] != idComp ) {
				bridges.append( idBranch ) ;
				if ( !edges.contains( idComp ) ) edges.insert( idComp, QList<tlabel>() ) ;
				if ( !edges.contains( NewLabelBranch[idBranch] ) ) edges.insert( NewLabelBranch[idBranch], QList<tlabel>() ) ;
				edges[ idComp ].append( NewLabelBranch[idBranch] ) ;
				//edges[ idComp ].append( idBranch ) ;
				edges[ NewLabelBranch[idBranch] ].append( idComp ) ;
				//edges[ NewLabelBranch[idBranch] ].append( idBranch ) ; /// it is this value that is the edge between the two
			}
		} else if ( NewLabelBranch.contains( idBranch ) ) {
			bridges.append( idBranch ) ;
		}
		iterVoxel++ ;
	}
	/// component that get their identifier in bridges are connected to at least two components
	qSort( bridges.begin(), bridges.end(), qLess< tlabelbranch >() ) ;
	while ( !bridges.isEmpty() ) {
		NewLabelBranch.take( bridges.takeFirst() ) ;
	}
	
	for ( QMap<tlabel,QList<tlabel> >::ConstIterator e_source_it = edges.begin() ; e_source_it != edges.end() ; e_source_it++ ) {
		std::cout<<(int)e_source_it.key()<<" connected to ";
		for ( QList<tlabel>::ConstIterator e_target_it = e_source_it.value().begin() ; e_target_it != e_source_it.value().end() ; e_target_it++ )
			std::cout<<(int)*e_target_it<<" " ;
		std::cout<<std::endl;
	}
	
}
Example #17
0
void MarksDB::deleteLesson(int lessonId)
{
    QList<QString> listStudents = markMap.uniqueKeys();

    for (int i=0; i<listStudents.size(); i++)
    {
        QString name = listStudents.at(i);

        QMap<int,int> tempMap = markMap.take(name);

        if (tempMap.contains(lessonId))
        {
            tempMap.remove(lessonId);
        }
        if (tempMap.size() > 0)
        {
            markMap.insert(name,tempMap);
        }
    }
}
QList<ProcessorInputPortWidget*> ProcessorInputsWidget::updatePorts(QList<FilterGroupPort> portList)
{
    QMap<PortId, ProcessorInputPortWidget*> ports = mPorts;
    foreach(FilterGroupPort port, portList)
    {
        PortId id(port.filterId, port.port.name);
        ProcessorInputPortWidget* portWidget;
        if(ports.contains(id))
            portWidget = ports.take(id);
        else
        {
            portWidget = new ProcessorInputPortWidget(port, false, this);
            connect(portWidget, SIGNAL(startConnect(FilterPortWidget*)), SIGNAL(startConnect(FilterPortWidget*)));
            connect(portWidget, SIGNAL(startDisconnect(FilterPortWidget*)), SIGNAL(startDisconnect(FilterPortWidget*)));
            if(port.port.isMainType)
                ui->leftOutputs->addWidget(portWidget);
            else
                ui->rightOutputs->addWidget(portWidget);
            mPorts[id] = portWidget;
        }
        portWidget->setNewName(port.name);
    }
Example #19
0
void CWebTaskView::SyncWebTasks(const QVariantMap& Response)
{
	QMap<uint64, QTreeWidgetItem*> OldWebTasks;
	for(int i = 0; i < m_pWebTaskTree->topLevelItemCount(); ++i) 
	{
		QTreeWidgetItem* pItem = m_pWebTaskTree->topLevelItem(i);
		uint64 ID = pItem->data(0, Qt::UserRole).toULongLong();
		Q_ASSERT(!OldWebTasks.contains(ID));
		OldWebTasks.insert(ID,pItem);
	}

	QList<QTreeWidgetItem*> NewItems;
	foreach (const QVariant vWebTask, Response["Tasks"].toList())
	{
		QVariantMap WebTask = vWebTask.toMap();
		uint64 SubID = WebTask["ID"].toULongLong();

		QTreeWidgetItem* pItem = OldWebTasks.take(SubID);
		if(!pItem)
		{
			pItem = new QTreeWidgetItem();
			pItem->setData(eUrl, Qt::UserRole, SubID);
			NewItems.append(pItem);
		}

		pItem->setText(eUrl, WebTask["Url"].toString());

		pItem->setText(eEntry, WebTask["Entry"].toString());

		pItem->setText(eStatus, WebTask["Status"].toString());
	}
	m_pWebTaskTree->addTopLevelItems(NewItems);

	foreach(QTreeWidgetItem* pItem, OldWebTasks)
		delete pItem;
}
bool HsMenuClientPrivate::add(const QVariantMap &entryPreference)
{
    bool result = false;
    QMap<QString, QVariant> pref = entryPreference;
    
    CaIconDescription iconDesc;
    if(pref.contains(hsItemId))
        {
            QSharedPointer<CaEntry> update_entry = CaService::instance()->getEntry(pref.take(hsItemId).toInt());
            
            if(pref.contains(hsItemLocName))
                {
                update_entry->setText(pref.take(hsItemLocName).toString(),true);
                }
            else
                {
                update_entry->setText(pref.take(hsItemName).toString());   
                }
            
            if(pref.contains(hsItemLocDescription))
                {
                update_entry->setDescription(pref.take(hsItemLocDescription).toString(), true);
                }
            else
                {
                update_entry->setDescription(pref.take(hsItemDescription).toString());
                }                                             
            
            iconDesc.setFilename(pref.take(hsIconFileName).toString());
            iconDesc.setSkinId(pref.take(hsIconName).toString());
            iconDesc.setApplicationId(pref.take(hsIconApplicationId).toString());
            update_entry->setIconDescription(iconDesc);
            QMapIterator<QString, QVariant> k(pref);
            while (k.hasNext()) {
                k.next();
                update_entry->setAttribute(k.key(),k.value().toString());
            }
            
            result = CaService::instance()->updateEntry(*update_entry);
        }
    else if ((pref.contains(hsItemName) || pref.contains(hsItemLocName)) && pref.contains(hsitemLaunchUri) && pref.contains(hsitemPublisherId))
        {
            CaEntry add_entry(ItemEntryRole);
            add_entry.setEntryTypeName(Hs::templatedApplicationTypeName);
            // mandatory values
            if(pref.contains(hsItemLocName))
                {
                add_entry.setText(pref.take(hsItemLocName).toString(),true);
                }
            else
                {
                add_entry.setText(pref.take(hsItemName).toString());
                }
            
            iconDesc.setFilename(pref.take(hsIconFileName).toString());
            iconDesc.setSkinId(pref.take(hsIconName).toString());
            iconDesc.setApplicationId(pref.take(hsIconApplicationId).toString());            
            add_entry.setIconDescription(iconDesc);  
            
            if(pref.contains(hsItemLocDescription))
                {
                add_entry.setDescription(pref.take(hsItemLocDescription).toString(), true);
                }
            else
                {
                add_entry.setDescription(pref.take(hsItemDescription).toString());
                }  
            QMapIterator<QString, QVariant> k(pref);
            while (k.hasNext()) {
                k.next();
                add_entry.setAttribute(k.key(),k.value().toString());
            }

            add_entry.setFlags(add_entry.flags() & ~RemovableEntryFlag);
            
            QSharedPointer<CaEntry> entry = CaService::instance()->createEntry(add_entry);
            if (!entry.isNull()) {
                result = true;
            }      
        }
    else
        {
            return false;
        }
    return result;
    
  
}
QgsVectorLayerExporter::ExportError
QgsVectorLayerExporter::exportLayer( QgsVectorLayer *layer,
                                     const QString &uri,
                                     const QString &providerKey,
                                     const QgsCoordinateReferenceSystem &destCRS,
                                     bool onlySelected,
                                     QString *errorMessage,
                                     const QMap<QString, QVariant> &options,
                                     QgsFeedback *feedback )
{
  QgsCoordinateReferenceSystem outputCRS;
  QgsCoordinateTransform ct;
  bool shallTransform = false;

  if ( !layer )
    return ErrInvalidLayer;

  if ( destCRS.isValid() )
  {
    // This means we should transform
    outputCRS = destCRS;
    shallTransform = true;
  }
  else
  {
    // This means we shouldn't transform, use source CRS as output (if defined)
    outputCRS = layer->crs();
  }


  bool overwrite = false;
  bool forceSinglePartGeom = false;
  QMap<QString, QVariant> providerOptions = options;
  if ( !options.isEmpty() )
  {
    overwrite = providerOptions.take( QStringLiteral( "overwrite" ) ).toBool();
    forceSinglePartGeom = providerOptions.take( QStringLiteral( "forceSinglePartGeometryType" ) ).toBool();
  }

  QgsFields fields = layer->fields();
  QgsWkbTypes::Type wkbType = layer->wkbType();

  // Special handling for Shapefiles
  if ( layer->providerType() == QLatin1String( "ogr" ) && layer->storageType() == QLatin1String( "ESRI Shapefile" ) )
  {
    // convert field names to lowercase
    for ( int fldIdx = 0; fldIdx < fields.count(); ++fldIdx )
    {
      fields[fldIdx].setName( fields.at( fldIdx ).name().toLower() );
    }

    if ( !forceSinglePartGeom )
    {
      // convert wkbtype to multipart (see #5547)
      switch ( wkbType )
      {
        case QgsWkbTypes::Point:
          wkbType = QgsWkbTypes::MultiPoint;
          break;
        case QgsWkbTypes::LineString:
          wkbType = QgsWkbTypes::MultiLineString;
          break;
        case QgsWkbTypes::Polygon:
          wkbType = QgsWkbTypes::MultiPolygon;
          break;
        case QgsWkbTypes::Point25D:
          wkbType = QgsWkbTypes::MultiPoint25D;
          break;
        case QgsWkbTypes::LineString25D:
          wkbType = QgsWkbTypes::MultiLineString25D;
          break;
        case QgsWkbTypes::Polygon25D:
          wkbType = QgsWkbTypes::MultiPolygon25D;
          break;
        default:
          break;
      }
    }
  }

  QgsVectorLayerExporter *writer =
    new QgsVectorLayerExporter( uri, providerKey, fields, wkbType, outputCRS, overwrite, providerOptions );

  // check whether file creation was successful
  ExportError err = writer->errorCode();
  if ( err != NoError )
  {
    if ( errorMessage )
      *errorMessage = writer->errorMessage();
    delete writer;
    return err;
  }

  if ( errorMessage )
  {
    errorMessage->clear();
  }

  QgsFeature fet;

  QgsFeatureRequest req;
  if ( wkbType == QgsWkbTypes::NoGeometry )
    req.setFlags( QgsFeatureRequest::NoGeometry );
  if ( onlySelected )
    req.setFilterFids( layer->selectedFeatureIds() );

  QgsFeatureIterator fit = layer->getFeatures( req );

  // Create our transform
  if ( destCRS.isValid() )
  {
    Q_NOWARN_DEPRECATED_PUSH
    ct = QgsCoordinateTransform( layer->crs(), destCRS );
    Q_NOWARN_DEPRECATED_POP
  }
int OracleImporter::importTextSpoiler(CardSet *set, const QVariant &data)
{
    int cards = 0;

    QListIterator<QVariant> it(data.toList());
    QVariantMap map;
    QString cardName;
    QString cardCost;
    QString cardType;
    QString cardPT;
    QString cardText;
    int cardId;
    int cardLoyalty;
    QMap<int, QVariantMap> splitCards;

    while (it.hasNext()) {
        map = it.next().toMap();
        if(0 == QString::compare(map.value("layout").toString(), QString("split"), Qt::CaseInsensitive))
        {
            // Split card handling
            cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
            if(splitCards.contains(cardId))
            {
                // merge two split cards
                QVariantMap tmpMap = splitCards.take(cardId);
                QVariantMap * card1 = 0, * card2 = 0;
                // same cardid
                cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
                // this is currently an integer; can't accept 2 values
                cardLoyalty = 0;

                // determine which subcard is the first one in the split
                QStringList names=map.contains("names") ? map.value("names").toStringList() : QStringList("");
                if(names.count()>0 &&
                        map.contains("name") &&
                        0 == QString::compare(map.value("name").toString(), names.at(0)))
                {
                    // map is the left part of the split card, tmpMap is right part
                    card1 = &map;
                    card2 = &tmpMap;
                } else {
                    //tmpMap is the left part of the split card, map is right part
                    card1 = &tmpMap;
                    card2 = &map;
                }

                // add first card's data
                cardName = card1->contains("name") ? card1->value("name").toString() : QString("");
                cardCost = card1->contains("manaCost") ? card1->value("manaCost").toString() : QString("");
                cardType = card1->contains("type") ? card1->value("type").toString() : QString("");
                cardPT = card1->contains("power") || card1->contains("toughness") ? card1->value("power").toString() + QString('/') + card1->value("toughness").toString() : QString("");
                cardText = card1->contains("text") ? card1->value("text").toString() : QString("");

                // add second card's data
                cardName += card2->contains("name") ? QString(" // ") + card2->value("name").toString() : QString("");
                cardCost += card2->contains("manaCost") ? QString(" // ") + card2->value("manaCost").toString() : QString("");
                cardType += card2->contains("type") ? QString(" // ") + card2->value("type").toString() : QString("");
                cardPT += card2->contains("power") || card2->contains("toughness") ? QString(" // ") + card2->value("power").toString() + QString('/') + card2->value("toughness").toString() : QString("");
                cardText += card2->contains("text") ? QString("\n\n---\n\n") + card2->value("text").toString() : QString("");
            } else {
                // first card od a pair; enqueue for later merging
                splitCards.insert(cardId, map);
                continue;
            }
        } else {
            // normal cards handling
            cardName = map.contains("name") ? map.value("name").toString() : QString("");
            cardCost = map.contains("manaCost") ? map.value("manaCost").toString() : QString("");
            cardType = map.contains("type") ? map.value("type").toString() : QString("");
            cardPT = map.contains("power") || map.contains("toughness") ? map.value("power").toString() + QString('/') + map.value("toughness").toString() : QString("");
            cardText = map.contains("text") ? map.value("text").toString() : QString("");
            cardId = map.contains("multiverseid") ? map.value("multiverseid").toInt() : 0;
            cardLoyalty = map.contains("loyalty") ? map.value("loyalty").toInt() : 0;
        }

        CardInfo *card = addCard(set->getShortName(), cardName, false, cardId, cardCost, cardType, cardPT, cardLoyalty, cardText.split("\n"));

        if (!set->contains(card)) {
            card->addToSet(set);
            cards++;
        }
    }

    return cards;
}
Example #23
0
void CServicesWidget::UpdateTree()
{
	bool bAccOnly = m_pAccountsOnly->isChecked();
	QString Filter = m_pHostFilter->text();

	QMap<QString, SHoster*> OldHosters = m_Hosters;

	foreach (const QVariantMap& Hoster, m_Services.values(m_Mode))
	{
		QString Name = Hoster["HostName"].toString();

		QVariantList Logins = Hoster["Logins"].toList();
		if(bAccOnly && Logins.isEmpty())
			continue;
		if(!Filter.isEmpty() && !Name.contains(Filter))
			continue;

		SHoster* pHoster = OldHosters.take(Name);
		if(!pHoster)
		{
			pHoster = new SHoster();
			pHoster->pItem = new QTreeWidgetItem();
			m_pHosterTree->addTopLevelItem(pHoster->pItem);

			pHoster->pItem->setText(eName, Name);

			m_Hosters.insert(Name, pHoster);
		}
		if(pHoster->pItem->icon(eName).isNull())
			pHoster->pItem->setIcon(eName, theGUI->GetHosterIcon(Name, false));

		QFont Font = pHoster->pItem->font(eName);
		if(Font.bold() != !Logins.isEmpty())
		{
			Font.setBold(!Logins.isEmpty());
			pHoster->pItem->setFont(eName, Font);
		}


		pHoster->pItem->setText(eStatus, Hoster["Status"].toString());
		pHoster->pItem->setText(eAPIs, Hoster["APIs"].toStringList().join(", "));

		// logins:

		QMap<QString, QTreeWidgetItem*> OldAccounts;
		for(int i = 0; i < pHoster->pItem->childCount(); ++i) 
		{
			QTreeWidgetItem* pItem = pHoster->pItem->child(i);
			QString Login = pItem->text(eName);
			Q_ASSERT(!OldAccounts.contains(Login));
			OldAccounts.insert(Login,pItem);
		}

		foreach (const QVariant vLogin, Logins)
		{
			QVariantMap Login = vLogin.toMap();
			QString Account = Login["UserName"].toString();

			QTreeWidgetItem* pItem = OldAccounts.take(Account);
			if(!pItem)
			{
				pItem = new QTreeWidgetItem();
				pHoster->pItem->addChild(pItem);
				pHoster->pItem->setExpanded(true);
				
				pItem->setText(eName, Account);
			}

			pItem->setText(eStatus, Login["Status"].toString() + (Login["Free"].toBool() ? tr(" (Free)") : ""));
		}

		foreach(QTreeWidgetItem* pItem, OldAccounts)
			delete pItem;
	}