/*************************************************************************** * 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 starts; static TQMemArray totals; static TQMemArray 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