You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.8 KiB
85 lines
2.8 KiB
15 years ago
|
/*
|
||
|
* Copyright (C) 2003 Dominik Seichter <domseichter@web.de>
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdefile_kbarcode.h"
|
||
15 years ago
|
|
||
|
#include <kgenericfactory.h>
|
||
|
#include <klocale.h>
|
||
|
|
||
14 years ago
|
#include <tqfile.h>
|
||
|
#include <tqdom.h>
|
||
15 years ago
|
|
||
12 years ago
|
K_EXPORT_COMPONENT_FACTORY(tdefile_kbarcode, KGenericFactory<KBarcodePlugin>( "tdefile_kbarcode" ));
|
||
15 years ago
|
|
||
14 years ago
|
KBarcodePlugin::KBarcodePlugin(TQObject *parent, const char *name,
|
||
14 years ago
|
const TQStringList &args)
|
||
15 years ago
|
|
||
14 years ago
|
: KFilePlugin(parent, name, args)
|
||
15 years ago
|
{
|
||
|
KFileMimeTypeInfo* info = addMimeTypeInfo( "application/kbarcode-label" );
|
||
|
|
||
|
KFileMimeTypeInfo::GroupInfo* group = 0L;
|
||
|
|
||
|
group = addGroupInfo(info, "Label", i18n("Label"));
|
||
|
|
||
|
KFileMimeTypeInfo::ItemInfo* item;
|
||
|
|
||
14 years ago
|
item = addItemInfo(group, "Manufacturer", i18n("Manufacturer"), TQVariant::String );
|
||
|
item = addItemInfo(group, "Type", i18n("Type"), TQVariant::String);
|
||
|
item = addItemInfo(group, "Description", i18n("Description"), TQVariant::String );
|
||
|
item = addItemInfo(group, "Id", i18n("Label Id"), TQVariant::String );
|
||
|
item = addItemInfo(group, "Dimensions", i18n("Dimensions"), TQVariant::Size);
|
||
15 years ago
|
setHint( item, KFileMimeTypeInfo::Size );
|
||
|
setUnit(item, KFileMimeTypeInfo::Centimeters );
|
||
|
}
|
||
|
|
||
|
|
||
|
bool KBarcodePlugin::readInfo( KFileMetaInfo& info, uint )
|
||
|
{
|
||
14 years ago
|
TQFile f( info.path() );
|
||
15 years ago
|
if ( !f.open( IO_ReadOnly ) )
|
||
|
return false;
|
||
|
|
||
14 years ago
|
TQDomDocument doc( "KBarcodeLabel" );
|
||
15 years ago
|
if ( !doc.setContent( &f ) ) {
|
||
|
f.close();
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
KFileMetaInfoGroup group = appendGroup(info, "Label");
|
||
|
|
||
14 years ago
|
TQDomNode n = doc.documentElement().firstChild();
|
||
15 years ago
|
while( !n.isNull() ) {
|
||
14 years ago
|
TQDomElement e = n.toElement(); // try to convert the node to an element.
|
||
15 years ago
|
if( !e.isNull() )
|
||
|
if( e.tagName() == "label" ) {
|
||
14 years ago
|
TQDomNode node = e.firstChild();
|
||
15 years ago
|
while( !node.isNull() ) {
|
||
14 years ago
|
TQDomElement e = node.toElement(); // try to convert the node to an element.
|
||
15 years ago
|
if( !e.isNull() )
|
||
|
if( e.tagName() == "description" )
|
||
|
appendItem(group, "Description", e.text() );
|
||
|
else if( e.tagName() == "id" ) {
|
||
|
appendItem(group, "Manufacturer", e.attribute("producer", "") );
|
||
|
appendItem(group, "Type", e.attribute("type", "") );
|
||
|
appendItem(group, "Id", e.text() );
|
||
|
appendItem(group, "Dimensions",
|
||
14 years ago
|
TQSize( int(e.attribute("width", "0").toDouble()/10), int(e.attribute("height", "0").toDouble()/10) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
node = node.nextSibling();
|
||
|
}
|
||
|
n = n.nextSibling();
|
||
|
}
|
||
|
|
||
|
n = n.nextSibling();
|
||
|
}
|
||
|
|
||
|
|
||
|
f.close();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdefile_kbarcode.moc"
|