From kde-core-devel Thu May 12 04:34:53 2011 From: "Commit Hook" Date: Thu, 12 May 2011 04:34:53 +0000 To: kde-core-devel Subject: Re: Review Request: Allow KWidgetItemDelegate::createItemWidgets to Message-Id: <20110512043453.11200.77667 () vidsolbach ! de> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=130520169617409 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0416058465506154725==" --===============0416058465506154725== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/101219/#review3274 ----------------------------------------------------------- This review has been submitted with commit a1a697436e16f86a545d0aced1f35dbd= 16772856 by eli mackenzie. - Commit On April 24, 2011, 7:49 a.m., Eli MacKenzie wrote: > = > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > http://git.reviewboard.kde.org/r/101219/ > ----------------------------------------------------------- > = > (Updated April 24, 2011, 7:49 a.m.) > = > = > Review request for kdelibs and Rafael Fern=C3=A1ndez L=C3=B3pez. > = > = > Summary > ------- > = > Ideally KWidgetItemDelegate::createItemWidgets would take a const QModelI= ndex& argument. Unfortunately its public API, so the signature cannot be ch= anged until KDE5. Additionally, its pure virtual so the option of adding a = createItemWidgets(const QModelIndex&) method won't work either. > = > Instead, I've added a dynamic property called "creatingWidgetForIndex" to= the delegate, that is only present while the widget pool is creating widge= ts. This means the only change kwidgetitemdelegate.h is documentation. The = QModelIndex could be stashed on one of the d-objects and made available thr= ough an accessor, but that would mean that d-object would have to carry a Q= ModelIndex that would be invalid almost all of the time. > = > Another benefit is that an application where this feature is desired (for= KDE < 4.7) only has to include an the new version of kwidgetitemdelegatepo= ol.cpp, which is easy to keep in sync with kdelibs. > = > This change allows you to set a delegate for a particular column in the m= odel, and put a type of widget in each row that works best for the data. > = > = > Diffs > ----- > = > kdeui/itemviews/kwidgetitemdelegate.h 58dd60868f476d925f3abd53e67b22c1e= d7149ac = > kdeui/itemviews/kwidgetitemdelegatepool.cpp b287584a594e97a091f96447386= a588acb08c59e = > = > Diff: http://git.reviewboard.kde.org/r/101219/diff > = > = > Testing > ------- > = > In my test app I started with a model that only included 5 rows, and woul= d only create a widget for row 2. As long as KWidgetItemDelegate::updateWid= gets doesn't assume that the QList argument has something in it, = all is well. After implementing this change I caused the model to change th= e type of widget for each row per the index pulled out of the property, aga= in keeping updateWidgets in sync, and have encountered no problems. > = > = > Screenshots > ----------- > = > with no filtering > http://git.reviewboard.kde.org/r/101219/s/136/ > With filtering > http://git.reviewboard.kde.org/r/101219/s/137/ > = > = > Thanks, > = > Eli > = > --===============0416058465506154725== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable
This is an automatically generated e-mail. To reply, visit: http://git.revie= wboard.kde.org/r/101219/

This revie=
w has been submitted with commit a1a697436e16f86a545d0aced1f35dbd16772856 b=
y eli mackenzie.

- Commit


On April 24th, 2011, 7:49 a.m., Eli MacKenzie wrote:

Review request for kdelibs and Rafael Fern=C3=A1ndez L=C3=B3pez.
By Eli MacKenzie.

Updated April 24, 2011, 7:49 a.m.

Descripti= on

Ideally KWidgetItemDelegate::createItemWidgets would take a =
const QModelIndex& argument. Unfortunately its public API, so the signa=
ture cannot be changed until KDE5. Additionally, its pure virtual so the op=
tion of adding a createItemWidgets(const QModelIndex&) method won't=
 work either.

Instead, I've added a dynamic property called "creatingWidgetForIn=
dex" to the delegate, that is only present while the widget pool is cr=
eating widgets. This means the only change kwidgetitemdelegate.h is documen=
tation. The QModelIndex could be stashed on one of the d-objects and made a=
vailable through an accessor, but that would mean that d-object would have =
to carry a QModelIndex that would be invalid almost all of the time.

Another benefit is that an application where this feature is desired (for K=
DE < 4.7) only has to include an the new version of kwidgetitemdelegatep=
ool.cpp, which is easy to keep in sync with kdelibs.

This change allows you to set a delegate for a particular column in the mod=
el, and put a type of widget in each row that works best for the data.

Testing <= /h1>
In my test app I started with a model that only included 5 r=
ows, and would only create a widget for row 2. As long as KWidgetItemDelega=
te::updateWidgets doesn't assume that the QList<QWidget*> argumen=
t has something in it, all is well. After implementing this change I caused=
 the model to change the type of widget for each row per the index pulled o=
ut of the property, again keeping updateWidgets in sync, and have encounter=
ed no problems.

Diffs=

  • kdeui/itemviews/kwidgetitemdelegate.h (58d= d60868f476d925f3abd53e67b22c1ed7149ac)
  • kdeui/itemviews/kwidgetitemdelegatepool.cpp View Diff

    Screensho= ts

    3D"with 3D"With
--===============0416058465506154725==--