~ubuntu-branches/ubuntu/lucid/skrooge/lucid

« back to all changes in this revision

Viewing changes to skgbasemodeler/skgdocument.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2009-05-02 06:47:15 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090502064715-b7l4eciitw3asos3
Tags: 0.2.7-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
307
307
                if (err.isSucceeded()) err = msg.setAttribute("t_message", iMessage);
308
308
                if (err.isSucceeded()) err = msg.setAttribute("t_popup", iPopup ? "Y" : "N");
309
309
                if (err.isSucceeded()) err = msg.save();
 
310
        } else {
 
311
                //Addition message in global variable in case of no transaction opened
 
312
                if (iPopup) unTransactionnalMessages.push_back(iMessage);
310
313
        }
311
 
 
312
 
        //Addition message in global variable in case of
313
 
        if (iPopup) unTransactionnalMessages.push_back(iMessage);
314
314
        return err;
315
315
}
316
316
 
705
705
                                        } else {
706
706
                                                //Copy in memory
707
707
                                                {//This scope is needed to avoid a warning at remove
708
 
                                                        QSqlDatabase dbfile = QSqlDatabase::addDatabase("QSQLITE", "TEMPORARY");
 
708
                                                        QSqlDatabase dbfile = QSqlDatabase::addDatabase("QSQLITE", "TEMPORARY_LOAD");
709
709
                                                        dbfile.setDatabaseName(name);
710
710
                                                        if (!dbfile.open()) {
711
711
                                                                //Set error message
713
713
                                                                err = SKGError(SQLLITEERROR + sqlErr.number(), sqlErr.text());
714
714
                                                        } else {
715
715
                                                                //Copy db from file to memory
716
 
                                                                err = SKGServices::copySqliteDatabase(name, &dbfile, getDatabase(), true);
 
716
                                                                err = SKGServices::copySqliteDatabase(&dbfile, getDatabase(), true);
717
717
 
718
718
                                                                //Close
719
719
                                                                dbfile.close();
720
720
                                                        }
721
721
                                                }
722
722
                                                //Remove database
723
 
                                                QSqlDatabase::removeDatabase("TEMPORARY");
 
723
                                                QSqlDatabase::removeDatabase("TEMPORARY_LOAD");
724
724
                                        }
725
725
 
726
726
                                        currentFileName=name;
885
885
                                } else {
886
886
                                        //Open database
887
887
                                        if (getDatabaseMode()==CopiedInMemory) {
888
 
                                                //Remove previous file
889
 
                                                QFile(name).remove();
890
 
 
891
888
                                                {//This scope is needed to avoid a warning at remove
892
 
                                                        //Copy memory in file
893
 
                                                        QSqlDatabase dbfile = QSqlDatabase::addDatabase("QSQLITE", "TEMPORARY");
894
 
                                                        dbfile.setDatabaseName(name);
895
 
                                                        if (!dbfile.open()) {
 
889
                                                        //Remove previous file
 
890
                                                        if (QFile(name).exists()) {
 
891
                                                                SKGTRACEL(20) << "WARNING: [" << name << "] exists ==> remove it !" << endl;
 
892
                                                                QFile::remove(name);
 
893
                                                        }
 
894
 
 
895
                                                        if (QFile(name).exists()) {
896
896
                                                                //Set error message
897
 
                                                                QSqlError sqlErr=dbfile.lastError();
898
 
                                                                err = SKGError(SQLLITEERROR + sqlErr.number(), sqlErr.text());
 
897
                                                                err.setReturnCode(ERR_FAIL);
 
898
                                                                err.setMessage(tr("Impossible to remove [%1]").arg(name));
899
899
                                                        } else {
900
 
                                                                //Copy db from memory to file
901
 
                                                                err = SKGServices::copySqliteDatabase(name, &dbfile, getDatabase(), false);
 
900
                                                                //Copy memory in file
 
901
                                                                QSqlDatabase dbfile = QSqlDatabase::addDatabase("QSQLITE", "TEMPORARY_SAVE");
 
902
                                                                dbfile.setDatabaseName(name);
 
903
                                                                if (!dbfile.open()) {
 
904
                                                                        //Set error message
 
905
                                                                        QSqlError sqlErr=dbfile.lastError();
 
906
                                                                        err = SKGError(SQLLITEERROR + sqlErr.number(), sqlErr.text());
 
907
                                                                } else {
 
908
                                                                        //Copy db from memory to file
 
909
                                                                        err = SKGServices::copySqliteDatabase(&dbfile, getDatabase(), false);
902
910
 
903
 
                                                                //Close db
904
 
                                                                dbfile.close();
 
911
                                                                        //Close db
 
912
                                                                        dbfile.close();
 
913
                                                                }
905
914
                                                        }
906
915
                                                }
907
916
 
908
917
                                                //Remove database
909
 
                                                QSqlDatabase::removeDatabase("TEMPORARY");
 
918
                                                QSqlDatabase::removeDatabase("TEMPORARY_SAVE");
910
919
                                        } else if (getDatabaseMode()==CopiedInFile) {
911
920
                                                //Rename previous file
912
921
                                                QFile(name).rename(name+".old");
1562
1571
        if (output.endsWith("t_name")) output=tr("Name");
1563
1572
        else if (output.endsWith("d_date")) output=tr("Date");
1564
1573
        else if (output.endsWith("t_savestep")) output=tr("Save");
 
1574
        else if (output.endsWith("t_value")) output=tr("Value");
 
1575
        else if (output.endsWith("d_lastmodifdate")) output=tr("Last modification");
1565
1576
        return output;
1566
1577
}
1567
1578