• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

kiten/lib

linearEDICTFile.cpp

Go to the documentation of this file.
00001 /* This file is part of Kiten, a KDE Japanese Reference Tool...
00002     Copyright (C) 2001 by Jason Katz-Brown
00003               (C) 2008 by Joseph Kerian  <jkerian@gmail.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "linearEDICTFile.h"
00022 
00023 #include <kglobal.h>
00024 #include <kdebug.h>
00025 #include <kstandarddirs.h>
00026 #include <kprocess.h>
00027 #include <kapplication.h>
00028 
00029 #include <QtCore/QTextCodec>
00030 #include <QtCore/QFile>
00031 
00032 
00033 linearEDICTFile::linearEDICTFile() :
00034     properlyLoaded(false)
00035 {
00036 }
00037 
00038 linearEDICTFile::~linearEDICTFile()
00039 {
00040 
00041 }
00042 
00043 bool linearEDICTFile::loadFile(const QString& filename)
00044 {
00045     kDebug() << "Loading edict from " << filename << "\n";
00046 
00047     //if already loaded
00048     if (!edict.isEmpty())
00049         return true;
00050 
00051     QFile file(filename);
00052     if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
00053         return false;
00054 
00055     QTextStream fileStream(&file);
00056     fileStream.setCodec(QTextCodec::codecForName("eucJP"));
00057 
00058     QString lastLine;
00059     while (!fileStream.atEnd()) {
00060         lastLine = fileStream.readLine();
00061         if (lastLine[0] != '#') edict << lastLine;
00062     }
00063 
00064     file.close();
00065     properlyLoaded = true;
00066 
00067     return true;
00068 }
00069 
00070 bool linearEDICTFile::valid() const
00071 {
00072     return properlyLoaded;
00073 }
00074 
00076 QVector<QString> linearEDICTFile::findMatches(const QString &searchString) const
00077 {
00078 
00079     QVector<QString> matches;
00080     foreach(const QString &it, edict) {
00081         if (it.contains(searchString))
00082         {
00083             matches.append(it);
00084         }
00085     }
00086     return matches;
00087 
00088 }

kiten/lib

Skip menu "kiten/lib"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal