00001 #ifndef FOLDERTABLEITEM_H
00002 #define FOLDERTABLEITEM_H
00003
00004 #include <QtCore/QList>
00005 #include <QtCore/QMap>
00006 #include <QtCore/QVariant>
00007 #include <QtCore/QPair>
00008 #include <QtCore/QSettings>
00009
00010
00011 class RootFolderTableItem;
00012
00013
00014 class FolderTableItem
00015 {
00016 friend class RootFolderTableItem;
00017
00018 public:
00019 FolderTableItem( const QList<QVariant>& data, RootFolderTableItem* parent, bool newItem = false );
00020 ~FolderTableItem() {};
00021 void setClonedSourceItem( FolderTableItem* newClonedSourceItem );
00022 FolderTableItem* getClonedSourceItem();
00023 int columnCount() const;
00024 QVariant data( int column ) const;
00025 QList<QVariant> data() const;
00026 void setData( const QVariant& data, int column = 0 );
00027 int row() const;
00028 RootFolderTableItem* parent();
00029 bool isNew() const;
00030 bool isHidden() const;
00031 void setHidden( bool enabled = true );
00032 unsigned getChannelId() const;
00033 void setOld();
00034
00035 protected:
00036 QList<QVariant> tableItemData;
00037 RootFolderTableItem* rootTableItem;
00038 FolderTableItem* clonedSourceItem;
00039 bool hidden;
00040 bool newItem;
00041 };
00042
00043
00044 class RootFolderTableItem
00045 {
00046 friend class FolderTableItem;
00047
00048 public:
00049 RootFolderTableItem( const QList<QString>& headerNames, const QList< QPair< QString, QVariant > >& headerTypes );
00050 ~RootFolderTableItem();
00051
00052 QList<FolderTableItem*> getChildren() const;
00053 void appendChild( FolderTableItem* child );
00054 void insertChild( FolderTableItem* child, int row = 0 );
00055 void removeChildAt( int row );
00056 FolderTableItem* child( int row );
00057 int childCount() const;
00058 int columnCount() const;
00059 QString header( int column ) const;
00060 int headerPos( const QString& headerName ) const;
00061 QPair< QString, QVariant > headerType( int column ) const;
00062 bool setHeader( const QString& headerName, int column = 0 );
00063 QList< FolderTableItem* > newItems() const;
00064 bool anyNew() const;
00065 bool isFiltered() const;
00066 QMap< int, FolderTableItem* > filteredChildren() const;
00067 int find( unsigned channelId ) const;
00068 void sort( int column, Qt::SortOrder order );
00069 template <typename ColumnType> void sort1( int column, Qt::SortOrder order );
00070
00071 QSettings settings;
00072
00073 private:
00074 QList<FolderTableItem*> childTableItems;
00075 QList<QString> headerNameList;
00076 QList< QPair< QString, QVariant > > headerTypeList;
00077
00078
00079 };
00080
00081 #endif
00082