Updated the README file with some contributor tips.
[basket4.git] / src / tools.h
blob8d0321d1132cea752e9744e165a8fe408702b8ec
1 //Added by qt3to4:
2 #include <Q3MemArray>
3 #include <QPixmap>
4 /***************************************************************************
5 * Copyright (C) 2003 by Sébastien Laoût *
6 * slaout@linux62.org *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22 ***************************************************************************/
24 #ifndef TOOLS_H
25 #define TOOLS_H
27 class QString;
28 class QColor;
29 class QMimeSource;
31 class StopWatch
33 public:
34 static void start(uint id);
35 static void check(uint id);
36 private:
37 static Q3MemArray<QTime> starts;
38 static Q3MemArray<double> totals;
39 static Q3MemArray<uint> counts;
42 /** Some useful functions for that application.
43 * @author Sébastien Laoût
45 namespace Tools
47 // Text <-> HTML Conversions and Tools:
48 QString textToHTML(const QString &text);
49 QString textToHTMLWithoutP(const QString &text);
50 QString htmlToParagraph(const QString &html);
51 QString htmlToText(const QString &html);
52 QString tagURLs(const QString &test);
53 QString cssFontDefinition(const QFont &font, bool onlyFontFamily = false);
55 // String Manipulations:
56 QString stripEndWhiteSpaces(const QString &string);
58 // Pixmap Manipulations:
59 /** @Return true if it is a Web color
61 bool isWebColor(const QColor &color);
62 /** @Return a color that is 50% of @p color1 and 50% of @p color2.
64 QColor mixColor(const QColor &color1, const QColor &color2);
65 /** @Return true if the color is too dark to be darkened one more time.
67 bool tooDark(const QColor &color);
68 /** Make sure the @p pixmap is of the size (@p width, @p height) and @return a pixmap of this size.
69 * If @p height <= 0, then width will be used to make the picture square.
71 QPixmap normalizePixmap(const QPixmap &pixmap, int width, int height = 0);
72 /** @Return the pixmap @p source with depth*deltaX transparent pixels added to the left.\n
73 * If @p deltaX is <= 0, then an indent delta is computed depending on the @p source width.
75 QPixmap indentPixmap(const QPixmap &source, int depth, int deltaX = 0);
77 // File and Folder Manipulations:
78 /** Delete the folder @p folderOrFile recursively (to remove sub-folders and child files too).
80 void deleteRecursively(const QString &folderOrFile);
81 /** @Return a new filename that doesn't already exist in @p destFolder.
82 * If @p wantedName alread exist in @p destFolder, a dash and a number will be added before the extenssion.
83 * Id there were already such a number in @p wantedName, it is incremented until a free filename is found.
85 QString fileNameForNewFile(const QString &wantedName, const QString &destFolder);
87 // Other:
88 //void iconForURL(const KUrl &url);
89 /** @Return true if the source is from a file cutting in Konqueror.
90 * @Return false if it was just a copy or if it was a drag.
92 bool isAFileCut(QMimeSource *source);
94 // Debug
95 void printChildren(QObject* parent);
98 #endif // TOOLS_H