Diffstat (limited to 'noncore/apps/opie-sheet/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/mainwindow.cpp | 38 |
1 files changed, 18 insertions, 20 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 @@ -54,4 +54,5 @@ MainWindow::MainWindow() // construct objects + currentDoc=0; fileSelector=new FileSelector("application/sheet-qt", this, QString::null); connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); @@ -72,12 +73,13 @@ MainWindow::MainWindow() // create sheets - selectorFileNew(currentDoc); + selectorFileNew(DocLnk()); } MainWindow::~MainWindow() { + if (currentDoc) delete currentDoc; } -void MainWindow::documentSave(DocLnk &lnkDoc) +void MainWindow::documentSave(DocLnk *lnkDoc) { FileManager fm; @@ -101,6 +103,6 @@ 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)) { QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); @@ -173,10 +175,12 @@ int MainWindow::saveCurrentFile(bool ask=TRUE) } - if (currentDoc.name().isEmpty() || !currentDoc.isValid()) + if (!currentDoc->isValid()) { TextDialog dialogText(this); if (dialogText.exec(tr("Save File"), tr("&File Name:"), tr("UnnamedFile"))!=QDialog::Accepted || dialogText.getValue().isEmpty()) return QMessageBox::Cancel; - currentDoc.setName(dialogText.getValue()); + currentDoc->setName(dialogText.getValue()); + currentDoc->setFile(QString::null); + currentDoc->setLinkFile(QString::null); } @@ -185,14 +189,4 @@ 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) { @@ -200,5 +194,6 @@ 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(); comboSheets->clear(); @@ -224,5 +219,6 @@ 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(); comboSheets->clear(); @@ -755,7 +751,9 @@ 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); } |