//! Constructor
ModelicaEditor::ModelicaEditor(ProjectTab *pParent)
    : QPlainTextEdit(pParent)
{
    mpParentProjectTab = pParent;
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setTabStopWidth(Helper::tabWidth);
    setObjectName("ModelicaEditor");
    document()->setDocumentMargin(2);
    setLineWrapMode(QPlainTextEdit::NoWrap);
    // depending on the project tab readonly state set the text view readonly state
    setReadOnly(mpParentProjectTab->isReadOnly());
    connect(this, SIGNAL(focusOut()), mpParentProjectTab, SLOT(modelicaEditorTextChanged()));
    connect(this, SIGNAL(textChanged()), SLOT(hasChanged()));

    mpFindWidget = new QWidget;
    mpFindWidget->setContentsMargins(0, 0, 0, 0);
    mpFindWidget->hide();

    mpSearchLabelImage = new QLabel;
    mpSearchLabelImage->setPixmap(QPixmap(":/Resources/icons/search.png"));
    mpSearchLabel = new QLabel(Helper::search);
    mpSearchTextBox = new QLineEdit;
    connect(mpSearchTextBox, SIGNAL(textChanged(QString)), SLOT(updateButtons()));
    connect(mpSearchTextBox, SIGNAL(returnPressed()), SLOT(findNextText()));

    mpPreviuosButton = new QToolButton;
    mpPreviuosButton->setAutoRaise(true);
    mpPreviuosButton->setText(tr("Previous"));
    mpPreviuosButton->setIcon(QIcon(":/Resources/icons/previous.png"));
    mpPreviuosButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    connect(mpPreviuosButton, SIGNAL(clicked()), SLOT(findPreviuosText()));

    mpNextButton = new QToolButton;
    mpNextButton->setAutoRaise(true);
    mpNextButton->setText(tr("Next"));
    mpNextButton->setIcon(QIcon(":/Resources/icons/next.png"));
    mpNextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    connect(mpNextButton, SIGNAL(clicked()), SLOT(findNextText()));

    mpMatchCaseCheckBox = new QCheckBox(tr("Match case"));
    mpMatchWholeWordCheckBox = new QCheckBox(tr("Match whole word"));

    mpCloseButton = new QToolButton;
    mpCloseButton->setAutoRaise(true);
    mpCloseButton->setIcon(QIcon(":/Resources/icons/exit.png"));
    connect(mpCloseButton, SIGNAL(clicked()), SLOT(hideFindWidget()));

    mpLineNumberArea = new LineNumberArea(this);
    connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));

    updateLineNumberAreaWidth(0);
    highlightCurrentLine();
    // make previous and next buttons disabled for first time
    updateButtons();
}
Beispiel #2
0
void Search::findNext()
{
	bool found = false;
	if(fieldArchive==NULL)	return;

	buttonNext->setEnabled(false);
	buttonNext->setDefault(true);

	if(currentIndex() == Text)
	{
		found = findNextText();
	}
	else if(currentIndex() == Script)
	{
		found = findNextScript();
	}

	if(!found)
	{
		QMessageBox::information(this, windowTitle(), tr("Dernier fichier,\npoursuite de la recherche dans le premier fichier."));
	}

	buttonNext->setEnabled(true);
}