16 #include <QTextDocument> 17 #include <QPushButton> 18 #include <QTextStream> 23 #include <QFileSystemWatcher> 32 mTextDocument(new QTextDocument(this)),
33 mTextEdit(new QTextEdit(this)),
34 mSaveButton(new QPushButton(
"Save", this))
36 this->setToolTip(
"Preview and edit a file");
37 mSyntaxHighlighter = NULL;
38 connect(mSaveButton, SIGNAL(clicked()),
this, SLOT(
saveSlot()));
39 mSaveButton->setEnabled(
false);
41 QHBoxLayout* buttonLayout =
new QHBoxLayout();
42 buttonLayout->addStretch();
43 buttonLayout->setMargin(0);
44 buttonLayout->addWidget(mSaveButton);
46 QVBoxLayout* layout =
new QVBoxLayout(
this);
48 layout->addWidget(mTextEdit);
49 layout->addLayout(buttonLayout);
51 connect(mTextEdit, SIGNAL(textChanged()),
this, SLOT(
textChangedSlot()));
52 mTextEdit->setDocument(mTextDocument);
53 mTextEdit->setLineWrapMode(QTextEdit::NoWrap);
55 this->setSyntaxHighLighter<snw::SyntaxHighlighter>();
63 mSaveButton->setEnabled(mTextDocument->isModified());
68 mSaveButton->setEnabled(
false);
74 QString text = stream.readAll();
77 mTextDocument->setPlainText(text);
78 mTextDocument->setModified(
false);
88 if(!
mCurrentFile->open(QIODevice::WriteOnly | QIODevice::Truncate))
94 mCurrentFile->write(mTextDocument->toPlainText().toLatin1());
97 mTextDocument->setModified(
false);
void reportWarning(QString msg)
Namespace for all CustusX production code.