summaryrefslogtreecommitdiffstats
path: root/kfile-plugins/ts
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbd9e6617827818fd043452c08c606f07b78014a0 (patch)
tree425bb4c3168f9c02f10150f235d2cb998dcc6108 /kfile-plugins/ts
downloadtdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz
tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kfile-plugins/ts')
-rw-r--r--kfile-plugins/ts/Makefile.am21
-rw-r--r--kfile-plugins/ts/kfile_ts.cpp93
-rw-r--r--kfile-plugins/ts/kfile_ts.desktop54
-rw-r--r--kfile-plugins/ts/kfile_ts.h39
4 files changed, 207 insertions, 0 deletions
diff --git a/kfile-plugins/ts/Makefile.am b/kfile-plugins/ts/Makefile.am
new file mode 100644
index 00000000..dd64ec48
--- /dev/null
+++ b/kfile-plugins/ts/Makefile.am
@@ -0,0 +1,21 @@
+## Makefile.am for text file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+noinst_HEADERS = kfile_ts.h
+
+kde_module_LTLIBRARIES = kfile_ts.la
+
+kfile_ts_la_SOURCES = kfile_ts.cpp
+kfile_ts_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kfile_ts_la_LIBADD = $(LIB_KIO)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kfile_ts.pot
+
+services_DATA = kfile_ts.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/kfile-plugins/ts/kfile_ts.cpp b/kfile-plugins/ts/kfile_ts.cpp
new file mode 100644
index 00000000..d6783fd7
--- /dev/null
+++ b/kfile-plugins/ts/kfile_ts.cpp
@@ -0,0 +1,93 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Carsten Niehaus <cniehaus@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "kfile_ts.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <qfile.h>
+#include <qstringlist.h>
+
+typedef KGenericFactory<KTsPlugin> TsFactory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_ts, TsFactory("kfile_ts"))
+
+KTsPlugin::KTsPlugin(QObject *parent, const char *name,
+ const QStringList &args) : KFilePlugin(parent, name, args)
+{
+ makeMimeTypeInfo( "application/x-linguist" );
+}
+
+void KTsPlugin::makeMimeTypeInfo(const QString& mimeType)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo(mimeType);
+
+ KFileMimeTypeInfo::GroupInfo* group =
+ addGroupInfo(info, "General", i18n("General"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+ item = addItemInfo(group, "Messages", i18n("Messages"), QVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Translated", i18n("Translated"), QVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Untranslated", i18n("Untranslated"), QVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Obsolete", i18n("Obsolete"), QVariant::Int);
+}
+
+bool KTsPlugin::readInfo(KFileMetaInfo& info, uint)
+{
+ QFile f(info.path());
+ if (!f.open(IO_ReadOnly))
+ return false;
+
+ int messages = 0;
+ int untranslated = 0;
+ int obsolete = 0;
+
+ QTextStream stream( &f );
+ QString line = stream.readLine();
+
+ // is it really a linguist file?
+ if (!line.contains("<!DOCTYPE TS>", false))
+ return false;
+
+ while (!stream.eof())
+ {
+ line = stream.readLine();
+
+ if (line.contains("type=\"obsolete\"")) obsolete++;
+
+ if (line.contains("<source>")) messages++;
+
+ if (line.contains("type=\"unfinished\"")) untranslated++;
+
+ }
+
+ KFileMetaInfoGroup group = appendGroup(info, "General");
+ appendItem(group, "Messages", messages);
+ appendItem(group, "Translated", messages-untranslated-obsolete);
+ appendItem(group, "Untranslated", untranslated);
+ appendItem(group, "Obsolete", obsolete);
+
+ return true;
+}
+
+#include "kfile_ts.moc"
diff --git a/kfile-plugins/ts/kfile_ts.desktop b/kfile-plugins/ts/kfile_ts.desktop
new file mode 100644
index 00000000..09c3ae7d
--- /dev/null
+++ b/kfile-plugins/ts/kfile_ts.desktop
@@ -0,0 +1,54 @@
+[Desktop Entry]
+Type=Service
+Name=Qt Linguist File Info
+Name[bg]=Информация за файла Qt Linguist
+Name[br]=Restr titouroù Qt Linguist
+Name[bs]=Qt Linguist informacije o datoteci
+Name[ca]=Informació fitxer de Qt Linguist
+Name[cs]=Info o souboru Qt Linguist
+Name[cy]=Gwybodaeth Ffeil Qt Linguist
+Name[da]=Qt Linguist Fil-info
+Name[de]=Qt Linguist-Dateiinfo
+Name[el]=Πληροφορίες αρχείου Qt Linguist
+Name[es]=Información de archivo de Qt Linguist
+Name[et]=Qt Linguisti faili info
+Name[eu]=Qt Linguist fitxategi informazioa
+Name[fa]=اطلاعات پروندۀ زبان‌شناسQt
+Name[fi]=Qt Linquist -tiedoston tiedot
+Name[fr]=Fichier d'informations Qt Linguist
+Name[ga]=Eolas faoi Chomhad Qt Linguist
+Name[gl]=Información do Ficheiro de Qt Linguist
+Name[hi]=क्यूटी लिंग्विस्ट फ़ाइल जानकारी
+Name[hu]=Qt Linguist fájljellemzők
+Name[is]=Qt Linguist skráarupplýsingar
+Name[it]=Informazioni file per Qt Linguist
+Name[ja]=Qt Linguist ファイル情報
+Name[ka]=Qt Linguist ფაილის ინფორმაცია
+Name[kk]=Qt Linguist файл мәліметі
+Name[lt]=Qt Linguist bylos informacija
+Name[nb]=Informasjon om Qt Linguist-fil
+Name[nds]=QtLinguist-Datei-Info
+Name[ne]=Qt बहुभाषी फाइल सूचना
+Name[nl]=Qt Linquïst-bestandsinformatie
+Name[nn]=Informasjon om Qt Linguist-fil
+Name[pa]=Qt Linguist ਫਾਇਲ ਜਾਣਕਾਰੀ
+Name[pl]=Informacja pliku Qt Linguist
+Name[pt]=Informação do Ficheiro do Qt Linguist
+Name[pt_BR]=Arquivo de Informações de Lingüística do Qt
+Name[ru]=Информация о файле в формате Qt Linguist
+Name[sk]=Informácie pre Qt Linguist
+Name[sl]=Informacije o Qt Linguist
+Name[sr]=Информације о фајлу Qt Linguist-а
+Name[sr@Latn]=Informacije o fajlu Qt Linguist-a
+Name[sv]=Qt Linguist-filinformation
+Name[ta]=Qt மொழியியல் கோப்புகள் தகவல்
+Name[tg]=Ахборот дар бораи файл дар формати Qt Linguist
+Name[tr]=Qt Dilbilimci Dosya Bilgisi
+Name[uk]=інформація про файл формату Qt Linguist
+Name[zh_CN]=Qt 语言大师文件信息
+Name[zh_TW]=Qt 語言檔資訊
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_ts
+MimeType=application/x-linguist
+PreferredGroups=General
+PreferredItems=Messages,Translated,Untranslated,Fuzzi
diff --git a/kfile-plugins/ts/kfile_ts.h b/kfile-plugins/ts/kfile_ts.h
new file mode 100644
index 00000000..0f976bbf
--- /dev/null
+++ b/kfile-plugins/ts/kfile_ts.h
@@ -0,0 +1,39 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Carsten Niehaus <cniehaus@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __KFILE_TS_H_
+#define __KFILE_TS_H_
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class KTsPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+public:
+ KTsPlugin(QObject *parent, const char *name, const QStringList& args);
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+
+private:
+ void makeMimeTypeInfo(const QString& mimeType);
+};
+
+#endif