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 <qstring.h> 00023 #include <qstringlist.h> 00024 #include <qregexp.h> // for the word ranges 00025 #include <qfontmetrics.h> 00026 #include "kdelibs_export.h" 00027 00069 class KDECORE_EXPORT KStringHandler 00070 { 00071 public: 00080 static QString word( const QString &text , uint pos ) KDE_DEPRECATED; 00081 00094 static QString word( const QString &text , const char *range ); 00095 00105 static QString insword( const QString &text , const QString &word , uint pos ); 00106 00116 static QString setword( const QString &text , const QString &word , uint pos ); 00117 00130 static QString remrange( const QString &text , const char *range ); 00131 00132 00139 static QString remword( const QString &text , uint pos ); 00140 00147 static QString remword( const QString &text , const QString &word ); 00148 00154 static QString capwords( const QString &text ); 00155 00161 static QStringList capwords( const QStringList &list ); 00162 00168 static QString reverse( const QString &text ); 00169 00175 static QStringList reverse( const QStringList &list ); 00176 00186 static QString ljust( const QString &text , uint width ) KDE_DEPRECATED; 00187 00197 static QString rjust( const QString &text , uint width ) KDE_DEPRECATED; 00198 00207 static QString center( const QString &text , uint width ); 00208 00215 static QString lsqueeze( const QString & str, uint maxlen = 40 ); 00216 00227 static QString lEmSqueeze( const QString & name, 00228 const QFontMetrics& fontMetrics, 00229 uint maxlen = 30 ); 00230 00240 static QString lPixelSqueeze( const QString & name, 00241 const QFontMetrics& fontMetrics, 00242 uint maxPixels ); 00243 00250 static QString csqueeze( const QString & str, uint maxlen = 40 ); 00251 00262 static QString cEmSqueeze( const QString & name, 00263 const QFontMetrics& fontMetrics, 00264 uint maxlen = 30 ); 00265 00275 static QString cPixelSqueeze( const QString & name, 00276 const QFontMetrics& fontMetrics, 00277 uint maxPixels ); 00278 00285 static QString rsqueeze( const QString & str, uint maxlen = 40 ); 00286 00297 static QString rEmSqueeze( const QString & name, 00298 const QFontMetrics& fontMetrics, 00299 uint maxlen = 30 ); 00300 00310 static QString rPixelSqueeze( const QString & name, 00311 const QFontMetrics& fontMetrics, 00312 uint maxPixels ); 00313 00322 static bool matchFileName( const QString& filename, const QString& pattern ); 00323 // KDE4: move to KShell 00324 00342 static QStringList perlSplit 00343 (const QString & sep, const QString & s, uint max = 0); 00344 00362 static QStringList perlSplit 00363 (const QChar & sep, const QString & s, uint max = 0); 00364 00382 static QStringList perlSplit 00383 (const QRegExp & sep, const QString & s, uint max = 0); 00384 00393 static QString tagURLs( const QString& text ); 00394 00408 static QString obscure( const QString &str ); 00409 00417 static bool isUtf8( const char *str ); 00418 00427 static QString from8Bit( const char *str ); 00428 00429 #ifdef KDE_NO_COMPAT 00430 private: 00431 #endif 00432 00435 static KDE_DEPRECATED bool matchFilename( const QString& filename, const QString& pattern ) 00436 { 00437 return matchFileName (filename, pattern); 00438 } 00439 00440 }; 00441 #endif