当前位置: 首页>>代码示例>>C++>>正文


C++ QMap::count方法代码示例

本文整理汇总了C++中QMap::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::count方法的具体用法?C++ QMap::count怎么用?C++ QMap::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMap的用法示例。


在下文中一共展示了QMap::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: mapiTagString

QString mapiTagString( int key )
{
  if ( MAPI_TagMap.count() == 0 ) {
    for ( int i=0; MAPI_TagStrings[ i ].str; i++ ) {
      MAPI_TagMap[ MAPI_TagStrings[ i ].tag ] =
        i18n( MAPI_TagStrings[ i ].str );
    }
  }
  QMap<int,QString>::ConstIterator it = MAPI_TagMap.constFind( key );
  if ( it == MAPI_TagMap.constEnd() ) {
    return QString().sprintf( "0x%04X", key );
  } else {
    return QString().sprintf( "0x%04X ________: ", key ) + *it;
  }
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:15,代码来源:mapi.cpp

示例2: open

void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
{
    QHelpIndexModel *model = qobject_cast<QHelpIndexModel*>(indexWidget->model());
    if (model) {
        QString keyword = model->data(index, Qt::DisplayRole).toString();
        QMap<QString, QUrl> links = model->linksForKeyword(keyword);

        QUrl url;
        if (links.count() > 1) {
            TopicChooser tc(this, keyword, links);
            if (tc.exec() == QDialog::Accepted)
                url = tc.link();
        } else if (links.count() == 1) {
            url = links.constBegin().value();
        } else {
            return;
        }

        if (!HelpViewer::canOpenPage(url.path()))
            CentralWidget::instance()->setSource(url);
        else
            OpenPagesManager::instance().createPage(url);
    }
}
开发者ID:CNOT,项目名称:julia-studio,代码行数:24,代码来源:indexwindow.cpp

示例3: populateCountryAndScript

void GroupchatTopicDlg::populateCountryAndScript()
{
    QLocale::Language lang = static_cast<QLocale::Language>(m_addLangUi->cmbLang->currentData().toInt());
    QMap<QString,QLocale::Script> scripts;
    QMap<QString,QLocale::Country> countries;
    m_addLangUi->cmbCountry->clear();
    m_addLangUi->cmbScript->clear();
    m_addLangUi->cmbCountry->addItem(tr("Any Country"), 0);
    m_addLangUi->cmbScript->addItem(tr("Any Script"), 0);
    if (lang) {
        for (auto const &loc : QLocale::matchingLocales(lang, QLocale::AnyScript, QLocale::AnyCountry)) {
            if (loc != QLocale::c()) {
                scripts.insert(QLocale::scriptToString(loc.script()), loc.script());
                countries.insert(QLocale::countryToString(loc.country()), loc.country());
            }
        }
        m_addLangUi->cmbScript->setVisible(scripts.count() > 1);
        m_addLangUi->lblScript->setVisible(scripts.count() > 1);
        if (scripts.count() > 1) {
            for (auto it = scripts.constBegin(); it != scripts.constEnd(); ++it) {
                m_addLangUi->cmbScript->addItem(it.key(), it.value());
            }
        }
        m_addLangUi->cmbCountry->setVisible(countries.count() > 1);
        m_addLangUi->lblCountry->setVisible(countries.count() > 1);
        if (countries.count() > 1) {
            for (auto it = countries.constBegin(); it != countries.constEnd(); ++it) {
                LanguageManager::LangId id;
                id.language = lang;
                id.country = it.value();
                QString country = LanguageManager::countryName(id);
                m_addLangUi->cmbCountry->addItem(country, it.value());
            }
        }
    }
}
开发者ID:psi-im,项目名称:psi,代码行数:36,代码来源:groupchattopicdlg.cpp

示例4: AssembleTreeWidget

void FlyLinks::AssembleTreeWidget(
        const QMap<QString,QString>& objDataMap) {
    m_pObjPopup->setWindowFlags(Qt::Popup);
    m_pObjPopup->setFocusPolicy(Qt::NoFocus);
    m_pObjPopup->setMouseTracking(true);
    m_pObjPopup->viewport()->setMouseTracking(true);
    m_pObjPopup->viewport()->installEventFilter(this);

    m_pObjPopup->setColumnCount(1);
    m_pObjPopup->setUniformRowHeights(true);
    m_pObjPopup->setRootIsDecorated(false);
    m_pObjPopup->setEditTriggers(QTreeWidget::NoEditTriggers);
    m_pObjPopup->setSelectionBehavior(QTreeWidget::SelectRows);
    m_pObjPopup->setFrameStyle(QFrame::Box | QFrame::Plain);
    m_pObjPopup->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_pObjPopup->header()->hide();
    m_pObjPopup->viewport()->
            setProperty("cursor",
                        QVariant(QCursor(Qt::PointingHandCursor)));

    m_pObjPopup->installEventFilter(this);
    PopulateTreeWidgetItems(objDataMap);
    //popup->setCurrentItem(popup->topLevelItem(0));
    m_pObjPopup->resizeColumnToContents(0);
    m_pObjPopup->adjustSize();
    m_pObjPopup->setUpdatesEnabled(true);

    int h = m_pObjPopup->sizeHintForRow(0) * (objDataMap.count()+1);
    //popup->resize(popup->width(), h);
    //popup->setMinimumHeight(h);
    m_pObjPopup->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_pObjPopup->setMaximumHeight(h);
    QList<QString> objKeyList = objDataMap.keys();
    QListIterator<QString> objKeyIter(objKeyList);
    int iLenMax = 0,iLenCurrent = 0;
    while(objKeyIter.hasNext()) {
        iLenCurrent = objKeyIter.next().length();
        if(iLenCurrent > iLenMax) {
            iLenMax = iLenCurrent;
        }
    }
    QFontMetrics objMetrics(m_pObjPopup->font());
    m_pObjPopup->setMaximumWidth(objMetrics.maxWidth() * iLenMax); //adjust if necessary
    m_pObjPopup->resizeColumnToContents(0);
    m_pObjPopup->adjustSize();
    m_pObjPopup->setUpdatesEnabled(true);

}
开发者ID:PSaraph,项目名称:FlyLabel,代码行数:48,代码来源:FlyLinks.cpp

示例5: mousePressEvent

void TransferFunctionEditor::mousePressEvent(QMouseEvent* e)
{
	bool handled = false;

	lastMouseClick = e->pos();

	if ((e->button() == Qt::LeftButton) && (e->modifiers() == Qt::NoButton))
	{
		// Create context menu
		QMenu contextMenu(this);
		contextMenu.addAction(addPointAct);
		contextMenu.addSeparator();
		QMap<QAction*, int> pointMap;

		for (int i = 0; i < controlPoints.size(); ++i)
		{
			Vector3 vec = controlPoints[i].point;
			QString text("Point: ");
			text += QString::number(vec.x);
			text += " ";
			text += QString::number(vec.y);
			QAction* action = contextMenu.addAction(text);
			action->setCheckable(true);
			if (i == selectedPoint)
			{
				action->setChecked(true);
			}
			pointMap[action] = i;
		}

		QAction* action = contextMenu.exec(e->globalPos());
		if (pointMap.count(action) != 0)
		{
			selectedPoint = pointMap[action];
		}
		handled = true;
	}
	else if (e->button() == Qt::RightButton)
	{
		actionsMenu->exec(e->globalPos());
		handled = true;
	}

	if (!handled)
	{
		QGLViewer::mousePressEvent(e);
	}
}
开发者ID:juanmarcus,项目名称:Visualization,代码行数:48,代码来源:TransferFunctionEditor.cpp

示例6: addAllChild

/**
 * @brief RsCollectionDialog::addAllChild: Add children to RsCollection
 * @param fileInfoParent: Parent's QFileInfo to scan
 * @param dirToAdd: QMap where directories are added
 * @param fileToHash: QStringList where files are added
 * @return false if too many items is selected and aborted
 */
bool RsCollectionDialog::addAllChild(QFileInfo &fileInfoParent
                                     , QMap<QString, QString > &dirToAdd
                                     , QStringList &fileToHash
                                     , int &count)
{
	//Save count only first time to not scan all items on list .count()
	if (count == 0) count = (dirToAdd.count() + fileToHash.count());
	QDir dirParent = fileInfoParent.absoluteFilePath();
	dirParent.setFilter(QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot);
	QFileInfoList childrenList = dirParent.entryInfoList();
	foreach (QFileInfo fileInfo, childrenList)
	{
		if (count == MAX_FILE_ADDED_BEFORE_ASK)
		{
			QMessageBox msgBox;
			msgBox.setText(tr("Warning, selection contains more than %1 items.").arg(MAX_FILE_ADDED_BEFORE_ASK));
			msgBox.setInformativeText("Do you want to continue?");
			msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
			msgBox.setDefaultButton(QMessageBox::No);
			int ret = msgBox.exec();
			switch (ret) {
				case QMessageBox::Yes:
				break;
				case QMessageBox::No:
					return false;
				break;
				break;
				default:
					// should never be reached
				break;
			}//switch (ret)
		}
		if (fileInfo.isDir()) {
			dirToAdd.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath());
			++count;
			if (!addAllChild(fileInfo, dirToAdd, fileToHash, count)) return false;
		}//if (fileInfo.isDir())
		if (fileInfo.isFile()){
			fileToHash.append(fileInfo.absoluteFilePath());
			++count;
			if (dirToAdd.contains(fileInfo.absolutePath()))
				_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),fileInfo.absolutePath());
			else
				_listOfFilesAddedInDir.insert(fileInfo.absoluteFilePath(),"");
		}//if (fileInfo.isFile())
	}//foreach (QFileInfo fileInfo, dirParent.entryInfoList())
	return true;
}
开发者ID:andy737,项目名称:RetroShare,代码行数:55,代码来源:RsCollectionDialog.cpp

