-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.h | 5 |
2 files changed, 20 insertions, 23 deletions
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index efbcc20..09ee68b 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp @@ -55,2 +55,3 @@ MainWindow::MainWindow() // construct objects + currentDoc=0; fileSelector=new FileSelector("application/sheet-qt", this, QString::null); @@ -73,3 +74,3 @@ MainWindow::MainWindow() // create sheets - selectorFileNew(currentDoc); + selectorFileNew(DocLnk()); } @@ -78,5 +79,6 @@ MainWindow::~MainWindow() { + if (currentDoc) delete currentDoc; } -void MainWindow::documentSave(DocLnk &lnkDoc) +void MainWindow::documentSave(DocLnk *lnkDoc) { @@ -102,4 +104,4 @@ void MainWindow::documentSave(DocLnk &lnkDoc) - lnkDoc.setType("application/sheet-qt"); - if (!fm.saveFile(lnkDoc, streamBuffer)) + lnkDoc->setType("application/sheet-qt"); + if (!fm.saveFile(*lnkDoc, streamBuffer)) { @@ -174,3 +176,3 @@ int MainWindow::saveCurrentFile(bool ask=TRUE) - if (currentDoc.name().isEmpty() || !currentDoc.isValid()) + if (!currentDoc->isValid()) { @@ -179,3 +181,5 @@ int MainWindow::saveCurrentFile(bool ask=TRUE) - currentDoc.setName(dialogText.getValue()); + currentDoc->setName(dialogText.getValue()); + currentDoc->setFile(QString::null); + currentDoc->setLinkFile(QString::null); } @@ -186,12 +190,2 @@ int MainWindow::saveCurrentFile(bool ask=TRUE) -void MainWindow::copyDocLnk(const DocLnk &source, DocLnk &target) -{ - target.setName(source.name()); - target.setFile(source.file()); - target.setLinkFile(source.linkFile()); - target.setComment(source.comment()); - target.setType(source.type()); - target.setCategories(source.categories()); -} - void MainWindow::selectorFileNew(const DocLnk &lnkDoc) @@ -201,3 +195,4 @@ void MainWindow::selectorFileNew(const DocLnk &lnkDoc) if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; - copyDocLnk(lnkDoc, currentDoc); + if (currentDoc) delete currentDoc; + currentDoc = new DocLnk(lnkDoc); listSheets.clear(); @@ -225,3 +220,4 @@ void MainWindow::selectorFileOpen(const DocLnk &lnkDoc) if (documentModified && saveCurrentFile()==QMessageBox::Cancel) return; - copyDocLnk(lnkDoc, currentDoc); + if (currentDoc) delete currentDoc; + currentDoc = new DocLnk(lnkDoc); listSheets.clear(); @@ -756,5 +752,7 @@ void MainWindow::slotFileSaveAs() TextDialog dialogText(this); - if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc.name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; + if (dialogText.exec(tr("Save File As"), tr("&File Name:"), currentDoc->name())!=QDialog::Accepted || dialogText.getValue().isEmpty()) return; - currentDoc.setName(dialogText.getValue()); + currentDoc->setName(dialogText.getValue()); + currentDoc->setFile(QString::null); + currentDoc->setLinkFile(QString::null); documentSave(currentDoc); diff --git a/noncore/apps/opie-sheet/mainwindow.h b/noncore/apps/opie-sheet/mainwindow.h index 554e6f6..d68e25c 100644 --- a/noncore/apps/opie-sheet/mainwindow.h +++ b/noncore/apps/opie-sheet/mainwindow.h @@ -41,3 +41,3 @@ class MainWindow: public QMainWindow // QPE objects - DocLnk currentDoc; + DocLnk* currentDoc; QPEMenuBar *menu; @@ -78,4 +78,3 @@ class MainWindow: public QMainWindow void documentOpen(const DocLnk &lnkDoc); - void copyDocLnk(const DocLnk &source, DocLnk &target); - void documentSave(DocLnk &lnkDoc); + void documentSave(DocLnk *lnkDoc); void closeEvent(QCloseEvent *e); |