ctkCheckableHeaderView.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 /*=========================================================================
00021 
00022    Program: ParaView
00023    Module:    $RCSfile: pqCheckableHeaderView.h,v $
00024 
00025    Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
00026    All rights reserved.
00027 
00028    ParaView is a free software; you can redistribute it and/or modify it
00029    under the terms of the ParaView license version 1.2. 
00030 
00031    See License_v1.2.txt for the full ParaView license.
00032    A copy of this license can be obtained by contacting
00033    Kitware Inc.
00034    28 Corporate Drive
00035    Clifton Park, NY 12065
00036    USA
00037 
00038 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00039 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00040 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00041 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
00042 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00043 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00044 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00045 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00046 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00047 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00048 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00049 
00050 =========================================================================*/
00051 
00052 #ifndef _ctkCheckableHeaderView_h
00053 #define _ctkCheckableHeaderView_h
00054 
00055 // Qt includes
00056 #include <QHeaderView>
00057 
00058 // CTK includes
00059 #include <ctkPimpl.h>
00060 
00061 #include "CTKWidgetsExport.h"
00062 
00063 class ctkCheckableHeaderViewPrivate;
00064 
00071 class CTK_WIDGETS_EXPORT ctkCheckableHeaderView : public QHeaderView
00072 {
00073   Q_OBJECT;
00074   Q_PROPERTY(bool propagateToItems READ propagateToItems WRITE setPropagateToItems);
00075 public:
00076   ctkCheckableHeaderView(Qt::Orientation orient, QWidget *parent=0);
00077   virtual ~ctkCheckableHeaderView();
00078 
00079   virtual void setModel(QAbstractItemModel *model);
00080   virtual void setRootIndex(const QModelIndex &index);
00081 
00086   bool isCheckable(int section)const;
00087 
00092   Qt::CheckState checkState(int section)const;
00093 
00098   bool checkState(int section,Qt::CheckState& checkState )const;
00099 
00106   virtual bool eventFilter(QObject *object, QEvent *e);
00107 
00111   void setPropagateToItems(bool propagate);
00112   bool propagateToItems()const;
00113 
00114 public slots:
00117   void toggleCheckState(int section);
00121   void setCheckState(int section, Qt::CheckState checkState);
00122 
00123 private slots:
00124   void updateHeaderData(Qt::Orientation orient, int first, int last);
00125   void insertHeaderSection(const QModelIndex &parent, int first, int last);
00126   inline void updateHeaders();
00127   void updateHeadersFromItems(const QModelIndex& topLeft, const QModelIndex& bottomRight);
00128 
00129 protected:
00130   virtual void updateHeaders(int first, int last);
00131   virtual void initStyleSectionOption(QStyleOptionHeader *option, int section, QRect rect)const;
00132   virtual void mousePressEvent(QMouseEvent *e);
00133   virtual void mouseReleaseEvent(QMouseEvent *e);
00134   bool isPointInCheckBox(int section, QPoint pos)const;
00135 
00136 private:
00137   CTK_DECLARE_PRIVATE(ctkCheckableHeaderView);
00138 };
00139 
00140 //-----------------------------------------------------------------------------
00141 void ctkCheckableHeaderView::updateHeaders()
00142 {
00143   this->updateHeaders(0, this->count()-1);
00144 }
00145 
00146 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 21 May 2010 for CTK by  doxygen 1.6.1