From 57abd83eb7b79b95301de36dc178174d9b28b6c2 Mon Sep 17 00:00:00 2001 From: hrw Date: Thu, 20 Oct 2005 14:55:34 +0000 Subject: added Opie-Notes --- (limited to 'core/pim/notes/editwindow.cpp') 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() +{ +} -- cgit v0.9.0.2