Example #1
0
void FindBar::keyPressEvent(QKeyEvent *event)
{
    if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
        if (event->modifiers() == Qt::ShiftModifier) {
            findPrevious();
        } else {
            findNext();
        }
    }

    QWidget::keyPressEvent(event);
}
Example #2
0
void FindDialog::findClicked()
{
    QString text = lineEdit->text();
    Qt::CaseSensitivity cs =
            caseCheckBox->isChecked() ? Qt::CaseSensitive
                                      : Qt::CaseInsensitive;
    if (backwardCheckBox->isChecked()) {
        emit findPrevious(text, cs);
    } else {
        emit findNext(text, cs);
    }
}
Example #3
0
File: 2947.c Project: saki45/OJ
int main(){
	char buf1[60], buf2[60], ch1, ch2;
	int N, N1, N2, p1, p2, isSame;
	scanf("%d", &N);

	while(N > 0){
		scanf("%d\n", &N1);
		fgets(buf1, sizeof(buf1), stdin);
		scanf("%d\n", &N2);
		fgets(buf2, sizeof(buf2), stdin);

		if(N1 != N2){
			displayResult(0);
		}
		else{
			p1 = 0;
			p2 = 0;
			ch1 = buf1[p1];
			ch2 = buf2[p2];
			isSame = 1;

			if(ch1 != ch2)
				displayResult(0);
			else{
				N1--;
				while(N1 > 0){
					ch1 = findNext(buf1, &p1);
					ch2 = findNext(buf2, &p2);
					if(ch1 != ch2){
						isSame = 0;
						break;
					}
					N1 --;
				}
				displayResult(isSame);
			}
		}
		N--;
	}
}
Example #4
0
/** Constuctor. This will probably do more later */
HelpBrowser::HelpBrowser(QWidget *parent)
 : RWindow("HelpBrowser", parent)
{
  RshareSettings _settings;

  /* Invoke Qt Designer generated QObject setup routine */
  ui.setupUi(this);
#if defined(Q_WS_MAC)
  ui.actionHome->setShortcut(QString("Shift+Ctrl+H"));
#endif
#if !defined(Q_WS_WIN)
  ui.actionClose->setShortcut(QString("Ctrl+W"));
#endif

  /* Hide Search frame */
  ui.frmFind->setHidden(true);
 
  /* Set the splitter pane sizes so that only the txtBrowser pane expands
   * and set to arbitrary sizes (the minimum sizes will take effect */
  QList<int> sizes;
  sizes.append(MINIMUM_PANE_SIZE); 
  sizes.append(MINIMUM_PANE_SIZE);
  ui.splitter->setSizes(sizes);
  ui.splitter->setStretchFactor(LEFT_PANE_INDEX, NO_STRETCH);

  connect(ui.treeContents,
          SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
          this, SLOT(contentsItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));

  connect(ui.treeSearch,
          SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
          this, SLOT(searchItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));

  /* Connect the navigation actions to their slots */
  connect(ui.actionHome, SIGNAL(triggered()), ui.txtBrowser, SLOT(home()));
  connect(ui.actionBack, SIGNAL(triggered()), ui.txtBrowser, SLOT(backward()));
  connect(ui.actionForward, SIGNAL(triggered()), ui.txtBrowser, SLOT(forward()));
  connect(ui.txtBrowser, SIGNAL(backwardAvailable(bool)), 
          ui.actionBack, SLOT(setEnabled(bool)));
  connect(ui.txtBrowser, SIGNAL(forwardAvailable(bool)),
          ui.actionForward, SLOT(setEnabled(bool)));
  connect(ui.btnFindNext, SIGNAL(clicked()), this, SLOT(findNext()));
  connect(ui.btnFindPrev, SIGNAL(clicked()), this, SLOT(findPrev()));
  connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(search()));
  
  /* Load the help topics from XML */
  loadContentsFromXml(":/help/" + language() + "/contents.xml");

  /* Show the first help topic in the tree */
  ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0));
  ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true);
}
Example #5
0
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
    if (object == ui->searchText && event->type() == QEvent::KeyPress)
    {
        auto keyEvent = static_cast<QKeyEvent*>(event);
        if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)
        {
            findNext();
            return true;
        }
    }
    return QMainWindow::eventFilter(object, event);
}
CTextViewerWindow::CTextViewerWindow(QWidget *parent) :
	CPluginWindow(parent),
	_findDialog(this),
	ui(new Ui::CTextViewerWindow)
{
	ui->setupUi(this);

	connect(ui->actionOpen, &QAction::triggered, [this](){
		const QString fileName = QFileDialog::getOpenFileName(this);
		if (!fileName.isEmpty())
			loadTextFile(fileName);
	});
	connect(ui->actionReload, &QAction::triggered, [this](){
		loadTextFile(_sourceFilePath);
	});
	connect(ui->actionClose, SIGNAL(triggered()), SLOT(close()));

	connect(ui->actionFind, &QAction::triggered, [this](){
		_findDialog.exec();
	});
	connect(ui->actionFind_next, SIGNAL(triggered()), SLOT(findNext()));

	connect(ui->actionSystemLocale, SIGNAL(triggered()), SLOT(asSystemDefault()));
	connect(ui->actionUTF_8, SIGNAL(triggered()), SLOT(asUtf8()));
	connect(ui->actionUTF_16, SIGNAL(triggered()), SLOT(asUtf16()));
	connect(ui->actionHTML_RTF, SIGNAL(triggered()), SLOT(asRichText()));

	QActionGroup * group = new QActionGroup(this);
	group->addAction(ui->actionSystemLocale);
	group->addAction(ui->actionUTF_8);
	group->addAction(ui->actionUTF_16);
	group->addAction(ui->actionHTML_RTF);

	connect(&_findDialog, SIGNAL(find()), SLOT(find()));
	connect(&_findDialog, SIGNAL(findNext()), SLOT(findNext()));

	auto escScut = new QShortcut(QKeySequence("Esc"), this, SLOT(close()));
	connect(this, SIGNAL(destroyed()), escScut, SLOT(deleteLater()));
}
Example #7
0
void KexiFindDialog::setActions(KAction *findnext, KAction *findprev,
                                KAction *replace, KAction *replaceall)
{
    d->findnextAction = findnext;
    d->findprevAction = findprev;
    d->replaceAction = replace;
    d->replaceallAction = replaceall;
    qDeleteAll(d->shortcuts);
    d->setActionAndShortcut(d->findnextAction, this, SIGNAL(findNext()));
    d->setActionAndShortcut(d->findprevAction, this, SIGNAL(findPrevious()));
    d->setActionAndShortcut(d->replaceAction, this, SIGNAL(replaceNext()));
    d->setActionAndShortcut(d->replaceallAction, this, SIGNAL(replaceAll()));
}
Example #8
0
 TreeNode* next(){
   if(hasNext()){
     TreeNode* res = stk.top();
     stk.pop();
     if(!stk.empty()){
       TreeNode* top = stk.top();
       if(res == top->left){
         findNext(top->right);
       }
     }
   }
   return res;
 }
