• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • view
  • stringsextract
extractstringsjob.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "extractstringsjob.h"
24 
25 // Okteta core
26 #include <abstractbytearraymodel.h>
27 #include <charcodec.h>
28 #include <character.h>
29 // Qt
30 #include <QtGui/QApplication>
31 
32 
33 namespace Kasten2
34 {
35 
36 static const int ExtractStringBlockSize = 100000;
37 
38 void ExtractStringsJob::exec()
39 {
40 
41  // reset
42  mContainedStringList->clear();
43 
44  // check
45  if( !mByteArrayModel || !mSelection.isValid() )
46  {
47  deleteLater(); // TODO: could be reused on next operation
48 
49  return;
50  }
51 
52  bool stringStarted = false;
53  Okteta::Address stringStart = mSelection.start();
54  QString string;
55 
56  Okteta::Address i = mSelection.start();
57  Okteta::Address blockEnd = mSelection.start();
58  while( i<=mSelection.end() )
59  {
60  blockEnd += ExtractStringBlockSize;
61  if( blockEnd > mSelection.end() )
62  blockEnd = mSelection.end();
63 
64  for( ; i<=blockEnd; ++i )
65  {
66  const Okteta::Character decodedChar = mCharCodec->decode( mByteArrayModel->byte(i) );
67  // TODO: Zeilenumbrüche ausnehmen
68  const bool isStringChar = ( !decodedChar.isUndefined() &&
69  (decodedChar.isLetterOrNumber() || decodedChar.isSpace() || decodedChar.isPunct()) );
70 
71  if( isStringChar )
72  {
73  if( !stringStarted )
74  {
75  stringStart = i;
76  stringStarted = true;
77  string.clear();
78  }
79  string.append( decodedChar );
80  }
81  else
82  {
83  if( stringStarted )
84  {
85  if( i-stringStart >= mMinLength )
86  mContainedStringList->append( ContainedString(string,stringStart) );
87  stringStarted = false;
88  }
89  }
90  }
91 
92  QApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 100 );
93  }
94 
95  // last string not ended?
96  if( stringStarted )
97  {
98  if( i-stringStart >= mMinLength )
99  mContainedStringList->append( ContainedString(string,stringStart) );
100  stringStarted = false;
101  }
102 
103  deleteLater(); // TODO: could be reused on next operation
104 }
105 
106 }
character.h
Okteta::Address
qint32 Address
Definition: address.h:34
Kasten2::ExtractStringsJob::mCharCodec
const Okteta::CharCodec * mCharCodec
Definition: extractstringsjob.h:60
abstractbytearraymodel.h
extractstringsjob.h
Kasten2::ExtractStringsJob::mContainedStringList
QList< ContainedString > * mContainedStringList
Definition: extractstringsjob.h:63
KDE::Range::start
T start() const
Definition: range.h:86
Okteta::Character::isUndefined
bool isUndefined() const
Definition: character.h:52
Okteta::CharCodec::decode
virtual Character decode(Byte byte) const =0
Kasten2::ExtractStringsJob::mByteArrayModel
const Okteta::AbstractByteArrayModel * mByteArrayModel
Definition: extractstringsjob.h:58
Kasten2::ExtractStringsJob::mMinLength
const int mMinLength
Definition: extractstringsjob.h:61
Kasten2::ExtractStringsJob::mSelection
const Okteta::AddressRange mSelection
Definition: extractstringsjob.h:59
KDE::Range::end
T end() const
Definition: range.h:88
Okteta::AbstractByteArrayModel::byte
virtual Byte byte(Address offset) const =0
locates working range The idea behind is to tell buffer which range will be requested in the followin...
charcodec.h
ContainedString
Definition: containedstring.h:33
Kasten2::ExtractStringBlockSize
static const int ExtractStringBlockSize
Definition: extractstringsjob.cpp:36
Kasten2::ExtractStringsJob::exec
void exec()
Definition: extractstringsjob.cpp:38
KDE::Range::isValid
bool isValid() const
returns true if the range covers at least one index
Definition: range.h:122
Okteta::Character
Definition: character.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal