void	QsvTextOperationsWidget::searchPrevious()
{
	if (!searchFormUi)
	return;
	issue_search( searchFormUi->searchText->text(),
		getTextCursor(), 
		getSearchFlags() | QTextDocument::FindBackward, 
		searchFormUi->searchText,
		true
	);
}
void	QsvTextOperationsWidget::on_replaceAll_clicked()
{
	// WHY NOT HIDING THE WIDGET?
	// it seems that if you hide the widget, when the replace all action
	// is triggered by pressing control+enter on the replace widget
	// eventually an "enter event" is sent to the text eidtor.
	// the work around is to update the transparency of the widget, to let the user
	// see the text bellow the widget

	//showReplaceWidget();
	m_replace->hide();

	int replaceCount = 0;
	//        replaceWidget->setWidgetTransparency( 0.2 );
	QTextCursor c = getTextCursor();
	c = getTextDocument()->find( replaceFormUi->replaceText->text(), c, getReplaceFlags() );

	while (!c.isNull())
	{
		setTextCursor( c );
		QMessageBox::StandardButton button = QMessageBox::question( qobject_cast<QWidget*>(parent()), tr("Replace all"), tr("Replace this text?"),
			QMessageBox::Yes | QMessageBox::Ignore | QMessageBox::Cancel );

		if (button == QMessageBox::Cancel)
		{
			break;

		}
		else if (button == QMessageBox::Yes)
		{
			c.beginEditBlock();
			c.deleteChar();
			c.insertText( replaceFormUi->replaceText->text() );
			c.endEditBlock();
			setTextCursor( c );
			replaceCount++;
		}

		c = getTextDocument()->find( replaceFormUi->replaceText->text(), c, getReplaceFlags() );
	}
	// replaceWidget->setWidgetTransparency( 0.8 );
	m_replace->show();

	QMessageBox::information( 0, tr("Replace all"), tr("%1 replacement(s) made").arg(replaceCount) );
}
void QsvTextOperationsWidget::showSearch()
{
	if (!m_search)
		initSearchWidget();
	if (m_replace && m_replace->isVisible())
		m_replace->hide();

	QWidget *parent = qobject_cast<QWidget*>(this->parent());
	if (m_search->isVisible()) {
		m_search->hide();
		if (parent)
			parent->setFocus();
		return;
	}

	m_searchCursor = getTextCursor();
	searchFormUi->searchText->setFocus();
	searchFormUi->searchText->selectAll();
	showBottomWidget(m_search);
}
void	QsvTextOperationsWidget::showReplace()
{
	if (!m_replace)
		initReplaceWidget();
	if (m_search && m_search->isVisible())
		m_search->hide();

	QWidget *parent = qobject_cast<QWidget*>(this->parent());
	if (m_replace->isVisible()) {
		m_replace->hide();
		if (parent)
			parent->setFocus();
		return;
	}

	if (m_searchCursor.isNull())
		m_searchCursor = getTextCursor();
	replaceFormUi->findText->setFocus();
	replaceFormUi->findText->selectAll();
	showBottomWidget(m_replace);
}
Ejemplo n.º 5
0
bool CMissiveOMat::KeyCharMsg(CKeyCharMsg *msg) {
	CTreeItem *loginControl = findRoom()->findByName("MissiveOMat Login Control");
	CTreeItem *welcome = findRoom()->findByName("MissiveOMat Welcome");
	CTreeItem *scrollUp = findRoom()->findByName("MissiveOMat ScrollUp Button");
	CEditControlMsg editMsg;

	switch (_mode) {
	case 1: {
		playSound("z#228.wav");
		editMsg._mode = 6;
		editMsg._param = msg->_key;
		editMsg.execute(loginControl);

		if (editMsg._param == 1000) {
			editMsg._mode = 3;
			editMsg.execute(loginControl);
		
			_string1 = editMsg._text;
			if (!_string1.empty()) {
				loadFrame(2);
				_mode = 2;

				editMsg._mode = 1;
				editMsg.execute(loginControl);
				editMsg._mode = 10;
				editMsg._param = 24;
				editMsg.execute(loginControl);
			}
		}
		break;
	}

	case 2: {
		playSound("z#228.wav");
		editMsg._mode = 6;
		editMsg._param = msg->_key;
		editMsg.execute(loginControl);

		_string2 = editMsg._text;
		if (_string1 == "Droot Scraliontis") {
			_string1 = "Scraliontis";
		} else if (_string1 == "Antar Brobostigon") {
			_string1 = "Brobostigon";
		} else if (_string1 == "colin") {
			_string1 = "Leovinus";
		}

		bool flag = false;
		if (_string1 == "Leovinus") {
			if (_string2 == "Other") {
				flag = true;
				_personIndex = 0;
			}
		} else if (_string1 == "Scraliontis") {
			if (_string2 == "This") {
				flag = true;
				_personIndex = 1;
			}
		} else if (_string1 == "Brobostigon") {
			if (_string2 == "That") {
				flag = true;
				_personIndex = 2;
			}
		}

		if (flag) {
			_mode = 4;
			loadFrame(4);
			editMsg._mode = 1;
			editMsg.execute(loginControl);

			getTextCursor()->hide();
			editMsg._mode = 13;
			editMsg.execute(loginControl);

			editMsg._mode = 12;
			editMsg.execute(welcome);

			editMsg._mode = 2;
			editMsg._text = _welcomeMessages[_personIndex];
			editMsg.execute(welcome);

			editMsg._mode = 12;
			editMsg._text = "MissiveOMat OK Button";
			editMsg.execute(welcome);
			editMsg.execute(scrollUp);
		} else {
			_mode = 3;
			loadFrame(3);
			addTimer(1500);

			editMsg._mode = 1;
			editMsg.execute(loginControl);

			getTextCursor()->hide();
		}
		break;
	}

	default:
		break;
	}

	return true;
}