本文整理汇总了C++中QSet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QSet::size方法的具体用法?C++ QSet::size怎么用?C++ QSet::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSet
的用法示例。
在下文中一共展示了QSet::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
void Su2Writer::writeBoundaries()
{
QTextStream f(m_File);
f << "%\n";
f << "% Boundary elements\n";
f << "%\n";
QSet<int> bcs = GuiMainWindow::pointer()->getAllBoundaryCodes();
f << "NMARK= " << bcs.size() << "\n";
EG_VTKDCC(vtkIntArray, cell_code, m_Grid, "cell_code");
foreach (int bc, bcs) {
BoundaryCondition BC = GuiMainWindow::pointer()->getBC(bc);
f << "MARKER_TAG= " << BC.getName() << "\n";
QList<vtkIdType> faces;
for (vtkIdType id_cell = 0; id_cell < m_Grid->GetNumberOfCells(); ++id_cell) {
if (isSurface(id_cell, m_Grid)) {
if (cell_code->GetValue(id_cell) == bc) {
faces.append(id_cell);
}
}
}
f << "MARKER_ELEMS= " << faces.size() << "\n";
foreach (vtkIdType id_cell, faces) {
f << m_Grid->GetCellType(id_cell);
vtkIdType N_pts, *pts;
m_Grid->GetCellPoints(id_cell, N_pts, pts);
for (int j = 0; j < N_pts; ++j) {
f << " " << pts[j];
}
f << "\n";
}
示例2: getPreferredCrs
QString QgsWFSSourceSelect::getPreferredCrs( const QSet<QString>& crsSet ) const
{
if ( crsSet.size() < 1 )
{
return QLatin1String( "" );
}
//first: project CRS
QgsCoordinateReferenceSystem projectRefSys = QgsProject::instance()->crs();
//convert to EPSG
QString ProjectCRS;
if ( projectRefSys.isValid() )
{
ProjectCRS = projectRefSys.authid();
}
if ( !ProjectCRS.isEmpty() && crsSet.contains( ProjectCRS ) )
{
return ProjectCRS;
}
//second: WGS84
if ( crsSet.contains( GEO_EPSG_CRS_AUTHID ) )
{
return GEO_EPSG_CRS_AUTHID;
}
//third: first entry in set
return *( crsSet.constBegin() );
}
示例3: drivers
QScriptValue Sql::drivers(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(context)
QStringList driverNames = QSqlDatabase::drivers();
QSet<Driver> driverList;
for(int index = 0; index < driverNames.size(); ++index)
{
const QString &driverNameToInclude = driverNames.at(index);
for(int driverIndex = 0; driverIndex < DriverCount; ++driverIndex)
{
if(driverName(static_cast<Driver>(driverIndex)) == driverNameToInclude)
driverList.insert(static_cast<Driver>(driverIndex));
}
}
QScriptValue back = engine->newArray(driverList.size());
int index = 0;
for(const Driver &driver: driverList)
{
back.setProperty(index, driver);
++index;
}
return back;
}
示例4: testHash
void tst_QVersitProperty::testHash()
{
QVersitProperty property1;
property1.setGroups(QStringList() << QLatin1String("group1") << QLatin1String("group2"));
property1.setName(QLatin1String("name"));
property1.setValue(QLatin1String("value"));
property1.insertParameter(QLatin1String("param"), QLatin1String("value"));
QVersitProperty property2;
property2.setGroups(QStringList() << QLatin1String("group1") << QLatin1String("group2"));
property2.setName(QLatin1String("name"));
property2.setValue(QLatin1String("value"));
property2.insertParameter(QLatin1String("param"), QLatin1String("value"));
QVersitProperty property3; // no groups
property3.setName(QLatin1String("name"));
property3.setValue(QLatin1String("value"));
property3.insertParameter(QLatin1String("param"), QLatin1String("value"));
QVersitProperty property4; // no params
property4.setGroups(QStringList() << QLatin1String("group1") << QLatin1String("group2"));
property4.setName(QLatin1String("name"));
property4.setValue(QLatin1String("value"));
QVERIFY(qHash(property1) == qHash(property2));
QVERIFY(qHash(property1) != qHash(property3));
QVERIFY(qHash(property1) != qHash(property4));
QVERIFY(qHash(property3) != qHash(property4));
QSet<QVersitProperty> set;
set.insert(property1);
set.insert(property2);
set.insert(property3);
set.insert(property4);
QCOMPARE(set.size(), 3);
}
示例5: readShortcutsFromSettings
void VConfigManager::readShortcutsFromSettings()
{
const QString group("shortcuts");
m_shortcuts.clear();
m_shortcuts = readShortcutsFromSettings(defaultSettings, group);
// Update default settings according to user settings.
QHash<QString, QString> userShortcuts = readShortcutsFromSettings(userSettings,
group);
QSet<QString> matched;
matched.reserve(m_shortcuts.size());
for (auto it = userShortcuts.begin(); it != userShortcuts.end(); ++it) {
auto defaultIt = m_shortcuts.find(it.key());
if (defaultIt != m_shortcuts.end()) {
QString sequence = it.value().trimmed();
if (sequence != defaultIt.value()) {
if (isValidKeySequence(sequence)) {
matched.insert(it.key());
*defaultIt = sequence;
}
} else {
matched.insert(it.key());
}
}
}
if (matched.size() < m_shortcuts.size()) {
qDebug() << "override user shortcuts settings using default settings";
writeShortcutsToSettings(userSettings, group, m_shortcuts);
}
}
示例6: routeData
bool QXmppServerPrivate::routeData(const QString &to, const QByteArray &data)
{
// refuse to route packets to empty destination, own domain or sub-domains
const QString toDomain = QXmppUtils::jidToDomain(to);
if (to.isEmpty() || to == domain || toDomain.endsWith("." + domain))
return false;
if (toDomain == domain) {
// look for a client connection
QList<QXmppIncomingClient*> found;
if (QXmppUtils::jidToResource(to).isEmpty()) {
foreach (QXmppIncomingClient *conn, incomingClientsByBareJid.value(to))
found << conn;
} else {
QXmppIncomingClient *conn = incomingClientsByJid.value(to);
if (conn)
found << conn;
}
// send data
foreach (QXmppStream *conn, found)
QMetaObject::invokeMethod(conn, "sendData", Q_ARG(QByteArray, data));
return !found.isEmpty();
} else if (!serversForServers.isEmpty()) {
bool check;
Q_UNUSED(check);
// look for an outgoing S2S connection
foreach (QXmppOutgoingServer *conn, outgoingServers) {
if (conn->remoteDomain() == toDomain) {
// send or queue data
QMetaObject::invokeMethod(conn, "queueData", Q_ARG(QByteArray, data));
return true;
}
}
// if we did not find an outgoing server,
// we need to establish the S2S connection
QXmppOutgoingServer *conn = new QXmppOutgoingServer(domain, 0);
conn->setLocalStreamKey(QXmppUtils::generateStanzaHash().toLatin1());
conn->moveToThread(q->thread());
conn->setParent(q);
check = QObject::connect(conn, SIGNAL(disconnected()),
q, SLOT(_q_outgoingServerDisconnected()));
Q_UNUSED(check);
// add stream
outgoingServers.insert(conn);
q->setGauge("outgoing-server.count", outgoingServers.size());
// queue data and connect to remote server
QMetaObject::invokeMethod(conn, "queueData", Q_ARG(QByteArray, data));
QMetaObject::invokeMethod(conn, "connectToHost", Q_ARG(QString, toDomain));
return true;
} else {
示例7: onEffect
void NosJujianCard::onEffect(const CardEffectStruct &effect) const{
int n = subcardsLength();
effect.to->drawCards(n);
Room *room = effect.from->getRoom();
room->playSkillEffect("jujian");
if(n == 3){
QSet<Card::CardType> types;
foreach(int card_id, effect.card->getSubcards()){
const Card *card = Sanguosha->getCard(card_id);
types << card->getTypeId();
}
if(types.size() == 1){
LogMessage log;
log.type = "#JujianRecover";
log.from = effect.from;
const Card *card = Sanguosha->getCard(subcards.first());
log.arg = card->getType();
room->sendLog(log);
RecoverStruct recover;
recover.card = this;
recover.who = effect.from;
room->recover(effect.from, recover);
}
}
示例8: getPreferredCrs
QString QgsWFSSourceSelect::getPreferredCrs( const QSet<QString>& crsSet ) const
{
if ( crsSet.size() < 1 )
{
return "";
}
//first: project CRS
long ProjectCRSID = QgsProject::instance()->readNumEntry( "SpatialRefSys", "/ProjectCRSID", -1 );
//convert to EPSG
QgsCoordinateReferenceSystem projectRefSys = QgsCRSCache::instance()->crsBySrsId( ProjectCRSID );
QString ProjectCRS;
if ( projectRefSys.isValid() )
{
ProjectCRS = projectRefSys.authid();
}
if ( !ProjectCRS.isEmpty() && crsSet.contains( ProjectCRS ) )
{
return ProjectCRS;
}
//second: WGS84
if ( crsSet.contains( GEO_EPSG_CRS_AUTHID ) )
{
return GEO_EPSG_CRS_AUTHID;
}
//third: first entry in set
return *( crsSet.constBegin() );
}
示例9: sendCoins
WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipient> &recipients, const CCoinControl *coinControl)
{
qint64 total = 0;
QSet<QString> setAddress;
QString hex;
if(recipients.empty())
{
return OK;
}
// Pre-check input data for validity
foreach(const SendCoinsRecipient &rcp, recipients)
{
if(!validateAddress(rcp.address))
{
return InvalidAddress;
}
setAddress.insert(rcp.address);
if(rcp.amount <= 0)
{
return InvalidAmount;
}
total += rcp.amount;
}
if(recipients.size() > setAddress.size())
{
return DuplicateAddress;
}
int64 nBalance = getBalance(coinControl);
if(total > nBalance)
{
return AmountExceedsBalance;
}
if((total + nTransactionFee) > nBalance)
{
return SendCoinsReturn(AmountWithFeeExceedsBalance, nTransactionFee);
}
// Sendmany
std::vector<std::pair<CScript, int64> > vecSend;
foreach(const SendCoinsRecipient &rcp, recipients)
{
CBitcoinAddress myAddress = CBitcoinAddress(rcp.address.toStdString());
LOCK2(cs_main, wallet->cs_wallet);
{
CScript scriptPubKey;
scriptPubKey.SetDestination(myAddress.Get());
vecSend.push_back(make_pair(scriptPubKey, rcp.amount));
}
}
示例10: slotTracksRemoved
void BaseTrackCache::slotTracksRemoved(QSet<TrackId> trackIds) {
if (sDebug) {
qDebug() << this << "slotTracksRemoved" << trackIds.size();
}
for (const auto& trackId : trackIds) {
m_trackInfo.remove(trackId);
}
}
示例11: populateProject
void NimProject::populateProject()
{
m_lastProjectScan.start();
QSet<QString> oldFiles(m_files);
m_files.clear();
recursiveScanDirectory(m_projectDir, m_files);
QSet<QString> removedFiles = oldFiles - m_files;
QSet<QString> addedFiles = m_files - oldFiles;
removeNodes(removedFiles);
addNodes(addedFiles);
if (removedFiles.size() || addedFiles.size())
emit fileListChanged();
}
示例12: subgraphSize
int ctkDependencyGraphPrivate::subgraphSize(int rootId)
{
Q_ASSERT(rootId > 0);
QSet<int> vertices;
vertices << rootId;
this->subgraphSizeRec(rootId, vertices);
return vertices.size();
}
示例13: validate
virtual bool validate(const Configuration* cfg, ProblemList &problemList) const {
QString annotations = cfg->getParameter(ANN_ATTR)->getAttributeValueWithoutScript<QString>();
QSet<QString> names = QSet<QString>::fromList(annotations.split(QRegExp("\\W+"), QString::SkipEmptyParts));
if (names.size() < 2) {
problemList.append(Problem(CollocationWorker::tr("At least 2 annotations are required for collocation search.")));
return false;
}
return true;
}
示例14: foreach
foreach (const QByteArray &extensionCppName, extensionCppNames) {
if (c != extensionCppNames.size() - 1) {
QByteArray adjustedName = QString("__extension__%1.%2").arg(QString::number(c), QString(extendedId)).toAscii();
cppToId.insert(extensionCppName, adjustedName);
} else {
cppToId.insert(extensionCppName, extendedId);
}
++c;
}
示例15: sendMessages
MessageModel::StatusCode MessageModel::sendMessages(const QList<SendMessagesRecipient> &recipients, const QString &addressFrom)
{
QSet<QString> setAddress;
if(recipients.empty())
return OK;
// Pre-check input data for validity
foreach(const SendMessagesRecipient &rcp, recipients)
{
if(!walletModel->validateAddress(rcp.address))
return InvalidAddress;
if(rcp.message == "")
return MessageCreationFailed;
std::string sendTo = rcp.address.toStdString();
std::string pubkey = rcp.pubkey.toStdString();
std::string message = rcp.message.toStdString();
std::string addFrom = addressFrom.toStdString();
SecureMsgAddAddress(sendTo, pubkey);
setAddress.insert(rcp.address);
std::string sError;
if (SecureMsgSend(addFrom, sendTo, message, sError) != 0)
{
QMessageBox::warning(NULL, tr("Send Secure Message"),
tr("Send failed: %1.").arg(sError.c_str()),
QMessageBox::Ok, QMessageBox::Ok);
return FailedErrorShown;
};
// Add addresses / update labels that we've sent to to the address book
std::string strAddress = rcp.address.toStdString();
CTxDestination dest = CBitcoinAddress(strAddress).Get();
std::string strLabel = rcp.label.toStdString();
{
LOCK(wallet->cs_wallet);
std::map<CTxDestination, std::string>::iterator mi = wallet->mapAddressBook.find(dest);
// Check if we have a new address or an updated label
if (mi == wallet->mapAddressBook.end() || mi->second != strLabel)
{
wallet->SetAddressBookName(dest, strLabel);
}
}
}
if(recipients.size() > setAddress.size())
return DuplicateAddress;
return OK;
}