1 /***************************************************************************
2 * Copyright (C) 2005/06 by the Quassel Project *
3 * devel@quassel-irc.org *
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) version 3. *
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. *
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 ***************************************************************************/
28 #include <QMetaMethod>
31 // TODO Use versions from Network instead
32 QString nickFromMask(QString mask);
33 QString userFromMask(QString mask);
34 QString hostFromMask(QString mask);
35 bool isChannelName(QString str);
37 //! Strip mIRC format codes
38 QString stripFormatCodes(QString);
40 QString secondsToString(int timeInSeconds);
42 //! Take a string and decode it using the specified text codec, recognizing utf8.
43 /** This function takes a string and first checks if it is encoded in utf8, in which case it is
44 * decoded appropriately. Otherwise, the specified text codec is used to transform the string.
45 * \param input The input string containing encoded data
46 * \param codec The text codec we use if the input is not utf8
47 * \return The decoded string.
49 QString decodeString(const QByteArray &input, QTextCodec *codec = 0);
51 uint editingDistance(const QString &s1, const QString &s2);
55 //! Returns a list of data directory paths
56 /** There are several locations for applications to install their data files in. On Unix,
57 * a common location is /usr/share; others include $PREFIX/share and additional directories
58 * specified in the env variable XDG_DATA_DIRS.
59 * \return A list of directory paths to look for data files in
61 QStringList dataDirPaths();
63 //! Searches for a data file in the possible data directories
64 /** Data files can reside in $DATA_DIR/apps/quassel, where $DATA_DIR is one of the directories
65 * returned by \sa dataDirPaths().
66 * \return The full path to the data file if found; a null QString else
68 QString findDataFilePath(const QString &fileName);
70 void loadTranslation(const QLocale &locale);
73 QVariantList toVariantList(const QList<T> &list) {
74 QVariantList variants;
75 for(int i = 0; i < list.count(); i++) {
76 variants << QVariant::fromValue<T>(list[i]);
82 QList<T> fromVariantList(const QVariantList &variants) {
84 for(int i = 0; i < variants.count(); i++) {
85 list << variants[i].value<T>();