ctkModelTester.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 #ifndef __ctkModelTester_h
00022 #define __ctkModelTester_h
00023 
00025 #include <QObject> 
00026 #include <QModelIndex>
00027 #include <QPersistentModelIndex>
00028 #include <QList>
00029 
00031 #include "ctkPimpl.h"
00032 #include "CTKCoreExport.h"
00033 
00034 class QAbstractItemModel;
00035 class ctkModelTesterPrivate;
00036 
00044 class CTK_CORE_EXPORT ctkModelTester: public QObject
00045 {
00046   Q_OBJECT
00047   Q_PROPERTY(bool nestedInserts READ nestedInserts WRITE setNestedInserts);
00048 public:
00053   explicit ctkModelTester(QObject *parent = 0);
00054 
00058   ctkModelTester(QAbstractItemModel *model, QObject *parent = 0);
00059 
00063   void setModel(QAbstractItemModel* model);
00064   QAbstractItemModel* model()const;
00065 
00069   void setThrowOnError(bool throwException);
00070   bool throwOnError()const;
00071  
00078   void setNestedInserts(bool enable);
00079   bool nestedInserts()const;
00080 
00084   virtual void testData(const QModelIndex& index)const;
00085 
00088   virtual void testModel()const;
00089 
00092   virtual void testModelIndex(const QModelIndex& index)const;
00093 
00097   virtual void testParent(const QModelIndex& parent)const;
00098 
00101   virtual void testPersistentModelIndex(const QPersistentModelIndex& index)const;
00102 
00103 protected slots:
00104   void onColumnsAboutToBeInserted(const QModelIndex & parent, int start, int end);
00105   void onColumnsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
00106   void onColumnsInserted(const QModelIndex & parent, int start, int end);
00107   void onColumnsRemoved(const QModelIndex & parent, int start, int end);
00108   void onDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
00109   void onHeaderDataChanged(Qt::Orientation orientation, int first, int last);
00110   void onLayoutAboutToBeChanged();
00111   void onLayoutChanged();
00112   void onModelAboutToBeReset();
00113   void onModelReset();
00114   void onRowsAboutToBeInserted(const QModelIndex &parent, int start, int end);
00115   void onRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
00116   void onRowsInserted(const QModelIndex & parent, int start, int end);
00117   void onRowsRemoved(const QModelIndex & parent, int start, int end);
00118   
00119 protected:
00123   virtual void onItemsAboutToBeInserted(const QModelIndex& parent, Qt::Orientation, int start, int end);
00124 
00128   virtual void onItemsAboutToBeRemoved(const QModelIndex& parent, Qt::Orientation, int start, int end);
00129 
00133   virtual void onItemsInserted(const QModelIndex& parent, Qt::Orientation, int start, int end);
00134 
00138   virtual void onItemsRemoved(const QModelIndex& parent, Qt::Orientation, int start, int end);
00139 
00142   QList<QPersistentModelIndex> persistentModelIndexes(const QModelIndex& index)const;
00143 
00146   virtual void test(bool result, const QString& errorString)const;
00147   
00148 private:
00149   CTK_DECLARE_PRIVATE(ctkModelTester);
00150 };
00151 
00152 #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