void TraceLoader::search(const ApiTrace::SearchRequest &request) { if (request.direction == ApiTrace::SearchRequest::Next) { searchNext(request); } else { searchPrev(request); } }
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 ); } }
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 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())); }
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); }
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(); } } }