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.
94 lines
2.9 KiB
94 lines
2.9 KiB
15 years ago
|
/* 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
|
||
15 years ago
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
* Boston, MA 02110-1301, USA.
|
||
15 years ago
|
*
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include "tdefile_ts.h"
|
||
15 years ago
|
|
||
|
#include <kgenericfactory.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
14 years ago
|
#include <tqfile.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
|
typedef KGenericFactory<KTsPlugin> TsFactory;
|
||
|
|
||
12 years ago
|
K_EXPORT_COMPONENT_FACTORY(tdefile_ts, TsFactory("tdefile_ts"))
|
||
15 years ago
|
|
||
13 years ago
|
KTsPlugin::KTsPlugin(TQObject *parent, const char *name,
|
||
|
const TQStringList &args) : KFilePlugin(parent, name, args)
|
||
15 years ago
|
{
|
||
|
makeMimeTypeInfo( "application/x-linguist" );
|
||
|
}
|
||
|
|
||
14 years ago
|
void KTsPlugin::makeMimeTypeInfo(const TQString& mimeType)
|
||
15 years ago
|
{
|
||
|
KFileMimeTypeInfo* info = addMimeTypeInfo(mimeType);
|
||
|
|
||
|
KFileMimeTypeInfo::GroupInfo* group =
|
||
|
addGroupInfo(info, "General", i18n("General"));
|
||
|
|
||
|
KFileMimeTypeInfo::ItemInfo* item;
|
||
14 years ago
|
item = addItemInfo(group, "Messages", i18n("Messages"), TQVariant::Int);
|
||
15 years ago
|
setAttributes(item, KFileMimeTypeInfo::Averaged);
|
||
14 years ago
|
item = addItemInfo(group, "Translated", i18n("Translated"), TQVariant::Int);
|
||
15 years ago
|
setAttributes(item, KFileMimeTypeInfo::Averaged);
|
||
14 years ago
|
item = addItemInfo(group, "Untranslated", i18n("Untranslated"), TQVariant::Int);
|
||
15 years ago
|
setAttributes(item, KFileMimeTypeInfo::Averaged);
|
||
14 years ago
|
item = addItemInfo(group, "Obsolete", i18n("Obsolete"), TQVariant::Int);
|
||
15 years ago
|
}
|
||
|
|
||
|
bool KTsPlugin::readInfo(KFileMetaInfo& info, uint)
|
||
|
{
|
||
14 years ago
|
TQFile f(info.path());
|
||
15 years ago
|
if (!f.open(IO_ReadOnly))
|
||
|
return false;
|
||
|
|
||
|
int messages = 0;
|
||
|
int untranslated = 0;
|
||
|
int obsolete = 0;
|
||
|
|
||
14 years ago
|
TQTextStream stream( &f );
|
||
|
TQString line = stream.readLine();
|
||
15 years ago
|
|
||
|
// is it really a linguist file?
|
||
13 years ago
|
if (!line.contains("<!DOCTYPE TS>", false))
|
||
15 years ago
|
return false;
|
||
|
|
||
|
while (!stream.eof())
|
||
|
{
|
||
|
line = stream.readLine();
|
||
|
|
||
13 years ago
|
if (line.contains("type=\"obsolete\"")) obsolete++;
|
||
15 years ago
|
|
||
13 years ago
|
if (line.contains("<source>")) messages++;
|
||
15 years ago
|
|
||
13 years ago
|
if (line.contains("type=\"unfinished\"")) untranslated++;
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
12 years ago
|
#include "tdefile_ts.moc"
|