author | hrw <hrw> | 2005-10-20 14:55:34 (UTC) |
---|---|---|
committer | hrw <hrw> | 2005-10-20 14:55:34 (UTC) |
commit | 57abd83eb7b79b95301de36dc178174d9b28b6c2 (patch) (side-by-side diff) | |
tree | b869bb94ec37a278bfed66877a1320d807399f94 /core/pim/notes/editwindow.cpp | |
parent | 0f25331618ea6cac8a59f2c2298a9e1684748b97 (diff) | |
download | opie-57abd83eb7b79b95301de36dc178174d9b28b6c2.zip opie-57abd83eb7b79b95301de36dc178174d9b28b6c2.tar.gz opie-57abd83eb7b79b95301de36dc178174d9b28b6c2.tar.bz2 |
added Opie-Notes
Diffstat (limited to 'core/pim/notes/editwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/notes/editwindow.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/core/pim/notes/editwindow.cpp b/core/pim/notes/editwindow.cpp new file mode 100644 index 0000000..1b2d4a6 --- a/dev/null +++ b/core/pim/notes/editwindow.cpp @@ -0,0 +1,57 @@ +#include "editwindow.h" + +editWindowWidget::editWindowWidget( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) +{ + setCaption( tr( "Information:" ) ); + QGridLayout *gridLayout = new QGridLayout(this, 1, 1, 5, 5); + editArea = new QMultiLineEdit(this, "editArea"); + gridLayout->addWidget(editArea, 0, 0); + editArea->setWordWrap(QMultiLineEdit::WidgetWidth); + + showMaximized(); +} + +void editWindowWidget::loadFile(QString fileName) +{ + QFileInfo fileinfo(fileName); + setCaption(fileinfo.fileName()); + + QFile file(fileName); + + if (file.exists()) + { + if (!file.open(IO_ReadOnly)) + { + QMessageBox::warning(0, tr("File i/o error"), fileName.sprintf(tr("Could not read file '%s'"), fileName)); + } + else + { + QTextStream inStream(&file); + inStream.setEncoding(QTextStream::UnicodeUTF8); + editArea->setText(inStream.read()); + file.close(); + } + } +} + +void editWindowWidget::saveFile(QString fileName) +{ + QFile file(fileName); + + if(!file.open(IO_WriteOnly)) + { + QMessageBox::warning(0, tr("File i/o error"), fileName.sprintf(tr("Could not write file '%s'"), fileName)); + } + else + { + QTextStream outStream(&file); + outStream.setEncoding(QTextStream::UnicodeUTF8); + outStream << editArea->text(); + file.close(); + this->accept(); + } +} + +editWindowWidget::~editWindowWidget() +{ +} |