1 /***************************************************************************
2 * Copyright (C) 2004 by Pino Toscano *
3 * toscano.pino@tiscali.it *
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. *
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. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "kfile_kig.h"
26 #include <kgenericfactory.h>
29 typedef KGenericFactory
<KigPlugin
> kigFactory
;
31 K_EXPORT_COMPONENT_FACTORY( kfile_kig
, kigFactory( "kfile_kig" ) )
33 KigPlugin::KigPlugin( QObject
*parent
, const char *name
, const QStringList
&args
)
34 : KFilePlugin( parent
, name
, args
)
36 KFileMimeTypeInfo::ItemInfo
* item
;
38 info
= addMimeTypeInfo( "application/x-kig" );
40 group
= addGroupInfo( info
, "KigInfo", i18n( "Summary" ) );
41 item
= addItemInfo( group
, "Version", i18n( "Version" ), QVariant::String
);
42 item
= addItemInfo( group
, "CompatVersion", i18n( "Compatibility Version" ), QVariant::String
);
43 item
= addItemInfo( group
, "CoordSystem", i18n( "Coordinate System" ), QVariant::String
);
44 item
= addItemInfo( group
, "Grid", i18n( "Grid" ), QVariant::String
);
45 item
= addItemInfo( group
, "Axes", i18n( "Axes" ), QVariant::String
);
48 bool KigPlugin::readInfo( KFileMetaInfo
& metainfo
, uint
/*what*/ )
50 KFileMetaInfoGroup metagroup
= appendGroup( metainfo
, "KigInfo");
52 QFile
f( metainfo
.path() );
53 QDomDocument
doc( "KigDocument" );
54 if ( !doc
.setContent( &f
) )
56 QDomElement main
= doc
.documentElement();
58 // reading the version...
59 QString version
= main
.attribute( "Version" );
60 if ( ! version
) version
= main
.attribute( "version" );
61 if ( ! version
) version
= i18n( "Translators: Not Available", "n/a" );
62 appendItem( metagroup
, "Version", version
);
64 // reading the compatibility version...
65 QString compatversion
= main
.attribute( "CompatibilityVersion" );
66 if ( ! compatversion
)
67 compatversion
= i18n( "%1 represents Kig version",
68 "%1 (as the version)" ).arg( version
);
69 appendItem( metagroup
, "CompatVersion", compatversion
);
71 // reading the Coordinate System...
73 for ( QDomNode n
= main
.firstChild(); ! n
.isNull(); n
= n
.nextSibling() )
75 QDomElement e
= n
.toElement();
76 if ( e
.isNull() ) continue;
77 if ( e
.tagName() == "CoordinateSystem" )
78 coordsystem
= e
.text().latin1();
80 appendItem( metagroup
, "CoordSystem", coordsystem
);
82 // has Kig document the grid?
84 QString stmp
= main
.attribute( "grid" );
85 if ( !( stmp
.isEmpty() || ( stmp
!= "0" ) ) )
86 btmp
= ( stmp
!= "0" );
87 QString stmp2
= btmp
? i18n( "Yes" ) : i18n( "No" );
88 appendItem( metagroup
, "Grid", stmp2
);
90 // has Kig document the axes?
92 stmp
= main
.attribute( "axes" );
93 if ( !( stmp
.isEmpty() || ( stmp
!= "0" ) ) )
94 btmp
= ( stmp
!= "0" );
95 stmp2
= btmp
? i18n( "Yes" ) : i18n( "No" );
96 appendItem( metagroup
, "Axes", stmp2
);
101 #include "kfile_kig.moc"