Example #9
0
// ---------------------------------------------------------------------------
//  RefHashTableOfEnumerator: Constructors and Destructor
// ---------------------------------------------------------------------------
template <class TVal> RefHashTableOfEnumerator<TVal>::
RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum, const bool adopt)
	: fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum)
{
    //
    //  Find the next available bucket element in the hash table. If it
    //  comes back zero, that just means the table is empty.
    //
    //  Note that the -1 in the current hash tells it to start from the
    //  beginning.
    //
    findNext();
}
Example #10
0
void Outline::findFirst()
//-----------------------
{
    if( _queryConfig->editFilter( _findFilter ) ) {
        if( _findStack == NULL ) {
            _findStack = new WCPtrOrderedVector<OutlineElement>;
        }

        _findStack->clear();
        _findStack->append( _sentinel );
        findNext();
    }
}
Example #11
0
int _find::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: findNext(); break;
        case 1: close(); break;
        }
        _id -= 2;
    }
    return _id;
}
Example #12
0
void FindDialog::emitFindNext()
{
    DataModel::FindLocation where;
    if (sourceText != 0)
        where =
            DataModel::FindLocation(
                (sourceText->isChecked() ? DataModel::SourceText : 0) |
                (translations->isChecked() ? DataModel::Translations : 0) |
                (comments->isChecked() ? DataModel::Comments : 0));
    else
        where = DataModel::Translations;
    emit findNext(led->text(), where, matchCase->isChecked(), ignoreAccelerators->isChecked());
    led->selectAll();
}
bool RlvMultiStringSearch::findLast(const std::string& strText, RlvMultiStringSearchMatch& match) const {
	RlvMultiStringSearchMatch matchTemp;
	match.idxMatch = -1;	// (Needed to make the return work in case we don't find anything)
	matchTemp.lenMatch = 0; // (Needed to make the first loop iteration start at 0)
	
	// Iterating over a "const char*" is *significantly* faster than "std::string"
	const char* pstrText = strText.c_str();
	int lenText = strText.length();

	while (findNext(pstrText, matchTemp.idxMatch + matchTemp.lenMatch + 1, lenText, matchTemp))
		match = matchTemp;

	return (match.idxMatch != -1);
}
Example #14
0
AnnotateDialog::AnnotateDialog(KConfig& cfg, QWidget *parent)
    : QDialog(parent)
    , partConfig(cfg)
{
    QVBoxLayout *mainLayout = new QVBoxLayout;
    setLayout(mainLayout);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);

    QPushButton *user1Button = new QPushButton;
    user1Button->setText(i18n("Go to Line..."));
    user1Button->setAutoDefault(false);
    buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);

    QPushButton *user2Button = new QPushButton;
    user2Button->setText(i18n("Find Prev"));
    user2Button->setAutoDefault(false);
    buttonBox->addButton(user2Button, QDialogButtonBox::ActionRole);

    QPushButton *user3Button = new QPushButton;
    user3Button->setText(i18n("Find Next"));
    buttonBox->addButton(user3Button, QDialogButtonBox::ActionRole);

    buttonBox->button(QDialogButtonBox::Help)->setAutoDefault(false);

    connect(buttonBox, &QDialogButtonBox::rejected, this, &AnnotateDialog::reject);
    connect(buttonBox, &QDialogButtonBox::helpRequested, this, &AnnotateDialog::slotHelp);

    findEdit = new QLineEdit;
    findEdit->setClearButtonEnabled(true);
    findEdit->setPlaceholderText(i18n("Search"));

    annotate = new AnnotateView(this);

    mainLayout->addWidget(findEdit);
    mainLayout->addWidget(annotate);
    mainLayout->addWidget(buttonBox);

    connect(user3Button, SIGNAL(clicked()), this, SLOT(findNext()));
    connect(user2Button, SIGNAL(clicked()), this, SLOT(findPrev()));
    connect(user1Button, SIGNAL(clicked()), this, SLOT(gotoLine()));

    setAttribute(Qt::WA_DeleteOnClose, true);

    KConfigGroup cg(&partConfig, "AnnotateDialog");
    restoreGeometry(cg.readEntry<QByteArray>("geometry", QByteArray()));

    findEdit->setFocus();
}
Example #15
0
/* TextEditor::onFRDKeyDown
 * Called when a key is pressed on the Find+Replace frame
 *******************************************************************/