示例7: showHelp

void OptionsSimple::showHelp()
{
    QList<CodecProblems::Problem> problemList;
    QMap<QString,QStringList> problems = config->pluginLoader()->encodeProblems();
    for( int i=0; i<problems.count(); i++ )
    {
        CodecProblems::Problem problem;
        problem.codecName = problems.keys().at(i);
        if( problem.codecName != "wav" )
        {
            problem.solutions = problems.value(problem.codecName);
            problemList += problem;
        }
    }
    CodecProblems *problemsDialog = new CodecProblems( CodecProblems::Debug, problemList, this );
    problemsDialog->exec();
}
开发者ID:EQ4,项目名称:soundkonverter,代码行数:17,代码来源:optionssimple.cpp

示例8: UpdateAdvancedDistanceTable

void AdvancedDistance::UpdateAdvancedDistanceTable()
{
    table_->horizontalHeader()->setClickable(false);
    table_->setSelectionMode(QAbstractItemView::SingleSelection);
    table_->verticalHeader()->setHidden(true);
    table_->horizontalHeader()->setStretchLastSection(true);
    table_->setColumnCount(2);

    SpinBoxDelegate *delegate = new SpinBoxDelegate;
    table_->setItemDelegateForColumn(1, delegate);

    QStringList headers;
    headers << STRING_ADVANCED_DISTANCE_DATE << STRING_ADVANCED_DISTANCE_MINEING_DAILY_ADVANCE_DISTANCE + "(m)";
    table_->setHorizontalHeaderLabels(headers);

    QMap<QDate, float> map;

    if (handler_->GetDayAdvanceDistance(map))
    {
        table_->setRowCount(map.count());

        int cnt = 0;
        QMapIterator<QDate, float> i(map);
        while(i.hasNext())
        {
            i.next();
            QDate date = i.key();
            float distance = i.value();

            QTableWidgetItem* dateitem = new QTableWidgetItem;
            QString datestr = QString().sprintf("%d", date.month()) + STRING_ADVANCED_MONTH +
                    QString().sprintf("%2d", date.day()) + STRING_ADVANCED_DAY;
            dateitem->setText(datestr);
            dateitem->setTextAlignment(Qt::AlignCenter);
            dateitem->setFlags(Qt::NoItemFlags);

            QTableWidgetItem* distanceitem = new QTableWidgetItem;
            distanceitem->setTextAlignment(Qt::AlignCenter);
            distanceitem->setData(0, QVariant::fromValue(distance));

            table_->setItem(cnt, 0, dateitem);
            table_->setItem(cnt, 1, distanceitem);
            cnt++;
        }
    }
}
开发者ID:liye0005,项目名称:QT_POJ,代码行数:46,代码来源:advanceddistance.cpp

