ICS

QicsTable Documentation Set

QicsSorter.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 **
00003 ** Copyright (C) 2002-2006 Integrated Computer Solutions, Inc
00004 ** All rights reserved.
00005 **
00006 ** This file is part of the QicsTable Product.
00007 **
00008 **********************************************************************/
00009 
00010 #ifndef _QICSSORTER_H
00011 #define _QICSSORTER_H
00012 
00013 #include <QObject>
00014 #include <QVector>
00015 #include <QDomElement>
00016 #include <QicsNamespace.h>
00017 #include <QicsDataItem.h>
00018 
00019 class QicsDataModel;
00020 
00022 
00023 
00037 
00038 
00041 
00042 
00043 //
00044 class QICS_EXPORT QicsSorter: public QObject, public Qics
00045 {
00046     Q_OBJECT
00047 
00048 public:
00049 
00053     QicsSorter(Qics::QicsIndexType _type, QicsDataModel *dm);
00054 
00055     inline QicsDataModel *dataModel() const { return myDataModel; }
00056     inline Qics::QicsIndexType type() const { return myType; }
00057 
00062     void setSortingSensitivity(Qt::CaseSensitivity cs);
00063 
00076     void sort(const QVector<int> &otherAxisesIndex,
00077           QicsSortOrder order = Qics::Ascending,
00078           int from = 0, int to = -1,
00079           DataItemComparator func = 0);
00080 
00084     int visualToModel(int x);
00085 
00089     QVector<int>& visualToModelVector()
00090     { return order; }
00091 
00092 
00096     int modelToVisual(int x);
00097 
00104     void moveItems(int target, const QVector<int> &itms);
00105 
00110     void setSortMode(Qics::QicsSortMode mode)
00111      { mySortMode = mode; }
00112 
00117     Qics::QicsSortMode sortMode(void)
00118      { return mySortMode; }
00119 
00124     void reorder(const QVector<int> &newOrder, int from = 0, int to = -1); 
00125 
00129     const QVector<int>& currentOrder() 
00130     { 
00131         if (order.isEmpty()) fillVisualToModelMap();
00132         return order; 
00133     }
00134 
00135 
00136 protected slots:
00141     void insertElements(int num, int start_position);
00142 
00147     void appendElements(int num);
00148 
00153     void deleteElements(int num, int start_position);
00154 
00155     QDomElement toDomXml(const QString &tag, QDomDocument* doc) const;
00156 
00157     void configureFromDomXml(const QDomElement&);
00158 
00159 protected:
00163     void integrityCheck(void);
00164 
00166     Qics::QicsSortMode mySortMode;
00167 
00168 private:
00171     void expandTo(int how_many);
00172 
00174     void fillVisualToModelMap(void);
00175 
00177     void fillModelToVisualMap(void);
00178 
00180     void flushModelToVisualMap(void);
00181 
00184     void installNewOrder(int *neworder, int newlen);
00185 
00186 
00188     //
00189     // Signals
00190     //
00192 
00193 signals:
00194 
00200     void orderChanged(Qics::QicsIndexType type, QVector<int> &map);
00201 
00202 
00204     //
00205     // Data members
00206     //
00208 
00209 /* private data members */
00210 private:
00211 
00213     Qics::QicsIndexType myType;
00214 
00216     QicsDataModel *myDataModel;
00217 
00219     QVector<int>    order;
00220 
00222     QVector<int>    modelToVisualMap;
00223 };
00224 
00225 #endif /* _QICSSORTER_H */

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.