kstringhandler.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Ian Zepp (icszepp@islc.net) 00003 Copyright (C) 2000 Rik Hemsley (rikkus) <rik@kde.org> 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 version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef KSTRINGHANDLER_H 00020 #define KSTRINGHANDLER_H 00021 00022 #include <tqstring.h> 00023 #include <tqstringlist.h> 00024 #include <tqregexp.h> // for the word ranges 00025 #include <tqfontmetrics.h> 00026 #include "kdelibs_export.h" 00027 00069 class KDECORE_EXPORT KStringHandler 00070 { 00071 public: 00080 static TQString word( const TQString &text , uint pos ) KDE_DEPRECATED; 00081 00094 static TQString word( const TQString &text , const char *range ); 00095 00105 static TQString insword( const TQString &text , const TQString &word , uint pos ); 00106 00116 static TQString setword( const TQString &text , const TQString &word , uint pos ); 00117 00130 static TQString remrange( const TQString &text , const char *range ); 00131 00132 00139 static TQString remword( const TQString &text , uint pos ); 00140 00147 static TQString remword( const TQString &text , const TQString &word ); 00148 00154 static TQString capwords( const TQString &text ); 00155 00161 static TQStringList capwords( const TQStringList &list ); 00162 00168 static TQString reverse( const TQString &text ); 00169 00175 static TQStringList reverse( const TQStringList &list ); 00176 00186 static TQString ljust( const TQString &text , uint width ) KDE_DEPRECATED; 00187 00197 static TQString rjust( const TQString &text , uint width ) KDE_DEPRECATED; 00198 00207 static TQString center( const TQString &text , uint width ); 00208 00215 static TQString lsqueeze( const TQString & str, uint maxlen = 40 ); 00216 00227 static TQString lEmSqueeze( const TQString & name, 00228 const TQFontMetrics& fontMetrics, 00229 uint maxlen = 30 ); 00230 00240 static TQString lPixelSqueeze( const TQString & name, 00241 const TQFontMetrics& fontMetrics, 00242 uint maxPixels ); 00243 00250 static TQString csqueeze( const TQString & str, uint maxlen = 40 ); 00251 00262 static TQString cEmSqueeze( const TQString & name, 00263 const TQFontMetrics& fontMetrics, 00264 uint maxlen = 30 ); 00265 00275 static TQString cPixelSqueeze( const TQString & name, 00276 const TQFontMetrics& fontMetrics, 00277 uint maxPixels ); 00278 00285 static TQString rsqueeze( const TQString & str, uint maxlen = 40 ); 00286 00297 static TQString rEmSqueeze( const TQString & name, 00298 const TQFontMetrics& fontMetrics, 00299 uint maxlen = 30 ); 00300 00310 static TQString rPixelSqueeze( const TQString & name, 00311 const TQFontMetrics& fontMetrics, 00312 uint maxPixels ); 00313 00322 static bool matchFileName( const TQString& filename, const TQString& pattern ); 00323 // KDE4: move to KShell 00324 00342 static TQStringList perlSplit 00343 (const TQString & sep, const TQString & s, uint max = 0); 00344 00362 static TQStringList perlSplit 00363 (const TQChar & sep, const TQString & s, uint max = 0); 00364 00382 static TQStringList perlSplit 00383 (const TQRegExp & sep, const TQString & s, uint max = 0); 00384 00393 static TQString tagURLs( const TQString& text ); 00394 00408 static TQString obscure( const TQString &str ); 00409 00417 static bool isUtf8( const char *str ); 00418 00427 static TQString from8Bit( const char *str ); 00428 00429 #ifdef KDE_NO_COMPAT 00430 private: 00431 #endif 00432 00435 static KDE_DEPRECATED bool matchFilename( const TQString& filename, const TQString& pattern ) 00436 { 00437 return matchFileName (filename, pattern); 00438 } 00439 00440 }; 00441 #endif