示例9: createGraphTable

void LoadGraphWindow::createGraphTable()
{
	Manager::GraphManager* manager = Manager::GraphManager::getInstance();
	Model::DB* db = manager->getDB();
	bool error = false;
	qlonglong id;
	int graphsCount,row;
	QList<qlonglong> nodes;
	QList<qlonglong> edges;
	QList<qlonglong> layouts;
	QString name;
	QMap<qlonglong, Data::Graph*>::iterator iterGraph;

	QMap<qlonglong, Data::Graph*> graphs = Model::GraphDAO::getGraphs( db->tmpGetConn(), &error );
	graphsCount = graphs.count();

	numberOfGraphs->setText( tr( "%1 graph(s) found" ).arg( graphsCount ) );
	graphsTable->setRowCount( graphsCount );
	nodes = Model::NodeDAO::getListOfNodes( db->tmpGetConn(), &error );
	edges = Model::EdgeDAO::getListOfEdges( db->tmpGetConn(), &error );
	layouts = Model::GraphLayoutDAO::getListOfLayouts( db->tmpGetConn(), &error );

	qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of nodes in DB: " << nodes.count();
	qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of edges in DB: " << edges.count();
	qDebug() << "[QOSG::LoadGraphWindow::createGraphTable] total number of layouts in DB: " << layouts.count();

	for ( iterGraph = graphs.begin(), row=0; iterGraph != graphs.end(); ++iterGraph, row++ ) {
		id = iterGraph.key();

		name = graphs.value( id )->getName();

		QTableWidgetItem* itemID = new QTableWidgetItem( tr( "%1" ).arg( id ) );
		QTableWidgetItem* itemName = new QTableWidgetItem( name );
		QTableWidgetItem* itemNumberOfLayouts = new QTableWidgetItem( tr( "%1" ).arg( layouts.count( id ) ) );
		QTableWidgetItem* itemNumberOfNodes = new QTableWidgetItem( tr( "%1" ).arg( nodes.count( id ) ) );
		QTableWidgetItem* itemNumberOfEdges = new QTableWidgetItem( tr( "%1" ).arg( edges.count( id ) ) );
		graphsTable->setItem( row, 0, itemID );
		graphsTable->setItem( row, 1, itemName );
		graphsTable->setItem( row, 2, itemNumberOfLayouts );
		graphsTable->setItem( row, 3, itemNumberOfNodes );
		graphsTable->setItem( row, 4, itemNumberOfEdges );
	}
	if ( graphsTable->rowCount() > 0 ) {
		graphsTable->selectRow( 0 );
	}
}
开发者ID:vexta,项目名称:3dsoftviz,代码行数:46,代码来源:LoadGraphWindow.cpp

