summaryrefslogtreecommitdiffstats
path: root/fileplugin
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-15 18:34:54 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-15 18:34:54 +0000
commit8805e6b17b1460f3316ccb28629e8ad78e4b9c2c (patch)
treedc9b702962ecf0060cc473397b9f80268c2456c9 /fileplugin
downloadkbarcode-8805e6b17b1460f3316ccb28629e8ad78e4b9c2c.zip
kbarcode-8805e6b17b1460f3316ccb28629e8ad78e4b9c2c.tar.gz
Added abandoned KDE3 version of kbarcode
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbarcode@1090667 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'fileplugin')
-rw-r--r--fileplugin/Makefile.am18
-rw-r--r--fileplugin/kfile_kbarcode.cpp84
-rw-r--r--fileplugin/kfile_kbarcode.desktop9
-rw-r--r--fileplugin/kfile_kbarcode.h23
4 files changed, 134 insertions, 0 deletions
diff --git a/fileplugin/Makefile.am b/fileplugin/Makefile.am
new file mode 100644
index 0000000..83e54db
--- /dev/null
+++ b/fileplugin/Makefile.am
@@ -0,0 +1,18 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+kde_module_LTLIBRARIES = kfile_kbarcode.la
+
+kfile_kbarcode_la_SOURCES = kfile_kbarcode.cpp
+kfile_kbarcode_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+kfile_kbarcode_la_LIBADD = $(LIB_KSYCOCA) $(LIB_KDECORE)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+# messages: rc.cpp
+# $(XGETTEXT) *.cpp -o $(podir)/kfile_kbarcode.pot
+
+services_DATA = kfile_kbarcode.desktop
+servicesdir = $(kde_servicesdir)
+
diff --git a/fileplugin/kfile_kbarcode.cpp b/fileplugin/kfile_kbarcode.cpp
new file mode 100644
index 0000000..bd2c1c8
--- /dev/null
+++ b/fileplugin/kfile_kbarcode.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2003 Dominik Seichter <domseichter@web.de>
+ */
+
+#include "kfile_kbarcode.h"
+
+#include <kgenericfactory.h>
+#include <klocale.h>
+
+#include <qfile.h>
+#include <qdom.h>
+
+K_EXPORT_COMPONENT_FACTORY(kfile_kbarcode, KGenericFactory<KBarcodePlugin>( "kfile_kbarcode" ));
+
+KBarcodePlugin::KBarcodePlugin(QObject *parent, const char *name,
+ const QStringList &args)
+
+ : KFilePlugin(parent, name, args)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "application/kbarcode-label" );
+
+ KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+ group = addGroupInfo(info, "Label", i18n("Label"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+
+ item = addItemInfo(group, "Manufacturer", i18n("Manufacturer"), QVariant::String );
+ item = addItemInfo(group, "Type", i18n("Type"), QVariant::String);
+ item = addItemInfo(group, "Description", i18n("Description"), QVariant::String );
+ item = addItemInfo(group, "Id", i18n("Label Id"), QVariant::String );
+ item = addItemInfo(group, "Dimensions", i18n("Dimensions"), QVariant::Size);
+ setHint( item, KFileMimeTypeInfo::Size );
+ setUnit(item, KFileMimeTypeInfo::Centimeters );
+}
+
+
+bool KBarcodePlugin::readInfo( KFileMetaInfo& info, uint )
+{
+ QFile f( info.path() );
+ if ( !f.open( IO_ReadOnly ) )
+ return false;
+
+ QDomDocument doc( "KBarcodeLabel" );
+ if ( !doc.setContent( &f ) ) {
+ f.close();
+ return false;
+ }
+
+ KFileMetaInfoGroup group = appendGroup(info, "Label");
+
+ QDomNode n = doc.documentElement().firstChild();
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement(); // try to convert the node to an element.
+ if( !e.isNull() )
+ if( e.tagName() == "label" ) {
+ QDomNode node = e.firstChild();
+ while( !node.isNull() ) {
+ QDomElement e = node.toElement(); // try to convert the node to an element.
+ 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",
+ QSize( int(e.attribute("width", "0").toDouble()/10), int(e.attribute("height", "0").toDouble()/10) ) );
+ }
+
+ node = node.nextSibling();
+ }
+ n = n.nextSibling();
+ }
+
+ n = n.nextSibling();
+ }
+
+
+ f.close();
+ return true;
+}
+
+#include "kfile_kbarcode.moc"
diff --git a/fileplugin/kfile_kbarcode.desktop b/fileplugin/kfile_kbarcode.desktop
new file mode 100644
index 0000000..e9a9d33
--- /dev/null
+++ b/fileplugin/kfile_kbarcode.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Service
+Name=KBarcode Info
+Comment=KBarcode Info
+Icon=kbarcode
+ServiceTypes=KFilePlugin
+MimeType=application/kbarcode-label
+X-KDE-Library=kfile_kbarcode
+SupportsThumbnail=
diff --git a/fileplugin/kfile_kbarcode.h b/fileplugin/kfile_kbarcode.h
new file mode 100644
index 0000000..fd71ada
--- /dev/null
+++ b/fileplugin/kfile_kbarcode.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2003 Dominik Seichter <domseichter@web.de>
+ */
+
+#ifndef _PLUGIN_KBARCODEFILEPLUGIN_H_
+#define _PLUGIN_KBARCODEFILEPLUGIN_H_
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class KBarcodePlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KBarcodePlugin( QObject *parent, const char *name, const QStringList& args );
+
+ virtual bool readInfo( KFileMetaInfo& info, uint );
+};
+
+
+#endif // _PLUGIN_KBARCODEFILEPLUGIN_H_