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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi
From:       Volker Krause <vkrause () kde ! org>
Date:       2008-03-21 21:24:54
Message-ID: 1206134694.731108.19171.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 788577 by vkrause:

Make ctor symmetric for both kind of views. Having the simple one also
makes it possible to use those views from Qt designer.


 M  +33 -16    collectionview.cpp  
 M  +12 -0     collectionview.h  
 M  +20 -6     itemview.cpp  
 M  +10 -1     itemview.h  


--- trunk/KDE/kdepimlibs/akonadi/collectionview.cpp #788576:788577
@@ -48,6 +48,7 @@
     {
     }
 
+    void init();
     void dragExpand();
     void itemClicked( const QModelIndex& );
     void itemCurrentChanged( const QModelIndex& );
@@ -60,6 +61,25 @@
     KXmlGuiWindow *xmlGuiWindow;
 };
 
+void CollectionView::Private::init()
+{
+  mParent->header()->setClickable( true );
+  mParent->header()->setStretchLastSection( false );
+
+  mParent->setSortingEnabled( true );
+  mParent->setEditTriggers( QAbstractItemView::EditKeyPressed );
+  mParent->setAcceptDrops( true );
+  mParent->setDropIndicatorShown( true );
+  mParent->setDragDropMode( DragDrop );
+  mParent->setDragEnabled( true );
+
+  dragExpandTimer.setSingleShot( true );
+  mParent->connect( &dragExpandTimer, SIGNAL(timeout()), SLOT(dragExpand()) );
+
+  mParent->connect( mParent, SIGNAL( clicked( const QModelIndex& ) ),
+                    mParent, SLOT( itemClicked( const QModelIndex& ) ) );
+}
+
 bool CollectionView::Private::hasParent( const QModelIndex& idx, int parentId )
 {
   QModelIndex idx2 = idx;
@@ -102,27 +122,19 @@
   emit mParent->currentChanged( Collection( currentCollection ) );
 }
 
+CollectionView::CollectionView(QWidget * parent) :
+    QTreeView( parent ),
+    d( new Private( this ) )
+{
+  d->init();
+}
+
 CollectionView::CollectionView( KXmlGuiWindow *xmlGuiWindow, QWidget * parent ) :
     QTreeView( parent ),
     d( new Private( this ) )
 {
   d->xmlGuiWindow = xmlGuiWindow;
-
-  header()->setClickable( true );
-  header()->setStretchLastSection( false );
-
-  setSortingEnabled( true );
-  setEditTriggers( QAbstractItemView::EditKeyPressed );
-  setAcceptDrops( true );
-  setDropIndicatorShown( true );
-  setDragDropMode( DragDrop );
-  setDragEnabled( true );
-
-  d->dragExpandTimer.setSingleShot( true );
-  connect( &d->dragExpandTimer, SIGNAL(timeout()), SLOT(dragExpand()) );
-
-  connect( this, SIGNAL( clicked( const QModelIndex& ) ),
-           this, SLOT( itemClicked( const QModelIndex& ) ) );
+  d->init();
 }
 
 CollectionView::~CollectionView()
@@ -224,4 +236,9 @@
     popup->exec( event->globalPos() );
 }
 
+void CollectionView::setKXmlGuiWindow(KXmlGuiWindow * xmlGuiWindow)
+{
+  d->xmlGuiWindow = xmlGuiWindow;
+}
+
 #include "collectionview.moc"
--- trunk/KDE/kdepimlibs/akonadi/collectionview.h #788576:788577
@@ -46,6 +46,12 @@
   public:
     /**
       Create a new collection view.
+      @param the parent widget.
+    */
+    explicit CollectionView( QWidget *parent );
+
+    /**
+      Create a new collection view.
       @param xmlGuiWindow The KXmlGuiWindow this is used in. This is needed for the
       XMLGUI based context menu. Passing 0 is ok and will disable the builtin context
       menu.
@@ -63,6 +69,12 @@
     */
     virtual void setModel ( QAbstractItemModel * model );
 
+    /**
+      Sets the KXmlGuiWindow which this view is used in. This is needed
+      if you want to use the built-in context menu.
+      @param xmlGuiWindow The KXmlGuiWindow this view is used in.
+    */
+    void setKXmlGuiWindow( KXmlGuiWindow *xmlGuiWindow );
 
   Q_SIGNALS:
     /**
--- trunk/KDE/kdepimlibs/akonadi/itemview.cpp #788576:788577
@@ -40,6 +40,7 @@
     {
     }
 
+    void init();
     void itemActivated( const QModelIndex& );
     void itemCurrentChanged( const QModelIndex& );
 
@@ -49,6 +50,17 @@
     ItemView *mParent;
 };
 
+void ItemView::Private::init()
+{
+  mParent->setRootIsDecorated( false );
+
+  mParent->header()->setClickable( true );
+  mParent->header()->setStretchLastSection( true );
+
+  mParent->connect( mParent, SIGNAL( activated( const QModelIndex& ) ),
+                    mParent, SLOT( itemActivated( const QModelIndex& ) ) );
+}
+
 void ItemView::Private::itemActivated( const QModelIndex &index )
 {
   if ( !index.isValid() )
@@ -81,13 +93,15 @@
     QTreeView( parent ),
     d( new Private( this ) )
 {
-  setRootIsDecorated( false );
+  d->init();
+}
 
-  header()->setClickable( true );
-  header()->setStretchLastSection( true );
-
-  connect( this, SIGNAL( activated( const QModelIndex& ) ),
-           this, SLOT( itemActivated( const QModelIndex& ) ) );
+ItemView::ItemView(KXmlGuiWindow * xmlGuiWindow, QWidget * parent) :
+    QTreeView( parent ),
+    d( new Private( this ) )
+{
+  d->xmlGuiWindow = xmlGuiWindow;
+  d->init();
 }
 
 ItemView::~ItemView()
--- trunk/KDE/kdepimlibs/akonadi/itemview.h #788576:788577
@@ -46,9 +46,18 @@
       Create a new item view.
       @param parent the parent widget.
     */
-    explicit ItemView( QWidget *parent = 0 );
+    ItemView( QWidget *parent );
 
     /**
+      Create a new item view.
+      @param xmlGuiWindow The KXmlGuiWindow this is used in. This is needed for the
+      XMLGUI based context menu. Passing 0 is ok and will disable the builtin context
+      menu.
+      @param parent the parent widget.
+    */
+    explicit ItemView( KXmlGuiWindow *xmlGuiWindow = 0, QWidget *parent = 0 );
+
+    /**
       Destroys this item view.
     */
     virtual ~ItemView();
[prev in list] [next in list] [prev in thread] [next in thread] 

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