OSDN Git Service

[denncoCreator] save functionality in progress
[dennco/denncoCreator.git] / Source / mainwindow.cpp
index 9ba7703..978af16 100644 (file)
@@ -102,40 +102,24 @@ void MainWindow::open()
 
 //! [9]
 bool MainWindow::save()
-//! [9] //! [10]
 {
-    if (curContent.isEmpty()) {
-        return saveAs();
-    } else {
-        return saveContent(curContent);
-    }
+    return saveContent();
 }
-//! [10]
 
-//! [11]
 bool MainWindow::saveAs()
-//! [11] //! [12]
 {
-    QString dirName = QFileDialog::getSaveFileName(this);
-    if (dirName.isEmpty())
-        return false;
-
-    return saveContent(dirName);
+    //TODO
+    return false;
 }
-//! [12]
 
-//! [13]
 void MainWindow::about()
-//! [13] //! [14]
 {
    QMessageBox::about(this, tr("About Application"),
             tr("TODO: exampalin\81@about <b>dennco creator</b>  "
                "TODO: exampalin\81@about <b>dennco creator</b> "
                "TODO: exampalin\81@about <b>dennco creator</b>"));
 }
-//! [14]
 
-//! [15]
 void MainWindow::documentWasModified()
 //! [15] //! [16]
 {
@@ -305,34 +289,30 @@ bool MainWindow::maybeSave()
 
 //! [42]
 void MainWindow::loadContent(const QString &contentDirectory)
-//! [42] //! [43]
 {
-
     if (!mCreator)
         return;
 
-    //TODO
-    QByteArray aContentDirectory = contentDirectory.toLocal8Bit();
-    mCreator->loadContent(aContentDirectory.data());
+    mCreator->loadContent(contentDirectory);
 
     setCurrentContent(contentDirectory);
     statusBar()->showMessage(tr("Content loaded"), 2000);
 }
-//! [43]
 
-//! [44]
-bool MainWindow::saveContent(const QString &contentDirectory)
+bool MainWindow::saveContent()
 {
+    if (!mCreator)
+        return false;
 
-    //TODO
+    if (mCreator->getCurrentContainer())
+    {
+        mCreator->saveAll();
+        statusBar()->showMessage(tr("Content saved"), 2000);
+    }
 
-    setCurrentContent(contentDirectory);
-    statusBar()->showMessage(tr("Content saved"), 2000);
     return true;
 }
-//! [45]
 
-//! [46]
 void MainWindow::setCurrentContent(const QString &contentDirectory)
 {
     curContent = contentDirectory;