示例10: showHelp

void DirOpener::showHelp()
{
    QList<CodecProblems::Problem> problemList;

    QMap<QString,QStringList> problems = ( mode == Convert ) ? config->pluginLoader()->decodeProblems() : config->pluginLoader()->replaygainProblems();
    for( int i=0; i<problems.count(); i++ )
    {
        CodecProblems::Problem problem;
        problem.codecName = problems.keys().at(i);
        if( problem.codecName != "wav" )
        {
            problem.solutions = problems.value(problem.codecName);
            problemList += problem;
        }
    }
    CodecProblems *problemsDialog = new CodecProblems( CodecProblems::Debug, problemList, this );
    problemsDialog->exec();
}
开发者ID:isoft-linux,项目名称:soundkonverter,代码行数:18,代码来源:diropener.cpp

示例11: loadInvalidLines

void TagDatabaseInMemoryTest::loadInvalidLines()
{
	QTemporaryFile file;
	QVERIFY(file.open());
	file.write("tag1,1\ntag3\n");
	file.seek(0);

	TagDatabaseInMemory database("tests/resources/tag-types.txt", file.fileName());
	QVERIFY(database.load());

	QMap<QString, TagType> types = database.getTagTypes(QStringList() << "tag1" << "tag3");

	QCOMPARE(types.count(), 1);
	QCOMPARE(types.contains("tag1"), true);
	QCOMPARE(types.contains("tag3"), false);
	QCOMPARE(types.value("tag1").name(), QString("artist"));
	QCOMPARE(database.count(), 1);
}
开发者ID:Flat,项目名称:imgbrd-grabber,代码行数:18,代码来源:tag-database-in-memory-test.cpp

示例12: loadValidData

void TagDatabaseInMemoryTest::loadValidData()
{
	QTemporaryFile file;
	QVERIFY(file.open());
	file.write("tag1,0\ntag2,1\ntag3,3\ntag4,4");
	file.seek(0);

	TagDatabaseInMemory database("tests/resources/tag-types.txt", file.fileName());
	QVERIFY(database.load());

	QMap<QString, TagType> types = database.getTagTypes(QStringList() << "tag1" << "tag3");

	QCOMPARE(types.count(), 2);
	QCOMPARE(types.contains("tag1"), true);
	QCOMPARE(types.contains("tag3"), true);
	QCOMPARE(types.value("tag1").name(), QString("general"));
	QCOMPARE(types.value("tag3").name(), QString("copyright"));
	QCOMPARE(database.count(), 4);
}
开发者ID:Flat,项目名称:imgbrd-grabber,代码行数:19,代码来源:tag-database-in-memory-test.cpp

