• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

cantor/src/lib

  • sources
  • kde-4.14
  • kdeedu
  • cantor
  • src
  • lib
animationresult.cpp
Go to the documentation of this file.
1 /*
2  This program is free software; you can redistribute it and/or
3  modify it under the terms of the GNU General Public License
4  as published by the Free Software Foundation; either version 2
5  of the License, or (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin Street, Fifth Floor,
15  Boston, MA 02110-1301, USA.
16 
17  ---
18  Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
19  */
20 
21 #include "animationresult.h"
22 using namespace Cantor;
23 
24 #include <QImage>
25 #include <QImageWriter>
26 #include <kzip.h>
27 #include <kmimetype.h>
28 #include <kdebug.h>
29 #include <kio/job.h>
30 #include <QMovie>
31 
32 class Cantor::AnimationResultPrivate
33 {
34  public:
35  AnimationResultPrivate()
36  {
37 
38  }
39 
40  KUrl url;
41  QMovie* movie;
42  QString alt;
43 };
44 
45 AnimationResult::AnimationResult( const KUrl& url, const QString& alt ) : d(new AnimationResultPrivate)
46 {
47  d->url=url;
48  d->alt=alt;
49  d->movie=new QMovie();
50  d->movie->setFileName(url.toLocalFile());
51 }
52 
53 
54 AnimationResult::~AnimationResult()
55 {
56  delete d->movie;
57  delete d;
58 }
59 
60 QString AnimationResult::toHtml()
61 {
62  return QString("<img src=\"%1\" alt=\"%2\"/>").arg(d->url.toLocalFile(), d->alt);
63 }
64 
65 QVariant AnimationResult::data()
66 {
67  return QVariant::fromValue(static_cast<QObject*>(d->movie));
68 }
69 
70 KUrl AnimationResult::url()
71 {
72  return d->url;
73 }
74 
75 int AnimationResult::type()
76 {
77  return AnimationResult::Type;
78 }
79 
80 QString AnimationResult::mimeType()
81 {
82  KMimeType::Ptr type=KMimeType::findByUrl(d->url);
83 
84  return type->name();
85 }
86 
87 QDomElement AnimationResult::toXml(QDomDocument& doc)
88 {
89  kDebug()<<"saving imageresult "<<toHtml();
90  QDomElement e=doc.createElement("Result");
91  e.setAttribute("type", "animation");
92  e.setAttribute("filename", d->url.fileName());
93  kDebug()<<"done";
94 
95  return e;
96 }
97 
98 void AnimationResult::saveAdditionalData(KZip* archive)
99 {
100  archive->addLocalFile(d->url.toLocalFile(), d->url.fileName());
101 }
102 
103 void AnimationResult::save(const QString& filename)
104 {
105  //just copy over the file..
106  KIO::file_copy(d->url, KUrl(filename), -1, KIO::HideProgressInfo);
107 }
Cantor::AnimationResult::AnimationResult
AnimationResult(const KUrl &url, const QString &alt=QString())
Definition: animationresult.cpp:45
QMovie
Cantor::AnimationResult::~AnimationResult
~AnimationResult()
Definition: animationresult.cpp:54
Cantor::AnimationResult::type
int type()
returns an unique number, representing the type of this result.
Definition: animationresult.cpp:75
Cantor::AnimationResult::toHtml
QString toHtml()
returns html code, that represents this result, e.g.
Definition: animationresult.cpp:60
Cantor::AnimationResult::toXml
QDomElement toXml(QDomDocument &doc)
returns a DomElement, containing the information of the result
Definition: animationresult.cpp:87
Cantor::AnimationResult::Type
Definition: animationresult.h:33
Cantor::AnimationResult::save
void save(const QString &filename)
saves this to a file
Definition: animationresult.cpp:103
QDomElement::setAttribute
void setAttribute(const QString &name, const QString &value)
Cantor::AnimationResult::data
QVariant data()
returns data associated with this result (text/images/etc)
Definition: animationresult.cpp:65
Cantor::AnimationResult::url
KUrl url()
returns an url, data for this result resides at
Definition: animationresult.cpp:70
QString
QDomDocument
QVariant::fromValue
QVariant fromValue(const T &value)
Cantor::AnimationResult::saveAdditionalData
void saveAdditionalData(KZip *archive)
saves all the data, that can't be saved in xml in an extra file in the archive.
Definition: animationresult.cpp:98
QDomDocument::createElement
QDomElement createElement(const QString &tagName)
QDomElement
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Cantor::AnimationResult::mimeType
QString mimeType()
returns the mimetype, this result is
Definition: animationresult.cpp:80
animationresult.h
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:16:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

cantor/src/lib

Skip menu "cantor/src/lib"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal