Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

SaveAllAction.cpp 2.53 KB
Newer Older
1
2
3
4
/*****************************************************************************
 * $CAMITK_LICENCE_BEGIN$
 *
 * CamiTK - Computer Assisted Medical Intervention ToolKit
5
 * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6
 *
7
8
 * Visit http://camitk.imag.fr for more information
 *
9
10
11
12
13
 * This file is part of CamiTK.
 *
 * CamiTK is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
14
 *
15
 * CamiTK is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details.
19
 *
20
21
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with CamiTK.  If not, see <http://www.gnu.org/licenses/>.
22
23
 *
 * $CAMITK_LICENCE_END$
24
 ****************************************************************************/
25
26
27
#include "SaveAllAction.h"

#include <Application.h>
28
#include <Log.h>
29
30
31
32
33

using namespace camitk;


// --------------- constructor -------------------
34
SaveAllAction::SaveAllAction(ActionExtension* extension) : Action(extension) {
35
36
37
    // Setting name, description and input component
    setName("Save All");
    setEmbedded(false);
38
    setDescription(tr("Saves all the currently loaded data"));
39
40
41
42
43
    setComponent("Component");
    setIcon(QPixmap(":/fileSaveAll"));

    // Setting classification family and tags
    setFamily("Application");
44
    addTag(tr("Save All"));
45
46
47
48
49
50
51
52
}

// --------------- destructor -------------------
SaveAllAction::~SaveAllAction() {
    // do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}

// --------------- getWidget --------------
53
QWidget* SaveAllAction::getWidget() {
54
    return nullptr;
55
56
57
58
}

// --------------- apply -------------------
Action::ApplyStatus SaveAllAction::apply() {
59
    Application::showStatusBarMessage(tr("Saving all data..."));
60
61

    // and save 'em all
62
    QList<Component*>::const_iterator it = Application::getTopLevelComponents().constBegin();
63
    while (it != Application::getTopLevelComponents().constEnd() && Application::save(*it)) {
64
        ++it;
65
    }
66

67
    Application::showStatusBarMessage(tr("Ready."));
68
69
70
71
72

    if (it == Application::getTopLevelComponents().constEnd()) {
        return SUCCESS;
    }
    else {
73
        CAMITK_WARNING(tr("Canceled. Action Aborted."))
74
75
        return ABORTED;
    }
76
77
}