From 75efabd713a23f72e890bd36b0e3a1bf6d7fc45e Mon Sep 17 00:00:00 2001 From: nils Date: Thu, 26 Jan 2012 17:24:31 +0000 Subject: commenting and code shortening git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@780 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- editorpage.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'editorpage.cpp') diff --git a/editorpage.cpp b/editorpage.cpp index fbf6209..b057f8b 100644 --- a/editorpage.cpp +++ b/editorpage.cpp @@ -24,18 +24,21 @@ EditorPage::EditorPage(const QString &filePath, QWidget *parent) : QWidget(parent), fullFilePath(filePath) { + // Set the Textedit properties textPage = new QTextEdit(); textPage->setAcceptRichText(false); + + // Set the layout style mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); mainLayout->addWidget(textPage); mainLayout->setContentsMargins(0,0,0,0); setLayout(mainLayout); + setAttribute(Qt::WA_DeleteOnClose); textPage->setFocus(); //connect(textPage, SIGNAL(textChanged()), this, SLOT(formatGpgHeader())); - } const QString& EditorPage::getFilePath() const @@ -73,6 +76,8 @@ void EditorPage::closeNoteByClass(const char *className) void EditorPage::formatGpgHeader() { QString content = textPage->toPlainText(); + + // Get positions of the gpg-headers, if they exist int start = content.indexOf(GpgConstants::PGP_SIGNED_BEGIN); int startSig = content.indexOf(GpgConstants::PGP_SIGNATURE_BEGIN); int endSig = content.indexOf(GpgConstants::PGP_SIGNATURE_END); @@ -83,15 +88,18 @@ void EditorPage::formatGpgHeader() { signMarked = true; + // Set the fontstyle for the header QTextCharFormat signFormat; signFormat.setForeground(QBrush(QColor::fromRgb(80,80,80))); signFormat.setFontPointSize(9); + // set font style for the signature QTextCursor cursor(textPage->document()); cursor.setPosition(startSig, QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, endSig); cursor.setCharFormat(signFormat); + // set the font style for the header int headEnd = content.indexOf("\n\n", start); cursor.setPosition(start, QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, headEnd); -- cgit v1.2.3