summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/umlviewimageexporterall.cpp
blob: 95801867ec154a46dbeee89c157b0d831e24a4e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   copyright (C) 2006-2007                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

// own header
#include "umlviewimageexporterall.h"

// include files for TQt
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqcheckbox.h>

// kde include files
#include <klocale.h>
#include <kurl.h>
#include <kurlrequester.h>
#include <kfilefiltercombo.h>
#include <kmessagebox.h>

// application specific includes
#include "dialogs/exportallviewsdialog.h"
#include "umlviewimageexportermodel.h"
#include "uml.h"
#include "umldoc.h"

UMLViewImageExporterAll::UMLViewImageExporterAll() {
    m_dialog = new ExportAllViewsDialog(0, "exportAllViewsDialog", false, 0, UMLApp::app()->getImageMimeType());
}

UMLViewImageExporterAll::~UMLViewImageExporterAll() {
    delete m_dialog;
}

void UMLViewImageExporterAll::exportAllViews() {
    UMLApp* app = UMLApp::app();
    UMLDoc* umlDoc = app->getDocument();

    // default url can't be set when creating the action because the
    // document wasn't loaded
    if (m_dialog->m_kURL->url().isEmpty()) {
        m_dialog->m_kURL->setURL(umlDoc->URL().directory());
    }

    if (m_dialog->exec() == TQDialog::Rejected) {
        return;
    }

    app->setImageMimeType(m_dialog->m_imageType->currentFilter());

    // export all views
    umlDoc->writeToStatusBar(i18n("Exporting all views..."));
    TQStringList errors = UMLViewImageExporterModel().exportAllViews(
                                UMLViewImageExporterModel::mimeTypeToImageType(m_dialog->m_imageType->currentFilter()),
                                KURL(m_dialog->m_kURL->url()), m_dialog->m_useFolders->isChecked());
    if (!errors.empty()) {
#if KDE_IS_VERSION(3,4,0)
        KMessageBox::errorList(app, i18n("Some errors happened when exporting the images:"), errors);
#else
        TQString errorsCaption;
        for (TQStringList::Iterator it = errors.begin(); it != errors.end(); ++it) {
            errorsCaption += "\n" + *it;
        }
        KMessageBox::error(app, i18n("Some errors happened when exporting the images:") + errorsCaption);
#endif
    }
    umlDoc->writeToStatusBar(i18n("Ready."));
}