本文整理汇总了C++中QSet::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ QSet::erase方法的具体用法?C++ QSet::erase怎么用?C++ QSet::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSet
的用法示例。
在下文中一共展示了QSet::erase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scanFolder
void MusicScanner::scanFolder(MusicLibraryItemRoot *library, const QString &topLevel, const QString &f,
QSet<FileOnlySong> &existing, int level)
{
if (stopRequested) {
return;
}
if (level<4) {
QDir d(f);
QFileInfoList entries=d.entryInfoList(QDir::Files|QDir::NoSymLinks|QDir::Dirs|QDir::NoDotAndDotDot);
MusicLibraryItemArtist *artistItem = 0;
MusicLibraryItemAlbum *albumItem = 0;
foreach (const QFileInfo &info, entries) {
if (stopRequested) {
return;
}
if (info.isDir()) {
scanFolder(library, topLevel, info.absoluteFilePath(), existing, level+1);
} else if(info.isReadable()) {
Song song;
QString fname=info.absoluteFilePath().mid(topLevel.length());
if (fname.endsWith(".jpg", Qt::CaseInsensitive) || fname.endsWith(".png", Qt::CaseInsensitive) ||
fname.endsWith(".lyrics", Qt::CaseInsensitive) || fname.endsWith(".pamp", Qt::CaseInsensitive)) {
continue;
}
song.file=fname;
QSet<FileOnlySong>::iterator it=existing.find(song);
if (existing.end()==it) {
song=Tags::read(info.absoluteFilePath());
song.file=fname;
} else {
song=*it;
existing.erase(it);
}
if (song.isEmpty()) {
continue;
}
count++;
int t=time(NULL);
if ((t-lastUpdate)>=2 || 0==(count%5)) {
lastUpdate=t;
emit songCount(count);
}
song.fillEmptyFields();
song.size=info.size();
if (!artistItem || song.artistOrComposer()!=artistItem->data()) {
artistItem = library->artist(song);
}
if (!albumItem || albumItem->parentItem()!=artistItem || song.albumName()!=albumItem->data()) {
albumItem = artistItem->album(song);
}
MusicLibraryItemSong *songItem = new MusicLibraryItemSong(song, albumItem);
albumItem->append(songItem);
albumItem->addGenre(song.genre);
artistItem->addGenre(song.genre);
library->addGenre(song.genre);
}
}
}
示例2: processProjects
void Session::processProjects(const QList<ProjectInfo> &projects)
{
QSet<QString> projectsSet = QSet<QString>::fromList(m_projects.keys());
QList<QString> added;
QList<QString> changed;
// Zistenie zmien v projektoch a ich aktualizácia
foreach(const ProjectInfo &project, projects) {
const QString masterURL = project.primaryKey();
QSet<QString>::iterator projectIterator = projectsSet.find(project.primaryKey());
// Projekt ešte nie je v zozname projektov
if (projectIterator == projectsSet.end()) {
m_projects.insert(masterURL, project);
createProjectData(masterURL);
added.append(masterURL);
}
else {
if (project != this->project(masterURL)) {
m_projects.insert(masterURL, project);
changed.append(masterURL);
}
projectsSet.erase(projectIterator);
}
}
if (!added.isEmpty()) {
emit projectsAdded(added, m_id);
}
if (!projectsSet.isEmpty()) {
emit projectsRemoved(projectsSet.toList(), m_id);
}
if (!changed.isEmpty()) {
emit projectsChanged(changed, m_id);
}
foreach(const QString &masterURL, projectsSet) {
m_projects.remove(masterURL);
removeProjectData(masterURL);
}
示例3: getStateVariables
qint32 HRenderingControlService::getStateVariables(
quint32 instanceId, const QSet<QString>& stateVariableNames,
QString* stateVariableValuePairs)
{
HLOG2(H_AT, H_FUN, h_ptr->m_loggingIdentifier);
Q_ASSERT(stateVariableValuePairs);
HRendererConnection* mediaConnection =
m_owner->findConnectionByRcsId(instanceId);
if (!mediaConnection)
{
return HRenderingControlInfo::InvalidInstanceId;
}
QString retVal;
QXmlStreamWriter writer(&retVal);
writer.setCodec("UTF-8");
writer.writeStartDocument();
writer.writeStartElement("stateVariableValuePairs");
writer.writeDefaultNamespace("urn:schemas-upnp-org:av:avs");
writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
writer.writeAttribute("xsi:schemaLocation",
"urn:schemas-upnp-org:av:avs" \
"http://www.upnp.org/schemas/av/avs.xsd");
QSet<QString> stateVarNames;
if (stateVariableNames.contains("*"))
{
stateVarNames = HRenderingControlInfo::stateVariablesSetupData().names();
QSet<QString>::iterator it = stateVarNames.begin();
for(; it != stateVarNames.end();)
{
if (it->startsWith("A_ARG") || *it == "LastChange" ||
*it == "PresetNameList")
{
it = stateVarNames.erase(it);
}
else
{
++it;
}
}
}
else
{
stateVarNames = stateVariableNames;
}
foreach(QString svName, stateVarNames)
{
bool ok = false;
svName = svName.trimmed();
if (HRendererConnectionInfo::hasChannelAssociated(svName))
{
foreach(const HChannel& ch, HChannel::allChannels())
{
QString value = mediaConnection->value(svName, ch, &ok);
if (ok && !value.isEmpty())
{
writer.writeStartElement("stateVariable");
writer.writeAttribute("variableName", svName);
writer.writeAttribute("channel", ch.toString());
writer.writeCharacters(value);
writer.writeEndElement();
}
}
}
示例4: transfer
void CRateController::transfer()
{
m_bTransferSheduled = false;
QMutexLocker l(m_pMutex);
qint64 nMsecs = 1000;
if(m_tStopWatch.isValid())
{
nMsecs = qMin(nMsecs, m_tStopWatch.elapsed());
}
qint64 nToRead = (m_nDownloadLimit * nMsecs) / 1000;
qint64 nToWrite = (m_nUploadLimit * nMsecs) / 1000;
if(nToRead == 0 && nToWrite == 0)
{
sheduleTransfer();
return;
}
QSet<CNetworkConnection*> lSockets;
for(QSet<CNetworkConnection*>::const_iterator itSocket = m_lSockets.constBegin(); itSocket != m_lSockets.constEnd(); ++itSocket)
{
CNetworkConnection* pSock = *itSocket;
if(pSock->HasData())
{
lSockets.insert(pSock);
}
}
if(lSockets.isEmpty())
{
return;
}
m_tStopWatch.start();
bool bCanTransferMore = false;
do
{
bCanTransferMore = false;
qint64 nWriteChunk = qMax(qint64(1), nToWrite / lSockets.size());
qint64 nReadChunk = qMax(qint64(1), nToRead / lSockets.size());
quint32 nDownloaded = 0, nUploaded = 0;
for(QSet<CNetworkConnection*>::iterator itSocket = lSockets.begin(); itSocket != lSockets.end() && (nToRead > 0 || nToWrite > 0);)
{
CNetworkConnection* pConn = *itSocket;
bool bDataTransferred = false;
qint64 nAvailable = qMin(nReadChunk, pConn->networkBytesAvailable());
if(nAvailable > 0)
{
qint64 nReadBytes = pConn->readFromNetwork(qMin(nAvailable, nToRead));
if(nReadBytes > 0)
{
nToRead -= nReadBytes;
nDownloaded += nReadBytes;
bDataTransferred = true;
}
}
if(m_nUploadLimit * 2 > pConn->m_pSocket->bytesToWrite())
{
qint64 nChunkSize = qMin(qMin(nWriteChunk, nToWrite), m_nUploadLimit * 2 - pConn->m_pSocket->bytesToWrite());
if(nChunkSize > 0)
{
qint64 nBytesWritten = pConn->writeToNetwork(nChunkSize);
if(nBytesWritten > 0)
{
nToWrite -= nBytesWritten;
nUploaded += nBytesWritten;
bDataTransferred = true;
}
}
}
if(bDataTransferred && pConn->HasData())
{
bCanTransferMore = true;
}
else
{
itSocket = lSockets.erase(itSocket);
continue;
}
++itSocket;
}
m_mDownload.Add(nDownloaded);
m_mUpload.Add(nUploaded);
}
while(bCanTransferMore && (nToRead > 0 || nToWrite > 0) && !lSockets.isEmpty());
if(bCanTransferMore || nToRead == 0 || nToWrite == 0)
//.........这里部分代码省略.........
示例5: getStateVariables
qint32 HTransportSinkService::getStateVariables(
quint32 instanceId, const QSet<QString>& stateVariableNames,
QString* stateVariableValuePairs)
{
HLOG2(H_AT, H_FUN, h_ptr->m_loggingIdentifier);
Q_ASSERT(stateVariableValuePairs);
HRendererConnection* mediaConnection = m_owner->findConnectionByAvTransportId(instanceId);
if (!mediaConnection)
{
return HAvTransportInfo::InvalidInstanceId;
}
QString retVal;
QXmlStreamWriter writer(&retVal);
writer.setCodec("UTF-8");
writer.writeStartDocument();
writer.writeStartElement("stateVariableValuePairs");
writer.writeDefaultNamespace("urn:schemas-upnp-org:av:avs");
writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
writer.writeAttribute("xsi:schemaLocation",
"urn:schemas-upnp-org:av:avs " \
"http://www.upnp.org/schemas/av/avs.xsd");
QSet<QString> stateVarNames;
if (stateVariableNames.contains("*"))
{
stateVarNames = HAvTransportInfo::stateVariablesSetupData().names();
QSet<QString>::iterator it = stateVarNames.begin();
for(; it != stateVarNames.end();)
{
if (it->startsWith("A_ARG") || *it == "LastChange")
{
it = stateVarNames.erase(it);
}
else
{
++it;
}
}
}
else
{
stateVarNames = stateVariableNames;
}
foreach(QString svName, stateVarNames)
{
svName = svName.trimmed();
if (svName.compare("LastChange", Qt::CaseInsensitive) == 0 ||
svName.startsWith("A_ARG", Qt::CaseInsensitive))
{
return HAvTransportInfo::InvalidStateVariableList;
}
bool ok = false;
QString value = mediaConnection->info()->value(svName, &ok);
if (ok)
{
writer.writeStartElement("stateVariable");
writer.writeAttribute("variableName", svName);
writer.writeCharacters(value);
writer.writeEndElement();
}
else
{
HLOG_WARN(QString("Could not get the value of state variable [%1]").arg(svName));
return HAvTransportInfo::InvalidStateVariableList;
}
}