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