77 void resetIcon(int idx); |
77 void resetIcon(int idx); |
78 void newItem(QList< QPair< QVariant, int > >* list = NULL, bool silent = true); |
78 void newItem(QList< QPair< QVariant, int > >* list = NULL, bool silent = true); |
79 void newItem(QPair< QVariant, int > item, bool silent = true); |
79 void newItem(QPair< QVariant, int > item, bool silent = true); |
80 void insertItem(int pos, QList< QPair< QVariant, int > >* list = NULL, bool silent = true); |
80 void insertItem(int pos, QList< QPair< QVariant, int > >* list = NULL, bool silent = true); |
81 void insertItem(int pos, QPair< QVariant, int > item, bool silent = true); |
81 void insertItem(int pos, QPair< QVariant, int > item, bool silent = true); |
|
82 void clearItem(int pos, bool silent = false); |
82 |
83 |
83 private: |
84 private: |
84 void doInsertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent); |
85 void doInsertItem(int pos, QList< QPair< QVariant, int > >* list, bool silent); |
85 |
86 |
86 protected: |
87 protected: |
87 void removeItem(int pos); |
88 void removeItem(int pos, bool silent = false); |
88 void removeItems(int pos, int size); |
89 void removeItems(int pos, int size, bool silent = false); |
89 |
90 |
90 virtual QVariant defaultIcon() const = 0; |
91 virtual QVariant defaultIcon() const = 0; |
91 inline bool containsRole(int idx, int role) const; |
92 inline bool containsRole(int idx, int role) const; |
92 inline bool isIndexValid(int idx) const; |
93 inline bool isIndexValid(int idx) const; |
93 |
94 |
94 public: |
95 public: |
95 void resetModel(); |
96 void resetModel(); |
96 |
97 |
|
98 enum HgDataProviderIconMode { |
|
99 HgDataProviderIconHbIcon, |
|
100 HgDataProviderIconQIcon, |
|
101 HgDataProviderIconQImage, |
|
102 HgDataProviderIconQPixmap |
|
103 }; |
|
104 |
|
105 void setIconMode(HgDataProviderIconMode mode); |
|
106 HgDataProviderIconMode iconMode(); |
|
107 |
97 protected: |
108 protected: |
98 virtual void doResetModel() {}; |
109 virtual void doResetModel() {}; |
|
110 virtual QVariant getData(int idx, int role) const {Q_UNUSED(idx); Q_UNUSED(role); return QVariant(); }; |
99 |
111 |
100 // helpers fot emits |
112 // helpers fot emits |
101 protected: |
113 protected: |
102 void emitDataChanged(int start, int end, bool silent); |
114 void emitDataChanged(int start, int end, bool silent); |
103 |
115 |
117 QList<QMap<int, QVariant>*>* mCache; |
129 QList<QMap<int, QVariant>*>* mCache; |
118 int mCacheSize; //Number of cached Icons. Not same as mCache->count() |
130 int mCacheSize; //Number of cached Icons. Not same as mCache->count() |
119 QList< QPixmap* > mFreePixmaps; |
131 QList< QPixmap* > mFreePixmaps; |
120 QMap< int, QPixmap* > mUsedPixmaps; |
132 QMap< int, QPixmap* > mUsedPixmaps; |
121 int mUnallocatedPixmaps; |
133 int mUnallocatedPixmaps; |
122 // QMutex mQPixmapsLock; |
134 QMutex mQPixmapsLock; |
|
135 QMutex mDataLock; |
123 HgDataProviderModelObserver *mObserver; |
136 HgDataProviderModelObserver *mObserver; |
|
137 HgDataProviderIconMode mIconMode; |
124 }; |
138 }; |
125 |
139 |
126 inline bool HgDataProviderModel::isIndexValid(int idx) const |
140 inline bool HgDataProviderModel::isIndexValid(int idx) const |
127 { |
141 { |
128 return ((idx >= 0) && |
142 return ((idx >= 0) && |