Exemplo n.º 1
0
void Editor::findDialog()
{
    FindDialog dialog(this);

    // Get current selection and set default value.
    QTextCursor cursor = currentTextEdit()->textCursor();
    QString selection = cursor.selectedText();
    if( selection != "" ) {
        dialog.setSearchText(selection);
    }

    int result = dialog.exec();
    if( result == QDialog::Accepted ) {

        lastSearch = dialog.searchText();

        lastSearchOptions = 0;
        if( dialog.caseSensitive() ) lastSearchOptions |= QTextDocument::FindCaseSensitively;
        if( dialog.wholeWord() ) lastSearchOptions |= QTextDocument::FindWholeWords;
        if( dialog.direction() == FindDialog::Direction_Backward ) lastSearchOptions |= QTextDocument::FindBackward;

        if( !find(lastSearch, lastSearchOptions) ) {
            QMessageBox::information(this, tr("Find"), tr("String '%0' not found").arg(lastSearch));
        }
    }
}
Exemplo n.º 2
0
void MainWindow::on_actionEnregistrer_sous_triggered()
{
    QString t_fileName=QFileDialog::getSaveFileName(this,"Sauvegarder le fichier sous");
    if(t_fileName=="") return;
    currentTextEdit()->setWindowFilePath(t_fileName);
    ui->tabWidget->setTabText(ui->tabWidget->currentIndex(),veryReducedFileName(t_fileName));
    saveFile();
}
Exemplo n.º 3
0
bool Editor::find(const QString & text, QTextDocument::FindFlags flags/*=0*/)
{
    QTextCursor cursor = currentTextEdit()->textCursor();

    if( flags & QTextDocument::FindBackward )
    {
        // Move cursor to the beginning of selection.
        cursor.setPosition(cursor.selectionStart());
        currentTextEdit()->setTextCursor(cursor);
    }
    else
    {
        // Move cursor to the end of selection.
        cursor.setPosition(cursor.selectionEnd());
        currentTextEdit()->setTextCursor(cursor);
    }

    return currentTextEdit()->find(text, flags);
}
Exemplo n.º 4
0
void MainWindow::addRecentFile()
{

    for(QStringListIterator i(settings->allKeys());i.hasNext();) if(currentTextEdit()->windowFilePath()==settings->value(i.next())) return;

    addRecentFileActionFirst(currentTextEdit()->windowFilePath());
    if(settings->allKeys().length()==5)
    {
        QList<QAction *> la=ui->menuDocuments_recents->actions();
        ui->menuDocuments_recents->removeAction(la[5]);
    }

    QStringList l;
    for(QStringListIterator i(settings->allKeys());i.hasNext();) l<<settings->value(i.next()).toString();
    for (int i = 1; i <= l.size(); ++i)
    {
        if(i<5) settings->setValue(QString::number(i+1),l[i-1]);
    }
    settings->setValue("1",currentTextEdit()->windowFilePath());
}
Exemplo n.º 5
0
void Editor::onCurrentChanged(int idx)
{
    if(idx < 0) return;

    emit cursorPositionChanged();

    QTextDocument * document = currentTextEdit()->document();
    QTextCursor cursor = currentTextEdit()->textCursor();

    // update cursor position.
    emit cursorPositionChanged();

    // update copy/undo/redo available.
    emit copyAvailable(cursor.position() != cursor.anchor());
    emit undoAvailable(document->isUndoAvailable());
    emit redoAvailable(document->isRedoAvailable());
    emit pasteAvailable(true);

    connect(currentTextEdit(), SIGNAL(copyAvailable(bool)), this, SLOT(onCopyAvailable(bool)));
    connect(currentTextEdit(), SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
    connect(currentTextEdit(), SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
}
Exemplo n.º 6
0
void Editor::gotoDialog()
{
    GotoDialog dialog(this);

    // Get current line and set default value.
    dialog.setLine(line());

    // Set valid range.
    int lineCount = currentTextEdit()->document()->blockCount();
    dialog.setRange(1, lineCount);

    int result = dialog.exec();
    if( result == QDialog::Accepted ) {
        gotoLine(currentIndex(), dialog.line());
    }
}
Exemplo n.º 7
0
void MainWindow::on_actionSelectionner_tout_triggered()
{
    if(currentTextEdit()!=NULL) currentTextEdit()->selectAll();
}
Exemplo n.º 8
0
void Editor::copy()
{
    currentTextEdit()->copy();
}
Exemplo n.º 9
0
void Editor::paste()
{
    currentTextEdit()->paste();
}
Exemplo n.º 10
0
void Editor::redo()
{
    currentTextEdit()->document()->redo();
}
Exemplo n.º 11
0
void Editor::cut()
{
    currentTextEdit()->cut();
}
Exemplo n.º 12
0
int Editor::column() const
{
    return currentTextEdit()->textCursor().columnNumber() + 1;
}
Exemplo n.º 13
0
void MainWindow::on_actionEnregistrer_triggered()
{
    if(currentTextEdit()->windowFilePath()=="") on_actionEnregistrer_sous_triggered();
    else saveFile();
}
Exemplo n.º 14
0
void FrostEdit::pointOutOccurances(QString str) {
	if(currentTextEdit() != nullptr)
		currentTextEdit()->showOccurances(str);
}
Exemplo n.º 15
0
void MainWindow::on_actionCopier_triggered()
{
    if(currentTextEdit()!=NULL) currentTextEdit()->copy();
}
Exemplo n.º 16
0
void FrostEdit::replaceAllFromTextEdit() {
	if(currentTextEdit() != nullptr)
		currentTextEdit()->replaceAll();
}
Exemplo n.º 17
0
void FrostEdit::findAndReplaceFromTextEdit() {
	if(currentTextEdit() != nullptr)
		currentTextEdit()->findReplace();
}
Exemplo n.º 18
0
void FrostEdit::findFromTextEdit() {
	if(currentTextEdit() != nullptr)
		currentTextEdit()->find();
}
Exemplo n.º 19
0
void MainWindow::on_actionColler_triggered()
{
    if(currentTextEdit()!=NULL) currentTextEdit()->paste();
}
Exemplo n.º 20
0
// slots.
void Editor::undo()
{
    currentTextEdit()->document()->undo();
}
Exemplo n.º 21
0
int Editor::line() const
{
    return currentTextEdit()->textCursor().blockNumber() + 1;
}
Exemplo n.º 22
0
void MainWindow::on_actionDefaire_triggered()
{
    if(currentTextEdit()!=NULL) currentTextEdit()->undo();
}