16 #include <QTextDocument> 17 #include <QPushButton> 18 #include <QTextStream> 23 #include <QFileSystemWatcher> 33 mTextDocument(new QTextDocument(this)),
34 mTextEdit(new QTextEdit(this)),
35 mSaveButton(new QPushButton(
"Save", this))
37 mData = dataInterface;
44 this->setToolTip(
"Preview and edit a file");
45 mSyntaxHighlighter = NULL;
46 connect(mSaveButton, SIGNAL(clicked()),
this, SLOT(
saveSlot()));
47 mSaveButton->setEnabled(
false);
49 connect(mTextEdit, SIGNAL(textChanged()),
this, SLOT(
textChangedSlot()));
50 mTextEdit->setDocument(mTextDocument);
51 mTextEdit->setLineWrapMode(QTextEdit::NoWrap);
53 this->setSyntaxHighLighter<snw::SyntaxHighlighter>();
55 this->createAndAddEditorLayout(gridLayout, row);
61 void FilePreviewWidget::createAndAddEditorLayout(QGridLayout *gridLayout,
int row)
63 QHBoxLayout* buttonLayout =
new QHBoxLayout();
64 buttonLayout->addStretch();
65 buttonLayout->setMargin(0);
66 buttonLayout->addWidget(mSaveButton);
70 layout =
new QVBoxLayout();
72 layout =
new QVBoxLayout(
this);
75 layout->addWidget(mTextEdit);
76 layout->addLayout(buttonLayout);
79 gridLayout->addLayout(layout, row, 0);
87 mSaveButton->setEnabled(mTextDocument->isModified());
97 mSaveButton->setEnabled(
false);
103 QString text = stream.readAll();
106 mTextDocument->setPlainText(text);
107 mTextDocument->setModified(
false);
117 if(!
mCurrentFile->open(QIODevice::WriteOnly | QIODevice::Truncate))
123 mCurrentFile->write(mTextDocument->toPlainText().toLatin1());
126 mTextDocument->setModified(
false);
boost::shared_ptr< class FilePreviewProperty > FilePreviewPropertyPtr
void reportWarning(QString msg)
void changed()
emit when the underlying data value is changed: The user interface will be updated.
Namespace for all CustusX production code.