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

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • kfile
kfile_drgeo.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004 by Pino Toscano *
3  * toscano.pino@tiscali.it *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "kfile_drgeo.h"
22 
23 #include <qdom.h>
24 #include <qfile.h>
25 
26 #include <kgenericfactory.h>
27 
28 typedef KGenericFactory<DrgeoPlugin> drgeoFactory;
29 
30 K_EXPORT_COMPONENT_FACTORY( kfile_drgeo, drgeoFactory( "kfile_drgeo" ) )
31 
32 DrgeoPlugin::DrgeoPlugin( QObject *parent, const QStringList &args )
33  : KFilePlugin( parent, args )
34 {
35  info = addMimeTypeInfo( "application/x-drgeo" );
36 
37  KFileMimeTypeInfo::GroupInfo* group = addGroupInfo( info, "DrgeoInfo", i18n( "Summary" ) );
38  KFileMimeTypeInfo::ItemInfo* item;
39  item = addItemInfo( group, "NumOfFigures", i18n( "Figures" ), QVariant::Int );
40  item = addItemInfo( group, "NumOfTexts", i18n( "Texts" ), QVariant::Int );
41  item = addItemInfo( group, "NumOfMacros", i18n( "Macros" ), QVariant::Int );
42 
43  group_contents = addGroupInfo( info, "DrgeoContents", i18nc( "Translators: what this drgeo "
44  "file contains", "Contents" ) );
45 }
46 
47 bool DrgeoPlugin::readInfo( KFileMetaInfo& metainfo, uint /*what*/ )
48 {
49  KFileMetaInfoGroup metagroup = appendGroup( metainfo, "DrgeoContents");
50 
51  KFileMimeTypeInfo::ItemInfo* item;
52 
53  QFile f( metainfo.path() );
54  QDomDocument doc( "drgenius" );
55  if ( !doc.setContent( &f ) )
56  return false;
57  QDomElement main = doc.documentElement();
58  int numfig = 0;
59  int numtext = 0;
60  int nummacro = 0;
61  QString sectname;
62  // reading figures...
63  for ( QDomNode n = main.firstChild(); ! n.isNull(); n = n.nextSibling() )
64  {
65  QDomElement e = n.toElement();
66  if ( e.isNull() ) continue;
67  else if ( e.tagName() == "drgeo" )
68  {
69  numfig++;
70  sectname = QString( "Figure" ) + QString::number( numfig );
71  item = addItemInfo( group_contents, sectname, i18n( "Figure" ), QVariant::String );
72  appendItem( metagroup, sectname, e.attribute( "name" ) );
73  }
74  else if ( e.tagName() == "text" )
75  {
76  numtext++;
77  sectname = QString( "Text" ) + QString::number( numtext );
78  item = addItemInfo( group_contents, sectname, i18n( "Text" ), QVariant::String );
79  appendItem( metagroup, sectname, e.attribute( "name" ) );
80  }
81  else if ( e.tagName() == "macro" )
82  {
83  nummacro++;
84  sectname = QString( "Macro" ) + QString::number( nummacro );
85  item = addItemInfo( group_contents, sectname, i18n( "Macro" ), QVariant::String );
86  appendItem( metagroup, sectname, e.attribute( "name" ) );
87  }
88  }
89 
90  metagroup = appendGroup( metainfo, "DrgeoInfo");
91  appendItem( metagroup, "NumOfFigures", numfig );
92  appendItem( metagroup, "NumOfTexts", numtext );
93  appendItem( metagroup, "NumOfMacros", nummacro );
94 
95  return true;
96 }
97 
98 #include "kfile_drgeo.moc"
99 
main
int main(int argc, char **argv)
Definition: main.cpp:97
drgeoFactory
KGenericFactory< DrgeoPlugin > drgeoFactory
Definition: kfile_drgeo.cpp:28
KFilePlugin
kfile_drgeo.h
DrgeoPlugin
Definition: kfile_drgeo.h:28
DrgeoPlugin::group_contents
KFileMimeTypeInfo::GroupInfo * group_contents
Definition: kfile_drgeo.h:38
uint
unsigned int uint
Definition: object_imp.h:87
DrgeoPlugin::readInfo
virtual bool readInfo(KFileMetaInfo &metainfo, uint what)
Definition: kfile_drgeo.cpp:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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