aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--editorpage.cpp2
-rw-r--r--textedit.cpp23
-rw-r--r--textedit.h1
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));
+}
diff --git a/textedit.h b/textedit.h
index 32dca58..5ee9931 100644
--- a/textedit.h
+++ b/textedit.h
@@ -53,6 +53,7 @@ public slots:
void open();
void print();
void newTab();
+ void showModified();
private:
bool isKey(QString key);