[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KConfig and multiple values
From:       "David Boosalis" <david.boosalis () gmail ! com>
Date:       2007-07-13 14:09:05
Message-ID: 870c99310707130709m2af6257cg5a6fbc3377c54276 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


How about using QMap to create some thinkg like:
 QMap <QString,QColor> colorMap;
colorMap["black"]=QColor::black;
colorMap["red"] = QColor(255,0,0);
colorMap["white'"] = QColor::white;


Then create a class that inherits from QLisWidgetItem

Class ColorListItem : public QListWidgetItem
{
   public:
     ColorListtItem(QListWidget *parent,QColor &kolor,QString &name);
    private:
       QColor color;
       QString  text;
};

THen of course you just have to implement the paintEvent in a widget that
inherits from QListView.

Okay the colorMap has nothing to do with ColorListItem, but if you need the
colors on more then one area, it would be a good way to keep track of them

-David



On 7/13/07, David Jarvie <lists@astrojar.org.uk> wrote:
>
> On Wednesday 11 July 2007 23:25, Yannick Gingras wrote:
> >
> >> On Wednesday 11 July 2007, Yannick Gingras wrote:
> >>> I want to implement a list of configuration settings in my
> application.
> >>
> >> not exactly sure what you want given your description. is what you want
> >> something like an array of structs? e.g.: [snip]
> >
> > What I want is an array of colors.  The colors would be presented in a
> > listview and stored sequentially:
> >
> > [NickColors]
> > #ffbbff
> > #ffbbff
> > #fabbff
> > ...
> > #b3b3b3
> >
> > I want to use a listview rather than buttons like most people do because
> I
> > want 50+ colors.  The number of colors would also be variable.
>
> You could create a QStringList containing the all the colours (use
> QColor::name() to get each individual colour string). KConfig* reads and
> writes a QStringList entry in the format
>
> NickColors=#ffbbff,#ffbbff,...,#b3b3b3
>
> --
> David Jarvie.
> KAlarm author & maintainer.
> http://www.astrojar.org.uk/kalarm
>
>
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>

[Attachment #5 (text/html)]

How about using QMap to create some thinkg like:<br>&nbsp;QMap &lt;QString,QColor&gt; \
colorMap;<br>colorMap[&quot;black&quot;]=QColor::black;<br>colorMap[&quot;red&quot;] \
= QColor(255,0,0);<br>colorMap[&quot;white&#39;&quot;] = QColor::white; \
<br><br><br>Then create a class that inherits from QLisWidgetItem<br><br>Class \
ColorListItem : public QListWidgetItem<br>{<br>&nbsp;&nbsp; \
public:<br>&nbsp;&nbsp;&nbsp;&nbsp; ColorListtItem(QListWidget *parent,QColor \
&amp;kolor,QString &amp;name);<br> &nbsp;&nbsp;&nbsp; \
private:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QColor \
color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QString&nbsp; text;<br>};<br><br>THen \
of course you just have to implement the paintEvent in a widget that inherits from \
QListView.<br><br>Okay the colorMap has nothing to do with ColorListItem, but if you \
need the colors on more then one area, it would be a good way to keep track of them \
<br><br>-David<br><br><br><br><div><span class="gmail_quote">On 7/13/07, <b \
class="gmail_sendername">David Jarvie</b> &lt;<a \
href="mailto:lists@astrojar.org.uk">lists@astrojar.org.uk</a>&gt; \
wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> On Wednesday 11 July 2007 \
23:25, Yannick Gingras wrote:<br>&gt;<br>&gt;&gt; On Wednesday 11 July 2007, Yannick \
Gingras wrote:<br>&gt;&gt;&gt; I want to implement a list of configuration settings \
in my application.<br>&gt;&gt; <br>&gt;&gt; not exactly sure what you want given your \
description. is what you want<br>&gt;&gt; something like an array of structs? e.g.: \
[snip]<br>&gt;<br>&gt; What I want is an array of colors.&nbsp;&nbsp;The colors would \
be presented in a <br>&gt; listview and stored sequentially:<br>&gt;<br>&gt; \
[NickColors]<br>&gt; #ffbbff<br>&gt; #ffbbff<br>&gt; #fabbff<br>&gt; ...<br>&gt; \
#b3b3b3<br>&gt;<br>&gt; I want to use a listview rather than buttons like most people \
do because I <br>&gt; want 50+ colors.&nbsp;&nbsp;The number of colors would also be \
variable.<br><br>You could create a QStringList containing the all the colours \
(use<br>QColor::name() to get each individual colour string). KConfig* reads and \
<br>writes a QStringList entry in the \
format<br><br>NickColors=#ffbbff,#ffbbff,...,#b3b3b3<br><br>--<br>David \
Jarvie.<br>KAlarm author &amp; maintainer.<br><a \
href="http://www.astrojar.org.uk/kalarm">http://www.astrojar.org.uk/kalarm \
</a><br><br><br>&gt;&gt; Visit <a \
href="http://mail.kde.org/mailman/listinfo/kde-devel#unsub">http://mail.kde.org/mailman/listinfo/kde-devel#unsub</a> \
to unsubscribe &lt;&lt;<br></blockquote></div><br>



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic