/** * Constructs a DlgCustomCommandsImp which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ DlgCustomCommandsImp::DlgCustomCommandsImp( QWidget* parent ) : CustomizeActionPage(parent) { this->setupUi(this); // paints for active and inactive the same color QPalette pal = categoryTreeWidget->palette(); pal.setColor(QPalette::Inactive, QPalette::Highlight, pal.color(QPalette::Active, QPalette::Highlight)); pal.setColor(QPalette::Inactive, QPalette::HighlightedText, pal.color(QPalette::Active, QPalette::HighlightedText)); categoryTreeWidget->setPalette( pal ); connect(commandTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(onDescription(QTreeWidgetItem*))); connect(categoryTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(onGroupActivated(QTreeWidgetItem*))); CommandManager & cCmdMgr = Application::Instance->commandManager(); std::map<std::string,Command*> sCommands = cCmdMgr.getCommands(); GroupMap groupMap; groupMap.push_back(std::make_pair(QLatin1String("File"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Edit"), QString())); groupMap.push_back(std::make_pair(QLatin1String("View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Standard-View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Tools"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Window"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); for (std::map<std::string,Command*>::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { QLatin1String group(it->second->getGroupName()); QString text = qApp->translate(it->second->className(), it->second->getGroupName()); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { if (jt->second.isEmpty()) jt->second = text; } else { groupMap.push_back(std::make_pair(group, text)); } } QStringList labels; labels << tr("Category"); categoryTreeWidget->setHeaderLabels(labels); for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it) { QTreeWidgetItem* item = new QTreeWidgetItem(categoryTreeWidget); item->setText(0, it->second); item->setData(0, Qt::UserRole, QVariant(it->first)); } labels.clear(); labels << tr("Icon") << tr("Command"); commandTreeWidget->setHeaderLabels(labels); commandTreeWidget->header()->hide(); commandTreeWidget->setIconSize(QSize(32, 32)); commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); categoryTreeWidget->setCurrentItem(categoryTreeWidget->topLevelItem(0)); }
/** * Constructs a DlgCustomKeyboardImp which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ DlgCustomKeyboardImp::DlgCustomKeyboardImp( QWidget* parent ) : CustomizeActionPage(parent), firstShow(true) { this->setupUi(this); CommandManager & cCmdMgr = Application::Instance->commandManager(); std::map<std::string,Command*> sCommands = cCmdMgr.getCommands(); GroupMap groupMap; groupMap.push_back(std::make_pair(QLatin1String("File"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Edit"), QString())); groupMap.push_back(std::make_pair(QLatin1String("View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Standard-View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Tools"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Window"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); for (std::map<std::string,Command*>::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { QLatin1String group(it->second->getGroupName()); QString text = qApp->translate(it->second->className(), it->second->getGroupName()); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { if (jt->second.isEmpty()) jt->second = text; } else { groupMap.push_back(std::make_pair(group, text)); } } int index = 0; for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { categoryBox->addItem(it->second); categoryBox->setItemData(index, QVariant(it->first), Qt::UserRole); } QStringList labels; labels << tr("Icon") << tr("Command"); commandTreeWidget->setHeaderLabels(labels); commandTreeWidget->header()->hide(); commandTreeWidget->setIconSize(QSize(32, 32)); #if QT_VERSION >= 0x050000 commandTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); #else commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); #endif assignedTreeWidget->setHeaderLabels(labels); assignedTreeWidget->header()->hide(); }
MojErr MojDbSearchCursor::loadIds(ObjectSet& idsOut) { LOG_TRACE("Entering function %s", __FUNCTION__); MojUInt32 groupNum = 0; bool found = false; MojSharedPtr<ObjectSet> group; GroupMap groupMap; for(;;) { // get current id MojObject id; MojUInt32 idGroupNum = 0; MojErr err = m_storageQuery->getId(id, idGroupNum, found); MojErrCheck(err); if (!found) break; // if it is in a new group, create a new set if (!group.get() || idGroupNum != groupNum) { // find/create new group GroupMap::Iterator iter; err = groupMap.find(idGroupNum, iter); MojErrCheck(err); if (iter != groupMap.end()) { group = iter.value(); } else { err = group.resetChecked(new ObjectSet); MojErrCheck(err); err = groupMap.put(idGroupNum, group); MojErrCheck(err); } groupNum = idGroupNum; } // add id to current set err = group->put(id); MojErrCheck(err); } // no matches unless all groups are accounted for MojUInt32 groupCount = m_storageQuery->groupCount(); for (MojUInt32 i = 0; i < groupCount; ++i) { if (!groupMap.contains(i)) return MojErrNone; } // find intersection of all groups GroupMap::ConstIterator begin = groupMap.begin(); for (GroupMap::ConstIterator i = begin; i != groupMap.end(); ++i) { if (i == begin) { // special handling for first group idsOut = *(i.value()); } else { MojErr err = idsOut.intersect(*(i.value())); MojErrCheck(err); } } return MojErrNone; }
void writeStream(std::ostream &stream, int tabCount) { for(ValueMap::iterator vi = values.begin(); vi != values.end(); ++vi) { writeTabs(stream, tabCount); stream << (*vi).first << " = " << (*vi).second.first << std::endl; } for(GroupMap::iterator gi = groups.begin(); gi != groups.end(); ++gi) { if((gi != groups.begin()) || (!values.empty())) stream << std::endl; writeTabs(stream, tabCount); stream << (*gi).first << std::endl; writeTabs(stream, tabCount); stream << "{" << std::endl; (*gi).second->writeStream(stream, tabCount + 1), writeTabs(stream, tabCount); stream << "}" << std::endl; } if(!lines.empty() && ((!groups.empty() || !values.empty()))) stream << std::endl; for(LineList::iterator li = lines.begin(); li != lines.end(); ++li) { writeTabs(stream, tabCount); std::string &f = (*li); stream << (*li) << std::endl; } }
//----------------------------------------------------------------------------------------- void process_message_group_ordering(const GroupMap& gm) { for (GroupMap::const_iterator gitr(gm.begin()); gitr != gm.end(); ++gitr) { FieldTraitOrder go; for (Presence::const_iterator flitr(gitr->second._fields.get_presence().begin()); flitr != gitr->second._fields.get_presence().end(); ++flitr) go.insert(FieldTraitOrder::value_type(&*flitr)); unsigned gcnt(0); for (FieldTraitOrder::iterator fto(go.begin()); fto != go.end(); ++fto) (*fto)->_pos = ++gcnt; if (!gitr->second._groups.empty()) process_message_group_ordering(gitr->second._groups); } }
// The following is common part for 'cilk vector functions' and // 'omp declare simd' functions metadata generation. // void CodeGenModule::EmitVectorVariantsMetadata(const CGFunctionInfo &FnInfo, const FunctionDecl *FD, llvm::Function *Fn, GroupMap &Groups) { // Do not emit any vector variant if there is an unsupported feature. bool HasImplicitThis = false; if (!CheckElementalArguments(*this, FD, Fn, HasImplicitThis)) return; llvm::LLVMContext &Context = getLLVMContext(); ASTContext &C = getContext(); // Common metadata nodes. llvm::NamedMDNode *CilkElementalMetadata = getModule().getOrInsertNamedMetadata("cilk.functions"); llvm::Metadata *ElementalMDArgs[] = { llvm::MDString::get(Context, "elemental") }; llvm::MDNode *ElementalNode = llvm::MDNode::get(Context, ElementalMDArgs); llvm::Metadata *MaskMDArgs[] = { llvm::MDString::get(Context, "mask"), llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( llvm::IntegerType::getInt1Ty(Context), 1)) }; llvm::MDNode *MaskNode = llvm::MDNode::get(Context, MaskMDArgs); MaskMDArgs[1] = llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( llvm::IntegerType::getInt1Ty(Context), 0)); llvm::MDNode *NoMaskNode = llvm::MDNode::get(Context, MaskMDArgs); SmallVector<llvm::Metadata*, 8> ParameterNameArgs; ParameterNameArgs.push_back(llvm::MDString::get(Context, "arg_name")); llvm::MDNode *ParameterNameNode = 0; // // Vector variant metadata. // llvm::Value *VariantMDArgs[] = { // llvm::MDString::get(Context, "variant"), // llvm::UndefValue::get(llvm::Type::getVoidTy(Context)) // }; // llvm::MDNode *VariantNode = llvm::MDNode::get(Context, VariantMDArgs); for (GroupMap::iterator GI = Groups.begin(), GE = Groups.end(); GI != GE; ++GI) { CilkElementalGroup &G = GI->second; // Parameter information. QualType FirstNonStepParmType; SmallVector<llvm::Metadata *, 8> AligArgs; SmallVector<llvm::Metadata *, 8> StepArgs; AligArgs.push_back(llvm::MDString::get(Context, "arg_alig")); StepArgs.push_back(llvm::MDString::get(Context, "arg_step")); // Handle implicit 'this' parameter if necessary. if (HasImplicitThis) { ParameterNameArgs.push_back(llvm::MDString::get(Context, "this")); bool IsNonStepParm = handleParameter(*this, G, "this", StepArgs, AligArgs); if (IsNonStepParm) FirstNonStepParmType = cast<CXXMethodDecl>(FD)->getThisType(C); } // Handle explicit paramenters. for (unsigned I = 0; I != FD->getNumParams(); ++I) { const ParmVarDecl *Parm = FD->getParamDecl(I); StringRef ParmName = Parm->getName(); if (!ParameterNameNode) ParameterNameArgs.push_back(llvm::MDString::get(Context, ParmName)); bool IsNonStepParm = handleParameter(*this, G, ParmName, StepArgs, AligArgs); if (IsNonStepParm && FirstNonStepParmType.isNull()) FirstNonStepParmType = Parm->getType(); } llvm::MDNode *StepNode = llvm::MDNode::get(Context, StepArgs); llvm::MDNode *AligNode = llvm::MDNode::get(Context, AligArgs); if (!ParameterNameNode) ParameterNameNode = llvm::MDNode::get(Context, ParameterNameArgs); // If there is no vectorlengthfor() in this group, determine the // characteristic type. This can depend on the linear/uniform attributes, // so it can differ between groups. // // The rules for computing the characteristic type are: // // a) For a non-void function, the characteristic data type is the // return type. // // b) If the function has any non-uniform, non-linear parameters, the // the characteristic data type is the type of the first such parameter. // // c) If the characteristic data type determined by a) or b) above is // struct, union, or class type which is pass-by-value (except fo // the type that maps to the built-in complex data type) // the characteristic data type is int. // // d) If none of the above three cases is applicable, // the characteristic data type is int. // // e) For Intel Xeon Phi native and offload compilation, if the resulting // characteristic data type is 8-bit or 16-bit integer data type // the characteristic data type is int. // // These rules missed the reference types and we use their pointer types. // if (G.VecLengthFor.empty()) { QualType FnRetTy = FD->getReturnType(); QualType CharacteristicType; if (!FnRetTy->isVoidType()) CharacteristicType = FnRetTy; else if (!FirstNonStepParmType.isNull()) CharacteristicType = FirstNonStepParmType.getCanonicalType(); else CharacteristicType = C.IntTy; if (CharacteristicType->isReferenceType()) { QualType BaseTy = CharacteristicType.getNonReferenceType(); CharacteristicType = C.getPointerType(BaseTy); } else if (CharacteristicType->isAggregateType()) CharacteristicType = C.IntTy; // FIXME: handle Xeon Phi targets. G.VecLengthFor.push_back(CharacteristicType); } // // If no mask variants are specified, generate both. // if (G.Mask.empty()) { // G.Mask.push_back(1); // G.Mask.push_back(0); // } // If no vector length is specified, push a dummy value to iterate over. if (G.VecLength.empty()) G.VecLength.push_back(0); for (CilkElementalGroup::VecLengthForVector::iterator TI = G.VecLengthFor.begin(), TE = G.VecLengthFor.end(); TI != TE; ++TI) { uint64_t VectorRegisterBytes = 0; // Inspect the current target features to determine the // appropriate vector size. // This is currently X86 specific. if (Target.hasFeature("avx2")) VectorRegisterBytes = 64; else if (Target.hasFeature("avx")) VectorRegisterBytes = 32; else if (Target.hasFeature("sse2")) VectorRegisterBytes = 16; else if (Target.hasFeature("sse") && (*TI)->isFloatingType() && C.getTypeSizeInChars(*TI).getQuantity() == 4) VectorRegisterBytes = 16; else if (Target.hasFeature("mmx") && (*TI)->isIntegerType()) VectorRegisterBytes = 8; for (CilkElementalGroup::VecLengthVector::iterator LI = G.VecLength.begin(), LE = G.VecLength.end(); LI != LE; ++LI) { uint64_t VL = *LI ? *LI : (CharUnits::fromQuantity(VectorRegisterBytes) / C.getTypeSizeInChars(*TI)); llvm::MDNode *VecTypeNode = MakeVecLengthMetadata(*this, "vec_length", *TI, VL); { SmallVector <llvm::Metadata*, 7> kernelMDArgs; kernelMDArgs.push_back(llvm::ValueAsMetadata::get(Fn)); kernelMDArgs.push_back(ElementalNode); kernelMDArgs.push_back(ParameterNameNode); kernelMDArgs.push_back(StepNode); kernelMDArgs.push_back(AligNode); kernelMDArgs.push_back(VecTypeNode); if (!G.Mask.empty()) kernelMDArgs.push_back((G.Mask.back()==0)?(NoMaskNode):(MaskNode)); llvm::MDNode *KernelMD = llvm::MDNode::get(Context, kernelMDArgs); CilkElementalMetadata->addOperand(KernelMD); } // for (CilkElementalGroup::MaskVector::iterator // MI = G.Mask.begin(), // ME = G.Mask.end(); // MI != ME; // ++MI) { // // SmallVector <llvm::Value*, 7> kernelMDArgs; // kernelMDArgs.push_back(Fn); // kernelMDArgs.push_back(ElementalNode); // kernelMDArgs.push_back(ParameterNameNode); // kernelMDArgs.push_back(StepNode); // kernelMDArgs.push_back(AligNode); // kernelMDArgs.push_back(VecTypeNode); // kernelMDArgs.push_back((*MI==0)?(NoMaskNode):(MaskNode)); // if (ProcessorNode) // kernelMDArgs.push_back(ProcessorNode); // kernelMDArgs.push_back(VariantNode); // llvm::MDNode *KernelMD = llvm::MDNode::get(Context, kernelMDArgs); // CilkElementalMetadata->addOperand(KernelMD); // ElementalVariantToEmit.push_back( // ElementalVariantInfo(&FnInfo, FD, Fn, KernelMD)); // } } } } }
/** * Constructs a DlgCustomToolbars which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * true to construct a modal dialog. */ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) : CustomizeActionPage(parent), type(t) { this->setupUi(this); moveActionRightButton->setIcon(BitmapFactory().pixmap(":/icons/button_right.svg")); moveActionLeftButton->setIcon(BitmapFactory().pixmap(":/icons/button_left.svg")); moveActionDownButton->setIcon(BitmapFactory().pixmap(":/icons/button_down.svg")); moveActionUpButton->setIcon(BitmapFactory().pixmap(":/icons/button_up.svg")); CommandManager & cCmdMgr = Application::Instance->commandManager(); std::map<std::string,Command*> sCommands = cCmdMgr.getCommands(); GroupMap groupMap; groupMap.push_back(std::make_pair(QLatin1String("File"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Edit"), QString())); groupMap.push_back(std::make_pair(QLatin1String("View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Standard-View"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Tools"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Window"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Help"), QString())); groupMap.push_back(std::make_pair(QLatin1String("Macros"), qApp->translate("Gui::MacroCommand", "Macros"))); for (std::map<std::string,Command*>::iterator it = sCommands.begin(); it != sCommands.end(); ++it) { QLatin1String group(it->second->getGroupName()); QString text = qApp->translate(it->second->className(), it->second->getGroupName()); GroupMap::iterator jt; jt = std::find_if(groupMap.begin(), groupMap.end(), GroupMap_find(group)); if (jt != groupMap.end()) { if (jt->second.isEmpty()) jt->second = text; } else { groupMap.push_back(std::make_pair(group, text)); } } int index = 0; for (GroupMap::iterator it = groupMap.begin(); it != groupMap.end(); ++it, ++index) { categoryBox->addItem(it->second); categoryBox->setItemData(index, QVariant(it->first), Qt::UserRole); } // fills the combo box with all available workbenches QStringList workbenches = Application::Instance->workbenches(); workbenches.sort(); index = 1; workbenchBox->addItem(QApplication::windowIcon(), tr("Global")); workbenchBox->setItemData(0, QVariant(QString::fromLatin1("Global")), Qt::UserRole); for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) { QPixmap px = Application::Instance->workbenchIcon(*it); QString mt = Application::Instance->workbenchMenuText(*it); if (mt != QLatin1String("<none>")) { if (px.isNull()) workbenchBox->addItem(mt); else workbenchBox->addItem(px, mt); workbenchBox->setItemData(index, QVariant(*it), Qt::UserRole); index++; } } QStringList labels; labels << tr("Icon") << tr("Command"); commandTreeWidget->setHeaderLabels(labels); commandTreeWidget->header()->hide(); commandTreeWidget->setIconSize(QSize(32, 32)); commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); labels.clear(); labels << tr("Command"); toolbarTreeWidget->setHeaderLabels(labels); toolbarTreeWidget->header()->hide(); on_categoryBox_activated(categoryBox->currentIndex()); Workbench* w = WorkbenchManager::instance()->active(); if (w) { QString name = QString::fromLatin1(w->name().c_str()); int index = workbenchBox->findData(name); workbenchBox->setCurrentIndex(index); } on_workbenchBox_activated(workbenchBox->currentIndex()); }