Ejemplo n.º 1
0
void ScCodeEditor::insertFromMimeData ( const QMimeData * data )
{
    if (data->hasUrls()) {
        QTextCursor cursor = textCursor();
        QList<QUrl> urls = data->urls();
        bool multiple = urls.size() > 1;
        if (multiple) {
            cursor.insertText("[");
            cursor.insertBlock();
        }
        for (int i = 0; i < urls.size(); ++ i) {
            QUrl url = urls[i];
            cursor.insertText("\"");
            if ( QURL_IS_LOCAL_FILE(url) )
                cursor.insertText(url.toLocalFile());
            else
                cursor.insertText(url.toString());
            cursor.insertText("\"");
            if (i < urls.size() - 1) {
                cursor.insertText(",");
                cursor.insertBlock();
            }
        }
        if (multiple) {
            cursor.insertBlock();
            cursor.insertText("]");
        }
    }
    else
        QPlainTextEdit::insertFromMimeData(data);
}
Ejemplo n.º 2
0
void GenericCodeEditor::moveLineUpDown(bool up)
{
    // directly taken from qtcreator
    // Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
    // GNU Lesser General Public License
    QTextCursor cursor = textCursor();
    QTextCursor move = cursor;

    move.setVisualNavigation(false); // this opens folded items instead of destroying them

    move.beginEditBlock();

    bool hasSelection = cursor.hasSelection();

    if (cursor.hasSelection()) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
        move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock,
                          QTextCursor::KeepAnchor);
    } else {
        move.movePosition(QTextCursor::StartOfBlock);
        move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    }
    QString text = move.selectedText();

    move.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
    move.removeSelectedText();

    if (up) {
        move.movePosition(QTextCursor::PreviousBlock);
        move.insertBlock();
        move.movePosition(QTextCursor::Left);
    } else {
        move.movePosition(QTextCursor::EndOfBlock);
        if (move.atBlockStart()) { // empty block
            move.movePosition(QTextCursor::NextBlock);
            move.insertBlock();
            move.movePosition(QTextCursor::Left);
        } else {
            move.insertBlock();
        }
    }

    int start = move.position();
    move.clearSelection();
    move.insertText(text);
    int end = move.position();

    if (hasSelection) {
        move.setPosition(start);
        move.setPosition(end, QTextCursor::KeepAnchor);
    }

    move.endEditBlock();

    setTextCursor(move);
}
Ejemplo n.º 3
0
void GenericCodeEditor::copyUpDown(bool up)
{
    // directly taken from qtcreator
    // Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
    // GNU Lesser General Public License
    QTextCursor cursor = textCursor();
    QTextCursor move = cursor;
    move.beginEditBlock();

    bool hasSelection = cursor.hasSelection();

    if (hasSelection) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.setPosition(cursor.selectionEnd(), QTextCursor::KeepAnchor);
        move.movePosition(move.atBlockStart() ? QTextCursor::Left: QTextCursor::EndOfBlock,
                          QTextCursor::KeepAnchor);
    } else {
        move.movePosition(QTextCursor::StartOfBlock);
        move.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
    }

    QString text = move.selectedText();

    if (up) {
        move.setPosition(cursor.selectionStart());
        move.movePosition(QTextCursor::StartOfBlock);
        move.insertBlock();
        move.movePosition(QTextCursor::Left);
    } else {
        move.movePosition(QTextCursor::EndOfBlock);
        if (move.atBlockStart()) {
            move.movePosition(QTextCursor::NextBlock);
            move.insertBlock();
            move.movePosition(QTextCursor::Left);
        } else {
            move.insertBlock();
        }
    }

    int start = move.position();
    move.clearSelection();
    move.insertText(text);
    int end = move.position();

    move.setPosition(start);
    move.setPosition(end, QTextCursor::KeepAnchor);

    move.endEditBlock();

    setTextCursor(move);
}
Ejemplo n.º 4
0
void MainWindow::addParagraph(const QString &paragraph){
    if (paragraph.isEmpty())
        return;
    QTextDocument *document = chatbox->document();
    QTextCursor cursor = document->find(tr("Yours sincerely,"));
    if (cursor.isNull())
        return;
    cursor.beginEditBlock();
    cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor, 2);
    cursor.insertBlock();
    cursor.insertText(paragraph);
    cursor.insertBlock();
    cursor.endEditBlock();

}
Ejemplo n.º 5
0
// 3) CONTACTS
void ResWaReport::BuildContactsSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n3) Contacts (proactive outreach events\n", _headerFormat);
    cursor.insertText("!! This information is not available !!\n", _headerFormat);
}
Ejemplo n.º 6
0
// 4) TRAINING
void ResWaReport::BuildTrainingSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n4) TRAINING & IN-SERVICES\n");

    // VALUES
    int numTrainings;
    int numAttendingTrainings;
    CalculateTraining(numTrainings, numAttendingTrainings);
