summaryrefslogtreecommitdiffstats
path: root/tdefile-plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tdefile-plugins')
-rw-r--r--tdefile-plugins/CMakeLists.txt14
-rw-r--r--tdefile-plugins/Makefile.am1
-rw-r--r--tdefile-plugins/c++/CMakeLists.txt35
-rw-r--r--tdefile-plugins/c++/Makefile.am22
-rw-r--r--tdefile-plugins/c++/tdefile_cpp.cpp130
-rw-r--r--tdefile-plugins/c++/tdefile_cpp.desktop60
-rw-r--r--tdefile-plugins/c++/tdefile_cpp.h41
-rw-r--r--tdefile-plugins/c++/tdefile_h.desktop58
-rw-r--r--tdefile-plugins/diff/CMakeLists.txt34
-rw-r--r--tdefile-plugins/diff/Makefile.am22
-rw-r--r--tdefile-plugins/diff/tdefile_diff.cpp610
-rw-r--r--tdefile-plugins/diff/tdefile_diff.desktop57
-rw-r--r--tdefile-plugins/diff/tdefile_diff.h53
-rw-r--r--tdefile-plugins/ts/CMakeLists.txt35
-rw-r--r--tdefile-plugins/ts/Makefile.am21
-rw-r--r--tdefile-plugins/ts/tdefile_ts.cpp93
-rw-r--r--tdefile-plugins/ts/tdefile_ts.desktop54
-rw-r--r--tdefile-plugins/ts/tdefile_ts.h40
18 files changed, 1380 insertions, 0 deletions
diff --git a/tdefile-plugins/CMakeLists.txt b/tdefile-plugins/CMakeLists.txt
new file mode 100644
index 00000000..6b769e5c
--- /dev/null
+++ b/tdefile-plugins/CMakeLists.txt
@@ -0,0 +1,14 @@
+#################################################
+#
+# (C) 2012 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+add_subdirectory( diff )
+add_subdirectory( c++ )
+add_subdirectory( ts )
diff --git a/tdefile-plugins/Makefile.am b/tdefile-plugins/Makefile.am
new file mode 100644
index 00000000..aa4d2f43
--- /dev/null
+++ b/tdefile-plugins/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS=diff c++ ts
diff --git a/tdefile-plugins/c++/CMakeLists.txt b/tdefile-plugins/c++/CMakeLists.txt
new file mode 100644
index 00000000..60ce0c29
--- /dev/null
+++ b/tdefile-plugins/c++/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2012 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES tdefile_cpp.desktop tdefile_h.desktop
+ DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### tdefile_cpp (module) ########################
+
+tde_add_kpart( tdefile_cpp AUTOMOC
+ SOURCES tdefile_cpp.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/c++/Makefile.am b/tdefile-plugins/c++/Makefile.am
new file mode 100644
index 00000000..f74cf59e
--- /dev/null
+++ b/tdefile-plugins/c++/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for c++ file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = tdefile_cpp.h
+
+kde_module_LTLIBRARIES = tdefile_cpp.la
+
+tdefile_cpp_la_SOURCES = tdefile_cpp.cpp
+tdefile_cpp_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_cpp_la_LIBADD = $(LIB_KIO)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/tdefile_cpp.pot
+
+services_DATA = tdefile_cpp.desktop tdefile_h.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/c++/tdefile_cpp.cpp b/tdefile-plugins/c++/tdefile_cpp.cpp
new file mode 100644
index 00000000..31f777df
--- /dev/null
+++ b/tdefile-plugins/c++/tdefile_cpp.cpp
@@ -0,0 +1,130 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Rolf Magnus <ramagnus@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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "tdefile_cpp.h"
+
+#include <kurl.h>
+#include <klocale.h>
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <tqfile.h>
+#include <tqregexp.h>
+
+typedef KGenericFactory<KCppPlugin> CppFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_cpp, CppFactory("tdefile_cpp"))
+
+KCppPlugin::KCppPlugin(TQObject *parent, const char *name,
+ const TQStringList &args)
+ : KFilePlugin(parent, name, args)
+{
+ kdDebug(7034) << "c++ plugin\n";
+ makeMimeTypeInfo("text/x-c++src");
+ makeMimeTypeInfo("text/x-chdr");
+}
+
+void KCppPlugin::makeMimeTypeInfo(const TQString& mimetype)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( mimetype );
+
+ KFileMimeTypeInfo::GroupInfo* group =
+ addGroupInfo(info, "General", i18n("General"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+ item = addItemInfo(group, "Lines", i18n("Lines"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Code", i18n("Code"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Comment", i18n("Comment"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Blank", i18n("Blank"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Strings", i18n("Strings"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "i18n Strings", i18n("i18n Strings"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Included Files", i18n("Included Files"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+}
+
+bool KCppPlugin::readInfo( KFileMetaInfo& info, uint )
+{
+ TQFile f(info.path());
+ if (!f.open(IO_ReadOnly))
+ return false;
+
+ int codeLines = 0;
+ int commentLines = 0;
+ int totalLines = 0;
+ int emptyLines = 0;
+ int Strings = 0;
+ int Stringsi18n = 0;
+ int Includes = 0;
+
+ bool inComment = false;
+
+ TQString line;
+
+ TQTextStream stream( &f );
+ while (!stream.eof())
+ {
+ line = stream.readLine();
+ totalLines++;
+
+ if (line.stripWhiteSpace().isEmpty())
+ {
+ emptyLines++;
+ continue;
+ }
+
+ if (line.contains("/*")) inComment = true;
+
+ if (!inComment)
+ {
+ codeLines++;
+ if (line.contains(TQRegExp("^\\s*#\\s*include"))) Includes++;
+
+ int pos = line.find("//");
+ if (pos>=0) commentLines++;
+ // truncate the comment - we don't want to count strings in it
+ line.truncate(pos);
+
+ Strings+=line.contains(TQRegExp("\".*\""));
+ Stringsi18n+=line.contains(TQRegExp("(?:i18n|I18N_NOOP)\\s*\\("));
+ }
+ else
+ commentLines++;
+
+ if (line.contains("*/")) inComment = false;
+ }
+
+ KFileMetaInfoGroup group = appendGroup(info, "General");
+
+ appendItem(group, "Lines", int(totalLines));
+ appendItem(group, "Code", int(codeLines));
+ appendItem(group, "Comment", int(commentLines));
+ appendItem(group, "Blank", int(emptyLines));
+ appendItem(group, "Strings", int(Strings));
+ appendItem(group, "i18n Strings", int(Stringsi18n));
+ appendItem(group, "Included Files", int(Includes));
+ return true;
+}
+
+#include "tdefile_cpp.moc"
diff --git a/tdefile-plugins/c++/tdefile_cpp.desktop b/tdefile-plugins/c++/tdefile_cpp.desktop
new file mode 100644
index 00000000..7bbed693
--- /dev/null
+++ b/tdefile-plugins/c++/tdefile_cpp.desktop
@@ -0,0 +1,60 @@
+[Desktop Entry]
+Type=Service
+Name=C++ Info
+Name[af]=C++ Inligting
+Name[bg]=Изходен код на C++
+Name[br]=Titouroù C++
+Name[ca]=Informació C++
+Name[cs]=C++ info
+Name[cy]=Gwybodaeth C++
+Name[da]=C++-info
+Name[de]=C++-Info
+Name[el]=Πληροφορίες C++
+Name[eo]=C++-informo
+Name[es]=Info de C++
+Name[et]=C++ info
+Name[eu]=C++ informazioa
+Name[fa]=اطلاعات C++
+Name[fi]=C++-tiedot
+Name[fo]=C++-upplýsingar
+Name[fr]=Informations C++
+Name[ga]=Eolas C++
+Name[gl]=Información de C++
+Name[he]=מידע ++C
+Name[hi]=C++ जानकारी
+Name[hr]=C++ informacije
+Name[hu]=C++-jellemzők
+Name[is]=C++ upplýsingar
+Name[it]=Informazioni C++
+Name[ja]=C++ 情報
+Name[ka]=C++ ინფორმაცია
+Name[kk]=C++ мәліметі
+Name[lt]=C++ Informacija
+Name[ms]=Info C++
+Name[nds]=C++-Datei-Info
+Name[nl]=C++-info
+Name[nn]=C++-info
+Name[pa]=C++ ਜਾਣਕਾਰੀ
+Name[pl]=Informacja z C++
+Name[pt]=Informação de C++
+Name[pt_BR]=Informações C++
+Name[ro]=Informaţii C++
+Name[ru]=Информация C++
+Name[sk]=Informácie o C++
+Name[sl]=Informacije o C++
+Name[sr]=C++ информације
+Name[sr@Latn]=C++ informacije
+Name[sv]=C++-information
+Name[ta]= =C/C++ தகவல்
+Name[tg]=Ахбороти C++
+Name[th]=ข้อมูล C++
+Name[tr]=C++ Bilgisi
+Name[uk]=Інформація про C++
+Name[xh]=C++ Ulwazi
+Name[zh_CN]=C++ 信息
+Name[zh_TW]=C++ 資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_cpp
+MimeType=text/x-c++src;text/x-chdr
+PreferredGroups=General
+PreferredItems=Lines,Code,Comment,Blank,Strings,i18n Strings,Included Files
diff --git a/tdefile-plugins/c++/tdefile_cpp.h b/tdefile-plugins/c++/tdefile_cpp.h
new file mode 100644
index 00000000..f289b09b
--- /dev/null
+++ b/tdefile-plugins/c++/tdefile_cpp.h
@@ -0,0 +1,41 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2002 Rolf Magnus <ramagnus@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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __KFILE_CPP_H__
+#define __KFILE_CPP_H__
+
+#include <tdefilemetainfo.h>
+#include <kurl.h>
+
+class TQStringList;
+
+class KCppPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KCppPlugin(TQObject *parent, const char *name, const TQStringList& args);
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+
+private:
+ void makeMimeTypeInfo(const TQString& mimetype);
+};
+
+#endif
diff --git a/tdefile-plugins/c++/tdefile_h.desktop b/tdefile-plugins/c++/tdefile_h.desktop
new file mode 100644
index 00000000..539ff599
--- /dev/null
+++ b/tdefile-plugins/c++/tdefile_h.desktop
@@ -0,0 +1,58 @@
+[Desktop Entry]
+Type=Service
+Name=C/C++ Header Info
+Name[af]=C/C++ Opskrif Inligting
+Name[bg]=Информация за заглавната част на C/C++
+Name[br]=Titouriñ diwar-benn ar reollin C/C++
+Name[ca]=Informació de capçaleres C/C++
+Name[cs]=Informace o C/C++ hlavičce
+Name[cy]=Gwybodaeth Pennawd C/C++
+Name[da]=C/C++-headerinfo
+Name[de]=C++-Header-Info
+Name[el]=Πληροφορίες κεφαλίδων C/C++
+Name[es]=Info de cabecera C/C++
+Name[et]=C/C++ päise info
+Name[eu]=C/C++ goiburuen informazioa
+Name[fa]=اطلاعات سرآیند C/C++
+Name[fi]=C/C++-otsikkotiedot
+Name[fr]=Informations d'en-tête C/C++
+Name[gl]=Información da cabeceira de C/C++
+Name[he]=מידע כותרות ++C/C
+Name[hi]=C/C++ हेडर जानकारी
+Name[hr]=Informacije o C++ zaglavljima
+Name[hu]=C/C++ header fájl jellemzői
+Name[is]=C/C++ haus upplýsingar
+Name[it]=Informazioni intestazioni C/C++
+Name[ja]=C/C++ ヘッダ情報
+Name[ka]=C/C++ ზედა კოლონტიტულის ინფორმაცია
+Name[kk]=C/C++ айдар мәліметі
+Name[lt]=C/C++ antraščių informacija
+Name[ms]=Info Pengepala C/C++
+Name[nb]=C++-deklarasjonsfilinfo
+Name[nds]=C/C++-Koppdatei-Info
+Name[ne]=C/C++ Header info
+Name[nl]=C/C++ Header-info
+Name[nn]=C/C++-deklarasjonsinfo
+Name[pa]=C/C++ Header ਜਾਣਕਾਰੀ
+Name[pl]=Informacja z nagłówka C/C++
+Name[pt]=Informações do Cabeçalho de C/C++
+Name[pt_BR]=Informações sobre Cabeçalhos C/C++
+Name[ro]=Informaţii antet C/C++
+Name[ru]=Информация о файлах заголовков C/C++
+Name[sk]=Informácie o hlavičkách C/C++
+Name[sl]=Informacije o glavi C/C++
+Name[sr]=Информације о C/C++ заглављу
+Name[sr@Latn]=Informacije o C/C++ zaglavlju
+Name[sv]=Information om C/C++-deklarationsfiler
+Name[ta]= =C/C++ தலைப்பு தகவல்
+Name[tg]=Ахборот дар бораи сарлавҳаи файлҳои C/C++
+Name[th]=ข้อมูลแฟ้มส่วนหัว C/C++
+Name[tr]=C/C++ Başlık Bilgisi
+Name[uk]=Інформація по заголовкам C++
+Name[xh]=C/C++ Ulwazi lokubhaliweyo okuphezulu
+Name[zh_CN]=C/C++ 头文件信息
+Name[zh_TW]=C/C++ 檔頭資訊
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_cpp
+MimeType=text/x-chdr
+PreferredItems=Lines,Code,Comment,Blank,Strings,i18n Strings,Included Files
diff --git a/tdefile-plugins/diff/CMakeLists.txt b/tdefile-plugins/diff/CMakeLists.txt
new file mode 100644
index 00000000..08493d8f
--- /dev/null
+++ b/tdefile-plugins/diff/CMakeLists.txt
@@ -0,0 +1,34 @@
+#################################################
+#
+# (C) 2012 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES tdefile_diff.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### tdefile_diff (module) #######################
+
+tde_add_kpart( tdefile_diff AUTOMOC
+ SOURCES tdefile_diff.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/diff/Makefile.am b/tdefile-plugins/diff/Makefile.am
new file mode 100644
index 00000000..5e9b087f
--- /dev/null
+++ b/tdefile-plugins/diff/Makefile.am
@@ -0,0 +1,22 @@
+## Makefile.am for diff file meta info plugin
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = tdefile_diff.h
+
+kde_module_LTLIBRARIES = tdefile_diff.la
+
+tdefile_diff_la_SOURCES = tdefile_diff.cpp
+tdefile_diff_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_diff_la_LIBADD = $(LIB_KSYCOCA)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/tdefile_diff.pot
+
+services_DATA = tdefile_diff.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/diff/tdefile_diff.cpp b/tdefile-plugins/diff/tdefile_diff.cpp
new file mode 100644
index 00000000..2edee0a7
--- /dev/null
+++ b/tdefile-plugins/diff/tdefile_diff.cpp
@@ -0,0 +1,610 @@
+/**************************************************************************
+** tdefile_diff.cpp
+** -------------------
+** begin : Sun Jan 20 23:25:44 2002
+** copyright : (C) 2002-2003 by Otto Bruggeman
+** email : otto.bruggeman@home.nl
+**
+***************************************************************************/
+/***************************************************************************
+**
+** 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; either version 2 of the License, or
+** (at your option) any later version.
+**
+***************************************************************************/
+
+/*
+** Patch by Volker Augustin for empty diff files. Februari 8, 2002
+**
+** Patched to work with CVS from after February 26, 2002 Otto
+**
+** Patched to work with CVS from after March 24, 2002 Otto
+**
+** Added support for Perforce diffs, April 26, 2003 Otto Bruggeman
+**
+** Added support for Subversion diffs, September 11, 2003 Otto Bruggeman
+*/
+
+#include <tqcstring.h>
+#include <tqdatetime.h>
+#include <tqdict.h>
+#include <tqfile.h>
+#include <tqregexp.h>
+#include <tqvalidator.h>
+
+#include <kdebug.h>
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kprocess.h>
+#include <kurl.h>
+
+#include "tdefile_diff.h"
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_diff, KGenericFactory<KDiffPlugin>("tdefile_diff"))
+
+KDiffPlugin::KDiffPlugin(TQObject *parent, const char *name,
+ const TQStringList &preferredItems)
+ : KFilePlugin(parent, name, preferredItems)
+{
+ kdDebug(7034) << "diff plugin" << endl;
+
+ KFileMimeTypeInfo* info = addMimeTypeInfo( "text/x-diff" );
+
+ KFileMimeTypeInfo::GroupInfo* group;
+ group = addGroupInfo( info, "General", i18n( "General" ) );
+ addItemInfo( group, "Files", i18n( "Files" ), TQVariant::UInt );
+ addItemInfo( group, "First", i18n( "First File" ), TQVariant::String );
+ addItemInfo( group, "Format", i18n( "Format" ), TQVariant::String );
+ addItemInfo( group, "DiffProgram", i18n( "Diff Program" ), TQVariant::String );
+ addItemInfo( group, "Hunks", i18n( "Hunks" ), TQVariant::UInt );
+ group = addGroupInfo( info, "Statistics", i18n( "Statistics" ) );
+ addItemInfo( group, "Insert", i18n( "Insertions" ), TQVariant::UInt );
+ addItemInfo( group, "Modify", i18n( "Changes" ), TQVariant::UInt );
+ addItemInfo( group, "Delete", i18n( "Deletions" ), TQVariant::UInt );
+}
+
+bool KDiffPlugin::readInfo( KFileMetaInfo& info, uint what )
+{
+ // This is a hack to avoid using the what stuff, since it is not yet implemented
+ what = 0;
+
+ // Used to determine if false or true should be returned
+ bool dataSet = false;
+
+ KFileMetaInfoGroup group;
+
+ TQFile file( info.path() );
+ TQStringList lines;
+
+ if( file.open( IO_ReadOnly ) )
+ {
+ TQTextStream stream( &file );
+ while (!stream.eof())
+ {
+ lines.append( stream.readLine() );
+ }
+ file.close();
+ }
+
+ TQString format;
+ TQString program;
+
+ enum KDiffPlugin::Format diffFormat;
+ enum KDiffPlugin::DiffProgram diffProgram;
+
+ diffFormat = determineDiffFormat ( lines );
+
+ format = determineI18nedFormat( diffFormat );
+
+ diffProgram = determineDiffProgram( lines );
+
+ program = determineI18nedProgram( diffProgram );
+
+ int numberOfAdditions = 0;
+ int numberOfDeletions = 0;
+ int numberOfChanges = 0;
+ int numberOfHunks = 0;
+ int numberOfFiles = 0;
+
+
+ if ( what != KFileMetaInfo::Fastest )
+ {
+ determineDiffInfo( lines, diffFormat, &numberOfFiles, &numberOfHunks, &numberOfAdditions, &numberOfChanges, &numberOfDeletions );
+ }
+
+ TQString filename;
+ TQRegExp firstFile( "^Index: (.*)" );
+ TQStringList::ConstIterator it = lines.begin();
+
+ it = lines.begin();
+ while ( it != lines.end() )
+ {
+ if ( firstFile.exactMatch( (*it) ) )
+ {
+ filename = firstFile.cap(1);
+ // only interested in the first filename
+ break;
+ }
+ ++it;
+ }
+
+ kdDebug(7034) << "Diff Format : " << format << endl; // i18n-ed but that is not a problem unless i get i18n-ed debug output ah well, we'll figure something out when then happens
+
+ if (what != KFileMetaInfo::Fastest )
+ {
+ // These dont get calculated in fastest mode...
+ kdDebug(7034) << "Number of additions : " << numberOfAdditions << endl;
+ kdDebug(7034) << "Number of deletions : " << numberOfDeletions << endl;
+ kdDebug(7034) << "Number of changes : " << numberOfChanges << endl;
+ kdDebug(7034) << "Number of hunks : " << numberOfHunks << endl;
+ }
+
+ group = appendGroup( info, "General" );
+
+ if ( numberOfFiles != 0 && what != KFileMetaInfo::Fastest )
+ {
+ appendItem( group, "Files", numberOfFiles );
+ dataSet = true;
+ }
+
+ if ( !filename.isEmpty() )
+ {
+ appendItem( group, "First", filename );
+ dataSet = true;
+ }
+
+ if ( !format.isEmpty() )
+ {
+ appendItem( group, "Format", format );
+ dataSet = true;
+ }
+
+ if ( !program.isEmpty() )
+ {
+ appendItem( group, "DiffProgram", program );
+ dataSet = true;
+ }
+
+ if ( numberOfHunks != 0 && what != KFileMetaInfo::Fastest )
+ {
+ appendItem( group, "Hunks", numberOfHunks );
+ dataSet = true;
+ }
+
+ group = appendGroup( info, "Statistics" );
+
+ if ( numberOfAdditions != 0 && what != KFileMetaInfo::Fastest )
+ {
+ appendItem( group, "Insert", numberOfAdditions );
+ dataSet = true;
+ }
+
+ if ( numberOfChanges != 0 && what != KFileMetaInfo::Fastest )
+ {
+ appendItem( group, "Modify", numberOfChanges );
+ dataSet = true;
+ }
+
+ if ( numberOfDeletions != 0 && what != KFileMetaInfo::Fastest )
+ {
+ appendItem( group, "Delete", numberOfDeletions );
+ dataSet = true;
+ }
+
+ return dataSet;
+}
+
+enum KDiffPlugin::Format KDiffPlugin::determineDiffFormat( const TQStringList lines ) const
+{
+ TQString line;
+
+ if ( lines.count() == 0 )
+ {
+ return KDiffPlugin::Empty;
+ }
+
+ TQStringList::ConstIterator it = lines.begin();
+
+ while ( it != lines.end() )
+ {
+ line = (*it);
+ if ( line.find( TQRegExp( "^[0-9]+[0-9,]*[acd][0-9]+[0-9,]*$" ), 0 ) == 0 )
+ {
+ return KDiffPlugin::Normal;
+ }
+ else if ( line.find( TQRegExp( "^--- " ), 0 ) == 0 )
+ {
+ // unified has first a '^--- ' line, then a '^+++ ' line
+ return KDiffPlugin::Unified;
+ }
+ else if ( line.find( TQRegExp( "^\\*\\*\\* [^\\t]+\\t" ), 0 ) == 0 )
+ {
+ // context has first a '^*** ' line, then a '^--- ' line
+ return KDiffPlugin::Context;
+ }
+ else if ( line.find( TQRegExp( "^[acd][0-9]+ [0-9]+" ), 0 ) == 0 )
+ {
+ return KDiffPlugin::RCS;
+ }
+ else if ( line.find( TQRegExp( "^[0-9]+[0-9,]*[acd]" ), 0 ) == 0 )
+ {
+ return KDiffPlugin::Ed;
+ }
+ ++it;
+ }
+ return KDiffPlugin::Unknown;
+}
+
+enum KDiffPlugin::DiffProgram KDiffPlugin::determineDiffProgram( const TQStringList lines ) const
+{
+ if ( lines.count() == 0 )
+ {
+ return KDiffPlugin::Undeterminable;
+ }
+
+ TQStringList::ConstIterator it = lines.begin();
+ // very crude, might need some more refining
+ TQRegExp diffRE( "^diff .*" );
+ TQRegExp p4sRE("^==== ");
+
+ bool indexFound = false;
+
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith( "Index:" ) )
+ indexFound = true;
+ else if ( (*it).startsWith( "retrieving revision") )
+ return KDiffPlugin::CVSDiff;
+ else if ( diffRE.exactMatch( *it ) )
+ return KDiffPlugin::Diff;
+ else if ( p4sRE.exactMatch( *it ) )
+ return KDiffPlugin::Perforce;
+
+ ++it;
+ }
+
+ if ( indexFound ) // but no "retrieving revision" found like only cvs diff adds.
+ return KDiffPlugin::SubVersion;
+
+ return KDiffPlugin::Undeterminable;
+}
+
+const TQString KDiffPlugin::determineI18nedFormat( enum KDiffPlugin::Format diffFormat ) const
+{
+ TQString format;
+ switch( diffFormat )
+ {
+ case KDiffPlugin::Context:
+ format = i18n( "Context" );
+ break;
+ case KDiffPlugin::Ed:
+ format = i18n( "Ed" );
+ break;
+ case KDiffPlugin::Normal:
+ format = i18n( "Normal" );
+ break;
+ case KDiffPlugin::RCS:
+ format = i18n( "RCS" );
+ break;
+ case KDiffPlugin::Unified:
+ format = i18n( "Unified" );
+ break;
+ case KDiffPlugin::Empty:
+ format = i18n( "Not Available (file empty)" );
+ break;
+ case KDiffPlugin::Unknown:
+ format = i18n( "Unknown" );
+ break;
+ case KDiffPlugin::SideBySide:
+ format = i18n( "Side by Side" );
+ }
+ return format;
+}
+
+const TQString KDiffPlugin::determineI18nedProgram( enum KDiffPlugin::DiffProgram diffProgram ) const
+{
+ TQString program;
+
+ switch( diffProgram )
+ {
+ case KDiffPlugin::CVSDiff:
+ program = i18n( "CVSDiff" );
+ break;
+ case KDiffPlugin::Diff:
+ program = i18n( "Diff" );
+ break;
+ case KDiffPlugin::Diff3:
+ program = i18n( "Diff3" );
+ break;
+ case KDiffPlugin::Perforce:
+ program = i18n( "Perforce" );
+ break;
+ case KDiffPlugin::SubVersion:
+ program = i18n( "SubVersion" );
+ break;
+ case KDiffPlugin::Undeterminable:
+ program = i18n( "Unknown" );
+ break;
+ }
+ return program;
+}
+
+void KDiffPlugin::determineDiffInfo( const TQStringList lines,
+ enum KDiffPlugin::Format diffFormat,
+ int* numberOfFiles,
+ int* numberOfHunks,
+ int* numberOfAdditions,
+ int* numberOfChanges,
+ int* numberOfDeletions )
+{
+ TQString line;
+
+ TQRegExp edAdd( "([0-9]+)(|,([0-9]+))a" );
+ TQRegExp edDel( "([0-9]+)(|,([0-9]+))d" );
+ TQRegExp edMod( "([0-9]+)(|,([0-9]+))c" );
+
+ TQRegExp normalAdd( "[0-9]+a([0-9]+)(|,([0-9]+))" );
+ TQRegExp normalDel( "([0-9]+)(|,([0-9]+))d(|[0-9]+)" );
+ TQRegExp normalMod( "([0-9]+)(|,([0-9]+))c([0-9]+)(|,([0-9]+))" );
+
+ TQRegExp rcsAdd( "a[0-9]+ ([0-9]+)" );
+ TQRegExp rcsDel( "d[0-9]+ ([0-9]+)" );
+
+ TQStringList::ConstIterator it = lines.begin();
+
+ switch( diffFormat )
+ {
+ case KDiffPlugin::Context:
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith("***************") )
+ {
+ (*numberOfHunks)++;
+// kdDebug(7034) << "Context Hunk : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("***") )
+ {
+ (*numberOfFiles)++;
+// kdDebug(7034) << "Context File : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("---") ) {} // ignore
+ else if ( (*it).startsWith("+") )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Context Insertion : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("-") )
+ {
+ (*numberOfDeletions)++;
+// kdDebug(7034) << "Context Deletion : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("!") )
+ {
+ (*numberOfChanges)++;
+// kdDebug(7034) << "Context Modified : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith(" ") )
+ {
+// kdDebug(7034) << "Context Context : " << (*it) << endl;
+ }
+ else
+ {
+// kdDebug(7034) << "Context Unknown : " << (*it) << endl;
+ }
+
+ ++it;
+ }
+ (*numberOfChanges) /= 2; // changes are in both parts of the hunks
+ (*numberOfFiles) -= (*numberOfHunks); // it counts old parts of a hunk as files :(
+ break;
+ case KDiffPlugin::Ed:
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith( "diff" ) )
+ {
+ (*numberOfFiles)++;
+// kdDebug(7034) << "Ed File : " << (*it) << endl;
+ }
+ else if ( edAdd.exactMatch( (*it) ) )
+ {
+// kdDebug(7034) << "Ed Insertion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ ++it;
+ while( it != lines.end() && !(*it).startsWith(".") )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Ed Insertion : " << (*it) << endl;
+ ++it;
+ }
+ }
+ else if ( edDel.exactMatch( (*it) ) )
+ {
+// kdDebug(7034) << "Ed Deletion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ (*numberOfDeletions) += (edDel.cap(3).isEmpty() ? 1 : edDel.cap(3).toInt() - edDel.cap(1).toInt() + 1);
+// kdDebug(7034) << "Ed noOfLines : " << (edDel.cap(3).isEmpty() ? 1 : edDel.cap(3).toInt() - edDel.cap(1).toInt() + 1) << endl;
+ }
+ else if ( edMod.exactMatch( (*it) ) )
+ {
+// kdDebug(7034) << "Ed Modification : " << (*it) << endl;
+ if ( edMod.cap(3).isEmpty() )
+ (*numberOfDeletions)++;
+ else
+ (*numberOfDeletions) += edMod.cap(3).toInt() - edMod.cap(1).toInt() + 1;
+ (*numberOfHunks)++;
+ ++it;
+ while( it != lines.end() && !(*it).startsWith(".") )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Ed Modification : " << (*it) << endl;
+ ++it;
+ }
+ }
+ else
+ {
+// kdDebug(7034) << "Ed Unknown : " << (*it) << endl;
+ }
+
+ ++it;
+ }
+ break;
+ case KDiffPlugin::Normal:
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith( "diff" ) )
+ {
+ (*numberOfFiles)++;
+// kdDebug(7034) << "Normal File : " << (*it) << endl;
+ }
+ else if ( normalAdd.exactMatch( *it ) )
+ {
+// kdDebug(7034) << "Normal Insertion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ if ( normalAdd.cap(3).isEmpty() )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Normal Addition : " << 1 << endl;
+ }
+ else
+ {
+ (*numberOfAdditions) += normalAdd.cap(3).toInt() - normalAdd.cap(1).toInt() + 1;
+// kdDebug(7034) << "Normal Addition : " << normalAdd.cap(3).toInt() - normalAdd.cap(1).toInt() + 1 << endl;
+ }
+ }
+ else if ( normalDel.exactMatch( *it ) )
+ {
+// kdDebug(7034) << "Normal Deletion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ if ( normalDel.cap(3).isEmpty() )
+ {
+ (*numberOfDeletions)++;
+// kdDebug(7034) << "Normal Deletion : " << 1 << endl;
+ }
+ else
+ {
+ (*numberOfDeletions) += normalDel.cap(3).toInt() - normalDel.cap(1).toInt() + 1;
+// kdDebug(7034) << "Normal Deletion : " << normalDel.cap(3).toInt() - normalDel.cap(1).toInt() + 1 << endl;
+ }
+ }
+ else if ( normalMod.exactMatch( *it ) )
+ {
+// kdDebug(7034) << "Normal Modification : " << (*it) << endl;
+ (*numberOfHunks)++;
+ if ( normalMod.cap(3).isEmpty() )
+ {
+ (*numberOfDeletions)++;
+// kdDebug(7034) << "Normal Deletion : " << 1 << endl;
+ }
+ else
+ {
+ (*numberOfDeletions) += normalMod.cap(3).toInt() - normalMod.cap(1).toInt() + 1;
+// kdDebug(7034) << "Normal Deletion : " << normalMod.cap(3).toInt() - normalMod.cap(1).toInt() + 1 << endl;
+ }
+ if ( normalMod.cap(6).isEmpty() )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Normal Addition : " << 1 << endl;
+ }
+ else
+ {
+ (*numberOfAdditions) += normalMod.cap(6).toInt() - normalMod.cap(4).toInt() + 1;
+// kdDebug(7034) << "Normal Addition : " << normalMod.cap(6).toInt() - normalMod.cap(4).toInt() + 1 << endl;
+ }
+ }
+ else if ( (*it).startsWith(">") )
+ {
+// numberOfAdditions++;
+// kdDebug(7034) << "Normal Insertion : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("<") )
+ {
+// numberOfDeletions++;
+// kdDebug(7034) << "Normal Deletion : " << (*it) << endl;
+ }
+ else
+ {
+// kdDebug(7034) << "Normal Unknown : " << (*it) << endl;
+ }
+
+ ++it;
+ }
+ break;
+ case KDiffPlugin::RCS:
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith( "diff" ) ) // works for cvs diff, have to test for normal diff
+ {
+// kdDebug(7034) << "RCS File : " << (*it) << endl;
+ (*numberOfFiles)++;
+ }
+ else if ( rcsAdd.exactMatch( *it ) )
+ {
+// kdDebug(7034) << "RCS Insertion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ (*numberOfAdditions) += rcsAdd.cap(1).toInt();
+// kdDebug(7034) << "RCS noOfLines : " << rcsAdd.cap(1).toInt() << endl;
+ }
+ else if ( rcsDel.exactMatch( *it ) )
+ {
+// kdDebug(7034) << "RCS Deletion : " << (*it) << endl;
+ (*numberOfHunks)++;
+ (*numberOfDeletions) += rcsDel.cap(1).toInt();
+// kdDebug(7034) << "RCS noOfLines : " << rcsDel.cap(1).toInt() << endl;
+ }
+ else
+ {
+// kdDebug(7034) << "RCS Unknown : " << (*it) << endl;
+ }
+
+ ++it;
+ }
+ break;
+ case KDiffPlugin::Unified:
+ while ( it != lines.end() )
+ {
+ if ( (*it).startsWith("@@ ") )
+ {
+ (*numberOfHunks)++;
+// kdDebug(7034) << "Unified Hunk : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("---") )
+ {
+ (*numberOfFiles)++;
+// kdDebug(7034) << "Unified File : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("+++") ) {} // ignore (dont count as insertion)
+ else if ( (*it).startsWith("+") )
+ {
+ (*numberOfAdditions)++;
+// kdDebug(7034) << "Unified Insertion : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith("-") )
+ {
+ (*numberOfDeletions)++;
+// kdDebug(7034) << "Unified Deletion : " << (*it) << endl;
+ }
+ else if ( (*it).startsWith(" ") )
+ {
+// kdDebug(7034) << "Unified Context : " << (*it) << endl;
+ }
+ else
+ {
+// kdDebug(7034) << "Unified Unknown : " << (*it) << endl;
+ }
+
+ ++it;
+ }
+ break;
+ case KDiffPlugin::Empty:
+ case KDiffPlugin::Unknown:
+ case KDiffPlugin::SideBySide:
+ break;
+ }
+}
+
+#include "tdefile_diff.moc"
+
+/* vim: set ts=4 sw=4 noet: */
+
diff --git a/tdefile-plugins/diff/tdefile_diff.desktop b/tdefile-plugins/diff/tdefile_diff.desktop
new file mode 100644
index 00000000..b1d0e9da
--- /dev/null
+++ b/tdefile-plugins/diff/tdefile_diff.desktop
@@ -0,0 +1,57 @@
+[Desktop Entry]
+Type=Service
+Name=Diff Stats
+Name[af]=Diff Statistiek
+Name[bg]=Статистика за разлики
+Name[br]=Stadegoù Diff
+Name[bs]=Diff statistika
+Name[ca]=Estadístiques de diff
+Name[cs]=Statistika rozdílů
+Name[cy]=Ystadegau Gwahaniaethau
+Name[da]=Diff-stats
+Name[de]=Diff-Statistiken
+Name[el]=Στατιστικά diff
+Name[es]=Estadísticas Diff
+Name[et]=Võrdlemise tulemused
+Name[eu]=Desberdintasun estatistikak
+Name[fa]=آمارهای Diff
+Name[fi]=Diff-tilastot
+Name[fr]=Statistiques de diff
+Name[ga]=Staitistic Diff
+Name[gl]=Estatísticas de diff
+Name[he]=סטטיסטיקת Diff
+Name[hi]=डिफ स्टेट्स
+Name[hr]=Diff statistike
+Name[hu]=Diff statisztika
+Name[it]=Statistiche di confronto
+Name[ja]=Diff 統計
+Name[kk]=Diff статистикасы
+Name[lt]=Skirtumų statistika
+Name[ms]=Stat Diff
+Name[nb]=Diff-statistikk
+Name[nds]=Verscheelstatistiken
+Name[ne]=भिन्न तथ्याङ्क
+Name[nl]=Diff-statistieken
+Name[nn]=Diff-statistikk
+Name[pa]=ਅੰਤਰ ਹਾਲਤ
+Name[pl]=Statystyka różnic
+Name[pt]=Estatísticas do diff
+Name[pt_BR]=Estados do Diff
+Name[ro]=Statistici Diff
+Name[ru]=Статистика различий
+Name[sk]=Štatistiky Diff
+Name[sl]=Statistike diff
+Name[sr]=Статистика разликовања
+Name[sr@Latn]=Statistika razlikovanja
+Name[sv]=Diff-statistik
+Name[ta]=டிப் ஸ்டட்ஸ்
+Name[tg]=Статистикаи фарқият
+Name[th]=สถานะแตกต่าง
+Name[tr]=Diff İstatistikleri
+Name[uk]=Статистика відмінностей
+Name[zh_CN]=Diff 统计
+Name[zh_TW]=Diff 狀態
+ServiceTypes=KFilePlugin
+X-TDE-Library=tdefile_diff
+MimeType=text/x-diff
+PreferredItems=Files,First,Format,Hunks,Insert,Modify,Delete
diff --git a/tdefile-plugins/diff/tdefile_diff.h b/tdefile-plugins/diff/tdefile_diff.h
new file mode 100644
index 00000000..15e9abeb
--- /dev/null
+++ b/tdefile-plugins/diff/tdefile_diff.h
@@ -0,0 +1,53 @@
+/**************************************************************************
+** tdefile_diff.h
+** -------------------
+** begin : Sun Jan 20 23:25:29 2002
+** copyright : (C) 2002 by Otto Bruggeman
+** email : otto.bruggeman@home.nl
+**
+***************************************************************************/
+/***************************************************************************
+**
+** 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; either version 2 of the License, or
+** (at your option) any later version.
+**
+***************************************************************************/
+
+#ifndef __KFILE_PDF_H__
+#define __KFILE_PDF_H__
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KDiffPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KDiffPlugin( TQObject *parent, const char *name,
+ const TQStringList& preferredItems );
+
+
+ virtual bool readInfo( KFileMetaInfo& info, uint what );
+
+public:
+ enum Format { Context, Ed, Normal, RCS, Unified, Empty, SideBySide, Unknown };
+ enum DiffProgram { CVSDiff, Diff, Diff3, Perforce, SubVersion, Undeterminable }; // cant use Unknown again :(
+
+private:
+ enum Format determineDiffFormat ( const TQStringList lines ) const;
+ enum DiffProgram determineDiffProgram ( const TQStringList lines ) const;
+ const TQString determineI18nedFormat ( enum KDiffPlugin::Format diffFormat ) const;
+ const TQString determineI18nedProgram( enum KDiffPlugin::DiffProgram diffProgram ) const;
+ // yes ugly, it's better to use a struct or classmembers to pass these parameters around
+ void determineDiffInfo ( const TQStringList lines,
+ enum KDiffPlugin::Format diffFormat, int* numberOfFiles,
+ int* numberOfHunks, int* numberOfAdditions,
+ int* numberOfChanges, int* numberOfDeletions );
+};
+
+#endif
diff --git a/tdefile-plugins/ts/CMakeLists.txt b/tdefile-plugins/ts/CMakeLists.txt
new file mode 100644
index 00000000..ff95bff9
--- /dev/null
+++ b/tdefile-plugins/ts/CMakeLists.txt
@@ -0,0 +1,35 @@
+#################################################
+#
+# (C) 2012 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES tdefile_ts.desktop
+ DESTINATION ${SERVICES_INSTALL_DIR} )
+
+
+##### tdefile_ts (module) #########################
+
+tde_add_kpart( tdefile_ts AUTOMOC
+ SOURCES tdefile_ts.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/tdefile-plugins/ts/Makefile.am b/tdefile-plugins/ts/Makefile.am
new file mode 100644
index 00000000..bb46c13c
--- /dev/null
+++ b/tdefile-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 = tdefile_ts.h
+
+kde_module_LTLIBRARIES = tdefile_ts.la
+
+tdefile_ts_la_SOURCES = tdefile_ts.cpp
+tdefile_ts_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+tdefile_ts_la_LIBADD = $(LIB_KIO)
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/tdefile_ts.pot
+
+services_DATA = tdefile_ts.desktop
+servicesdir = $(kde_servicesdir)
diff --git a/tdefile-plugins/ts/tdefile_ts.cpp b/tdefile-plugins/ts/tdefile_ts.cpp
new file mode 100644
index 00000000..2b136a09
--- /dev/null
+++ b/tdefile-plugins/ts/tdefile_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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "tdefile_ts.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <tqfile.h>
+#include <tqstringlist.h>
+
+typedef KGenericFactory<KTsPlugin> TsFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_ts, TsFactory("tdefile_ts"))
+
+KTsPlugin::KTsPlugin(TQObject *parent, const char *name,
+ const TQStringList &args) : KFilePlugin(parent, name, args)
+{
+ makeMimeTypeInfo( "application/x-linguist" );
+}
+
+void KTsPlugin::makeMimeTypeInfo(const TQString& mimeType)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo(mimeType);
+
+ KFileMimeTypeInfo::GroupInfo* group =
+ addGroupInfo(info, "General", i18n("General"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+ item = addItemInfo(group, "Messages", i18n("Messages"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Translated", i18n("Translated"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Untranslated", i18n("Untranslated"), TQVariant::Int);
+ setAttributes(item, KFileMimeTypeInfo::Averaged);
+ item = addItemInfo(group, "Obsolete", i18n("Obsolete"), TQVariant::Int);
+}
+
+bool KTsPlugin::readInfo(KFileMetaInfo& info, uint)
+{
+ TQFile f(info.path());
+ if (!f.open(IO_ReadOnly))
+ return false;
+
+ int messages = 0;
+ int untranslated = 0;
+ int obsolete = 0;
+
+ TQTextStream stream( &f );
+ TQString 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 "tdefile_ts.moc"
diff --git a/tdefile-plugins/ts/tdefile_ts.desktop b/tdefile-plugins/ts/tdefile_ts.desktop
new file mode 100644
index 00000000..1d4faebb
--- /dev/null
+++ b/tdefile-plugins/ts/tdefile_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-TDE-Library=tdefile_ts
+MimeType=application/x-linguist
+PreferredGroups=General
+PreferredItems=Messages,Translated,Untranslated,Fuzzi
diff --git a/tdefile-plugins/ts/tdefile_ts.h b/tdefile-plugins/ts/tdefile_ts.h
new file mode 100644
index 00000000..0f03fac1
--- /dev/null
+++ b/tdefile-plugins/ts/tdefile_ts.h
@@ -0,0 +1,40 @@
+/* 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __KFILE_TS_H_
+#define __KFILE_TS_H_
+
+#include <tdefilemetainfo.h>
+
+class TQStringList;
+
+class KTsPlugin: public KFilePlugin
+{
+ Q_OBJECT
+
+
+public:
+ KTsPlugin(TQObject *parent, const char *name, const TQStringList& args);
+ virtual bool readInfo(KFileMetaInfo& info, uint what);
+
+private:
+ void makeMimeTypeInfo(const TQString& mimeType);
+};
+
+#endif