void TextEditor::onFRDKeyDown(wxKeyEvent& e)
{
	// Esc (close)
	if (e.GetKeyCode() == WXK_ESCAPE)
		dlg_fr->Close();

	// Enter
	else if (e.GetKeyCode() == WXK_RETURN)
	{
		// Find Next
		if (dlg_fr->getTextFind()->HasFocus())
		{
			// Check find string
			string find = dlg_fr->getFindString();
			if (find.IsEmpty())
				return;

			// Set search options
			int flags = 0;
			if (dlg_fr->matchCase()) flags |= wxSTC_FIND_MATCHCASE;
			if (dlg_fr->matchWord()) flags |= wxSTC_FIND_WHOLEWORD;
			SetSearchFlags(flags);

			// Do find
			if (!findNext(find))
				wxLogMessage("No text matching \"%s\" found.", find);
		}

		// Replace
		else if (dlg_fr->getTextReplace()->HasFocus())
		{
			// Set search options
			int flags = 0;
			if (dlg_fr->matchCase()) flags |= wxSTC_FIND_MATCHCASE;
			if (dlg_fr->matchWord()) flags |= wxSTC_FIND_WHOLEWORD;
			SetSearchFlags(flags);

			// Do replace
			replaceCurrent(dlg_fr->getFindString(), dlg_fr->getReplaceString());
		}

		else
			e.Skip();
	}

	// Other
	else
		e.Skip();
}
Example #16
0
QueryWidget::QueryWidget(QWidget *parent) :
	QWidget(parent), m_ctx(nullptr), m_moreavailable(false)
{
	// The web view is used to show the results of the queries
	m_view = new QueryView(this);

	// The query entry box
	m_query = new SqlLineEdit(this);
	connect(m_query, SIGNAL(returnPressed(QString)), this, SLOT(doQuery(QString)));

	m_query->setEnabled(false);

	// Completer for the query entry box
	SqlCompletion *c = new SqlCompletion();
	c->setIgnoreCase(true);
	connect(this, &QueryWidget::dbStructure, c, &SqlCompletion::refreshModel);
	m_query->setCompletionObject(c);
	m_query->setCompletionMode(KCompletion::CompletionAuto);

	// Find in results widget
	m_find = new QWidget(this);
	m_findui = new Ui::FindWidget;
	m_findui->setupUi(m_find);
	m_find->setMaximumHeight(m_findui->findtext->height());
	m_find->hide();

	connect(m_findui->findtext, SIGNAL(textChanged(QString)),
			this, SLOT(findNext()));
	connect(m_findui->highlightall, SIGNAL(toggled(bool)),
			this, SLOT(findNext()));
	connect(m_findui->casesensitive, SIGNAL(toggled(bool)),
			this, SLOT(findNext()));

	connect(m_findui->closebutton, SIGNAL(clicked(bool)),
			m_find, SLOT(hide()));

	connect(m_findui->nextbutton, SIGNAL(clicked(bool)),
			this, SLOT(findNext()));
	connect(m_findui->prevbutton, SIGNAL(clicked(bool)),
			this, SLOT(findPrev()));

	// Finish up.
	QVBoxLayout *layout = new QVBoxLayout();
	layout->addWidget(m_view);
	layout->addWidget(m_find);
	layout->addWidget(m_query);

	setLayout(layout);
}
Example #17
0
void* RefHashTableOfEnumerator<TVal, THasher>::nextElementKey()
{
    // Make sure we have an element to return
    if (!hasMoreElements())
        ThrowXMLwithMemMgr(NoSuchElementException, XMLExcepts::Enum_NoMoreElements, fMemoryManager);

    //
    //  Save the current element, then move up to the next one for the
    //  next time around.
    //
    RefHashTableBucketElem<TVal>* saveElem = fCurElem;
    findNext();

    return saveElem->fKey;
}
Example #18
0
void SearchLocationID::findNext()
{
	kdebugf();
	
	currentServer_ = weather_global->nextServer(currentServer_);
	if (currentServer_ != weather_global->endServer())
	{
		emit nextServerSearch( city_, (*currentServer_).name_);
		findNext((*currentServer_).configFile_);
	}
	else
		emit finished();
	
	kdebugf2();
}
Example #19
0
template <class TVal> TVal& ValueHashTableOfEnumerator<TVal>::nextElement()
{
    // Make sure we have an element to return
    if (!hasMoreElements())
        ThrowXML(NoSuchElementException, XMLExcepts::Enum_NoMoreElements);

    //
    //  Save the current element, then move up to the next one for the
    //  next time around.
    //
    ValueHashTableBucketElem<TVal>* saveElem = fCurElem;
    findNext();

    return saveElem->fData;
}
Example #20
0
//bouton de recherche cliqué
void FindDialog::findClicked()
{
    QString text = m_lineEdit->text();
    Qt::CaseSensitivity cs =
          m_caseCheckBox->isChecked() ? Qt::CaseSensitive
                                    : Qt::CaseInsensitive;
    if (m_backwardCheckBox->isChecked()) {
       emit findPrevious(text, cs);
		m_findBefore = true;
		m_findAfter = false;
	} else {
    	emit findNext(text, cs);
		m_findBefore = false;	
		m_findAfter = true; 
	}
}
Example #21
0
	FindNotification::FindNotification (ICoreProxy_ptr proxy, QWebEngineView *near)
	: Util::FindNotification { proxy, near }
	, WebView_ { near }
	{
		connect (near,
				&QWebEngineView::loadFinished,
				this,
				[this]
				{
					if (PreviousFindText_.isEmpty ())
						return;

					ClearFindResults ();
					findNext ();
				});
	}