//    cursor.insertText("\t\t\t# of trainings: " + QString::number(numTrainings) + "\n");
//    cursor.insertText("\t\t\t# attending trainings: " + QString::number(numAttendingTrainings) + "\n");

    QTextTableFormat tableFormat;
    tableFormat.setHeaderRowCount(1);
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 35);
    constraints << QTextLength(QTextLength::PercentageLength, 35);

    tableFormat.setColumnWidthConstraints(constraints);
    QTextTable *table = cursor.insertTable(2, 2, tableFormat);
    // HEADERS
    TextToCell(table, 0, 0, "# of trainings (observers)", &_tableTextFormat);
    TextToCell(table, 0, 1, "# attending trainings (all people in room)", &_tableTextFormat);
    // VALUES
    TextToCell(table, 1, 0, QString::number(numTrainings), &_tableCellBlue);
    TextToCell(table, 1, 1, QString::number(numAttendingTrainings), &_tableCellBlue);
}
Ejemplo n.º 7
0
void ZModemDialog::addProgressText(const QString& text)
{
    QTextCursor cursor = _textEdit->textCursor();

    cursor.insertBlock();
    cursor.insertText(text);
}
Ejemplo n.º 8
0
void MediationProcess::BuildHeaderSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();  //  Is this necessary?
    cursor.insertText("\nMediation\n", _headerFormat);
    cursor.insertText("Inquiry, Mediation and Session types and statuses\n", _tableTextFormat);
}
void ComposerTextEdit::slotPasteAsQuotation()
{
    QString text = qApp->clipboard()->text();
    if (text.isEmpty())
        return;

    QStringList lines = text.split(QLatin1Char('\n'));
    for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it) {
        it->remove(QLatin1Char('\r'));
        if (it->startsWith(QLatin1Char('>'))) {
            *it = QLatin1Char('>') + *it;
        } else {
            *it = QLatin1String("> ") + *it;
        }
    }
    text = lines.join(QStringLiteral("\n"));
    if (!text.endsWith(QLatin1Char('\n'))) {
        text += QLatin1Char('\n');
    }

    QTextCursor cursor = textCursor();
    cursor.beginEditBlock();
    cursor.insertBlock();
    cursor.insertText(text);
    cursor.endEditBlock();
    setTextCursor(cursor);
}
Ejemplo n.º 10
0
	QTextList *tryReadList(QTextList *list, const QString &line)
	{
		QTextList *listOut = list;
		QRegularExpression exp("^( *)(\\d+\\.|\\*) (.*)$");
		QRegularExpressionMatch match = exp.match(line);
		if (match.hasMatch())
		{
			const int indent = match.captured(1).size() / 2 + 1;
			const QString contents = match.captured(3);
			const bool ordered = match.captured(2) != "*";
			QTextListFormat fmt;
			fmt.setStyle(ordered ? QTextListFormat::ListDecimal : QTextListFormat::ListDisc);
			fmt.setIndent(indent);
			if (!listOut || fmt != listOut->format())
			{
				listOut = cursor.insertList(fmt);
			}
			else
			{
				cursor.insertBlock();
			}
			readInlineText(contents);
			listOut->add(cursor.block());
			return listOut;
		}
		else
		{
			return 0;
		}
	}
