8
#include <qmultilineedit.h>
10
#include <qmessagebox.h>
11
#include <qfiledialog.h>
12
#include <qtextstream.h>
13
#include <qclipboard.h>
14
#include <qapplication.h>
17
* Constructs a TextView which is a child of 'parent', with the
18
* name 'name' and widget flags set to 'f'
20
* The dialog will by default be modeless, unless you set 'modal' to
21
* TRUE to construct a modal dialog.
23
TextView::TextView(QWidget* parent, const char* name, bool modal, WFlags fl)
24
: TextViewGUI( parent, name, modal, fl )
26
textEdit->setWordWrap(QTextEdit::FixedColumnWidth);
27
textEdit->setWrapColumnOrWidth(80);
29
f.setStyleHint(QFont::TypeWriter);
34
* Destroys the object and frees any allocated resources
38
// no need to delete child widgets, Qt does it all for us
44
void TextView::saveMe()
46
QString fileName(QFileDialog::getSaveFileName(QString::null,
47
tr("Text Files (*.txt);;All Files (*)"),
49
if (fileName.isEmpty())
54
// Confirm overwriting file.
55
if (QFile(fileName).exists())
56
if (QMessageBox::information(this, PACKAGE,
57
tr("This file already exists. Do you want to overwrite it?"),
58
tr("Yes"), tr("No"), 0, 0, 1) == 1)
61
if (!file.open(IO_WriteOnly))
64
s.sprintf(tr("Failed to write to file") + " %s", fileName.latin1());
65
QMessageBox::warning(this, PACKAGE, s);
69
QTextStream stream(&file);
70
stream << textEdit->text();
74
void TextView::setMatrix(Matrix *m, ASCII_Import *charset)
77
textEdit->setText(m->printMe(charset));
80
void TextView::toClipboard()
82
QApplication::clipboard()->setText(textEdit->text());