void NBMenuButton::showMenu() { setStyleSheet( "QToolButton#menuBtn{ background-color: darkgray; border: none; border-radius: 3px; }" ); NBSystemMenu *menu = new NBSystemMenu( this ); QPoint point = mapToGlobal( rect().bottomRight() - QPoint( menu->width(), 0 ) ); connect( menu, SIGNAL( newWindow() ), this, SIGNAL( newWindow() ) ); connect( menu, SIGNAL( zoomIn() ), this, SIGNAL( zoomIn() ) ); connect( menu, SIGNAL( zoomOut() ), this, SIGNAL( zoomOut() ) ); connect( menu, SIGNAL( cut() ), this, SIGNAL( cut() ) ); connect( menu, SIGNAL( copy() ), this, SIGNAL( copy() ) ); connect( menu, SIGNAL( paste() ), this, SIGNAL( paste() ) ); connect( menu, SIGNAL( openVTE() ), this, SIGNAL( openVTE() ) ); connect( menu, SIGNAL( changeViewMode( int ) ), this, SIGNAL( changeViewMode( int ) ) ); connect( menu, SIGNAL( sortByName() ), this, SIGNAL( sortByName() ) ); connect( menu, SIGNAL( sortByType() ), this, SIGNAL( sortByType() ) ); connect( menu, SIGNAL( sortBySize() ), this, SIGNAL( sortBySize() ) ); connect( menu, SIGNAL( sortByDate() ), this, SIGNAL( sortByDate() ) ); connect( menu, SIGNAL( toggleHidden() ), this, SIGNAL( toggleHidden() ) ); connect( menu, SIGNAL( toggleGrouping() ), this, SIGNAL( toggleGrouping() ) ); connect( menu, SIGNAL( showSettings() ), this, SIGNAL( showSettings() ) ); connect( menu, SIGNAL( closeWindow() ), this, SIGNAL( closeWindow() ) ); connect( menu, SIGNAL( quit() ), this, SIGNAL( quit() ) ); menu->exec( point ); setStyleSheet( "QToolButton#menuBtn{ border: none; } QToolButton#menuBtn:hover { border: none; background-color: #A1DFFF; border-radius: 3px; }" ); };
void sort() { clrscr(); puts("\t\t\t Sort Products \n\n\n"); switch(menu_sort()) { case 1: // Sort by code sortByCode(); puts("Sorted by code successfully..."); break; case 2: // Sort by name sortByName(); puts("Sorted by name successfully..."); break; case 3:// Sort by price sortByPrice(); puts("Sorted by price successfully..."); break; case 4: default: break; } getch(); }
bool sortByType (const CFile& a, const CFile& b) { if(a.Mode == b.Mode) return sortByName(a, b); else return a.Mode < b.Mode; }
void printResults(ArtistData artists[], int max, VoteCount c, FILE *out) { int j; fprintf(out, "\nNumber of voters: %d\n", c.valid + c.spoilt); fprintf(out, "Number of valid voters: %d\n", c.valid); fprintf(out, "Number of spoilt votes: %d\n", c.spoilt); sortByVote(artists, 1, MaxCandidates); fprintf(out, "\nBy Score"); fprintf(out, "\n%-15s\tScore\n\n", "Artist"); for (j = 1; j <= max; j++) { fprintf(out, "%-15s %3d\n", artists[j].name, artists[j].numVotes); } sortByName(artists, 1, MaxCandidates); fprintf(out, "\nBy Name"); fprintf(out, "\n%-15s\tScore\n\n", "Artist"); for (j = 1; j <= max; j++) { fprintf(out, "%-15s %3d\n", artists[j].name, artists[j].numVotes); } fprintf(out, "\nThe Winner(s)\n"); int win = getLargest(artists, 1, max); int winningVote = artists[win].numVotes; for (j = 1; j <= max; j++) { if (artists[j].numVotes == winningVote) { fprintf(out, "%s\n", artists[j].name); } } }
void BoardTable::sortEvent(int c) { //qDebug()<<c; //return;d if (Global::alreadyJudging) return; if (preHeaderClicked!=c) { clearHighlighted(preHeaderClicked); setHighlighted(c); } this->horizontalHeader()->setSortIndicatorShown(true); if (preHeaderClicked!=c&&c) this->horizontalHeader()->setSortIndicator(c,Qt::DescendingOrder); Global::preSortOrder=this->horizontalHeader()->sortIndicatorOrder(); if (!c) sortByName(); else if (c==1) sortBySumScore(); else sortByProblem(c-2); int k=0; for (auto&i:Global::players) { this->item(i.id,c)->setData(Qt::DisplayRole,k); i.id=Global::logicalRow(k);// k++; } this->sortByColumn(c); this->verticalScrollBar()->setValue(0); // for (int i=0; i<playerNum; i++) qDebug()<<ui->tableWidget->item(i,c)->data(Qt::DisplayRole); preHeaderClicked=c; }
void ViewTableListWidget::createRightMenuActions() { //创建右键菜单 lookupView_action = new QAction(tr("查看"),this); newview_action = new QAction(tr("新建"),this); editview_aciton = new QAction(tr("编辑"),this); sendview_action = new QAction(tr("发送"),this); deleteview_action = new QAction(tr("删除"),this); addto_action = new QAction(tr("添加到..."),this); detailinfolist_action = new QAction(tr("详细信息"),this); listmode_action = new QAction(tr("列表"),this); iconmode_action = new QAction(tr("图标"),this); sortbyname_aciton = new QAction(tr("名称"),this); sortbytype_action = new QAction(tr("类型"),this); sortbyfrequency_action = new QAction(tr("使用次数"),this); sortbymoditime_action = new QAction(tr("访问时间"),this); connect(lookupView_action,SIGNAL(triggered()),this,SLOT(lookupView())); connect(newview_action,SIGNAL(triggered()),this,SLOT(newView())); connect(editview_aciton,SIGNAL(triggered()),this,SLOT(editView())); connect(sendview_action,SIGNAL(triggered()),this,SLOT(sendView())); connect(deleteview_action,SIGNAL(triggered()),this,SLOT(deleteViewRequest())); connect(addto_action,SIGNAL(triggered()),this,SLOT(addViewTo())); connect(detailinfolist_action,SIGNAL(triggered()),this,SLOT(detailInfoPermutation())); connect(listmode_action,SIGNAL(triggered()),this,SLOT(listPermutation())); connect(iconmode_action,SIGNAL(triggered()),this,SLOT(iconPermutation())); connect(sortbyname_aciton,SIGNAL(triggered()),this,SLOT(sortByName())); connect(sortbytype_action,SIGNAL(triggered()),this,SLOT(sortByType())); connect(sortbyfrequency_action,SIGNAL(triggered()),this,SLOT(sortByFrequency())); connect(sortbymoditime_action,SIGNAL(triggered()),this,SLOT(sortByModiTime())); }
/* sort functions lexically between indices "start" and "ends" */ static void sortByName(FileInfo *data, int functionList[], int start, int ends) { int i, location = start; if (ends <= start) { return; } for (i = start; i < ends; i++) { if (compareNames(data, functionList[ends], functionList[i]) > 0) { swapArrayItems(functionList, location, i); location++; } } swapArrayItems(functionList, location, ends); sortByName(data, functionList, start, location - 1); sortByName(data, functionList, location + 1, ends); }
void ThreadList::updateSorting() { switch(sort_column) { case COL_LOCATION: sortByLocation(); break; case COL_CPUUSAGE: sortByCpuUsage(); break; case COL_TOTALCPU: sortByTotalCpuTime(); break; case COL_ID: sortByID(); break; case COL_NAME: sortByName(); break; } fillList(); }
// Sorts alphabetically with Directories first bool sortByNameDirsFirst(const CFile& a, const CFile& b) { int typea, typeb; typea = a.getType(); typeb = b.getType(); if (typea == CFile::FILE_DIR) if (typeb == CFile::FILE_DIR) //both directories return sortByName(a, b); else //only a is directory return true; else if (typeb == CFile::FILE_DIR) //only b is directory return false; else //no directory return sortByName(a, b); }
void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) { std::string filter = data.asString(); rebuildLocationHistory(filter); //Let's add landmarks to the top of the list if any if(!filter.empty() ) { LLInventoryModel::item_array_t landmark_items = LLLandmarkActions::fetchLandmarksByName(filter, TRUE); for(U32 i=0; i < landmark_items.size(); i++) { LLSD value; //TODO:: DO we need tooltip for Landmark?? value["item_type"] = LANDMARK; value["AssetUUID"] = landmark_items[i]->getAssetUUID(); add(landmark_items[i]->getName(), value); } //Let's add teleport history items LLTeleportHistory* th = LLTeleportHistory::getInstance(); LLTeleportHistory::slurl_list_t th_items = th->getItems(); std::set<std::string> new_item_titles;// duplicate control LLTeleportHistory::slurl_list_t::iterator result = std::find_if( th_items.begin(), th_items.end(), boost::bind( &LLLocationInputCtrl::findTeleportItemsByTitle, this, _1, filter)); while (result != th_items.end()) { //mTitile format - region_name[, parcel_name] //mFullTitile format - region_name[, parcel_name] (local_x,local_y, local_z) if (new_item_titles.insert(result->mFullTitle).second) { LLSD value; value["item_type"] = TELEPORT_HISTORY; value["global_pos"] = result->mGlobalPos.getValue(); std::string region_name = result->mTitle.substr(0, result->mTitle.find(',')); //TODO*: add Surl to teleportitem or parse region name from title value["tooltip"] = LLSLURL::buildSLURLfromPosGlobal(region_name, result->mGlobalPos, false); add(result->getTitle(), value); } result = std::find_if(result + 1, th_items.end(), boost::bind( &LLLocationInputCtrl::findTeleportItemsByTitle, this, _1, filter)); } } sortByName(); mList->mouseOverHighlightNthItem(-1); // Clear highlight on the last selected item. }
TEST_F(VarRenamerTests, ClashingNamesEndingWithNumberAreSuffixedWithUnderscores) { // Set-up the module. // // int a; // int b; // int c; // // void test() { // } // ShPtr<Variable> varA(Variable::create("a", IntType::create(32))); module->addGlobalVar(varA); ShPtr<Variable> varB(Variable::create("b", IntType::create(32))); module->addGlobalVar(varB); ShPtr<Variable> varC(Variable::create("c", IntType::create(32))); module->addGlobalVar(varC); // Setup the name generator so it always returns "g1". INSTANTIATE_VAR_NAME_GEN_AND_VAR_RENAMER(VarRenamerWithCreate, false); EXPECT_CALL(*varNameGenMock, getNextVarName()) .Times(3) .WillOnce(Return("g1")) .WillOnce(Return("g1")) .WillOnce(Return("g1")); // Do the renaming. varRenamer->renameVars(module); // We expect the following output: // // int g1; // int g1_; // int g1__; // // void test() { // } // VarSet globalVarsSet(module->getGlobalVars()); ASSERT_EQ(3, globalVarsSet.size()); // We have to sort the variables to ease the checking. VarVector globalVarsVector(globalVarsSet.begin(), globalVarsSet.end()); sortByName(globalVarsVector); ShPtr<Variable> var1(globalVarsVector[0]); EXPECT_EQ("g1", var1->getName()); ShPtr<Variable> var2(globalVarsVector[1]); EXPECT_EQ("g1_", var2->getName()); ShPtr<Variable> var3(globalVarsVector[2]); EXPECT_EQ("g1__", var3->getName()); }
void ChoroidTab::SetSortMenu () { auto sortGroup = new QActionGroup (this); SortMenu_ = new QMenu; auto byName = SortMenu_->addAction (tr ("By name"), this, SLOT (sortByName ())); byName->setCheckable (true); byName->setChecked (true); sortGroup->addAction (byName); auto byDate = SortMenu_->addAction (tr ("By date"), this, SLOT (sortByDate ())); byDate->setCheckable (true); sortGroup->addAction (byDate); auto bySize = SortMenu_->addAction (tr ("By size"), this, SLOT (sortBySize ())); bySize->setCheckable (true); sortGroup->addAction (bySize); auto byNumber = SortMenu_->addAction (tr ("By number"), this, SLOT (sortByNumber ())); byNumber->setCheckable (true); sortGroup->addAction (byNumber); sortByName (); auto sortModeButton = new QToolButton (); sortModeButton->setIcon (Proxy_->GetIcon ("view-sort-ascending")); sortModeButton->setText (tr ("Sort mode")); sortModeButton->setPopupMode (QToolButton::InstantPopup); sortModeButton->setMenu (SortMenu_); Bar_->addWidget (sortModeButton); }
std::vector<CArchiveScanner::ArchiveData> CArchiveScanner::GetAllArchives() const { std::vector<ArchiveData> ret; for (const auto& pair: archiveInfos) { const ArchiveData& aid = pair.second.archiveData; // Add the archive the mod is in as the first dependency ArchiveData md = aid; md.GetDependencies().insert(md.GetDependencies().begin(), pair.second.origName); ret.push_back(md); } sortByName(ret); return ret; }
std::vector<CArchiveScanner::ArchiveData> CArchiveScanner::GetPrimaryMods() const { std::vector<ArchiveData> ret; for (std::map<std::string, ArchiveInfo>::const_iterator i = archiveInfo.begin(); i != archiveInfo.end(); ++i) { if (i->second.archiveData.name != "" && i->second.archiveData.modType == modtype::primary) { // Add the archive the mod is in as the first dependency ArchiveData md = i->second.archiveData; md.dependencies.insert(md.dependencies.begin(), i->second.origName); ret.push_back(md); } } sortByName(ret); return ret; }
std::vector<CArchiveScanner::ArchiveData> CArchiveScanner::GetAllMods() const { std::vector<ArchiveData> ret; for (std::map<std::string, ArchiveInfo>::const_iterator i = archiveInfo.begin(); i != archiveInfo.end(); ++i) { if (!(i->second.archiveData.GetName().empty()) && ((i->second.archiveData.GetModType() == modtype::primary) || (i->second.archiveData.GetModType() == modtype::hidden))) { // Add the archive the mod is in as the first dependency ArchiveData md = i->second.archiveData; md.GetDependencies().insert(md.GetDependencies().begin(), i->second.origName); ret.push_back(md); } } sortByName(ret); return ret; }
Directory(const char *path) { numEntries = 0; entries = NULL; DIR *dir = opendir(path); if(dir == NULL) { // m(("Can't read dir '%s'", path)); return; } int n = 0; while(true) { if(readdir(dir) != NULL) { n++; } else { break; } } rewinddir(dir); if(n > 0) { entries = (char **)malloc(n * sizeof(const char *)); struct dirent *d; for(int i = 0; i < n; i++) { d = readdir(dir); entries[i] = (char *)malloc(strlen(d->d_name) + 1); strcpy(entries[i], d->d_name); numEntries++; } } closedir(dir); sortByName(); }
TEST_F(UnifiedVarRenamerTests, GlobalVariablesGetCorrectlyRenamed) { // Set-up the module. // // int a; // int b; // int c; // // void test() { // } // ShPtr<Variable> varA(Variable::create("a", IntType::create(32))); module->addGlobalVar(varA); ShPtr<Variable> varB(Variable::create("b", IntType::create(32))); module->addGlobalVar(varB); ShPtr<Variable> varC(Variable::create("c", IntType::create(32))); module->addGlobalVar(varC); // Setup the renamer. INSTANTIATE_VAR_NAME_GEN_AND_VAR_RENAMER(UnifiedVarRenamer, true); // Do the renaming. varRenamer->renameVars(module); // We expect the following output: // // int g1; // int g2; // int g3; // // void test() { // } // VarSet globalVarsSet(module->getGlobalVars()); ASSERT_EQ(3, globalVarsSet.size()); // We have to sort the variables to ease the checking. VarVector globalVarsVector(globalVarsSet.begin(), globalVarsSet.end()); sortByName(globalVarsVector); ShPtr<Variable> var1(globalVarsVector[0]); EXPECT_EQ("g1", var1->getName()); ShPtr<Variable> var2(globalVarsVector[1]); EXPECT_EQ("g2", var2->getName()); ShPtr<Variable> var3(globalVarsVector[2]); EXPECT_EQ("g3", var3->getName()); }
int List::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QTableView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: addChan((*reinterpret_cast< QString(*)>(_a[1]))); break; case 1: sortByName(); break; case 2: { QString* _r = parseChan((*reinterpret_cast< QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< QString**>(_a[0]) = _r; } break; case 3: clearAll(); break; default: ; } _id -= 4; } return _id; }
std::vector<CArchiveScanner::ArchiveData> CArchiveScanner::GetAllMods() const { std::vector<ArchiveData> ret; for (auto i = archiveInfos.cbegin(); i != archiveInfos.cend(); ++i) { const ArchiveData& aid = i->second.archiveData; if ((!aid.GetName().empty()) && aid.IsGame()) { // Add the archive the mod is in as the first dependency ArchiveData md = aid; md.GetDependencies().insert(md.GetDependencies().begin(), i->second.origName); ret.push_back(md); } } sortByName(ret); return ret; }
void addStruct(struct node* list){ struct node *newNode; newNode = malloc( sizeof(struct node) * 1); if (newNode == NULL) { printf("Error allocating memory...\n"); return; } char c, newName[255]; int i; printf("\n\tName: "); for ( i = 0; i < 255; i++){ c = getchar(); if (c == '\n') break; newName[i] = c; } newName[i] = '\0'; newNode->name = malloc( sizeof(char) * i+1 ); strncpy(newNode->name, newName, i+1); printf("\tAge: "); for ( i = 0; i < 3; i++ ){ c = getchar(); if (c == '\n') break; newName[i] = c; } newName[i] = '\0'; newNode->age = atoi(newName); newNode->nextName = NULL; newNode->nextAge = NULL; sortByName(list, newNode); sortByAge(list, newNode); return; }
void queryInfo() { int choice; menuQueryInfo(); printf("请输入你的选择:"); scanf("%d", &choice); switch (choice) { case 1: sortByName(); system("pause"); //system("cls"); break; case 2: sortBymanuFacturer(); system("pause"); //system("cls"); break; case 3: sortBySell(); system("pause"); //system("cls"); break; case 4: sortByresidue(); system("pause"); //system("cls"); break; case 5: sortByExpirationData(); system("pause"); //system("cls"); break; case 0: break; default: printf("输入信息有误"); break; } }
void NBFolderView::createAndSetupActions() { connect( IconView, SIGNAL( peek( QModelIndex ) ), this, SLOT( doPeek( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QModelIndex ) ), this, SLOT( doOpen( QModelIndex ) ) ); connect( IconView, SIGNAL( open( QString ) ), this, SLOT( doOpen( QString ) ) ); connect( IconView, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) ); connect( IconView, SIGNAL( actionsMenuRequested( QPoint ) ), this, SLOT( showActionsMenu( QPoint ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ) ); connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) ); connect( IconView, SIGNAL( link( QStringList, QString ) ), this, SLOT( link( QStringList, QString ) ) ); // DragDrop copy connect( IconView, SIGNAL( copy( QStringList, QString ) ), this, SLOT( copy( QStringList, QString ) ) ); // DragDrop move connect( IconView, SIGNAL( move( QStringList, QString ) ), this, SLOT( move( QStringList, QString ) ) ); // Update actions once the directory is loaded connect( fsModel, SIGNAL( directoryLoaded( QString ) ), this, SLOT( updateActions() ) ); // Peek peekAct = new QAction( QIcon( ":/icons/peek.png" ), "Pee&k", this ); peekAct->setShortcuts( Settings->shortcuts( "Peek" ) ); connect( peekAct, SIGNAL( triggered() ), this, SLOT( doPeek() ) ); addAction( peekAct ); // Home Dir actHomeDir = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actHomeDir->setShortcuts( Settings->shortcuts( "GoHome" ) ); connect( actHomeDir, SIGNAL( triggered() ), this, SLOT( loadHomeDir() ) ); addAction( actHomeDir ); // Home actGoHome = new QAction( QIcon( ":/icons/home.png" ), "&Home", this ); actGoHome->setShortcut( tr( "Alt+Shift+Home" ) ); connect( actGoHome, SIGNAL( triggered() ), this, SLOT( doOpenHome() ) ); addAction( actGoHome ); // Up actParDir = new QAction( QIcon( ":/icons/up.png" ), "&Up", this ); actParDir->setShortcuts( Settings->shortcuts( "GoUp" ) ); connect( actParDir, SIGNAL( triggered() ), fsModel, SLOT( goUp() ) ); addAction( actParDir ); // Back actPrevDir = new QAction( QIcon( ":/icons/prev.png" ), "&Back", this ); actPrevDir->setShortcuts( Settings->shortcuts( "GoLeft" ) ); connect( actPrevDir, SIGNAL( triggered() ), fsModel, SLOT( goBack() ) ); addAction( actPrevDir ); // Forward actNextDir = new QAction( QIcon( ":/icons/next.png" ), "&Forward", this ); actNextDir->setShortcuts( Settings->shortcuts( "GoRight" ) ); connect( actNextDir, SIGNAL( triggered() ), fsModel, SLOT( goForward() ) ); addAction( actNextDir ); // New Folder actNewDir = new QAction( QIcon::fromTheme( "folder-new" ), "New folder", this ); actNewDir->setShortcuts( Settings->shortcuts( "NewFolder" ) ); connect( actNewDir, SIGNAL( triggered() ), this, SLOT( newFolder() ) ); addAction( actNewDir ); // New file actNewFile = new QAction( QIcon::fromTheme( "document-new" ), "New File", this ); actNewFile->setShortcuts( Settings->shortcuts( "NewFile" ) ); connect( actNewFile, SIGNAL( triggered() ), this, SLOT( newFile() ) ); addAction( actNewFile ); // New file actNewEncFS = new QAction( QIcon::fromTheme( "document-new" ), "New Encrypted Directory", this ); actNewEncFS->setShortcuts( Settings->shortcuts( "NewEncFS" ) ); connect( actNewEncFS, SIGNAL( triggered() ), this, SLOT( createEncFS() ) ); addAction( actNewEncFS ); // Copy copyAct = new QAction( QIcon( ":/icons/copy.png" ), "&Copy", this ); copyAct->setShortcuts( Settings->shortcuts( "Copy" ) ); connect( copyAct, SIGNAL( triggered() ), this, SLOT( prepareCopy() ) ); addAction( copyAct ); // Move moveAct = new QAction( QIcon( ":/icons/cut.png" ), "Cu&t", this ); moveAct->setShortcuts( Settings->shortcuts( "Cut" ) ); connect( moveAct, SIGNAL( triggered() ), this, SLOT( prepareMove() ) ); addAction( moveAct ); // Paste pasteAct = new QAction( QIcon( ":/icons/paste.png" ), "&Paste", this ); pasteAct->setShortcuts( Settings->shortcuts( "Paste" ) ); connect( pasteAct, SIGNAL( triggered() ), this, SLOT( prepareIO() ) ); addAction( pasteAct ); // Rename renameAct = new QAction( QIcon( ":/icons/rename.png" ), "&Rename", this ); renameAct->setShortcuts( Settings->shortcuts( "Rename" ) ); connect( renameAct, SIGNAL( triggered() ), this, SLOT( doRename() ) ); addAction( renameAct ); // Reload reloadAct = new QAction( QIcon( ":/icons/reload.png" ), "Re&fresh", this ); reloadAct->setShortcuts( Settings->shortcuts( "Reload" ) ); connect( reloadAct, SIGNAL( triggered() ), this, SLOT( doReload() ) ); addAction( reloadAct ); // showDotFiles showHideDotFiles = new QAction( QIcon( ":/icons/showDotFiles.png" ), "Show &Hidden", this ); showHideDotFiles->setShortcuts( Settings->shortcuts( "ToggleHidden" ) ); connect( showHideDotFiles, SIGNAL( triggered() ), this, SLOT( doToggleHidden() ) ); addAction( showHideDotFiles ); // Trash trashAct = new QAction( QIcon( ":/icons/trash.png" ), "Move to trash", this ); trashAct->setShortcuts( Settings->shortcuts( "Trash" ) ); connect( trashAct, SIGNAL( triggered() ), this, SLOT( doSendToTrash() ) ); addAction( trashAct ); // Delete delAct = new QAction( QIcon( ":/icons/delete.png" ), "Delete", this ); delAct->setShortcuts( Settings->shortcuts( "Delete" ) ); connect( delAct, SIGNAL( triggered() ), this, SLOT( doDelete() ) ); addAction( delAct ); // Properties propertiesAct = new QAction( QIcon( ":/icons/props.png" ), "&Properties", this ); propertiesAct->setShortcuts( Settings->shortcuts( "Properties" ) ); connect( propertiesAct, SIGNAL( triggered() ), this, SIGNAL( showProperties() ) ); addAction( propertiesAct ); // Permissions permissionsAct = new QAction( QIcon::fromTheme( "system-users" ), "P&ermissions", this ); permissionsAct->setShortcuts( Settings->shortcuts( "Permissions" ) ); connect( permissionsAct, SIGNAL( triggered() ), this, SIGNAL( showPermissions() ) ); addAction( permissionsAct ); // Open a virtual terminal emulator openVTE = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE", this ); openVTE->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTE, SIGNAL( triggered() ), this, SLOT( openTerminal() ) ); addAction( openVTE ); // Open a virtual terminal emulator openVTEin = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE Here", this ); // openVTEin->setShortcuts( Settings->shortcuts( "Terminal" ) ); connect( openVTEin, SIGNAL( triggered() ), this, SLOT( openTerminalIn() ) ); // Select All QAction *selectAllAct = new QAction( "&Select All", this ); selectAllAct->setShortcuts( Settings->shortcuts( "SelectAll" ) ); connect( selectAllAct, SIGNAL( triggered() ), this, SLOT( selectAll() ) ); addAction( selectAllAct ); // Sorting sortByNameAct = new QAction( QIcon::fromTheme( "format-text-underline" ), "&Name", this ); sortByNameAct->setCheckable( true ); connect( sortByNameAct, SIGNAL( triggered() ), this, SLOT( sortByName() ) ); sortByTypeAct = new QAction( QIcon::fromTheme( "preferences-other" ), "&Type", this ); sortByTypeAct->setCheckable( true ); connect( sortByTypeAct, SIGNAL( triggered() ), this, SLOT( sortByType() ) ); sortBySizeAct = new QAction( QIcon( ":/icons/size.png" ), "&Size", this ); sortBySizeAct->setCheckable( true ); connect( sortBySizeAct, SIGNAL( triggered() ), this, SLOT( sortBySize() ) ); sortByDateAct = new QAction( QIcon::fromTheme( "office-calendar" ), "&Date", this ); sortByDateAct->setCheckable( true ); connect( sortByDateAct, SIGNAL( triggered() ), this, SLOT( sortByDate() ) ); QActionGroup *sortGroup = new QActionGroup( this ); sortGroup->addAction( sortByNameAct ); sortGroup->addAction( sortByTypeAct ); sortGroup->addAction( sortBySizeAct ); sortGroup->addAction( sortByDateAct ); switch( ( int )Settings->value( "SortColumn" ) ) { case 0: { sortByNameAct->setChecked( true ); break; } case 1: { sortBySizeAct->setChecked( true ); break; } case 2: { sortByTypeAct->setChecked( true ); break; } case 4: { sortByDateAct->setChecked( true ); break; } } groupsAct = new QAction( QIcon::fromTheme( "view-group", QIcon( ":/icons/groups.png" ) ), "Show in &Groups", this ); groupsAct->setCheckable( true ); groupsAct->setChecked( Settings->value( "Grouping" ) ); connect( groupsAct, SIGNAL( triggered() ), this, SIGNAL( toggleGroups() ) ); // Add bookmark addBookMarkAct = new QAction( QIcon( ":/icons/bookmark.png" ), "Add &Bookmark", this ); addBookMarkAct->setShortcuts( Settings->shortcuts( "AddBookmark" ) ); connect( addBookMarkAct, SIGNAL( triggered() ), this, SLOT( addBookMark() ) ); addAction( addBookMarkAct ); /* Add to SuperStart */ addToSuperStartAct = new QAction( QIcon( ":/icons/superstart.png" ), "Add to S&uperStart", this ); addToSuperStartAct->setShortcut( tr( "Ctrl+U" ) ); connect( addToSuperStartAct, SIGNAL( triggered() ), this, SLOT( addToSuperStart() ) ); addAction( addToSuperStartAct ); updateActions(); };
Monitor::Monitor(QWidget *parent) : QWidget(parent), ui(new Ui::Monitor) { qDebug("Monitor Init"); ui->setupUi(this); //Initialize the table ui->table->setColumnHidden(TASK_TIME_COL, true); ui->table->setColumnHidden(DELTA_TASK_TIME_COL, true); ui->table->setColumnWidth(STACK_HEAP_COL, 170); ui->table->setColumnWidth(PROCESS_ID_COL, 150); ui->table->setColumnWidth(THREAD_ID_COL, 145); ui->table->setColumnWidth(PRIO_COL, 145); ui->table->setColumnWidth(CPU_COL, 145); connect(&refreshTimer, SIGNAL(timeout()), this, SLOT(updateAll())); ui->killButton->setToolTip("Kill Selected User Process"); sortColumn = PROCESS_ID_COL; sortAscendingAction = new QAction( "Sort Ascending", ui->table ); sortAscendingAction->setCheckable(true); sortAscendingAction->setChecked(true); sortOrder = Qt::AscendingOrder; sortDescendingAction = new QAction( "Sort Descending", ui->table ); sortDescendingAction->setCheckable(true); sortDescendingAction->setChecked(false); QAction * separator = new QAction( "", ui->table ); separator->setSeparator(true); sortByProcessIdAction = new QAction( "Sort By Process ID", ui->table ); sortByProcessIdAction->setCheckable(true); sortByProcessIdAction->setChecked(true); sortColumn = PROCESS_ID_COL; sortByNameAction = new QAction( "Sort By Name", ui->table ); sortByNameAction->setCheckable(true); sortByCpuUsageAction = new QAction( "Sort By CPU Usage", ui->table ); sortByCpuUsageAction->setCheckable(true); sortByMemoryUsageAction = new QAction( "Sort By Allocated Memory", ui->table ); sortByMemoryUsageAction->setCheckable(true); connect( sortAscendingAction, SIGNAL( changed() ), this, SLOT( sortAscending() ) ); connect( sortDescendingAction, SIGNAL( changed() ), this, SLOT( sortDescending() ) ); connect( sortByProcessIdAction, SIGNAL( changed() ), this, SLOT( sortByProcessId() ) ); connect( sortByNameAction, SIGNAL( changed() ), this, SLOT( sortByName() ) ); connect( sortByCpuUsageAction, SIGNAL( changed() ), this, SLOT( sortByCpuUsage() ) ); connect( sortByMemoryUsageAction, SIGNAL( changed() ), this, SLOT( sortByMemoryUsage() ) ); /* ui->table->setContextMenuPolicy( Qt::ActionsContextMenu ); ui->table->addAction ( sortAscendingAction ); ui->table->addAction ( sortDescendingAction ); ui->table->addAction ( separator ); ui->table->addAction ( sortByProcessIdAction ); ui->table->addAction ( sortByNameAction ); ui->table->addAction ( sortByCpuUsageAction ); ui->table->addAction ( sortByMemoryUsageAction ); */ ui->notConnectedWidget->setObjectName("bordered"); ui->killButton->setObjectName("blueButton"); ui->killButton->setText(CFont::iconRemove()); ui->killButton->setToolTip("Kill process"); ui->continueButton->setObjectName("blueButton"); ui->continueButton->setText(CFont::iconPlay()); ui->continueButton->setToolTip("Continue process"); ui->pauseButton->setObjectName("blueButton"); ui->pauseButton->setText(CFont::iconPause()); ui->pauseButton->setToolTip("Pause process"); ui->termButton->setObjectName("blueButton"); ui->termButton->setText(CFont::iconStop()); ui->termButton->setToolTip("Terminate process"); ui->notConnectedLabel->setText(CFont::icomoon(CFont::iconInfoSign()) + " Not Connected"); ui->notConnectedLabel->setObjectName("acceptLabel"); ui->notConnectedLabel->setEnabled(false); ui->notConnectedWidget->setVisible(false); qDebug("Monitor Init Complete"); }
/* main functions that takes a parsed FileInfo from vtk and produces a * specific vtkXML format for desired functions to be incorporated in SimVTK * (ie. certain add, remove, get and set methods). */ void vtkParseOutput(FILE *fp, FileInfo *data) { /* store the last element index of the add, set, remove, get arrays so * easier when checking for stopping to compare values. setForInputOnly * is used to check if any set methods were used for parameters and not * just promoted inputs. indentation is to make sure that the XML format * is proper. */ int i; int endOfAddFunctions = -1; int endOfSetFunctions = -1; int endOfRemoveFunctions = -1; int endOfGetFunctions = -1; int endOfGetOnlyFunctions = -1; int endOfSetOnlyFunctions = -1; int endOfGetAndSetFunctions = -1; int endOfProtectedFunctions = -1; int indentation = 0; int designator; /* array to store indices of the data->Functions array that are * functions starting with "Add" */ int addFunctions[MAX_ARRAY_SIZE]; int setFunctions[MAX_ARRAY_SIZE]; int removeFunctions[MAX_ARRAY_SIZE]; int getFunctions[MAX_ARRAY_SIZE]; int setOnlyFunctions[MAX_ARRAY_SIZE]; int getOnlyFunctions[MAX_ARRAY_SIZE]; int getAndSetFunctions[MAX_ARRAY_SIZE]; int protectedFunctions[MAX_ARRAY_SIZE]; /* separate functions into functions beginning with "Add", "Remove", * "Set", and "Get" here */ separateFunctions(fp, data, addFunctions, &endOfAddFunctions, removeFunctions, &endOfRemoveFunctions, setFunctions, &endOfSetFunctions, getFunctions, &endOfGetFunctions, protectedFunctions, &endOfProtectedFunctions); /* categorize the Set/Get functions as follows: values with "Set" * only, values with "Get" only, and values with "Set" and "Get". */ categorizeSetGetFunctions(fp, data, getFunctions, &endOfGetFunctions, setFunctions, &endOfSetFunctions, setOnlyFunctions, &endOfSetOnlyFunctions, getOnlyFunctions, &endOfGetOnlyFunctions, getAndSetFunctions, &endOfGetAndSetFunctions); /* take only methods with both an add and remove method and place * in 'add' array. */ checkMatchBetweenAddAndRemoveList(fp, data, removeFunctions, &endOfRemoveFunctions, 6, addFunctions, &endOfAddFunctions, 3); /* remove all unwanted functions from the list (ie. those that may have * gotten by with duplicate names or those that have mixed arguments that * aren't indexed type) */ removeBadFunctions(data, setOnlyFunctions, &endOfSetOnlyFunctions); removeBadFunctions(data, getAndSetFunctions, &endOfGetAndSetFunctions); removeDuplicateFunctions(data, setOnlyFunctions, &endOfSetOnlyFunctions); removeDuplicateFunctions(data, getOnlyFunctions, &endOfGetOnlyFunctions); removeDuplicateFunctions(data, getAndSetFunctions, &endOfGetAndSetFunctions); /* for (i = 0; i < endOfGetAndSetFunctions; i++) { printf("%s after\n", data->Functions[getAndSetFunctions[i]].Name); } printf("%i = setOnly\n", endOfSetOnlyFunctions); printf("%i = getOnly\n", endOfGetOnlyFunctions); printf("%i = setget\n", endOfGetAndSetFunctions); */ /* sort function index lists based on alphabetical order of corresponding * function name in data */ sortByName(data, addFunctions, 0, endOfAddFunctions); sortByName(data, setOnlyFunctions, 0, endOfSetOnlyFunctions); sortByName(data, getOnlyFunctions, 0, endOfGetOnlyFunctions); sortByName(data, getAndSetFunctions, 0, endOfGetAndSetFunctions); sortByName(data, protectedFunctions, 0, endOfProtectedFunctions); /* get Functions starting with "Get" that have no * corresponding "Set" function to be used as promoters. */ getPromotedOutputs(fp, data, getFunctions, &endOfGetFunctions, getAndSetFunctions, &endOfGetAndSetFunctions); /* start new XML filter section for class */ indent(fp, indentation); fprintf(fp, "<Filter>\n"); indentation++; /* write the header of the file */ indent(fp, indentation); fprintf(fp, "<Filter_Name>%s</Filter_Name>\n", data->ClassName); indent(fp, indentation); fprintf(fp, "<Filter_Abstract_Flag>%i</Filter_Abstract_Flag>\n", data->IsAbstract); if (data->NumberOfSuperClasses > 0) { indent(fp, indentation); fprintf(fp, "<Super_Class>%s</Super_Class>\n", data->SuperClasses[0]); } /* print the documentation */ ClassDocumentation(fp, data, indentation); /* function handling code * First one is to list all inputs that come from the add, * remove functions.*/ for (i = 0; i <= endOfAddFunctions; i++) { InputFunctions(fp, &data->Functions[addFunctions[i]], indentation); } /* for addinng all the set functions that take vtkObjects as arguments, * which have been promoted to inputs */ for (i = 0; i <= endOfGetAndSetFunctions; i++) { InputFunctions(fp, &data->Functions[getAndSetFunctions[i]], indentation); } for (i = 0; i <= endOfSetOnlyFunctions; i++) { InputFunctions(fp, &data->Functions[setOnlyFunctions[i]], indentation); } /* All inputs should be added now, so only need to add parameters */ /* add all parameters to the XML file */ indent(fp, indentation); fprintf(fp, "<Filter_Parameters>\n"); indentation++; for (i = 0; i <= endOfSetOnlyFunctions; i++) { /* used to know what Parameter_Tag to print, 0 will be for Set only */ designator = 0; ParameterFunctions(fp, &data->Functions[setOnlyFunctions[i]], indentation, designator); } for (i = 0; i <= endOfGetOnlyFunctions; i++) { /* used to know what Parameter_Tag to print, 1 will be for Get only */ designator = 1; ParameterFunctions(fp, &data->Functions[getOnlyFunctions[i]], indentation, designator); } for (i = 0; i <= endOfGetAndSetFunctions; i++) { /* used to know what Parameter_Tag to print, 2 will be for Both */ designator = 2; ParameterFunctions(fp, &data->Functions[getAndSetFunctions[i]], indentation, designator); } indentation--; indent(fp, indentation); fprintf(fp, "</Filter_Parameters>\n"); sortByName(data, getFunctions, 0, endOfGetFunctions); /* print all promoted outputs in alphabetical order. */ for (i = 0; i <= endOfGetFunctions; i++) { PrintOutput(fp, data->Functions[getFunctions[i]].Name+3, data->Functions[getFunctions[i]].ReturnClass, indentation); } /* print a list of all protected functions. Only need to list the name * as will only be used to check against to make sure not to add if is * found in parent class */ for (i = 0; i <= endOfProtectedFunctions; i++) { PrintProtectedFunctions(fp, data->Functions[protectedFunctions[i]].Name, indentation); } /* PrintOutput(fp, "Self", data->ClassName, indentation); */ indentation--; indent(fp, indentation); fprintf(fp, "</Filter>\n"); }
TEST_F(UnifiedVarRenamerTests, WhenUseDebugNamesIsFalseDoNotUseDebugNames) { // Set-up the module. // // int g; // from debug info // int h; // // void test(int p, int m) { // p has name from debug info // int a; // int b; // from debug info // } // ShPtr<Variable> varG(Variable::create("g", IntType::create(32))); module->addGlobalVar(varG); module->addDebugNameForVar(varG, varG->getName()); ShPtr<Variable> varH(Variable::create("h", IntType::create(32))); module->addGlobalVar(varH); ShPtr<Variable> varP(Variable::create("p", IntType::create(32))); testFunc->addParam(varP); module->addDebugNameForVar(varP, varP->getName()); ShPtr<Variable> varM(Variable::create("m", IntType::create(32))); testFunc->addParam(varM); ShPtr<Variable> varA(Variable::create("a", IntType::create(32))); testFunc->addLocalVar(varA); ShPtr<Variable> varB(Variable::create("b", IntType::create(32))); testFunc->addLocalVar(varB); module->addDebugNameForVar(varB, varB->getName()); ShPtr<VarDefStmt> varDefB(VarDefStmt::create(varB)); ShPtr<VarDefStmt> varDefA(VarDefStmt::create(varA, ShPtr<Expression>(), varDefB)); testFunc->setBody(varDefA); // Setup the renamer (do not use debug names). INSTANTIATE_VAR_NAME_GEN_AND_VAR_RENAMER(UnifiedVarRenamer, false); // Do the renaming. varRenamer->renameVars(module); // We expect the following output: // // int g1; // int g2; // // void test(int a1, int a2) { // int v1; // int v2; // } // // Globals: VarSet globalVarsSet(module->getGlobalVars()); ASSERT_EQ(2, globalVarsSet.size()); // We have to sort the variables to ease the checking. VarVector globalVarsVector(globalVarsSet.begin(), globalVarsSet.end()); sortByName(globalVarsVector); ShPtr<Variable> var1(globalVarsVector[0]); EXPECT_EQ("g1", var1->getName()); ShPtr<Variable> var2(globalVarsVector[1]); EXPECT_EQ("g2", var2->getName()); // Parameters: VarVector params(testFunc->getParams()); ASSERT_EQ(2, params.size()); ShPtr<Variable> par1(params.front()); EXPECT_EQ("a1", par1->getName()); ShPtr<Variable> par2(params.back()); EXPECT_EQ("a2", par2->getName()); // Locals: EXPECT_EQ("v1", varDefA->getVar()->getName()); EXPECT_EQ("v2", varDefB->getVar()->getName()); }
void LLGestureComboList::refreshGestures() { //store current selection so we can maintain it LLSD cur_gesture = getValue(); mList->selectFirstItem(); mList->clearRows(); mGestures.clear(); LLGestureMgr::item_map_t::const_iterator it; const LLGestureMgr::item_map_t& active_gestures = LLGestureMgr::instance().getActiveGestures(); LLSD::Integer idx(0); for (it = active_gestures.begin(); it != active_gestures.end(); ++it) { LLMultiGesture* gesture = (*it).second; if (gesture) { mList->addSimpleElement(gesture->mName, ADD_BOTTOM, LLSD(idx)); mGestures.push_back(gesture); idx++; } } sortByName(); // store indices for Get More and View All items (idx is the index followed by the last added Gesture) if (mShowGetMore) { mGetMoreItemIndex = idx; mList->addSimpleElement(LLTrans::getString("GetMoreGestures"), ADD_BOTTOM, LLSD(mGetMoreItemIndex)); } if (mShowViewAll) { mViewAllItemIndex = idx + 1; mList->addSimpleElement(LLTrans::getString("ViewAllGestures"), ADD_BOTTOM, LLSD(mViewAllItemIndex)); } // Insert label after sorting, at top, with separator below it mList->addSeparator(ADD_TOP); mList->addSimpleElement(mLabel, ADD_TOP); if (cur_gesture.isDefined()) { mList->selectByValue(cur_gesture); } else { mList->selectFirstItem(); } LLCtrlListInterface* gestures = getListInterface(); LLMultiGesture* gesture = NULL; if (gestures) { S32 sel_index = gestures->getFirstSelectedIndex(); if (sel_index != 0) { S32 index = gestures->getSelectedValue().asInteger(); if (index<0 || index >= (S32)mGestures.size()) { llwarns << "out of range gesture access" << llendl; } else { gesture = mGestures.at(index); } } } if(gesture && LLGestureMgr::instance().isGesturePlaying(gesture)) { return; } mButton->setLabel(mLabel); }