示例13: processItem

/** Process each item to make a new RsCollection item */
void RsCollectionDialog::processItem(QMap<QString, QString> &dirToAdd
                                     , int &index
                                     , ColFileInfo &parent
                                     )
{
	ColFileInfo newChild;
	int count = dirToAdd.count();
	if (index < count) {
		QString key=dirToAdd.keys().at(index);
		bool bad_chars_detected = false;
		QFileInfo fileInfo=key;
		QString cleanDirName = purifyFileName(fileInfo.fileName(),bad_chars_detected);
		newChild.name = cleanDirName;
		newChild.filename_has_wrong_characters = bad_chars_detected;
		newChild.size = fileInfo.isDir()? 0: fileInfo.size();
		newChild.type = fileInfo.isDir()? DIR_TYPE_DIR: DIR_TYPE_FILE ;
		if (parent.name != "") {
			newChild.path = parent.path + "/" + parent.name;
		} else {
			newChild.path = parent.path;
		}
		dirToAdd[key] = newChild.path + "/" + newChild.name;
		//Move to next item
		++index;
		if (index < count){
			QString newKey = dirToAdd.keys().at(index);
			while ((dirToAdd.value(newKey) == key)
			       && (index < count)) {
				processItem(dirToAdd, index, newChild);
				if (index < count)newKey = dirToAdd.keys().at(index);
			}
		}

		//Save parent when child are processed
		if (parent.name != "") {
			parent.children.push_back(newChild);
			parent.size += newChild.size;
		} else {
			_newColFileInfos.push_back(newChild);
		}
	}//(index < count)
}
开发者ID:andy737,项目名称:RetroShare,代码行数:43,代码来源:RsCollectionDialog.cpp

示例14: setItems

void BindEnum::setItems(const QMap<int, QString>& i)
{
	Q_ASSERT(i.count() >= 1);

	mItems = i;

	mEditor->clear();

	QMapIterator<int, QString> it(i);
	while( it.hasNext() )
	{
		it.next();

		Q_ASSERT( !it.value().isEmpty() );

		mEditor->addItem( it.value(), it.key() );
	}

	clear();
}
开发者ID:erikku,项目名称:frosty,代码行数:20,代码来源:BindEnum.cpp

示例15: setKnownLogins

void KPasswordDialog::setKnownLogins(const QMap<QString, QString> &knownLogins)
{
    const int nr = knownLogins.count();
    if (nr == 0) {
        return;
    }

    if (nr == 1) {
        d->ui.userEdit->setText(knownLogins.begin().key());
        setPassword(knownLogins.begin().value());
        return;
    }

    Q_ASSERT(!d->ui.userEdit->isReadOnly());
    if (!d->userEditCombo) {
        int row = -1;
        QFormLayout::ItemRole userEditRole = QFormLayout::FieldRole;

        d->ui.formLayout->getWidgetPosition(d->ui.userEdit, &row, &userEditRole);
        d->ui.formLayout->removeWidget(d->ui.userEdit);
        delete d->ui.userEdit;
        d->userEditCombo = new QComboBox(d->ui.credentialsGroup);
        d->userEditCombo->setEditable(true);
        d->ui.userEdit = d->userEditCombo->lineEdit();
        d->ui.userNameLabel->setBuddy(d->userEditCombo);
        d->ui.formLayout->setWidget(row > -1 ? row : 0, userEditRole, d->userEditCombo);

        setTabOrder(d->ui.userEdit, d->ui.anonymousRadioButton);
        setTabOrder(d->ui.anonymousRadioButton, d->ui.domainEdit);
        setTabOrder(d->ui.domainEdit, d->ui.passEdit);
        setTabOrder(d->ui.passEdit, d->ui.keepCheckBox);
        connect(d->ui.userEdit, SIGNAL(returnPressed()), d->ui.passEdit, SLOT(setFocus()));
    }

    d->knownLogins = knownLogins;
    d->userEditCombo->addItems(knownLogins.keys());
    d->userEditCombo->setFocus();

    connect(d->userEditCombo, SIGNAL(activated(QString)),
            this, SLOT(activated(QString)));
}
开发者ID:KDE,项目名称:kwidgetsaddons,代码行数:41,代码来源:kpassworddialog.cpp


注:本文中的QMap::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。