umbrello API Documentation

umlviewimageexporterall.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2006-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "umlviewimageexporterall.h"
00014 
00015 // include files for Qt
00016 #include <qstring.h>
00017 #include <qstringlist.h>
00018 #include <qcheckbox.h>
00019 
00020 // kde include files
00021 #include <klocale.h>
00022 #include <kurl.h>
00023 #include <kurlrequester.h>
00024 #include <kfilefiltercombo.h>
00025 #include <kmessagebox.h>
00026 
00027 // application specific includes
00028 #include "dialogs/exportallviewsdialog.h"
00029 #include "umlviewimageexportermodel.h"
00030 #include "uml.h"
00031 #include "umldoc.h"
00032 
00033 UMLViewImageExporterAll::UMLViewImageExporterAll() {
00034     m_dialog = new ExportAllViewsDialog(0, "exportAllViewsDialog", false, 0, UMLApp::app()->getImageMimeType());
00035 }
00036 
00037 UMLViewImageExporterAll::~UMLViewImageExporterAll() {
00038     delete m_dialog;
00039 }
00040 
00041 void UMLViewImageExporterAll::exportAllViews() {
00042     UMLApp* app = UMLApp::app();
00043     UMLDoc* umlDoc = app->getDocument();
00044 
00045     // default url can't be set when creating the action because the
00046     // document wasn't loaded
00047     if (m_dialog->m_kURL->url().isEmpty()) {
00048         m_dialog->m_kURL->setURL(umlDoc->URL().directory());
00049     }
00050 
00051     if (m_dialog->exec() == QDialog::Rejected) {
00052         return;
00053     }
00054 
00055     app->setImageMimeType(m_dialog->m_imageType->currentFilter());
00056 
00057     // export all views
00058     umlDoc->writeToStatusBar(i18n("Exporting all views..."));
00059     QStringList errors = UMLViewImageExporterModel().exportAllViews(
00060                                 UMLViewImageExporterModel::mimeTypeToImageType(m_dialog->m_imageType->currentFilter()),
00061                                 KURL(m_dialog->m_kURL->url()), m_dialog->m_useFolders->isChecked());
00062     if (!errors.empty()) {
00063 #if KDE_IS_VERSION(3,4,0)
00064         KMessageBox::errorList(app, i18n("Some errors happened when exporting the images:"), errors);
00065 #else
00066         QString errorsCaption;
00067         for (QStringList::Iterator it = errors.begin(); it != errors.end(); ++it) {
00068             errorsCaption += "\n" + *it;
00069         }
00070         KMessageBox::error(app, i18n("Some errors happened when exporting the images:") + errorsCaption);
00071 #endif
00072     }
00073     umlDoc->writeToStatusBar(i18n("Ready."));
00074 }
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:02 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003