diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-01-02 14:04:57 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2011-01-02 14:04:57 +0000 |
commit | f9deac36aa7970c23d6b3965f9b7a09e4bcf89b8 (patch) | |
tree | 68904a125a5f85930a39407aa1f9ce35551fc2db | |
parent | added new tab action and made some minor bugfixes (diff) | |
download | gpg4usb-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
-rw-r--r-- | editorpage.cpp | 2 | ||||
-rw-r--r-- | textedit.cpp | 23 | ||||
-rw-r--r-- | textedit.h | 1 |
3 files changed, 21 insertions, 5 deletions
diff --git a/editorpage.cpp b/editorpage.cpp index 50faca8..f60f4aa 100644 --- a/editorpage.cpp +++ b/editorpage.cpp @@ -32,7 +32,7 @@ EditorPage::EditorPage(const QString &filePath, QWidget *parent) : QWidget(paren mainLayout = new QHBoxLayout(); mainLayout->setSpacing(0); mainLayout->addWidget(textPage); - + mainLayout->setContentsMargins(0,0,0,0); setLayout(mainLayout); setAttribute(Qt::WA_DeleteOnClose); } 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)); +} @@ -53,6 +53,7 @@ public slots: void open(); void print(); void newTab(); + void showModified(); private: bool isKey(QString key); |