Example #22
0
int FindDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: findNext((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< Qt::CaseSensitivity(*)>(_a[2]))); break;
        case 1: findPrevious((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< Qt::CaseSensitivity(*)>(_a[2]))); break;
        case 2: findClicked(); break;
        case 3: enableFindButton((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        }
        _id -= 4;
    }
    return _id;
}
Example #23
0
// ---------------------------------------------------------------------------
//  ValueHashTableOfEnumerator: Constructors and Destructor
// ---------------------------------------------------------------------------
template <class TVal> ValueHashTableOfEnumerator<TVal>::
ValueHashTableOfEnumerator(SimpleValueHashTableOf<TVal>* const toEnum, const bool adopt)
	: fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum)
{
    if (!toEnum)
        ThrowXML(NullPointerException, XMLExcepts::CPtr_PointerIsZero);

    //
    //  Find the next available bucket element in the hash table. If it
    //  comes back zero, that just means the table is empty.
    //
    //  Note that the -1 in the current hash tells it to start from the
    //  beginning.
    //
    findNext();
}
 vector<int> prisonAfterNDays(vector<int>& cells, int N) {
     vector<int> table;
     unordered_map<int, int> visited;
     int index = N - 1;
     for (int i = 0; i < N; ++i) {
         cells = findNext(cells);
         int num = convert(cells);
         if (visited.count(num)) {
             index = visited[num] + (N - 1 - visited[num]) % (i - visited[num]);
             break;
         }
         table.push_back(num);
         visited[num] = i;
     }
     return numToArray(table[index]);
 }
