[Kde-pim] Akonadi and PostgreSQL

Thomas McGuire mcguire at kde.org
Fri Mar 12 10:48:31 GMT 2010


Hi,

On Friday 12 March 2010 05:58:02 Brian DeRocher wrote:
> (1) I'm new to KDE/QT programming.  What's up with all these
> QLatinString() constructor call?  Are they really necessary?  It's been
> several years since my C++ courses, but isn't there a way to create a
> conversion operator...  yeah like this:
> 
> class Q_CORE_EXPORT QString
> {
> public:
> ...
> #ifndef QT_NO_CAST_FROM_ASCII
> inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch) :
> d(fromAscii_helper(ch)) {}
> 
> Then i thought g++ would automatically find this operator and use it
> where needed, like:  settings.value( "foo" );  I suppose there's a
> concern about encodings and code like this has been disabled.  And it's
> used everywhere.

Yep, the implicit conversion from char * to QString is disabled on purpose.
In KDE, it is mostly used so that we don't forget the i18n() call, which marks 
a string for translations.
In other places, it used to prevent confusion between QByteArray and QString, 
the distinction is often important. This is especially the case in the Akonadi 
server, which deals with raw byte arrays, for example the commands it receives 
from the client, but also deals with proper strings in some places.
Using QLatin1String or QString::fromLatin1() makes you think twice if you're 
really doing the correct thing.

Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100312/4166710b/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list