Ejemplo n.º 11
0
void TabTerminal::_insertPrompt()
{
	QTextCursor cursor = textCursor();
	cursor.insertBlock();
	insertHtml(_userPrompt);
	ensureCursorVisible();
}
Ejemplo n.º 12
0
// 设置字体格式
void MainWindow::setTextFont(bool checked)
{
    // 如果处于选中状态
    if(checked){
        QTextCursor cursor = ui->textEdit->textCursor();

        // 文本块格式
        QTextBlockFormat blockFormat;
        // 水平居中
        blockFormat.setAlignment(Qt::AlignCenter);
        // 使用文本块格式
        cursor.insertBlock(blockFormat);

        // 字符格式
        QTextCharFormat charFormat;
        // 背景色
        charFormat.setBackground(Qt::lightGray);
        // 字体颜色
        charFormat.setForeground(Qt::blue);
        // 使用宋体,12号,加粗,倾斜
        charFormat.setFont(QFont(tr("宋体"),12,QFont::Bold,true));

        // 使用下划线
        charFormat.setFontUnderline(true);
        // 使用字符格式
        cursor.setCharFormat(charFormat);
        // 插入文本
        cursor.insertText(tr("测试字体"));
    }
    // 如果处于非选中状态,可以进行其他操作
    else{/*恢复默认的字体格式*/}
}
Ejemplo n.º 13
0
/*! Append a new message to the current session and scroll to the end of the message protocol and
    returns true if the action was successful. The \a messageColor defines the color of the message
    box and should be provided as a full-color (no dimming required) color, as it is automatically
    adjusted for the border and background.
*/
bool QwcPrivateMessager::appendMessageToCurrentSession(QTextDocument *document, const QString message, const QColor messageColor)
{
    if (!document) { return false; }

    QTextCursor cursor = document->rootFrame()->lastCursorPosition();
    cursor.movePosition(QTextCursor::StartOfBlock);

    QTextFrameFormat frameFormat;
    frameFormat.setPadding(4);
    frameFormat.setBackground(messageColor.lighter(190));
    frameFormat.setMargin(0);
    frameFormat.setBorder(2);
    frameFormat.setBorderBrush(messageColor.lighter(150));
    frameFormat.setBorderStyle(QTextFrameFormat::BorderStyle_Outset);

    // Title
    QTextCharFormat backupCharFormat = cursor.charFormat();

    QTextCharFormat newCharFormat;
    newCharFormat.setFontPointSize(9);

    QTextBlockFormat headerFormat;
    headerFormat.setAlignment(Qt::AlignHCenter);
    cursor.insertBlock(headerFormat);
    cursor.setCharFormat(newCharFormat);
    cursor.insertText(QDateTime::currentDateTime().toString());

    QTextFrame *frame = cursor.insertFrame(frameFormat);
    cursor.setCharFormat(backupCharFormat);
    frame->firstCursorPosition().insertText(message);

    return true;
}
Ejemplo n.º 14
0
//	Flush the message history by flushing all current events
void
WChatLog::ChatLog_EventsRemoveAll()
	{
	clear();
	QTextCursor oTextCursor = textCursor();
	oTextCursor.insertBlock();
	m_oTextBlockComposing = oTextCursor.block();
	}
Ejemplo n.º 15
0
QTextCursor IrcChatBuffer::beginNewLine()
{
    QTextCursor cur (this->document());
    cur.movePosition(QTextCursor::End);
    cur.insertBlock();

    return cur;
}
Ejemplo n.º 16
0
void ResWaReport::BuildStaffSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n7) BuildStaffSection\n", _headerFormat);

    cursor.insertText("\n\t !! INFORMATION UNAVAILABLE !! \n", _headerFormat);
}
Ejemplo n.º 17
0
// 2)  CALLS
void ResWaReport::BuildCallsSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\n\n2) CALLS (Information, Intake, and Referal Calls)\n", _headerFormat);

    cursor.insertBlock();
    cursor.movePosition(QTextCursor::End);
    QTextTableFormat tableFormat;
    QVector<QTextLength> constraints;
    constraints << QTextLength(QTextLength::PercentageLength, 40);
    constraints << QTextLength(QTextLength::PercentageLength, 40);
    tableFormat.setColumnWidthConstraints(constraints);
    QTextTable *table = cursor.insertTable(1, 2, tableFormat);
    TextToCell(table, 0, 0, "Total calls", &_tableTextFormat);
    TextToCell(table, 0, 1, QString::number(_totalCalls), &_tableCellBlue);
}
Ejemplo n.º 18
0
void ResWaReport::BuildHeaderSection(QTextCursor& cursor)
{
    cursor.movePosition(QTextCursor::End);
    cursor.insertBlock();
    cursor.insertText("\nEVENTS\n", _headerFormat);
    cursor.insertText("1) CASES and Number of SETTLED CASES\n", _tableTextFormat);

}
Ejemplo n.º 19
0
void NotesWindow::setVisible(bool visible)
{
    if (ui->textEdit->document()->isEmpty()) {
        qSort(m_notes);
        QTextCursor cursor = ui->textEdit->textCursor();
        foreach (const NoteText &note, m_notes) {
            //cursor.insertText(s_separator);
            cursor.insertHtml(QStringLiteral("<hr>"));
            cursor.insertBlock();
            cursor.setBlockFormat(QTextBlockFormat());
            cursor.insertHtml(note.htmlHeader());
            cursor.setBlockFormat(QTextBlockFormat());
            cursor.insertBlock();
            cursor.insertBlock();
            if (note.isHtml())
                cursor.insertHtml(note.text());
            else
                cursor.insertText(note.text());
        }
Ejemplo n.º 20
0
int AutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor,
                                                       const TabSettings &tabSettings)
{
    if (!m_autoParenthesesEnabled)
        return 0;

    QTextDocument *doc = cursor.document();
    if (doc->characterAt(cursor.position() - 1) != QLatin1Char('{'))
        return 0;

    if (!contextAllowsAutoParentheses(cursor))
        return 0;

    // verify that we indeed do have an extra opening brace in the document
    QTextBlock block = cursor.block();
    const QString textFromCusror = block.text().mid(cursor.positionInBlock()).trimmed();
    int braceDepth = TextDocumentLayout::braceDepth(doc->lastBlock());

    if (braceDepth <= 0 && (textFromCusror.isEmpty() || textFromCusror.at(0) != QLatin1Char('}')))
        return 0; // braces are all balanced or worse, no need to do anything and separator inserted not between '{' and '}'

    // we have an extra brace , let's see if we should close it

    /* verify that the next block is not further intended compared to the current block.
       This covers the following case:

            if (condition) {|
                statement;
    */
    int indentation = tabSettings.indentationColumn(block.text());

    if (block.next().isValid()) { // not the last block
        block = block.next();
        //skip all empty blocks
        while (block.isValid() && tabSettings.onlySpace(block.text()))
            block = block.next();
        if (block.isValid()
                && tabSettings.indentationColumn(block.text()) > indentation)
            return 0;
    }

    const QString &textToInsert = insertParagraphSeparator(cursor);
    int pos = cursor.position();
    cursor.insertBlock();
    cursor.insertText(textToInsert);
    cursor.setPosition(pos);

    // if we actually insert a separator, allow it to be overwritten if
    // user types it
    if (!textToInsert.isEmpty())
        m_allowSkippingOfBlockEnd = true;

    return 1;
}
Ejemplo n.º 21
0
void dlgIRC::slot_joined(QString nick, QString chan )
{
    const QString _t = QTime::currentTime().toString();
    QString t = tr("<font color=#008800>[%1] %2 has joined the channel.</font>").arg(_t).arg(nick);
    QTextCursor cur = irc->textCursor();
    cur.movePosition(QTextCursor::End);
    cur.insertBlock();
    cur.insertHtml(t);
    irc->verticalScrollBar()->triggerAction(QScrollBar::SliderToMaximum);
    nickList->addItem( nick );
}
Ejemplo n.º 22
0
void dlgIRC::slot_parted(QString nick, QString chan, QString msg )
{
    const QString _t = QTime::currentTime().toString();
    QString t = tr("<font color=#888800>[%1] %2 has left the channel.</font>").arg(_t).arg(nick);
    QTextCursor cur = irc->textCursor();
    cur.movePosition(QTextCursor::End);
    cur.insertBlock();
    cur.insertHtml(t);
    irc->verticalScrollBar()->triggerAction(QScrollBar::SliderToMaximum);
    nickList->clear();
    session->sendCommand( IrcCommand::createNames( "#mudlet" ) );
}
Ejemplo n.º 23
0
int AutoCompleter::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
{
    QTextBlock block = cursor.block();
    const QString text = block.text().trimmed();
    if (text == "end"
            || text == "else"
            || text.startsWith("elsif")
            || text.startsWith("rescue")
            || text == "ensure") {
        Indenter indenter(const_cast<QTextDocument*>(block.document()));
        indenter.indentBlock(block, QChar(), tabSettings());
    }

    return 0;
    // This implementation is buggy
#if 0
    const QString textFromCursor = text.mid(cursor.positionInBlock()).trimmed();
    if (!textFromCursor.isEmpty())
        return 0;

    if (Language::symbolDefinition.indexIn(text) == -1
            && Language::startOfBlock.indexIn(text) == -1) {
        return 0;
    }

    int spaces = 0;
    for (const QChar c : text) {
        if (!c.isSpace())
            break;
        spaces++;
    }
    QString indent = text.left(spaces);

    QString line;
    QTextBlock nextBlock = block.next();
    while (nextBlock.isValid()) {
        line = nextBlock.text();
        if (Language::endKeyword.indexIn(line) != -1 && line.startsWith(indent))
            return 0;
        if (!line.trimmed().isEmpty())
            break;
        nextBlock = nextBlock.next();
    }

    int pos = cursor.position();
    cursor.insertBlock();
    cursor.insertText("end");
    cursor.setPosition(pos);

    return 1;
#endif
}
Ejemplo n.º 24
0
void PrintDialog::insertHeaderResult(QTextCursor & cursor, const QString & location, const QString & date)
{
	QTextBlockFormat blockHeaderFormat;
	blockHeaderFormat.setAlignment(Qt::AlignLeft);
	blockHeaderFormat.setTopMargin(5.0);
	blockHeaderFormat.setBottomMargin(0.0);
	blockHeaderFormat.setLeftMargin(20.0);

	QTextCharFormat headerFormat1;
	headerFormat1.setFontPointSize(10);
	headerFormat1.setFontWeight(50);
	QTextCharFormat headerFormat2;
	headerFormat2.setFontPointSize(10);
	headerFormat2.setFontWeight(50);

	cursor.insertBlock(blockHeaderFormat);
	cursor.insertText(tr("Location : "), headerFormat1);
	cursor.insertText(location, headerFormat2);

	cursor.insertBlock(blockHeaderFormat);
	cursor.insertText(tr("Date : "), headerFormat1);
	cursor.insertText(date, headerFormat2);
}
Ejemplo n.º 25
0
int Editor::autoIndent()
{
    QTextCursor cur = this->textCursor();
    if(cur.selectedText().length() > 0) {
        return 0;
    }

    int col = cur.columnNumber();

    cur.movePosition(QTextCursor::StartOfLine,QTextCursor::MoveAnchor);
    cur.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor,col);
    QString text = cur.selectedText();
    cur.clearSelection();

    int stop = -1;
    int indent = -1;
    int slcm = text.indexOf("'");

    if(slcm > -1) {
        stop = slcm;
    }

    cur.beginEditBlock();

    cur.insertBlock();

    for(int n = 0; n <= stop || isspace(text[n].toLatin1()); n++) {
        if(n == slcm) {
            if(text.indexOf("''") > -1)
                cur.insertText("''");
            else
                cur.insertText("'");
        }
        else {
            cur.insertText(" ");
        }
    }

    if(indent > 0) {
        for(int n = 0; n < indent; n++) {
            cur.insertText(" ");
        }
    }

    this->setTextCursor(cur);
    cur.endEditBlock();

    return 1;
}
Ejemplo n.º 26
0
void EmacsKeysPlugin::insertLineAndIndent()
{
    if (!m_currentEditorWidget)
        return;

    m_currentState->beginOwnAction();
    QTextCursor cursor = m_currentEditorWidget->textCursor();
    cursor.beginEditBlock();
    cursor.insertBlock();
    if (m_currentBaseTextEditorWidget != 0)
        m_currentBaseTextEditorWidget->textDocument()->autoIndent(cursor);
    cursor.endEditBlock();
    m_currentEditorWidget->setTextCursor(cursor);
    m_currentState->endOwnAction(KeysActionOther);
}
Ejemplo n.º 27
0
void PrintDialog::insertTitleResult(QTextCursor & cursor, const QString & raceName)
{
	QTextBlockFormat blockTitleFormat;
	blockTitleFormat.setAlignment(Qt::AlignCenter);
	blockTitleFormat.setTopMargin(0.0);
	blockTitleFormat.setBottomMargin(80.0);

	QTextCharFormat titleFormat;
	titleFormat.setFontPointSize(20);
	titleFormat.setFontWeight(50);
	titleFormat.setFontCapitalization(QFont::AllUppercase);

	cursor.insertBlock(blockTitleFormat);
	cursor.insertText(raceName, titleFormat);
}
Ejemplo n.º 28
0
void PrintDialog::insertSeparatorLine(QTextCursor & cursor)
{
	QTextBlockFormat blockSeparatorFormat;
	blockSeparatorFormat.setAlignment(Qt::AlignCenter);
	blockSeparatorFormat.setTopMargin(10.0);
	blockSeparatorFormat.setBottomMargin(10.0);

	QTextCharFormat separatorFormat;
	separatorFormat.setFontCapitalization(QFont::AllUppercase);
	separatorFormat.setFontWeight(50);
	separatorFormat.setFontPointSize(10.0);

	cursor.insertBlock(blockSeparatorFormat);
	cursor.insertText("_______________________________________________",separatorFormat);
}
Ejemplo n.º 29
0
void sbTermConsole::putData(const QByteArray &data, sbTermConsole::eInputSense sense)
{   
    QString prefix("");
    if (d->datetime) {
        prefix += QString("<span style='color:%1;font-family:Courier'>[ %2 ] </span> ")
                .arg(d->dtColor)
                .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"));
    }

    QString color;
    QString senseStr;
    switch(sense) {
    case RX:
        senseStr = "RX";
        color = QString(d->rxColor);
        break;
    case TX:
        senseStr = "TX";
        color = QString(d->txColor);
        break;
    default:
        senseStr = "NO-GO";
        color = "white";
        break;
    }
    QString toDisplay = d->displayHexa ? d->convertToHex(QString(data)) : QString(data);
    // replacing html entities:
    toDisplay.replace("&", "&amp;");
    toDisplay.replace(">", "&gt;");
    toDisplay.replace("<", "&lt;");
    toDisplay.replace(" ", "&nbsp;");

    QString htmlDisplay = QString("%1 <span style='color:%3;font-weight:bold;font-family:Courier'>%2 # </span><span style='color:%3;font-family:Courier'>%4</span>")
            .arg(prefix)
            .arg(senseStr)
            .arg(color)
            .arg(toDisplay);
    this->insertHtml(htmlDisplay);

    QTextCursor cursor = this->textCursor();
    cursor.insertBlock();
    this->setTextCursor(cursor);

    QScrollBar *bar = verticalScrollBar();
    bar->setValue(bar->maximum());
}
Ejemplo n.º 30
0
void instDialog::summary()
{
    QStringList str;

    str.append(QObject::tr("Summary:"));
    str.append(QObject::tr("* Running as user : %1").arg(user_name));
    str.append(QObject::tr("* Firewall name : %1")
               .arg(QString::fromUtf8(cnf.fwobj->getName().c_str())));
    str.append(QObject::tr("* Installer uses user name : %1").arg(cnf.user));

    // print destination machine address or name correctly, taking into
    // account putty session if any
    if (!cnf.putty_session.isEmpty())
        str.append(QObject::tr("* Using putty session: %1").arg(cnf.putty_session));
    else
        str.append(QObject::tr("* Management address : %1").arg(cnf.maddr));

    str.append(QObject::tr("* Platform : %1")
              .arg(cnf.fwobj->getStr("platform").c_str()));
    str.append(QObject::tr("* Host OS : %1")
              .arg(cnf.fwobj->getStr("host_OS").c_str()));
    str.append(QObject::tr("* Loading configuration from file %1")
              .arg(cnf.fwbfile));

    if (cnf.save_diff)
        str.append(QObject::tr("* Configuration diff will be saved in file %1").
                   arg(cnf.diff_file));

    if (cnf.dry_run)
        str.append(QObject::tr("* Commands will not be executed on the firewall"));

    if (fwbdebug)
    {
        str.append(QObject::tr("--------------------------------"));
        str.append(QObject::tr("* Variables:"));
        str.append(QObject::tr("* fwdir= %1") .arg(cnf.fwdir));
        str.append(QObject::tr("* fwscript= %1") .arg(cnf.fwscript));
        str.append(QObject::tr("* remote_script= %1") .arg(cnf.remote_script));
    }

    str.append("");

    QTextCursor cursor = m_dialog->procLogDisplay->textCursor();
    cursor.insertBlock();
    cursor.insertText(str.join("\n"), highlight_format);
}