aboutsummaryrefslogtreecommitdiffstats
path: root/textedit.cpp
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-02 14:04:57 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2011-01-02 14:04:57 +0000
commitf9deac36aa7970c23d6b3965f9b7a09e4bcf89b8 (patch)
tree68904a125a5f85930a39407aa1f9ce35551fc2db /textedit.cpp
parentadded new tab action and made some minor bugfixes (diff)
downloadgpg4usb-f9deac36aa7970c23d6b3965f9b7a09e4bcf89b8.tar.gz
gpg4usb-f9deac36aa7970c23d6b3965f9b7a09e4bcf89b8.zip
added star in tabtitle, if document is changed
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@421 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to 'textedit.cpp')
-rw-r--r--textedit.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/textedit.cpp b/textedit.cpp
index 6eb96e2..39e0626 100644
--- a/textedit.cpp
+++ b/textedit.cpp
@@ -77,9 +77,11 @@ void TextEdit::newTab()
QString header = "new " +
QString::number(++countPage);
- tabWidget->addTab(new EditorPage(), header);
+ EditorPage *page = new EditorPage();
+ tabWidget->addTab(page, header);
tabWidget->setCurrentIndex(tabWidget->count() - 1);
+ connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified()));
// setCursorPosition();
}
@@ -91,11 +93,12 @@ void TextEdit::open()
setCurrentFile(fileName);
if (!fileName.isEmpty())
{
- EditorPage *page = new EditorPage(fileName);
QFile file(fileName);
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
+ EditorPage *page = new EditorPage(fileName);
+
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
page->getTextPage()->setPlainText(in.readAll());
@@ -106,9 +109,11 @@ void TextEdit::open()
tabWidget->addTab(page, strippedName(fileName));
tabWidget->setCurrentIndex(tabWidget->count() - 1);
- QApplication::restoreOverrideCursor();
+ QApplication::restoreOverrideCursor();
+ connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified()));
// setCursorPosition();
- //enableAction(true);
+ //enableAction(true)
+
}
else
{
@@ -430,3 +435,13 @@ void TextEdit::print()
#endif
}
+/** put a * in front of every modified document tab
+ */
+void TextEdit::showModified() {
+ int index=tabWidget->currentIndex();
+ QString title= tabWidget->tabText(index);
+ if(curTextPage()->document()->isModified())
+ tabWidget->setTabText(index, title.prepend("* "));
+ else
+ tabWidget->setTabText(index, title.remove(0,2));
+}