本文整理汇总了C++中QSet::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ QSet::contains方法的具体用法?C++ QSet::contains怎么用?C++ QSet::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSet
的用法示例。
在下文中一共展示了QSet::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextFree
int State::nextFree(const QSet<int>& lst, int id) const
{
while (lst.contains(id)) ++id;
return id;
}
示例2: featureTypeList
void QgsWFSProjectParser::featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const
{
const QList<QDomElement>& projectLayerElements = mProjectParser->projectLayerElements();
if ( projectLayerElements.size() < 1 )
{
return;
}
QStringList wfsLayersId = mProjectParser->wfsLayers();
QSet<QString> wfstUpdateLayersId = wfstUpdateLayers();
QSet<QString> wfstInsertLayersId = wfstInsertLayers();
QSet<QString> wfstDeleteLayersId = wfstDeleteLayers();
QMap<QString, QgsMapLayer *> layerMap;
Q_FOREACH ( const QDomElement &elem, projectLayerElements )
{
QString type = elem.attribute( "type" );
if ( type == "vector" )
{
QString layerId = mProjectParser->layerId( elem );
if ( !wfsLayersId.contains( layerId ) )
{
continue;
}
QgsMapLayer *layer = mProjectParser->createLayerFromElement( elem );
if ( !layer )
{
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( !mAccessControl->layerReadPermission( layer ) )
{
continue;
}
#endif
QgsDebugMsg( QString( "add layer %1 to map" ).arg( layer->id() ) );
layerMap.insert( layer->id(), layer );
QDomElement layerElem = doc.createElement( "FeatureType" );
QDomElement nameElem = doc.createElement( "Name" );
//We use the layer name even though it might not be unique.
//Because the id sometimes contains user/pw information and the name is more descriptive
QString typeName = layer->name();
typeName = typeName.replace( " ", "_" );
QDomText nameText = doc.createTextNode( typeName );
nameElem.appendChild( nameText );
layerElem.appendChild( nameElem );
QDomElement titleElem = doc.createElement( "Title" );
QString titleName = layer->title();
if ( titleName.isEmpty() )
{
titleName = layer->name();
}
QDomText titleText = doc.createTextNode( titleName );
titleElem.appendChild( titleText );
layerElem.appendChild( titleElem );
QDomElement abstractElem = doc.createElement( "Abstract" );
QString abstractName = layer->abstract();
if ( abstractName.isEmpty() )
{
abstractName = "";
}
QDomText abstractText = doc.createTextNode( abstractName );
abstractElem.appendChild( abstractText );
layerElem.appendChild( abstractElem );
//keyword list
if ( !layer->keywordList().isEmpty() )
{
QDomElement keywordsElem = doc.createElement( "Keywords" );
QDomText keywordsText = doc.createTextNode( layer->keywordList() );
keywordsElem.appendChild( keywordsText );
layerElem.appendChild( keywordsElem );
}
//appendExGeographicBoundingBox( layerElem, doc, layer->extent(), layer->crs() );
QDomElement srsElem = doc.createElement( "SRS" );
QDomText srsText = doc.createTextNode( layer->crs().authid() );
srsElem.appendChild( srsText );
layerElem.appendChild( srsElem );
//wfs:Operations element
QDomElement operationsElement = doc.createElement( "Operations"/*wfs:Operations*/ );
//wfs:Query element
QDomElement queryElement = doc.createElement( "Query"/*wfs:Query*/ );
operationsElement.appendChild( queryElement );
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( layer );
QgsVectorDataProvider* provider = vlayer->dataProvider();
if (( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) && wfstInsertLayersId.contains( layer->id() ) )
{
//wfs:Insert element
QDomElement insertElement = doc.createElement( "Insert"/*wfs:Insert*/ );
operationsElement.appendChild( insertElement );
}
if (( provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) &&
//.........这里部分代码省略.........
示例3: match
void PowerDevilRunner::match(Plasma::RunnerContext &context)
{
const QString term = context.query();
if (term.length() < m_shortestCommand) {
return;
}
QList<Plasma::QueryMatch> matches;
QString parameter;
if (parseQuery(term,
QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "power profile %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "power profile"), Qt::CaseInsensitive),
parameter)) {
for (StringStringMap::const_iterator i = m_availableProfiles.constBegin(); i != m_availableProfiles.constEnd(); ++i) {
if (!parameter.isEmpty()) {
if (!i.value().startsWith(parameter, Qt::CaseInsensitive)) {
continue;
}
}
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIcon(KIcon(m_profileIcon[i.key()]));
match.setText(i18n("Set Profile to '%1'", i.value()));
match.setData(i.key());
match.setRelevance(1);
match.setId("ProfileChange "+ i.key());
matches.append(match);
}
} else if (parseQuery(term,
QList<QRegExp>() << QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "screen brightness %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "screen brightness"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword; %1 is a parameter", "dim screen %1", "(.*)"), Qt::CaseInsensitive)
<< QRegExp(i18nc("Note this is a KRunner keyword", "dim screen"), Qt::CaseInsensitive),
parameter)) {
if (!parameter.isEmpty()) {
bool test;
int b = parameter.toInt(&test);
if (test) {
int brightness = qBound(0, b, 100);
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::ExactMatch);
match.setIcon(KIcon("preferences-system-power-management"));
match.setText(i18n("Set Brightness to %1", brightness));
match.setData(brightness);
match.setRelevance(1);
match.setId("BrightnessChange");
matches.append(match);
}
} else {
Plasma::QueryMatch match1(this);
match1.setType(Plasma::QueryMatch::ExactMatch);
match1.setIcon(KIcon("preferences-system-power-management"));
match1.setText(i18n("Dim screen totally"));
match1.setRelevance(1);
match1.setId("DimTotal");
matches.append(match1);
Plasma::QueryMatch match2(this);
match2.setType(Plasma::QueryMatch::ExactMatch);
match2.setIcon(KIcon("preferences-system-power-management"));
match2.setText(i18n("Dim screen by half"));
match2.setRelevance(1);
match2.setId("DimHalf");
matches.append(match2);
Plasma::QueryMatch match3(this);
match3.setType(Plasma::QueryMatch::ExactMatch);
match3.setIcon(KIcon("video-display"));
match3.setText(i18n("Turn off screen"));
match3.setRelevance(1);
match3.setId("TurnOffScreen");
matches.append(match3);
}
} else if (term.compare(i18nc("Note this is a KRunner keyword", "suspend"), Qt::CaseInsensitive) == 0) {
QSet< Solid::PowerManagement::SleepState > states = Solid::PowerManagement::supportedSleepStates();
if (states.contains(Solid::PowerManagement::SuspendState)) {
addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
}
if (states.contains(Solid::PowerManagement::HibernateState)) {
addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
}
} else if (term.compare(i18nc("Note this is a KRunner keyword", "sleep"), Qt::CaseInsensitive) == 0 ||
term.compare(i18nc("Note this is a KRunner keyword", "to ram"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::SuspendState, matches);
} else if (term.compare(i18nc("Note this is a KRunner keyword", "hibernate"), Qt::CaseInsensitive) == 0 ||
term.compare(i18nc("Note this is a KRunner keyword", "to disk"), Qt::CaseInsensitive) == 0) {
addSuspendMatch(Solid::PowerManagement::HibernateState, matches);
}
if (!matches.isEmpty()) {
context.addMatches(term, matches);
}
}
示例4: editDetailGroup
bool SectionEditor::editDetailGroup(ReportSectionDetailGroup * rsdg)
{
DetailGroupSectionDialog * dgsd = new DetailGroupSectionDialog(this);
// add the current column and all columns not yet used for groups
const QStringList keys = m_reportDesigner->fieldKeys();
const QStringList columnNames = m_reportDesigner->fieldNames();
// in case of to-be-added group that column needs to be added to the used
const QSet<QString> usedColumns = groupingColumns() << rsdg->column();
// if the current column is not among the keys, something is broken.
// for now just simply select no column in the combobox, achieved by -1
int indexOfCurrentColumn = -1;
for (int i = 0; i < keys.count(); ++i) {
const QString &key = keys.at(i);
// skip any editor helper fields
if (isEditorHelperField(key)) {
continue;
}
// already used?
if (usedColumns.contains(key)) {
// and not the one of the group?
if (key != rsdg->column()) {
continue;
}
// remember index
indexOfCurrentColumn = dgsd->cbColumn->count();
}
dgsd->cbColumn->insertItem( i, columnNames.value(i), key);
}
dgsd->cbColumn->setCurrentIndex(indexOfCurrentColumn);
dgsd->cbSort->addItem(i18n("Ascending"), Qt::AscendingOrder);
dgsd->cbSort->addItem(i18n("Descending"), Qt::DescendingOrder);
dgsd->cbSort->setCurrentIndex(dgsd->cbSort->findData(rsdg->sort()));
dgsd->breakAfterFooter->setChecked(rsdg->pageBreak() == ReportSectionDetailGroup::BreakAfterGroupFooter);
dgsd->cbHead->setChecked(rsdg->groupHeaderVisible());
dgsd->cbFoot->setChecked(rsdg->groupFooterVisible());
const bool isOkayed = (dgsd->exec() == QDialog::Accepted);
if (isOkayed) {
const QString newColumn =
dgsd->cbColumn->itemData(dgsd->cbColumn->currentIndex()).toString();
const QString oldColumn = rsdg->column();
if (newColumn != oldColumn) {
rsdg->setColumn(newColumn);
}
rsdg->setGroupHeaderVisible(dgsd->cbHead->isChecked());
rsdg->setGroupFooterVisible(dgsd->cbFoot->isChecked());
const ReportSectionDetailGroup::PageBreak pageBreak = dgsd->breakAfterFooter->isChecked() ?
ReportSectionDetailGroup::BreakAfterGroupFooter : ReportSectionDetailGroup::BreakNone;
rsdg->setPageBreak(pageBreak);
const Qt::SortOrder sortOrder =
static_cast<Qt::SortOrder>(dgsd->cbSort->itemData(dgsd->cbSort->currentIndex()).toInt());
rsdg->setSort(sortOrder);
}
delete dgsd;
return isOkayed;
}
示例5: readTree
/*!
* Считать и построить дерево
* \param[in] xmlStream - покок чтения на вводный XML-файл
* \param[in] treeNum - номер дерева, которое считываются
* \param[out] root - указатель на корень входного дерева
*/
void readTree(QXmlStreamReader& xmlStream, node*& root, int treeNum){
QXmlStreamAttributes attr;
root = NULL;
QSet<int> setOfData;
// Размер дерева
int treeSize = 0;
// 1. Проверить верный ли идентификатор дерева. Если нет, то выбросить исключение (ошибка WRONG_TREE_ID)
xmlStream.readNext();
attr = xmlStream.attributes();
QString treeID = attr.value("id").toString();
if (treeNum == 1 && treeID != "1" || treeNum == 2 && treeID != "2")
throw error(WRONG_TREE_ID, treeNum == 1 ? 1 : 2, treeID);
xmlStream.readNext();
// 2. Создать указатель current - указатель на текущую вершину
node *current = NULL;
// 3. Считать каждую вершину дерева с помощью функции readNode
for (int cnt = 0;;){
node* newNode = NULL;
int newDepth;
try{
newDepth = readNode(xmlStream, treeNum, newNode);
} catch (const error& e){
// 3.1. Если возникла ошибка, то выбросить исключение
throw;
}
// 3.2. Если новая вершина создана
if (newDepth == 1){
// 3.1.1. Увеличить размер дерева
treeSize++;
// 3.1.2. Если цифра новой вершины уже существует, то выбросить исключение (ошибка COINCIDED_NUMBERS)
if (setOfData.contains(newNode->data))
throw error(COINCIDED_NUMBERS, treeNum == 1 ? 1 : 2, QString::number(newNode->data));
// 3.1.3. Добавить новую вершину в дерево, его родитель будет вершина current
setOfData.insert(newNode->data);
if (root == NULL)
root = newNode;
else
current->addChild(newNode);
// 3.1.4. Установить указатель current на новую вершину
current = newNode;
cnt++;
} else
// 3.3. Иначе вернуть указатель current на его родителя
if (newDepth == -1){
if (current == NULL){
xmlStream.readNext();
return;
}
current = current->parent;
cnt--;
}
// Если глубина текущей вершины равен 0, это показывает, что текущее дерево было прочитать
// затем закончить читать текущее дерево
if (cnt == 0){
xmlStream.readNext();
break;
}
}
// 4. Проверить количество вершин дерева. Если превышает максимальный размер, то выбросить исключение (ошибка OVER_SIZE)
if (treeSize > MAX_TREE_SIZE)
throw error(OVER_SIZE, treeNum == 1 ? 1 : 2, QString::number(treeSize));
xmlStream.readNext();
xmlStream.readNext();
}
示例6: main
int main (){
QMap<int,QString> pos[25][25];
char map[25][25];
int testcases;
scanf("%i\n", &testcases);
for (int TC=1; TC<=testcases;TC++){
for (int i=0;i<25;i++)
for (int j=0;j<25;j++) {
map[i][j]='\0';
pos[i][j].clear();
}
int wide; int queries;
QList<int> queryo;
QSet<int> query;
QMap<int, QString> res;
scanf("%i %i\n",&wide,&queries);
for (int i=1;i<=wide;i++)
scanf("%s\n",&map[i][1]);
for (int i=0;i<queries;i++) {
int q;
scanf("%i",&q);
queryo << q;
query << q;
}
scanf("\n");
//for (int i=0;i<wide;i++) printf("check: %s\n",&map[i][0]);
for (int i=1;i<=wide;i++)
for (int j=1;j<=wide;j++)
if (map[i][j]>='0' && map[i][j]<='9') {
pos[i][j].insert((int)(map[i][j]-'0'),QChar(map[i][j]));
if (query.contains((int)(map[i][j]-'0')) &&
!res.contains((int)(map[i][j]-'0')))
res.insert(map[i][j]-'0',QChar(map[i][j]));
}
while (res.size()!=query.size()) {
//fprintf(stderr,"TEST\n");
for (int i=1;i<=wide;i++)
for (int j=1;j<=wide;j++)
if (map[i][j]=='+' || map[i][j]=='-') {
for (int k=0;k<4;k++) {
//fprintf(stderr," %i %i %i\n",i,j,k);
QMap<int,QString>::iterator end=pos[i+dx[k]][j+dy[k]].end();
for (QMap<int,QString>::iterator it=pos[i+dx[k]][j+dy[k]].begin(); it!=end; it++){
int myval=it.key();
if (myval > 1500 || myval<-1500) continue;
if (map[i][j]=='-') myval-=2*(map[i+dx[k]][j+dy[k]]-'0');
if (!pos[i][j].contains(myval) ||
(newsolbetter(pos[i][j].value(myval),it.value()))) {
pos[i][j].insert(myval,it.value());
}
}
}
}
//fprintf(stderr,"TEST++\n");
for (int i=1;i<=wide;i++)
for (int j=1;j<=wide;j++)
if (map[i][j]>='0' && map[i][j]<='9') {
for (int k=0;k<4;k++) {
//fprintf(stderr," %i %i %i\n",i,j,k);
QMap<int,QString>::iterator end=pos[i+dx[k]][j+dy[k]].end();
for (QMap<int,QString>::iterator it=pos[i+dx[k]][j+dy[k]].begin(); it!=end; it++){
int myval=(int)(map[i][j]-'0')+it.key();
if (myval > 1500 || myval<-1500) continue;
QString news = QString(QChar(map[i][j]))+
QString(QChar(map[i+dx[k]][j+dy[k]]))+it.value();
if (!pos[i][j].contains(myval) ||
(newsolbetter(pos[i][j].value(myval),news))) {
pos[i][j].insert(myval,news);
//fprintf (stderr,"DEB: %i<-%s\n",myval,qPrintable(news));
if (query.contains(myval) &&
(!res.contains(myval) || (newsolbetter(res.value(myval),news)))){
res.insert(myval,news);
//fprintf (stderr,"DEBUG: %i<-%s\n",myval,qPrintable(news));
}
}
}
}
}
}
printf("Case #%i:\n",TC);
for (int i=0;i<queryo.size();i++)
printf("%s\n",qPrintable(res.value(queryo[i])));
}
//std::cout << "test\n";
return 0;
}
示例7: applyFilter
void SvgParser::applyFilter(KoShape *shape)
{
SvgGraphicsContext *gc = m_context.currentGC();
if (! gc)
return;
if (gc->filterId.isEmpty())
return;
SvgFilterHelper *filter = findFilter(gc->filterId);
if (! filter)
return;
KoXmlElement content = filter->content();
// parse filter region
QRectF bound(shape->position(), shape->size());
// work on bounding box without viewbox tranformation applied
// so user space coordinates of bounding box and filter region match up
bound = gc->viewboxTransform.inverted().mapRect(bound);
QRectF filterRegion(filter->position(bound), filter->size(bound));
// convert filter region to boundingbox units
QRectF objectFilterRegion;
objectFilterRegion.setTopLeft(SvgUtil::userSpaceToObject(filterRegion.topLeft(), bound));
objectFilterRegion.setSize(SvgUtil::userSpaceToObject(filterRegion.size(), bound));
KoFilterEffectLoadingContext context(m_context.xmlBaseDir());
context.setShapeBoundingBox(bound);
// enable units conversion
context.enableFilterUnitsConversion(filter->filterUnits() == SvgFilterHelper::UserSpaceOnUse);
context.enableFilterPrimitiveUnitsConversion(filter->primitiveUnits() == SvgFilterHelper::UserSpaceOnUse);
KoFilterEffectRegistry *registry = KoFilterEffectRegistry::instance();
KoFilterEffectStack *filterStack = 0;
QSet<QString> stdInputs;
stdInputs << "SourceGraphic" << "SourceAlpha";
stdInputs << "BackgroundImage" << "BackgroundAlpha";
stdInputs << "FillPaint" << "StrokePaint";
QMap<QString, KoFilterEffect*> inputs;
// create the filter effects and add them to the shape
for (KoXmlNode n = content.firstChild(); !n.isNull(); n = n.nextSibling()) {
KoXmlElement primitive = n.toElement();
KoFilterEffect *filterEffect = registry->createFilterEffectFromXml(primitive, context);
if (!filterEffect) {
debugFlake << "filter effect" << primitive.tagName() << "is not implemented yet";
continue;
}
const QString input = primitive.attribute("in");
if (!input.isEmpty()) {
filterEffect->setInput(0, input);
}
const QString output = primitive.attribute("result");
if (!output.isEmpty()) {
filterEffect->setOutput(output);
}
QRectF subRegion;
// parse subregion
if (filter->primitiveUnits() == SvgFilterHelper::UserSpaceOnUse) {
const QString xa = primitive.attribute("x");
const QString ya = primitive.attribute("y");
const QString wa = primitive.attribute("width");
const QString ha = primitive.attribute("height");
if (xa.isEmpty() || ya.isEmpty() || wa.isEmpty() || ha.isEmpty()) {
bool hasStdInput = false;
bool isFirstEffect = filterStack == 0;
// check if one of the inputs is a standard input
foreach(const QString &input, filterEffect->inputs()) {
if ((isFirstEffect && input.isEmpty()) || stdInputs.contains(input)) {
hasStdInput = true;
break;
}
}
if (hasStdInput || primitive.tagName() == "feImage") {
// default to 0%, 0%, 100%, 100%
subRegion.setTopLeft(QPointF(0, 0));
subRegion.setSize(QSizeF(1, 1));
} else {
// defaults to bounding rect of all referenced nodes
foreach(const QString &input, filterEffect->inputs()) {
if (!inputs.contains(input))
continue;
KoFilterEffect *inputFilter = inputs[input];
if (inputFilter)
subRegion |= inputFilter->filterRect();
}
}
} else {
const qreal x = parseUnitX(xa);
const qreal y = parseUnitY(ya);
const qreal w = parseUnitX(wa);
//.........这里部分代码省略.........
示例8: paint
void RowHeader::paint(QPainter* painter, const QRectF& painterRect)
{
register Sheet * const sheet = m_pCanvas->activeSheet();
if (!sheet)
return;
// ElapsedTime et( "Painting vertical header", ElapsedTime::PrintOnlyTime );
// FIXME Stefan: Make use of clipping. Find the repaint call after the scrolling.
// kDebug(36004) << event->rect();
// painting rectangle
const QRectF paintRect = m_pCanvas->zoomHandler()->viewToDocument(painterRect);
// the painter
painter->scale(m_pCanvas->zoomHandler()->zoomedResolutionX(), m_pCanvas->zoomHandler()->zoomedResolutionY());
painter->setRenderHint(QPainter::TextAntialiasing);
// fonts
QFont normalFont(KoGlobal::defaultFont());
QFont boldFont(normalFont);
boldFont.setBold(true);
// background brush/color
const QBrush backgroundBrush(palette().window());
const QColor backgroundColor(backgroundBrush.color());
// selection brush/color
QColor selectionColor(palette().highlight().color());
selectionColor.setAlpha(127);
const QBrush selectionBrush(selectionColor);
painter->setClipRect(paintRect);
double yPos;
// Get the top row and the current y-position
int y = sheet->topRow(paintRect.y() + m_pCanvas->yOffset(), yPos);
// Align to the offset
yPos = yPos - m_pCanvas->yOffset();
const KoViewConverter *converter = m_pCanvas->zoomHandler();
const double width = converter->viewToDocumentX(this->width() - 1);
QSet<int> selectedRows;
QSet<int> affectedRows;
if (!m_pCanvas->selection()->referenceSelectionMode() && m_cellToolIsActive) {
selectedRows = m_pCanvas->selection()->rowsSelected();
affectedRows = m_pCanvas->selection()->rowsAffected();
}
// Loop through the rows, until we are out of range
while (yPos <= paintRect.bottom() && y <= KS_rowMax) {
const bool selected = (selectedRows.contains(y));
const bool highlighted = (!selected && affectedRows.contains(y));
if (sheet->rowFormats()->isHiddenOrFiltered(y)) {
++y;
continue;
}
const double height = sheet->rowFormats()->rowHeight(y);
if (selected || highlighted) {
painter->setPen(selectionColor.dark(150));
painter->setBrush(selectionBrush);
} else {
painter->setPen(backgroundColor.dark(150));
painter->setBrush(backgroundBrush);
}
painter->drawRect(QRectF(0, yPos, width, height));
QString rowText = QString::number(y);
// Reset painter
painter->setFont(normalFont);
painter->setPen(palette().text().color());
if (selected)
painter->setPen(palette().highlightedText().color());
else if (highlighted)
painter->setFont(boldFont);
const int ascent = painter->fontMetrics().ascent();
if (height >= ascent - painter->fontMetrics().descent()) {
#if 0
const double len = painter->fontMetrics().width(rowText);
switch (y % 3) {
case 0: rowText = QString::number(height) + 'h'; break;
case 1: rowText = QString::number(painter.fontMetrics().ascent()) + 'a'; break;
case 2: rowText = QString::number(painter.fontMetrics().descent()) + 'd'; break;
}
//kDebug() << "font height: " << painter.fontMetrics().ascent();
painter.drawLine(1, yPos, 4, yPos + 3);
#endif
drawText(painter,
painter->font(),
yPos + (height - ascent) / 2,
// yPos + ( height - painter.fontMetrics().ascent() - painter.fontMetrics().descent() ) / 2 ),
width,
rowText);
}
//.........这里部分代码省略.........
示例9: registerTypes
void AsemanQtTools::registerTypes(const char *uri, bool exportMode)
{
static QSet<QByteArray> register_list;
if(register_list.contains(uri) && !exportMode)
return;
qRegisterMetaType<AsemanMimeData*>("AsemanMimeData*");
registerType<AsemanMimeData>(uri, 1, 0, "MimeData", exportMode);
registerType<AsemanDragObject>(uri, 1, 0, "DragObject", exportMode);
registerType<AsemanHashObject>(uri, 1,0, "HashObject", exportMode);
registerType<AsemanListObject>(uri, 1,0, "ListObject", exportMode);
registerType<AsemanDownloader>(uri, 1,0, "Downloader", exportMode);
registerType<AsemanEncrypter>(uri, 1,0, "Encrypter", exportMode);
#ifndef DISABLE_KEYCHAIN
registerType<AsemanKeychain>(uri, 1,0, "Keychain", exportMode);
#endif
#ifdef QT_WIDGETS_LIB
registerType<AsemanSystemTray>(uri, 1,0, "SystemTray", exportMode);
#endif
registerType<AsemanWindowDetails>(uri, 1,0, "WindowDetails", exportMode);
registerType<AsemanQuickObject>(uri, 1,0, "AsemanObject", exportMode);
registerType<AsemanImageColorAnalizor>(uri, 1,0, "ImageColorAnalizor", exportMode);
registerType<AsemanNotification>(uri, 1,0, "Notification", exportMode);
registerType<AsemanAutoStartManager>(uri, 1,0, "AutoStartManager", exportMode);
registerType<AsemanSettings>(uri, 1,0, "Settings", exportMode);
registerType<AsemanStoreManager>(uri, 1,0, "StoreManager", exportMode);
registerType<AsemanQuickItemImageGrabber>(uri, 1,0, "ItemImageGrabber", exportMode);
registerType<AsemanFileDownloaderQueueItem>(uri, 1,0, "FileDownloaderQueueItem", exportMode);
registerType<AsemanFileDownloaderQueue>(uri, 1,0, "FileDownloaderQueue", exportMode);
registerType<AsemanFontHandler>(uri, 1,0, "FontHandler", exportMode);
registerType<AsemanApplicationItem>(uri, 1,0, "AsemanApplication", exportMode);
registerType<AsemanQmlSmartComponent>(uri, 1,0, "SmartComponentCore", exportMode);
#ifdef DESKTOP_LINUX
registerType<AsemanMimeApps>(uri, 1,0, "MimeApps", exportMode);
#endif
registerType<AsemanWebPageGrabber>(uri, 1,0, "WebPageGrabber", exportMode);
registerType<AsemanHostChecker>(uri, 1,0, "HostChecker", exportMode);
registerType<AsemanNetworkManager>(uri, 1,0, "NetworkManager", exportMode);
registerType<AsemanNetworkSleepManager>(uri, 1,0, "NetworkSleepManager", exportMode);
registerType<AsemanTitleBarColorGrabber>(uri, 1,0, "TitleBarColorGrabber", exportMode);
registerType<AsemanTaskbarButton>(uri, 1,0, "TaskbarButton", exportMode);
registerType<AsemanMapDownloader>(uri, 1,0, "MapDownloader", exportMode);
registerType<AsemanDragArea>(uri, 1,0, "MouseDragArea", exportMode);
registerType<AsemanCalendarModel>(uri, 1,0, "CalendarModel", exportMode);
#if defined(Q_OS_LINUX) && defined(QT_DBUS_LIB)
registerType<AsemanKdeWallet>(uri, 1,0, "KdeWallet", exportMode);
#endif
#ifdef ASEMAN_SENSORS
registerType<AsemanSensors>(uri, 1,0, "AsemanSensors", exportMode);
#endif
#ifdef ASEMAN_MULTIMEDIA
registerType<AsemanAudioRecorder>(uri, 1,0, "AudioRecorder", exportMode);
registerType<AsemanAudioEncoderSettings>(uri, 1,0, "AudioEncoderSettings", exportMode);
#endif
registerModel<AsemanMixedListModel>(uri, 1,0, "MixedListModel", exportMode);
registerModel<AsemanCountriesModel>(uri, 1,0, "CountriesModel", exportMode);
registerModel<AsemanFileSystemModel>(uri, 1,0, "FileSystemModel", exportMode);
registerModel<AsemanStoreManagerModel>(uri, 1,0, "StoreManagerModel", exportMode);
registerModel<AsemanContributorsModel>(uri, 1,0, "ContributorsModel", exportMode);
registerSingletonType<AsemanDevices>(uri, 1, 0, "Devices", aseman_devices_singleton, exportMode);
registerSingletonType<AsemanTextTools>(uri, 1, 0, "TextTools", aseman_text_tools_singleton, exportMode);
registerSingletonType<AsemanTools>(uri, 1, 0, "Tools", aseman_tools_singleton, exportMode);
registerSingletonType<AsemanDesktopTools>(uri, 1, 0, "Desktop", aseman_desktoptools_singleton, exportMode);
registerSingletonType<AsemanCalendarConverter>(uri, 1, 0, "CalendarConv", aseman_calendarconv_singleton, exportMode);
registerSingletonType<AsemanBackHandler>(uri, 1, 0, "BackHandler", aseman_backhandler_singleton, exportMode);
registerSingletonType<AsemanApplication>(uri, 1, 0, "AsemanApp", aseman_app_singleton, exportMode);
registerSingletonType<AsemanQtLogger>(uri, 1, 0, "Logger", aseman_logger_singleton, exportMode);
registerSingletonType<AsemanQuickViewWrapper>(uri, 1, 0, "View", aseman_qview_singleton, exportMode);
#ifdef Q_OS_ANDROID
registerSingletonType<AsemanJavaLayer>(uri, 1, 0, "JavaLayer", aseman_javalayer_singleton, exportMode);
#endif
registerUncreatableType<QScreen>(uri, 1, 0, "Screen", "", exportMode);
registerUncreatableType<AsemanDesktopTools>(uri, 1,0, "AsemanDesktopTools", "It's a singleton class", exportMode);
registerUncreatableType<AsemanNetworkManagerItem>(uri, 1,0, "NetworkManagerItem", "It must create using NetworkManager component.", exportMode);
register_list.insert(uri);
}
示例10: processAutomations
void Song::processAutomations(const TrackList &tracklist, MidiTime timeStart, fpp_t)
{
AutomatedValueMap values;
QSet<const AutomatableModel*> recordedModels;
TrackContainer* container = this;
int tcoNum = -1;
switch (m_playMode)
{
case Mode_PlaySong:
break;
case Mode_PlayBB:
{
Q_ASSERT(tracklist.size() == 1);
Q_ASSERT(tracklist.at(0)->type() == Track::BBTrack);
auto bbTrack = dynamic_cast<BBTrack*>(tracklist.at(0));
auto bbContainer = Engine::getBBTrackContainer();
container = bbContainer;
tcoNum = bbTrack->index();
}
break;
default:
return;
}
values = container->automatedValuesAt(timeStart, tcoNum);
TrackList tracks = container->tracks();
Track::tcoVector tcos;
for (Track* track : tracks)
{
if (track->type() == Track::AutomationTrack) {
track->getTCOsInRange(tcos, 0, timeStart);
}
}
// Process recording
for (TrackContentObject* tco : tcos)
{
auto p = dynamic_cast<AutomationPattern *>(tco);
MidiTime relTime = timeStart - p->startPosition();
if (p->isRecording() && relTime >= 0 && relTime < p->length())
{
const AutomatableModel* recordedModel = p->firstObject();
p->recordValue(relTime, recordedModel->value<float>());
recordedModels << recordedModel;
}
}
// Apply values
for (auto it = values.begin(); it != values.end(); it++)
{
if (! recordedModels.contains(it.key()))
{
it.key()->setAutomatedValue(it.value());
}
}
}
示例11: updatePeers
void PeerListModel::updatePeers(const google::protobuf::RepeatedPtrField<Protos::GUI::State::Peer>& peers, const QSet<Common::Hash>& peersDownloadingOurData)
{
Common::SortedArray<Peer*> peersToRemove = this->orderedPeers;
QList<Peer*> peersToAdd;
for (int i = 0; i < peers.size(); i++)
{
const Common::Hash peerID(peers.Get(i).peer_id().hash());
const QString& nick = Common::ProtoHelper::getStr(peers.Get(i), &Protos::GUI::State::Peer::nick);
const QString& coreVersion = Common::ProtoHelper::getStr(peers.Get(i), &Protos::GUI::State::Peer::core_version);
const quint64 sharingAmount(peers.Get(i).sharing_amount());
const TransferInformation transferInformation { peers.Get(i).download_rate(), peers.Get(i).upload_rate(), peersDownloadingOurData.contains(peerID) };
const QHostAddress ip =
peers.Get(i).has_ip() ?
Common::ProtoHelper::getIP(peers.Get(i).ip()) :
QHostAddress();
Peer* peer = this->indexedPeers[peerID];
int j = this->orderedPeers.indexOf(peer);
if (j != -1)
{
peersToRemove.remove(peer);
if (peer->nick != nick)
{
if (this->currentSortType == Protos::GUI::Settings::BY_NICK)
{
this->beginRemoveRows(QModelIndex(), j, j);
this->orderedPeers.remove(peer);
this->endRemoveRows();
peer->nick = nick;
peersToAdd << peer;
}
else
{
peer->nick = nick;
emit dataChanged(this->createIndex(j, 1), this->createIndex(j, 1));
}
}
if (peer->sharingAmount != sharingAmount)
{
if (this->currentSortType == Protos::GUI::Settings::BY_SHARING_AMOUNT)
{
this->beginRemoveRows(QModelIndex(), j, j);
this->orderedPeers.remove(peer);
this->endRemoveRows();
peer->sharingAmount = sharingAmount;
peersToAdd << peer;
}
else
{
peer->sharingAmount = sharingAmount;
emit dataChanged(this->createIndex(j, 1), this->createIndex(j, 1));
}
}
if (peer->transferInformation != transferInformation)
{
peer->transferInformation = transferInformation;
emit dataChanged(this->createIndex(j, 0), this->createIndex(j, 0));
}
peer->ip = ip;
peer->coreVersion = coreVersion;
}
else
{
peersToAdd << new Peer(peerID, nick, coreVersion, sharingAmount, ip, transferInformation);
}
}
QList<Common::Hash> peerIDsRemoved;
for (Common::SortedArray<Peer*>::Iterator i(peersToRemove); i.hasNext();)
{
Peer* const peer = i.next();
peerIDsRemoved << peer->peerID;
int j = this->orderedPeers.indexOf(peer);
if (j != -1)
{
this->beginRemoveRows(QModelIndex(), j, j);
this->indexedPeers.remove(peer->peerID);
this->orderedPeers.remove(peer);
delete peer;
this->endRemoveRows();
}
}
if (!peerIDsRemoved.isEmpty())
emit peersRemoved(peerIDsRemoved);
for (QListIterator<Peer*> i(peersToAdd); i.hasNext();)
{
Peer* const peer = i.next();
int pos = this->orderedPeers.insert(peer);
this->beginInsertRows(QModelIndex(), pos, pos);
this->indexedPeers.insert(peer->peerID, peer);
this->endInsertRows();
}
}
示例12: botMove
void MapController::botMove()
{
int index;
QSet<int> continuedMove;
//continue the move
index=0;
while(index<botList.size())
{
if(botList.at(index).inMove)
{
if(!botMoveStepSlot(&botList[index]))
{
delete botList.at(index).mapObject;
botList.removeAt(index);
index--;
}
continuedMove << index;
}
index++;
}
//start move
index=0;
while(index<botList.size())
{
if(!botList.at(index).inMove && !continuedMove.contains(index))
{
QList<CatchChallenger::Direction> directions_allowed;
if(CatchChallenger::MoveOnTheMap::canGoTo(CatchChallenger::Direction_move_at_left,all_map[botList.at(index).map]->logicalMap,botList.at(index).x,botList.at(index).y,true))
directions_allowed << CatchChallenger::Direction_move_at_left;
if(CatchChallenger::MoveOnTheMap::canGoTo(CatchChallenger::Direction_move_at_right,all_map[botList.at(index).map]->logicalMap,botList.at(index).x,botList.at(index).y,true))
directions_allowed << CatchChallenger::Direction_move_at_right;
if(CatchChallenger::MoveOnTheMap::canGoTo(CatchChallenger::Direction_move_at_top,all_map[botList.at(index).map]->logicalMap,botList.at(index).x,botList.at(index).y,true))
directions_allowed << CatchChallenger::Direction_move_at_top;
if(CatchChallenger::MoveOnTheMap::canGoTo(CatchChallenger::Direction_move_at_bottom,all_map[botList.at(index).map]->logicalMap,botList.at(index).x,botList.at(index).y,true))
directions_allowed << CatchChallenger::Direction_move_at_bottom;
if(directions_allowed.size()>0)
{
int random = rand()%directions_allowed.size();
CatchChallenger::Direction final_direction=directions_allowed.at(random);
botList[index].direction=final_direction;
botList[index].inMove=true;
botList[index].moveStep=1;
switch(final_direction)
{
case CatchChallenger::Direction_move_at_left:
botMoveStepSlot(&botList[index]);
break;
case CatchChallenger::Direction_move_at_right:
botMoveStepSlot(&botList[index]);
break;
case CatchChallenger::Direction_move_at_top:
botMoveStepSlot(&botList[index]);
break;
case CatchChallenger::Direction_move_at_bottom:
botMoveStepSlot(&botList[index]);
break;
default:
qDebug() << QStringLiteral("transformLookToMove(): wrong direction");
return;
}
}
}
index++;
}
}
示例13: describeFeatureType
QDomDocument QgsWFSServer::describeFeatureType()
{
QgsDebugMsg( "Entering." );
QDomDocument doc;
//xsd:schema
QDomElement schemaElement = doc.createElement( "schema"/*xsd:schema*/ );
schemaElement.setAttribute( "xmlns", "http://www.w3.org/2001/XMLSchema" );
schemaElement.setAttribute( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema" );
schemaElement.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
schemaElement.setAttribute( "xmlns:gml", "http://www.opengis.net/gml" );
schemaElement.setAttribute( "xmlns:qgs", "http://www.qgis.org/gml" );
schemaElement.setAttribute( "targetNamespace", "http://www.qgis.org/gml" );
doc.appendChild( schemaElement );
//xsd:import
QDomElement importElement = doc.createElement( "import"/*xsd:import*/ );
importElement.setAttribute( "namespace", "http://www.opengis.net/gml" );
importElement.setAttribute( "schemaLocation", "http://schemas.opengis.net/gml/2.1.2/feature.xsd" );
schemaElement.appendChild( importElement );
//read TYPENAME
QString typeName;
QMap<QString, QString>::const_iterator type_name_it = mParameterMap.find( "TYPENAME" );
if ( type_name_it != mParameterMap.end() )
{
typeName = type_name_it.value();
}
else
{
return doc;
}
QStringList wfsLayersId = mConfigParser->wfsLayers();
QMap< QString, QMap< int, QString > > aliasInfo = mConfigParser->layerAliasInfo();
QMap< QString, QSet<QString> > hiddenAttributes = mConfigParser->hiddenAttributes();
QList<QgsMapLayer*> layerList;
QgsMapLayer* currentLayer = 0;
layerList = mConfigParser->mapLayerFromStyle( typeName, "" );
currentLayer = layerList.at( 0 );
QgsVectorLayer* layer = dynamic_cast<QgsVectorLayer*>( currentLayer );
if ( layer && wfsLayersId.contains( layer->id() ) )
{
//is there alias info for this vector layer?
QMap< int, QString > layerAliasInfo;
QMap< QString, QMap< int, QString > >::const_iterator aliasIt = aliasInfo.find( currentLayer->id() );
if ( aliasIt != aliasInfo.constEnd() )
{
layerAliasInfo = aliasIt.value();
}
//hidden attributes for this layer
QSet<QString> layerHiddenAttributes;
QMap< QString, QSet<QString> >::const_iterator hiddenIt = hiddenAttributes.find( currentLayer->id() );
if ( hiddenIt != hiddenAttributes.constEnd() )
{
layerHiddenAttributes = hiddenIt.value();
}
//do a select with searchRect and go through all the features
QgsVectorDataProvider* provider = layer->dataProvider();
if ( !provider )
{
return doc;
}
typeName = typeName.replace( QString( " " ), QString( "_" ) );
//xsd:element
QDomElement elementElem = doc.createElement( "element"/*xsd:element*/ );
elementElem.setAttribute( "name", typeName );
elementElem.setAttribute( "type", "qgs:" + typeName + "Type" );
elementElem.setAttribute( "substitutionGroup", "gml:_Feature" );
schemaElement.appendChild( elementElem );
//xsd:complexType
QDomElement complexTypeElem = doc.createElement( "complexType"/*xsd:complexType*/ );
complexTypeElem.setAttribute( "name", typeName + "Type" );
schemaElement.appendChild( complexTypeElem );
//xsd:complexType
QDomElement complexContentElem = doc.createElement( "complexContent"/*xsd:complexContent*/ );
complexTypeElem.appendChild( complexContentElem );
//xsd:extension
QDomElement extensionElem = doc.createElement( "extension"/*xsd:extension*/ );
extensionElem.setAttribute( "base", "gml:AbstractFeatureType" );
complexContentElem.appendChild( extensionElem );
//xsd:sequence
QDomElement sequenceElem = doc.createElement( "sequence"/*xsd:sequence*/ );
extensionElem.appendChild( sequenceElem );
//xsd:element
QDomElement geomElem = doc.createElement( "element"/*xsd:element*/ );
geomElem.setAttribute( "name", "geometry" );
geomElem.setAttribute( "type", "gml:GeometryPropertyType" );
geomElem.setAttribute( "minOccurs", "0" );
//.........这里部分代码省略.........
示例14: captionColor
GraphicsPortItem::GraphicsPortItem(GraphicsClientItemsClient *client_, const QString &fullPortName_, int style_, QFont font_, int padding, QGraphicsItem *parent) :
QGraphicsPathItem(parent),
client(client_),
fullPortName(fullPortName_),
shortPortName(fullPortName.split(":")[1]),
dataType(client->getPortType(fullPortName)),
isInput(client->getPortFlags(fullPortName) & JackPortIsInput),
style(style_),
font(font_),
showMenu(false)
{
bool gradient = false;
QColor captionColor(0xfc, 0xf9, 0xc2);
setPen(QPen(QBrush(Qt::black), 2));
setBrush(QBrush(captionColor));
setFlags(QGraphicsItem::ItemSendsScenePositionChanges);
setCursor(Qt::ArrowCursor);
font.setStyleStrategy(QFont::PreferAntialias);
QFontMetrics fontMetrics(font);
int portPadding = padding;
QGraphicsSimpleTextItem *portTextItem = new QGraphicsSimpleTextItem(shortPortName, this);
portTextItem->setFont(font);
portTextItem->setPos(portPadding, 0);
portRect = portTextItem->boundingRect().adjusted(-portPadding, -portPadding, portPadding, portPadding).translated(portTextItem->pos());
QPainterPath portPath;
if (style == 0) {
portPath = portPath.united(EllipsePath(portRect));
} else if (style == 1) {
portPath = portPath.united(SpeechBubblePath(portRect, portRect.height() / 4, portRect.height() / 4, Qt::AbsoluteSize));
} else if (style == 2) {
portPath = portPath.united(RoundedRectanglePath(portRect, portPadding + fontMetrics.height() / 2, portPadding + fontMetrics.height() / 2));
} else if (style == 3) {
portPath = portPath.united(RectanglePath(portRect));
}
setPath(portPath);
// register the port registration callback at the jack server:
QObject::connect(client, SIGNAL(portRegistered(QString,QString,int)), this, SLOT(onPortRegistered(QString,QString,int)), Qt::QueuedConnection);
QObject::connect(client, SIGNAL(portUnregistered(QString,QString,int)), this, SLOT(onPortUnregistered(QString,QString,int)), Qt::QueuedConnection);
QObject::connect(client, SIGNAL(portConnected(QString,QString)), this, SLOT(onPortConnected(QString,QString)), Qt::QueuedConnection);
QObject::connect(client, SIGNAL(portDisconnected(QString,QString)), this, SLOT(onPortDisconnected(QString,QString)), Qt::QueuedConnection);
if (gradient) {
QLinearGradient gradient(portRect.topLeft(), portRect.bottomRight());
gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, QColor("wheat"));
setBrush(QBrush(gradient));
}
// create the context menu:
connectMenu = contextMenu.addMenu("Connect");
disconnectMenu = contextMenu.addMenu("Disconnect");
// create the entries in connect- and disconnect-menus, as well as graphical representations of existing connections:
QStringList connectedPorts = client->getConnectedPorts(fullPortName);
QSet<QString> connectedPortsSet;
for (int i = 0; i < connectedPorts.size(); i++) {
// create an entry in the disconnect-menu:
QAction *action = disconnectMenu->addAction(connectedPorts[i]);
action->setData(connectedPorts[i]);
QObject::connect(action, SIGNAL(triggered()), this, SLOT(onDisconnectAction()));
mapPortNamesToActions[connectedPorts[i]] = action;
connectedPortsSet.insert(connectedPorts[i]);
// create a graphical representation of the connection:
if (isInput) {
client->getPortConnectionItem(connectedPorts[i], fullPortName)->setPos(fullPortName, getConnectionScenePos());
} else {
client->getPortConnectionItem(fullPortName, connectedPorts[i])->setPos(fullPortName, getConnectionScenePos());
}
}
// get all available ports that can be connected to this:
QStringList connectablePorts = client->getPorts(0, dataType.toAscii().data(), isInput ? JackPortIsOutput : JackPortIsInput);
for (int i = 0; i < connectablePorts.size(); i++) {
// skip ports that are already connected:
if (!connectedPortsSet.contains(connectablePorts[i])) {
// create an entry in the connect-menu:
QAction *action = connectMenu->addAction(connectablePorts[i]);
action->setData(connectablePorts[i]);
QObject::connect(action, SIGNAL(triggered()), this, SLOT(onConnectAction()));
mapPortNamesToActions[connectablePorts[i]] = action;
}
}
disconnectMenu->setEnabled(disconnectMenu->actions().size());
connectMenu->setEnabled(connectMenu->actions().size());
}
示例15: reducesToEpsilon
bool reducesToEpsilon(Model::Node *node, QSet<Model::Node*>& v)
{
if (node == 0)
return true;
if (v.contains(node))
return true;
v.insert(node);
if (Model::ConsItem *c = nodeCast<Model::ConsItem*>(node))
{
return reducesToEpsilon(c->mLeft, v) && reducesToEpsilon(c->mRight, v);
}
else if (nodeCast<Model::OperatorItem*>(node))
{
return false;
}
else if (Model::AlternativeItem *a = nodeCast<Model::AlternativeItem*>(node))
{
return reducesToEpsilon(a->mLeft, v) || reducesToEpsilon(a->mRight, v);
}
else if (Model::ActionItem *a = nodeCast<Model::ActionItem*>(node))
{
if(a->mItem)
return reducesToEpsilon(a->mItem, v);
else
return true;
}
else if (Model::ConditionItem *c = nodeCast<Model::ConditionItem*>(node))
{
return reducesToEpsilon(c->mItem, v);
}
else if (Model::TryCatchItem *t = nodeCast<Model::TryCatchItem*>(node))
{
return reducesToEpsilon(t->mTryItem, v)
|| (t->mCatchItem && reducesToEpsilon(t->mCatchItem, v));
}
else if (Model::AnnotationItem *a = nodeCast<Model::AnnotationItem*>(node))
{
return reducesToEpsilon(a->mItem, v);
}
else if (Model::NonTerminalItem *n = nodeCast<Model::NonTerminalItem*>(node))
{
return reducesToEpsilon(n->mSymbol, v);
}
else if (Model::InlinedNonTerminalItem *n = nodeCast<Model::InlinedNonTerminalItem*>(node))
{
return reducesToEpsilon(n->mSymbol, v);
}
else if (Model::SymbolItem *s = nodeCast<Model::SymbolItem*>(node))
{
return globalSystem.first(s).find(globalSystem.zero()) != globalSystem.first(s).end(); // hmm
}
else if (Model::PlusItem *p = nodeCast<Model::PlusItem*>(node))
{
return reducesToEpsilon(p->mItem, v);
}
else if (nodeCast<Model::StarItem*>(node))
{
return true;
}
else if (nodeCast<Model::ZeroItem*>(node))
{
return true;
}
return false;
}