KJanusWidget and Model-View (was: Re: KDialog / KDialogBase)

Tobias Koenig tokoe at kde.org
Tue May 9 09:16:54 BST 2006

On Mon, May 08, 2006 at 11:41:13PM +0200, Matthias Kretz wrote:
> On Monday, 8. May 2006 17:28, Tobias Koenig wrote:
Hi Matthias,

> > Passing the icon, name and title through a QVariant is fine, but how to
> > you want to pass the QWidget pointer?
> QWidget* test = new QWidget;
> QVariant testvar = QVariant::fromValue( test );
> QWidget* test2 = qvariant_cast<QWidget*>( testvar );
> => test == test2
Hmm, casting to an integer? Is it portable?

> interesting to note, the following compiles:
> QWidget* test = new QWidget;
> QVariant testvar( test );
> QWidget* test2 = qvariant_cast<QWidget*>( testvar );
> but => test != test
So is it the way to go?

> > Switching face types at runtime sounds interesting, but the current
> > implementation didn't support it as well and I can't see any real advantage
> > in this feature...
> Well we might want to have a standard way to figure out what dialog face to 
> use depending on the structure of the model:
> one page -> plain dialog
> flat list of (not too many) pages -> iconview dialog
> tree of pages -> treelist dialog
Well, personally I don't like 'magic' in the gui classes. What happens
when the content of the dialog is filled with plugins?
So if you have only one plugin installed the dialog looks completely
different than when you have > 1 plugins installed.

At the moment I think making a difference between a KXXXPageView and a
KXXXPageWidget doesn't make sense, since you don't need to reimplement
your own model, but can fill KPageModel with data.

We should have a class KPageModel which has a similar interface like the

class KPageModel : public QAbstractItemModel
    KPageModel( QObject *parent = 0 );

    // virtual methods reimplemented from QAbstractItemModel

    void addPage( QWidget *page, const QString &name,
                  const QString &header, const QIcon &icon = QIcon() );

    void addSubPage( QWidget *page, const QStringList &name,
                     const QString &header, const QIcon &icon = QIcon() );

    void removePage( QWidget *page );

// TODO: which index shall be used for an insertPage() method?
(If we find a working index, we could adapt the interface to QTabWidget)

So we have one model which can contain a single page, a list of pages
and a whole tree.

On the view side we should have a common base class KPageBaseView with
the following interface:

class KPageBaseView : public QWidget
    KPageView( QWidget *parent = 0 );

    void setModel( KPageModel *model );
    KPageModel *model() const;


and then the several subclasses

  KSinglePageView    // shows only the first page of the model
  KListPageView      // shows an icon list
  KTreePageView      // shows a tree list
  KTabbedPageView    // shows a tab widget with one tab for every page

for convenience we can provide an additional class KPageDialog with
the following interface:

class KPageDialog : public KDialog
    KPageDialog( KPageBaseView *view, KPageModel *model );

Comments, suggestions, objections?

Separate politics from religion and economy!
The Councile of the European Union is an undemocratic and illegal institution!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060509/b7cb5317/attachment.sig>

More information about the kde-core-devel mailing list