~ubuntu-branches/ubuntu/intrepid/ktranslator/intrepid

« back to all changes in this revision

Viewing changes to ktranslator/plugins/stardict/stardictplugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2006-07-20 23:02:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060720230258-18ijr919ancujnuz
Tags: 0.4-0ubuntu1
* New upstream release
* Added kubuntu_01_kdepot.patch for pot file extraction 
  to rosetta
* Added kubuntu_02_fix_desktop_file.patch to prepare desktop
  file for XDG directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2004-2006 by Raul Fernandes                             *
 
3
 *   rgfbr@yahoo.com.br                                                    *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "stardictplugin.h"
 
22
#include "stardict.h"
 
23
 
 
24
#include <kgenericfactory.h>
 
25
 
 
26
#include <qfile.h>
 
27
#include <qregexp.h>
 
28
#include <qlabel.h>
 
29
 
 
30
#include <kprocio.h>
 
31
 
 
32
#ifndef NDEBUG
 
33
 
 
34
#include <kdebug.h>
 
35
 
 
36
#endif
 
37
 
 
38
 
 
39
K_EXPORT_COMPONENT_FACTORY( ktranslator_stardict,
 
40
                            KGenericFactory<StarDictPlugin>( "ktranslator_stardict" ) )
 
41
 
 
42
StarDictPlugin::StarDictPlugin( QObject *parent, const char*, const QStringList &args )
 
43
            : KTranslator::DictionaryPlugin(parent, "StarDict" )
 
44
{
 
45
   KLocale::setMainCatalogue("ktranslator");
 
46
   dic = new StarDict( args[0] );
 
47
   dictName = args[1];
 
48
   setOk( dic->isOk() );
 
49
   setEnabled( true );
 
50
   m_tooltip = i18n( "StarDict Dictionary\nBookname: %1\nAuthor: %2\nVersion: %3\nDescription: %4\nWords: %5" ).arg( dic->bookname() ).arg( dic->author() ).arg( dic->version() ).arg( dic->description() ).arg( dic->size() );
 
51
}
 
52
 
 
53
QString StarDictPlugin::search( const QString &word )
 
54
{
 
55
 
 
56
  #ifndef NDEBUG
 
57
 
 
58
  kdDebug() << "StarDict Plugin search()" << endl;
 
59
 
 
60
  #endif
 
61
 
 
62
  QString result = dic->search( word );
 
63
 
 
64
  if( result.isEmpty() ) return QString ( "<dicName>%1</dicName><font color=#000000>%2</font>" ).arg( dictName ).arg( i18n( "Word not found" ) );
 
65
 
 
66
  result = result.stripWhiteSpace().replace( '\n', "<br>" );
 
67
  return QString( "<dicName>%1</dicName><definition>%3</definition>" ).arg( dictName ).arg( result );
 
68
}
 
69
 
 
70
 
 
71
QWidget *StarDictPlugin::confPage()
 
72
{
 
73
  return new QLabel( "This plugin has no configurations", 0 );
 
74
}
 
75
 
 
76
 
 
77
void StarDictPlugin::applyConf( QWidget * )
 
78
{
 
79
  return;
 
80
}
 
81
 
 
82
 
 
83
int StarDictPlugin::size()
 
84
{
 
85
  return dic->size();
 
86
}