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() {}; |
99 virtual QVariant getData(int idx, int role) const {return QVariant(); }; |
110 virtual QVariant getData(int idx, int role) const {Q_UNUSED(idx); Q_UNUSED(role); return QVariant(); }; |
100 |
111 |
101 // helpers fot emits |
112 // helpers fot emits |
102 protected: |
113 protected: |
103 void emitDataChanged(int start, int end, bool silent); |
114 void emitDataChanged(int start, int end, bool silent); |
104 |
115 |
121 QMap< int, QPixmap* > mUsedPixmaps; |
132 QMap< int, QPixmap* > mUsedPixmaps; |
122 int mUnallocatedPixmaps; |
133 int mUnallocatedPixmaps; |
123 QMutex mQPixmapsLock; |
134 QMutex mQPixmapsLock; |
124 QMutex mDataLock; |
135 QMutex mDataLock; |
125 HgDataProviderModelObserver *mObserver; |
136 HgDataProviderModelObserver *mObserver; |
|
137 HgDataProviderIconMode mIconMode; |
126 }; |
138 }; |
127 |
139 |
128 inline bool HgDataProviderModel::isIndexValid(int idx) const |
140 inline bool HgDataProviderModel::isIndexValid(int idx) const |
129 { |
141 { |
130 return ((idx >= 0) && |
142 return ((idx >= 0) && |