remove QtGui dependence of kdecore

Thiago Macieira thiago at kde.org
Wed Jan 3 20:55:04 GMT 2007


Aaron J. Seigo wrote:
>this is indeed more problematic; we've moved to mostly using QVariant in
> the branch which brings the usage of QColor down to two instances in
> KConfig itself one of which is easily resolvable and one which is
> trickier.
>
>in the latter case, using QVariant::convert(Type) might help but it
> would bring several problems with it:
>
> - it would use a different storage format than the one in kde3 (hex
> #RGB as opposed to decimal r,g,b,a)
> - it doesn't support a format that includes a value for alpha
>
>so, this remains a problem. otherwise, there are no uses of QFont left
> in the branch.
>
>but KConfigSkeleton remains an issue. the api may be able to be reworked
>around QVariant similarly to how KConfig has been. i just haven't looked
> at this part of the puzzle that is kconfig yet =)

We could use the same trick that QVariant itself uses to handle the GUI 
types: we use a "virtual table" of sorts.

To simplify:

in kdecore (in a _p.h):
class KConfigCoreWriter
{
public:
    virtual void writeEntry(KConfigBackend *, const QVariant &);
    virtual void readEntry(const KConfigBackend *, QVariant &);
    static KConfigCoreWriter *self;
};

in kdecore (in a .cpp):
KConfigCoreWriter *KConfigCoreWriter::self = new KConfigCoreWriter;

void KConfig::writeEntry(const QVariant &item)
{
    KConfigCoreWriter::self->writeEntry(d->backend, item);
}

in kdeui (in a .cpp):
class KConfigGuiWriter
{
public:
    virtual void writeEntry(KConfigBackend *backend, const QVariant &item)
    {
        switch (item->type())
        {
        ...
        };
        KConfigCoreWriter::writeEntry(backend, item);
    }

    virtual void readEntry(const KConfigBackend *, QVariant &);
};

static int initFunction()
{
    delete KConfigCoreWriter::self;
    KConfigCoreWriter::self = new KConfigGuiWriter;
}

static int init_variable = initFunction();
-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070103/b5190ee3/attachment.sig>


More information about the kde-core-devel mailing list