/** * Steps when uncontended: * 1. Publish request to dequeue in dequeuers[tid]; * 2. CAS node->deqTid from IDX_START to tid; * 3. Set dequeuers[tid] to the newly owned node; * 4. Advance the head with casHead(); * * We must protect either head or tail with HP before doing the check for * empty queue, otherwise we may get into retired-deleted-newed-reenqueued. * * @param tid: The tid must be a UNIQUE index for each thread, in the range 0 to maxThreads-1 */ T* dequeue(const int tid) { Node* prReq = deqself[tid].load(); // Previous request Node* myReq = deqhelp[tid].load(); deqself[tid].store(myReq); // Step 1 for (int i=0; i < maxThreads; i++) { if (deqhelp[tid].load() != myReq) break; // No need for HP Node* lhead = hp.protectPtr(kHpHead, head.load(), tid); if (lhead != head.load()) continue; if (lhead == tail.load()) { // Give up deqself[tid].store(prReq); // Rollback request to dequeue giveUp(myReq, tid); if (deqhelp[tid].load() != myReq) { deqself[tid].store(myReq, std::memory_order_relaxed); break; } hp.clear(tid); return nullptr; } Node* lnext = hp.protectPtr(kHpNext, lhead->next.load(), tid); if (lhead != head.load()) continue; if (searchNext(lhead, lnext) != IDX_NONE) casDeqAndHead(lhead, lnext, tid); } Node* myNode = deqhelp[tid].load(); Node* lhead = hp.protectPtr(kHpHead, head.load(), tid); // Do step 4 if needed if (lhead == head.load() && myNode == lhead->next.load()) head.compare_exchange_strong(lhead, myNode); hp.clear(tid); hp.retire(prReq, tid); return myNode->item; }
toTextView::toTextView(QWidget *parent /* = 0*/, const char *name /* = 0*/) : QWidget(parent) , toEditWidget() { if (name) setObjectName(name); toEditWidget::FlagSet.Save = true; toEditWidget::FlagSet.Paste = true; toEditWidget::FlagSet.SelectAll = true; toEditWidget::FlagSet.SelectBlock = true; m_view = new QTextBrowser(this); m_view->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_search = new toSearchReplace(this); m_search->SearchMode->hide(); QVBoxLayout *l = new QVBoxLayout(); l->setSpacing(0); l->setContentsMargins(0, 0, 0, 0); l->addWidget(m_view); l->addWidget(m_search); setLayout(l); connect(m_search, SIGNAL(searchNext(Search::SearchFlags)), this, SLOT(handleSearching(Search::SearchFlags))); connect(m_search, SIGNAL(windowClosed()), this, SLOT(setEditorFocus())); }
void TraceLoader::search(const ApiTrace::SearchRequest &request) { if (request.direction == ApiTrace::SearchRequest::Next) { searchNext(request); } else { searchPrev(request); } }
/** * Called only from dequeue() * * Giveup procedure, for when there are no nodes left to dequeue */ void giveUp(Node* myReq, const int tid) { Node* lhead = head.load(); if (deqhelp[tid].load() != myReq || lhead == tail.load()) return; hp.protectPtr(kHpHead, lhead, tid); if (lhead != head.load()) return; Node* lnext = hp.protectPtr(kHpNext, lhead->next.load(), tid); if (lhead != head.load()) return; if (searchNext(lhead, lnext) == IDX_NONE) lnext->casDeqTid(IDX_NONE, tid); casDeqAndHead(lhead, lnext, tid); }
void LineEditHistory::keyPressEvent( QKeyEvent *e ) { switch( e->key() ) { case Qt::Key_Up: emit invalidate(); if ( !history.isEmpty() ) { if ( currentHistoryIndex < history.size() ) currentHistoryIndex++; if ( currentHistoryIndex == history.size() ) clear(); else setText( history[currentHistoryIndex] ); } break; case Qt::Key_Down: emit invalidate(); if ( !history.isEmpty() ) { if ( currentHistoryIndex > 0 ) currentHistoryIndex--; setText( history[currentHistoryIndex] ); } break; case Qt::Key_Escape: emit invalidate(); clear(); break; case Qt::Key_Control: break; case Qt::Key_N: if( e->modifiers() & Qt::ControlModifier ) { emit searchNext(); break; } case Qt::Key_P: if( e->modifiers() & Qt::ControlModifier ) { emit searchPrev(); break; } case Qt::Key_T: if( e->modifiers() & Qt::ControlModifier ) { emit requestVisibleSymbols(); complete(); break; } default: emit invalidate(); QLineEdit::keyPressEvent( e ); } }
void DirBrowser::returnPressedInSearch() { if (ui->propsCMB->isEnabled()) { serverSearch(); } else { QString text = ui->searchCMB->lineEdit()->text(); if (ui->searchCMB->findText(text)) ui->searchCMB->insertItem(0, text); searchNext(); } }
void toSearchReplace::act_replaceAll(void) { QString t(ReplacementText->currentText()); if (t.length() > 0 && ReplacementText->findText(t) == -1) ReplacementText->addItem(t); if (SearchText->currentText().length()) { Search::SearchFlags f = Search::ReplaceAll | Search::Forward | sharedFlags(); emit searchNext(f); } }
UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui(new Ui::UserManual) { ui->setupUi(this); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(closeKey, SIGNAL(activated()), this, SLOT(close())); QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); QAction *actionShowSearch = new QAction(this); actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F); actionShowSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionShowSearch); QAction *actionHideSearch = new QAction(this); actionHideSearch->setShortcut(Qt::Key_Escape); actionHideSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionHideSearch); setWindowTitle(tr("User Manual")); ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath.size()) { // look for localized versions of the manual first QString lang = uiLanguage(NULL); QString prefix = searchPath.append("/user-manual"); QFile manual(prefix + "_" + lang + ".html"); if (!manual.exists()) manual.setFileName(prefix + "_" + lang.left(2) + ".html"); if (!manual.exists()) manual.setFileName(prefix + ".html"); if (!manual.exists()) { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } else { QString urlString = QString("file:///") + manual.fileName(); QUrl url(urlString, QUrl::TolerantMode); ui->webView->setUrl(url); } } else { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } ui->searchPanel->setParent(this); ui->searchPanel->hide(); connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel())); connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel())); connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext())); connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev())); }
void toSearchReplace::act_searchPrevious(void) { QString t(SearchText->currentText()); if (t.length() > 0 && SearchText->findText(t) == -1) SearchText->addItem(t); if (t.length()) { Search::SearchFlags f = Search::Search | Search::Backward | sharedFlags(); emit searchNext(f); } }
ConsoleWidget::ConsoleWidget(IPluginManager *APluginManager, QWidget *AParent) : QWidget(AParent) { REPORT_VIEW; ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose,true); IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_CONSOLE,0,0,"windowIcon"); FXmppStreams = NULL; FStanzaProcessor = NULL; FSearchMoveCursor = false; ui.cmbStreamJid->addItem(tr("<All Streams>")); initialize(APluginManager); if (!Options::isNull()) onOptionsOpened(); ui.cmbCondition->view()->setTextElideMode(Qt::ElideNone); QPalette palette = ui.tbrConsole->palette(); palette.setColor(QPalette::Inactive,QPalette::Highlight,palette.color(QPalette::Active,QPalette::Highlight)); palette.setColor(QPalette::Inactive,QPalette::HighlightedText,palette.color(QPalette::Active,QPalette::HighlightedText)); ui.tbrConsole->setPalette(palette); FTextHilightTimer.setSingleShot(true); connect(&FTextHilightTimer,SIGNAL(timeout()),SLOT(onTextHilightTimerTimeout())); connect(ui.tbrConsole,SIGNAL(visiblePositionBoundaryChanged()),SLOT(onTextVisiblePositionBoundaryChanged())); ui.lneTextSearch->setPlaceholderText(tr("Search")); ui.tlbTextSearchNext->setIcon(style()->standardIcon(QStyle::SP_ArrowDown, NULL, this)); ui.tlbTextSearchPrev->setIcon(style()->standardIcon(QStyle::SP_ArrowUp, NULL, this)); connect(ui.tlbTextSearchNext,SIGNAL(clicked()),SLOT(onTextSearchNextClicked())); connect(ui.tlbTextSearchPrev,SIGNAL(clicked()),SLOT(onTextSearchPreviousClicked())); connect(ui.lneTextSearch,SIGNAL(searchStart()),SLOT(onTextSearchStart())); connect(ui.lneTextSearch,SIGNAL(searchNext()),SLOT(onTextSearchNextClicked())); connect(ui.lneTextSearch,SIGNAL(textChanged(const QString &)),SLOT(onTextSearchTextChanged(const QString &))); connect(ui.tlbAddCondition,SIGNAL(clicked()),SLOT(onAddConditionClicked())); connect(ui.tlbRemoveCondition,SIGNAL(clicked()),SLOT(onRemoveConditionClicked())); connect(ui.tlbClearCondition,SIGNAL(clicked()),ui.ltwConditions,SLOT(clear())); connect(ui.cmbCondition->lineEdit(),SIGNAL(returnPressed()),SLOT(onAddConditionClicked())); connect(ui.tlbAddContext,SIGNAL(clicked()),SLOT(onAddContextClicked())); connect(ui.tlbRemoveContext,SIGNAL(clicked()),SLOT(onRemoveContextClicked())); connect(ui.cmbContext,SIGNAL(currentIndexChanged(int)),SLOT(onContextChanged(int))); connect(ui.tlbSendXML,SIGNAL(clicked()),SLOT(onSendXMLClicked())); connect(ui.tlbClearConsole,SIGNAL(clicked()),ui.tbrConsole,SLOT(clear())); connect(ui.tlbClearConsole,SIGNAL(clicked()),SLOT(onTextSearchStart())); connect(ui.chbWordWrap,SIGNAL(toggled(bool)),SLOT(onWordWrapButtonToggled(bool))); }
POSITION ZComputer::calculateStep(int player) { if (player != PLAYER_BLACK && player != PLAYER_RED) return INVALID_POSITION; // copyBoard(); bestValue = -100000; bestMove = INVALID_POSITION; currentDepth = 0; searchNext(); // return the first position searched. return searchStack[0]; }
void QuickFindMux::registerSearchable( QObject* searchable ) { LOG(logDEBUG) << "QuickFindMux::registerSearchable"; // The searchable can change our qf pattern connect( searchable, SIGNAL( changeQuickFind( const QString&, QuickFindMux::QFDirection ) ), this, SLOT( changeQuickFind( const QString&, QuickFindMux::QFDirection ) ) ); // Send us notifications connect( searchable, SIGNAL( notifyQuickFind( const QFNotification& ) ), this, SIGNAL( notify( const QFNotification& ) ) ); // And clear them connect( searchable, SIGNAL( clearQuickFindNotification() ), this, SIGNAL( clearNotification() ) ); // Search can be initiated by the view itself connect( searchable, SIGNAL( searchNext() ), this, SLOT( searchNext() ) ); connect( searchable, SIGNAL( searchPrevious() ), this, SLOT( searchPrevious() ) ); registeredSearchables_.push_back( searchable ); }
void QuickFindMux::confirmPattern( const QString& new_pattern, bool ignore_case ) { static std::shared_ptr<Configuration> config = Persistent<Configuration>( "settings" ); pattern_->changeSearchPattern( new_pattern, ignore_case ); // if non-incremental, we perform the search now if ( ! config->isQuickfindIncremental() ) { searchNext(); } else { if ( auto searchable = getSearchableWidget() ) searchable->incrementalSearchStop(); } }
void QsvTextOperationsWidget::initSearchWidget() { m_search = new QWidget( (QWidget*) parent() ); m_search->setObjectName("m_search"); searchFormUi = new Ui::searchForm(); searchFormUi->setupUi(m_search); searchFormUi->searchText->setFont( m_search->parentWidget()->font() ); if (searchFormUi->frame->style()->inherits("QWindowsStyle")) searchFormUi->frame->setFrameStyle(QFrame::StyledPanel); // otherwise it inherits the default font from the editor - fixed m_search->setFont(QApplication::font()); m_search->adjustSize(); m_search->hide(); connect(searchFormUi->searchText,SIGNAL(textChanged(QString)),this,SLOT(on_searchText_modified(QString))); connect(searchFormUi->nextButton,SIGNAL(clicked()),this,SLOT(searchNext())); connect(searchFormUi->previousButton,SIGNAL(clicked()),this,SLOT(searchPrev())); connect(searchFormUi->closeButton,SIGNAL(clicked()),this, SLOT(showSearch())); }
void ZComputer::searchNext() { if (currentDepth == searchDepth) { int advantage = calculateAdvantage(); if (advantage > bestValue) { bestValue = advantage; bestMove = searchStack[0]; } return; } if (currentDepth > searchDepth) return; POSITION movables[MAX_MOVABLE]; for (int index = 0; index < MAN_COUNT; index ++) { CHESS* pChessman = chessModel->chessAt(chessModel->currentPlayer() * MAN_COUNT + index); if (CHESS_DEAD(*pChessman)) continue; chessModel->getPossibleMoves(pChessman, movables); for (int s = 0; s < MAX_MOVABLE; s++) { // No more possible steps. if (movables[s] == 0x8080) break; int x = POSITION_X(movables[s]); int y = POSITION_Y((movables[s])); searchStack[currentDepth] = COMBINE_POSITION(CHESS_INDEX(*pChessman), x, y, CHESS_INDEX(* chessModel->chessAt(x, y))); if (chessModel->move(pChessman, x, y)) { currentDepth ++; searchNext(); currentDepth --; chessModel->backStep(); } } } }
void RealTimeTableVisualization::searchPrevious(QString str) { QList<QTableWidgetItem*> items = viewer->findItems(str, Qt::MatchContains | Qt::MatchCaseSensitive); if(items.size() == 0) return; if(!items[itemSearchedIndex]->isSelected()) { viewer->setCurrentItem(items[itemSearchedIndex]); //items[itemSearchedIndex]->setSelected(true); } else { if(itemSearchedIndex - 1 >= 0) { itemSearchedIndex --; searchNext(str); } } }
UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui(new Ui::UserManual) { ui->setupUi(this); QAction *actionShowSearch = new QAction(this); actionShowSearch->setShortcut(Qt::CTRL + Qt::Key_F); actionShowSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionShowSearch); QAction *actionHideSearch = new QAction(this); actionHideSearch->setShortcut(Qt::Key_Escape); actionHideSearch->setShortcutContext(Qt::WindowShortcut); addAction(actionHideSearch); setWindowTitle(tr("User Manual")); ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath != "") { QUrl url(searchPath.append("/user-manual.html")); ui->webView->setUrl(url); } else { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); } ui->searchPanel->setParent(this); ui->searchPanel->hide(); connect(actionShowSearch, SIGNAL(triggered(bool)), this, SLOT(showSearchPanel())); connect(actionHideSearch, SIGNAL(triggered(bool)), this, SLOT(hideSearchPanel())); connect(ui->webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl))); connect(ui->searchEdit, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); connect(ui->findNext, SIGNAL(clicked()), this, SLOT(searchNext())); connect(ui->findPrev, SIGNAL(clicked()), this, SLOT(searchPrev())); }
bool QsvTextOperationsWidget::eventFilter(QObject *obj, QEvent *event) { if (obj != parent()) return false; if (event->type() != QEvent::KeyPress) return false; QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); switch (keyEvent->key()){ case Qt::Key_Escape: if (m_search && m_search->isVisible()){ showSearch(); return true; } else if (m_replace && m_replace->isVisible()){ showReplace(); return true; }/* else if (m_gotoLine && m_gotoLine->isVisible()) { showGotoLine(); return true; }*/ break; case Qt::Key_Enter: case Qt::Key_Return: if (m_search && m_search->isVisible()){ if (keyEvent->modifiers().testFlag(Qt::ControlModifier) || keyEvent->modifiers().testFlag(Qt::AltModifier) || keyEvent->modifiers().testFlag(Qt::ShiftModifier) ) searchPrev(); else searchNext(); return true; } else if (m_replace && m_replace->isVisible()){ if (keyEvent->modifiers().testFlag(Qt::ControlModifier) || keyEvent->modifiers().testFlag(Qt::AltModifier) || keyEvent->modifiers().testFlag(Qt::ShiftModifier) ) on_replaceAll_clicked(); else on_replaceOldText_returnPressed(); return true; } // TODO replace, goto line break; case Qt::Key_Tab: case Qt::Key_Backtab: if (m_replace && m_replace->isVisible()){ /* // TODO - no cycle yet. if (Qt::Key_Tab == keyEvent->key()) m_replace->focusWidget()->nextInFocusChain()->setFocus(); else m_replace->focusWidget()->previousInFocusChain()->setFocus(); */ // Instead - cycle between those two input lines. IMHO good enough if (replaceFormUi->replaceText->hasFocus()){ replaceFormUi->findText->setFocus(); replaceFormUi->findText->selectAll(); } else{ replaceFormUi->replaceText->setFocus(); replaceFormUi->replaceText->selectAll(); } return true; } break; } return false; }
DirBrowser::DirBrowser(QWidget *parent, Playlist *pl) : QWidget(parent), ui(new Ui::DirBrowser), m_pl(pl), m_insertactive(false) { QKeySequence seq; QShortcut *sc; ui->setupUi(this); ui->searchFrame->hide(); ui->tabs->setTabsClosable(true); QToolButton *plusbut = new QToolButton(this); QString icon_path = Helper::getIconPath(); QIcon icon = QIcon(icon_path + "/addtab.png"); plusbut->setIcon(icon); ui->tabs->setCornerWidget(plusbut, Qt::TopRightCorner); plusbut->setCursor(Qt::ArrowCursor); plusbut->setAutoRaise(true); plusbut->setToolTip(tr("Add tab")); connect(plusbut, SIGNAL(clicked()), this, SLOT(addTab())); seq = QKeySequence("Ctrl+t"); sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT(addTab())); seq = QKeySequence("Ctrl+w"); sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT(closeCurrentTab())); connect(ui->tabs, SIGNAL(currentChanged(int)), this, SLOT(onCurrentTabChanged(int))); connect(ui->tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); icon = QIcon(icon_path + "/cross.png"); ui->closeSearchTB->setIcon(icon); connect(ui->closeSearchTB, SIGNAL(clicked()), this, SLOT(closeSearchPanel())); seq = QKeySequence("Ctrl+f"); sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT(openSearchPanel())); seq = QKeySequence("/"); sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT(openSearchPanel())); seq = QKeySequence("Esc"); sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), this, SLOT(closeSearchPanel())); seq = QKeySequence(Qt::Key_F3); sc = new QShortcut(seq, this); connect(sc, SIGNAL(activated()), this, SLOT(searchNext())); seq = QKeySequence(Qt::SHIFT + Qt::Key_F3); sc = new QShortcut(seq, this); connect(sc, SIGNAL(activated()), this, SLOT(searchPrev())); connect(ui->searchCMB->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(onSearchTextChanged(const QString&))); connect(ui->nextTB, SIGNAL(clicked()), this, SLOT(searchNext())); connect(ui->prevTB, SIGNAL(clicked()), this, SLOT(searchPrev())); connect(ui->searchCMB->lineEdit(), SIGNAL(returnPressed()), this, SLOT(returnPressedInSearch())); seq = QKeySequence("Ctrl+s"); sc = new QShortcut(seq, this); connect(sc, SIGNAL(activated()), this, SLOT(toggleSearchKind())); connect(ui->serverSearchCB, SIGNAL(stateChanged(int)), this, SLOT(onSearchKindChanged(int))); connect(ui->execSearchPB, SIGNAL(clicked()), this, SLOT(serverSearch())); onSearchKindChanged(int(ui->serverSearchCB->checkState())); ui->execSearchPB->hide(); setPlaylist(pl); }
TailoringWindow::TailoringWindow(struct xccdf_policy* policy, struct xccdf_benchmark* benchmark, bool newProfile, MainWindow* parent): QMainWindow(parent), mParentMainWindow(parent), mQSettings(new QSettings(this)), mSynchronizeItemLock(0), mItemPropertiesDockWidget(new XCCDFItemPropertiesDockWidget(this)), mProfilePropertiesDockWidget(new ProfilePropertiesDockWidget(this, this)), mUndoViewDockWidget(new QDockWidget(this)), mSearchBox(new QLineEdit()), mSearchButton(new QPushButton("Search")), mPolicy(policy), mProfile(xccdf_policy_get_profile(policy)), mBenchmark(benchmark), mUndoStack(this), mNewProfile(newProfile), mChangesConfirmed(false), mSearchSkippedItems(0), mSearchCurrentNeedle("") { // sanity check if (!mPolicy) throw TailoringWindowException("TailoringWindow needs a proper policy " "being given. NULL was given instead!"); if (!mProfile) throw TailoringWindowException("TailoringWindow was given a non-NULL " "policy but profile associated with it is NULL. Can't proceed!"); if (!mBenchmark) throw TailoringWindowException("TailoringWindow was given a NULL " "benchmark. Can't proceed!"); mUI.setupUi(this); QObject::connect( mUI.confirmButton, SIGNAL(released()), this, SLOT(confirmAndClose()) ); QObject::connect( mUI.cancelButton, SIGNAL(released()), this, SLOT(close()) ); QObject::connect( mUI.deleteProfileButton, SIGNAL(released()), this, SLOT(deleteProfileAndDiscard()) ); addDockWidget(Qt::RightDockWidgetArea, mItemPropertiesDockWidget); addDockWidget(Qt::RightDockWidgetArea, mProfilePropertiesDockWidget); { QAction* undoAction = mUndoStack.createUndoAction(this, QObject::tr("Undo")); undoAction->setIcon(getShareIcon("edit-undo.png")); QAction* redoAction = mUndoStack.createRedoAction(this, QObject::tr("Redo")); redoAction->setIcon(getShareIcon("edit-redo.png")); mUI.toolBar->addAction(undoAction); mUI.toolBar->addAction(redoAction); } // Column 1 is for search keywords mUI.itemsTree->setColumnHidden(1, true); QObject::connect( mUI.itemsTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(itemSelectionChanged(QTreeWidgetItem*, QTreeWidgetItem*)) ); QObject::connect( mUI.itemsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(itemChanged(QTreeWidgetItem*, int)) ); QObject::connect( mUI.itemsTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(itemExpanded(QTreeWidgetItem*)) ); QObject::connect( mUI.itemsTree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(itemCollapsed(QTreeWidgetItem*)) ); QTreeWidgetItem* benchmarkItem = new QTreeWidgetItem(); // benchmark can't be unselected benchmarkItem->setFlags( Qt::ItemIsSelectable | /*Qt::ItemIsUserCheckable |*/ Qt::ItemIsEnabled); mUI.itemsTree->addTopLevelItem(benchmarkItem); synchronizeTreeItem(benchmarkItem, xccdf_benchmark_to_item(mBenchmark), true); _refreshXCCDFItemChildrenDisabledState(benchmarkItem, true); mUI.itemsTree->header()->setResizeMode(0, QHeaderView::ResizeToContents); mUI.itemsTree->header()->setStretchLastSection(false); deserializeCollapsedItems(); syncCollapsedItems(); setWindowTitle(QObject::tr("Tailoring \"%1\"").arg(oscapTextIteratorGetPreferred(xccdf_profile_get_title(mProfile)))); mItemPropertiesDockWidget->refresh(); mProfilePropertiesDockWidget->refresh(); { mUndoViewDockWidget->setWindowTitle(QObject::tr("Undo History")); mUndoViewDockWidget->setWidget(new QUndoView(&mUndoStack, mUndoViewDockWidget)); addDockWidget(Qt::RightDockWidgetArea, mUndoViewDockWidget); mUndoViewDockWidget->hide(); mUI.toolBar->addAction(mUndoViewDockWidget->toggleViewAction()); } mUI.toolBar->addSeparator(); { QAction* action = new QAction(this); action->setText(QObject::tr("Deselect All")); QObject::connect( action, SIGNAL(triggered()), this, SLOT(deselectAllChildrenItems()) ); mUI.toolBar->addAction(action); } mUI.toolBar->addSeparator(); mSearchBox->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); mUI.toolBar->addSeparator(); mUI.toolBar->addWidget(mSearchBox); mUI.toolBar->addWidget(mSearchButton); QObject::connect( mSearchButton, SIGNAL(released()), this, SLOT(searchNext()) ); // start centered move(QApplication::desktop()->screen()->rect().center() - rect().center()); show(); }
void IRCViewBox::slotSearchNext() { searchNext(false); }
void MemoryEditor::search() { QDialog dlg(this); dlg.setWindowTitle("Search Memory"); QVBoxLayout *vbox = new QVBoxLayout; dlg.setLayout(vbox); vbox->addWidget(new QLabel("Enter a hex string, or \"ASCII text\" (in quotes)")); QLineEdit *edit = new QLineEdit; edit->setFont(QFont(Style::Monospace)); // TODO: put existing search string in box vbox->addWidget(edit); QGridLayout *grid = new QGridLayout; vbox->addLayout(grid); grid->addWidget(new QLabel("Search:"), 0, 0); grid->addWidget(new QLabel("Start from:"), 1, 0); QButtonGroup bgrpSearch, bgrpStart; QRadioButton *searchDown = new QRadioButton("Down"); bgrpSearch.addButton(searchDown); grid->addWidget(searchDown, 0, 1); searchDown->setChecked(true); QRadioButton *searchUp = new QRadioButton("Up"); bgrpSearch.addButton(searchUp); grid->addWidget(searchUp, 0, 2); QRadioButton *searchFromEnd = new QRadioButton("From start/end"); bgrpStart.addButton(searchFromEnd); grid->addWidget(searchFromEnd, 1, 1); searchFromEnd->setChecked(true); QRadioButton *searchFromCur = new QRadioButton("From cursor"); bgrpStart.addButton(searchFromCur); grid->addWidget(searchFromCur, 1, 2); QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(bbox, SIGNAL(accepted()), &dlg, SLOT(accept())); connect(bbox, SIGNAL(rejected()), &dlg, SLOT(reject())); grid->addWidget(bbox); if (dlg.exec()) { QString searchText = edit->text().trimmed(); // try quoted text if (searchText.startsWith("\"") && searchText.endsWith("\"")) { searchStr = searchText.mid(1, searchText.size() - 2).toUtf8(); } else { searchStr = QByteArray::fromHex(edit->text().toUtf8()); } int offset = (int)editor->cursorPosition() / 2; if (searchDown->isChecked()) { searchPos = searchFromEnd->isChecked() ? -1 : offset; searchNext(); } else { searchPos = searchFromEnd->isChecked() ? editor->editorSize() : offset; searchPrev(); } } }
void TableVisualization::searchNext(QString str) { QList<QTableWidgetItem*> items = viewer->findItems(str, Qt::MatchContains | Qt::MatchCaseSensitive); if(items.size() == 0) return; if(!items[itemSearchedIndex]->isSelected()) { viewer->setCurrentItem(items[itemSearchedIndex]); //items[itemSearchedIndex]->setSelected(true); } else { if(itemSearchedIndex + 1 < items.size()) { itemSearchedIndex ++; searchNext(str); } else { int pos = topLinePos + linesOnPage(); if(pos < currentLog->size()) { currentLog->seek(pos); while(pos < currentLog->size()) { qint64 binPageSize = 0; char *binPage = currentLog->read(1, binPageSize); qint64 posInBinPage = 0; qint64 readedSize = 0; Record record; int infoSize = 0; SimpleEventInfo *info = currentProject->info(infoSize); StaticRecordsReader::readRecord(binPage, binPageSize, posInBinPage, readedSize, record, info); posInBinPage += readedSize; QString resultLine = QString::number(record.time); if(resultLine.contains(str)) { topLinePos = pos; updatePage(); itemSearchedIndex = 0; searchNext(str); return; } resultLine = *info[record.eventID].type; if(resultLine.contains(str)) { topLinePos = pos; updatePage(); itemSearchedIndex = 0; searchNext(str); return; } for(int j = 0; j < info[record.eventID].argsCount; j ++) { resultLine = StaticVisualizationTools::updateValue(record.eventID, j, record.other[j], info[record.eventID].argsInfo[j].type, formats); if(resultLine.contains(str)) { topLinePos = pos; updatePage(); itemSearchedIndex = 0; searchNext(str); return; } } pos ++; } } } } }
void GaduSearchService::searchFirst(BuddySearchCriteria criteria) { Query = criteria; From = 0; searchNext(); }
void GaduSearchService::searchFirst(Contact contact) { Query = contact; From = 0; searchNext(); }
void IRCViewBox::slotSearchPrevious() { searchNext(true); }