Example #25
0
void SearchLocationID::downloadingFinished()
{
	kdebugf();
	
	disconnect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished()));
	disconnect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError()));
	disconnect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString)));
	
	timerTimeout_->stop();

	if (redirected_)
		redirected_ = false;
	else
	{
		const QByteArray &data = httpClient_.data();
		QString page = decoder_->toUnicode( data.data(), data.count());
		
		parser_.getSearch(page, weatherConfig_, serverConfigFile_, &results_);
		
		// Je�li strona zawiera wszystkie miasta,
		// trzeba dok�adniej przefiltrowa�
		if (weatherConfig_->readBoolEntry("Name Search","OnePage"))
		{
			CITYSEARCHRESULTS::iterator it, old_it;
			
			it = results_.begin();
			while (it != results_.end())
			{
				if ((*it).cityName_.find(city_, 0, false) == -1)
				{
					old_it = it;
					++it;
					results_.erase(old_it);
				}
				else
					++it;
			}
		}
	}
	
	if (searchAllServers_)
		findNext();
	else
		emit finished();
	
	kdebugf2();
}
Example #26
0
/* TextEditor::onFRDBtnFindNext
 * Called when the 'Find Next' button on the Find+Replace frame is
 * clicked
 *******************************************************************/
void TextEditor::onFRDBtnFindNext(wxCommandEvent& e)
{
	// Check find string
	string find = dlg_fr->getFindString();
	if (find.IsEmpty())
		return;

	// Set search options
	int flags = 0;
	if (dlg_fr->matchCase()) flags |= wxSTC_FIND_MATCHCASE;
	if (dlg_fr->matchWord()) flags |= wxSTC_FIND_WHOLEWORD;
	SetSearchFlags(flags);

	// Do find
	if (!findNext(find))
		wxLogMessage("No text matching \"%s\" found.", find);
}
Example #27
0
void SearchLineEdit::slotReturnPressed( const QString &text )
{
    Q_UNUSED(text);

    m_inputDelayTimer->stop();
    prepareLineEditForSearch();
    if ( QApplication::keyboardModifiers() == Qt::ShiftModifier )
    {
        m_searchType = Okular::Document::PreviousMatch;
        findPrev();
    }
    else
    {
        m_searchType = Okular::Document::NextMatch;
        findNext();
    }
}
Example #28
0
void QvvTreeWidget::keyPressEvent ( QKeyEvent * e )
{

    e->ignore();
    int a = e->text() == "" ? 0 : e->text().toAscii().at(0);
    int m = e->modifiers();

    if( ( m == Qt::ShiftModifier || m == Qt::NoModifier ) && a >= '!' && a <= 'z' )
    {
        findNext( QString( QVariant( a ).toChar() ) );
    }
    else
    {
        QTreeWidget::keyPressEvent( e );
    }

}
Example #29
0
void SearchLocationID::downloadingError()
{
	kdebugf();
	
	disconnect(&httpClient_, SIGNAL(finished()), this, SLOT(downloadingFinished()));
	disconnect(&httpClient_, SIGNAL(error()), this, SLOT(downloadingError()));
	disconnect(&httpClient_, SIGNAL(redirected(QString)), this, SLOT(downloadingRedirected(QString)));

	timerTimeout_->stop();
	
	if (searchAllServers_)
		findNext();
	else
		emit error(host_ + '/' + url_);

	kdebugf2();
}
Example #30
0
void FindDialog::on_finBut_ck()
{
    QString str = this->textFind->text();
    //Qt::CaseSensitivity 为枚举类型, 可取值Qt::CaseSensitive 和 Qt::CaseInsensitive, 表示匹配的灵敏度。
    Qt::CaseSensitivity cs = this->caseChBox->isChecked()?Qt::CaseSensitive : Qt::CaseInsensitive;

    if(this->backChBox->isChecked())
    {
        qDebug() << "findPrevious(str,cs): str:"<<str<<"  cs:" << cs;
        emit findPrevious(str,cs);//发送findPrevious信号
    }
    else
    {
        qDebug() << "findNext(str,cs)"<<str<<"  cs:" << cs;
        emit findNext(str,cs);//发送findNext信号
    }
}