From: <mrj...@us...> - 2007-02-10 22:13:33
|
Revision: 2101 http://svn.sourceforge.net/tora/?rev=2101&view=rev Author: mrjohnson0 Date: 2007-02-10 14:13:33 -0800 (Sat, 10 Feb 2007) Log Message: ----------- add countChars function Modified Paths: -------------- trunk/tora/src/utils.cpp trunk/tora/src/utils.h Modified: trunk/tora/src/utils.cpp =================================================================== --- trunk/tora/src/utils.cpp 2007-02-10 21:55:13 UTC (rev 2100) +++ trunk/tora/src/utils.cpp 2007-02-10 22:13:33 UTC (rev 2101) @@ -1530,3 +1530,15 @@ return (event->state() == state && event->key() == val); } + +int countChars(const QString &source, const char find) { + int found = 0; + int i; + + for(i = 0; i < source.length(); i++) { + if(source[i] == find) + found++; + } + + return found; +} Modified: trunk/tora/src/utils.h =================================================================== --- trunk/tora/src/utils.h 2007-02-10 21:55:13 UTC (rev 2100) +++ trunk/tora/src/utils.h 2007-02-10 22:13:33 UTC (rev 2101) @@ -468,6 +468,15 @@ */ QString toTranslateMayby(const QString &context, const QString &text); +/** + * Count occurrences of char in source. + * + * @param source The string to search. + * @param find The char to find in string + * @return Occurrences. + */ +int countChars(const QString &source, const char find); + /** Popup toolbutton that works like I think they should under Qt 3.0 as well. * this means they will pop up a tool menu when you click on the button as well. */ @@ -501,19 +510,19 @@ /* This can't be documented in KDoc, anyway it is an easy way to catch any exception that * might be sent by TOra or OTL and display the message in the statusbar of the main window. */ -#define TOCATCH \ - catch (const QString &str) {\ - toStatusMessage(str);\ +#define TOCATCH \ + catch (const QString &str) { \ + toStatusMessage(str); \ } /* This can't be documented in KDoc, anyway it is an easy way to catch any exception that * might be sent by TOra or OTL and display the message in the statusbar of the main window. */ -#define TOROLLBACK(x) \ - catch (const QString &str) { \ - toStatusMessage(str); \ - try { \ - x.rollback(); \ - } catch(...) { } \ +#define TOROLLBACK(x) \ + catch (const QString &str) { \ + toStatusMessage(str); \ + try { \ + x.rollback(); \ + } catch(...) { } \ } #define QTRANS(x,y) (qApp?qApp->translate(x,y):QString::fromLatin1(y)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |