~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/agents/rksaveagent.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2009-10-26 14:30:00 UTC
  • mfrom: (1.1.13 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20091026143000-wzwt6cryjnwce23k
Tags: 0.5.2-1
* new upstream release
  closes: #551306 (added support for the new dynamic help system)
* Add "DM-Upload-Allowed: yes" in control
* bump standards version to 3.8.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
                          rksaveagent  -  description
3
3
                             -------------------
4
4
    begin                : Sun Aug 29 2004
5
 
    copyright            : (C) 2004 by Thomas Friedrichsmeier
 
5
    copyright            : (C) 2004, 2009 by Thomas Friedrichsmeier
6
6
    email                : tfry@users.sourceforge.net
7
7
 ***************************************************************************/
8
8
 
30
30
 
31
31
#include "../debug.h"
32
32
 
33
 
RKSaveAgent::RKSaveAgent (KUrl url, bool save_file_as, DoneAction when_done, KUrl load_url) {
 
33
RKSaveAgent::RKSaveAgent (KUrl url, bool save_file_as, DoneAction when_done, KUrl load_url) : QObject () {
34
34
        RK_TRACE (APP);
35
35
        save_url = url;
36
36
        RKSaveAgent::when_done = when_done;
37
37
        RKSaveAgent::load_url = load_url;
38
38
        save_chain = 0;
39
39
        if (save_url.isEmpty () || save_file_as) {
40
 
                if (!askURL ()) return;
 
40
                if (!askURL ()) {
 
41
                        deleteLater();
 
42
                        return;
 
43
                }
41
44
        }
42
45
        
43
46
        RKWorkplace::mainWorkplace ()->flushAllData ();
44
47
        save_chain = RKGlobals::rInterface ()->startChain (0);
45
48
        
46
49
        RKWorkplace::mainWorkplace ()->saveWorkplace (save_chain);
47
 
        RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
 
50
        RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.toLocalFile () + "\")", RCommand::App, QString::null, this), save_chain);
48
51
        RKWorkplace::mainWorkplace ()->clearWorkplaceDescription (save_chain);
49
52
}
50
53
 
54
57
 
55
58
bool RKSaveAgent::askURL () {
56
59
        RK_TRACE (APP);
57
 
        save_url = KFileDialog::getSaveFileName (save_url.path (), "*.R");
 
60
        save_url = KFileDialog::getSaveFileName (save_url, "*.R");
58
61
        if (save_url.isEmpty ()) {
59
62
                if (when_done != DoNothing) {
60
 
                        if (KMessageBox::warningYesNo (0, i18n ("No filename given. Your data was NOT saved. Do you still want to proceed?")) == KMessageBox::No) when_done = DoNothing;
 
63
                        if (KMessageBox::warningYesNo (0, i18n ("No filename given. Your data was NOT saved. Do you still want to proceed?")) != KMessageBox::Yes) when_done = DoNothing;
61
64
                }
62
 
                done ();
63
65
                return false;
64
66
        }
65
67
        return true;
68
70
void RKSaveAgent::rCommandDone (RCommand *command) {
69
71
        RK_TRACE (APP);
70
72
        if (command->hasError ()) {
 
73
                int res;
71
74
                if (when_done != DoNothing) {
72
 
                        int res;
73
75
                        res = KMessageBox::warningYesNoCancel (0, i18n ("Saving to file '%1' failed. What do you want to do?", save_url.path ()), i18n ("Save failed"), KGuiItem (i18n ("Try saving with a different filename")), KGuiItem (i18n ("Saving failed")));
74
 
                        if (res == KMessageBox::Yes) {
75
 
                                if (askURL ()) RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
76
 
                                return;
77
 
                        } else if (res == KMessageBox::No) {
78
 
                                done ();
79
 
                                return;
80
 
                        } else {
81
 
                                when_done = DoNothing;
82
 
                                done ();
83
 
                                return;
84
 
                        }
85
76
                } else {
86
 
                        if (KMessageBox::warningYesNo (0, i18n ("Saving to file '%1' failed. Do you want to try saving to a different filename?", save_url.path ())) == KMessageBox::Yes) {
87
 
                                if (askURL ()) RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.path () + "\")", RCommand::App, QString::null, this), save_chain);
88
 
                                return;
89
 
                        } else {
90
 
                                done ();
 
77
                        res = KMessageBox::warningYesNo (0, i18n ("Saving to file '%1' failed. Do you want to try saving to a different filename?", save_url.path ()));
 
78
                }
 
79
 
 
80
                if (res == KMessageBox::Yes) {
 
81
                        if (askURL ()) {
 
82
                                RKGlobals::rInterface ()->issueCommand (new RCommand ("save.image (\"" + save_url.toLocalFile () + "\")", RCommand::App, QString::null, this), save_chain);
91
83
                                return;
92
84
                        }
 
85
                } else if (res == KMessageBox::No) {
 
86
                        done ();
 
87
                        return;
93
88
                }
 
89
 
 
90
                // else
 
91
                when_done = DoNothing;
94
92
        } else {
95
93
                RObjectList::getObjectList ()->setWorkspaceURL (save_url);
96
94
                RKWardMainWindow::getMain ()->setCaption (QString::null);       // trigger update of caption
97
 
                done ();
98
 
                return;
99
95
        }
 
96
        done ();
100
97
}
101
98
 
102
99
void RKSaveAgent::done () {
106
103
        }
107
104
        if (when_done == Load) {
108
105
                RKWardMainWindow::getMain ()->fileOpenNoSave (load_url);
109
 
                delete this;
110
 
        } else {
111
 
                delete this;
112
106
        }
 
107
        deleteLater ();
113
108
}
114