79
TagFilterViewItem(QListView* parent, TAlbum* tag, bool untagged=false)
80
: FolderCheckListItem(parent, tag ? tag->title() : i18n("Not Tagged"),
81
QCheckListItem::CheckBox/*Controller*/)
84
m_untagged = untagged;
85
setDragEnabled(!untagged);
88
tag->setExtraData(listView(), this);
91
TagFilterViewItem(QListViewItem* parent, TAlbum* tag)
92
: FolderCheckListItem(parent, tag->title(),
93
QCheckListItem::CheckBox/*Controller*/)
100
tag->setExtraData(listView(), this);
103
virtual void stateChange(bool val)
105
QCheckListItem::stateChange(val);
107
/* NOTE G.Caulier 2007/01/08: this code is now disable because TagFilterViewItem
108
have been changed from QCheckListItem::CheckBoxController
109
to QCheckListItem::CheckBox.
111
// All TagFilterViewItems are CheckBoxControllers. If they have no children,
112
// they should be of type CheckBox, but that is not possible with our way of adding items.
113
// When clicked, children-less items first change to the NoChange state, and a second
114
// click is necessary to set them to On and make the filter take effect.
115
// So set them to On if the condition is met.
116
if (!firstChild() && state() == NoChange)
122
((TagFilterView*)listView())->stateChanged(this);
125
int compare(QListViewItem* i, int column, bool ascending) const
130
TagFilterViewItem* dItem = dynamic_cast<TagFilterViewItem*>(i);
134
if (dItem && dItem->m_untagged)
137
return QListViewItem::compare(i, column, ascending);
140
void paintCell(QPainter* p, const QColorGroup & cg, int column, int width, int align)
144
FolderCheckListItem::paintCell(p, cg, column, width, align);
148
QFont f(listView()->font());
154
mcg.setColor(QColorGroup::Text, Qt::darkRed);
156
FolderCheckListItem::paintCell(p, mcg, column, width, align);
80
TagFilterViewItem(QListView* parent, TAlbum* tag, bool untagged=false);
81
TagFilterViewItem(QListViewItem* parent, TAlbum* tag);
83
TAlbum* album() const;
85
bool untagged() const;
88
void setCount(int count);
90
int compare(QListViewItem* i, int column, bool ascending) const;
94
void stateChange(bool val);
95
void paintCell(QPainter* p, const QColorGroup & cg, int column, int width, int align);
106
TagFilterViewItem::TagFilterViewItem(QListView* parent, TAlbum* album, bool untagged)
107
: FolderCheckListItem(parent, album ? album->title() : i18n("Not Tagged"),
108
QCheckListItem::CheckBox/*Controller*/)
111
m_untagged = untagged;
113
setDragEnabled(!untagged);
116
m_album->setExtraData(listView(), this);
119
TagFilterViewItem::TagFilterViewItem(QListViewItem* parent, TAlbum* album)
120
: FolderCheckListItem(parent, album->title(),
121
QCheckListItem::CheckBox/*Controller*/)
126
setDragEnabled(true);
129
m_album->setExtraData(listView(), this);
132
void TagFilterViewItem::refresh()
134
if (!m_album) return;
136
if (AlbumSettings::instance()->getShowFolderTreeViewItemsCount())
139
setText(0, QString("%1 (%2)").arg(m_album->title()).arg(m_count));
142
int countRecursive = m_count;
143
AlbumIterator it(m_album);
144
while ( it.current() )
146
TagFilterViewItem *item = (TagFilterViewItem*)it.current()->extraData(listView());
148
countRecursive += item->count();
151
setText(0, QString("%1 (%2)").arg(m_album->title()).arg(countRecursive));
156
setText(0, m_album->title());
160
void TagFilterViewItem::stateChange(bool val)
162
QCheckListItem::stateChange(val);
164
/* NOTE G.Caulier 2007/01/08: this code is now disable because TagFilterViewItem
165
have been changed from QCheckListItem::CheckBoxController
166
to QCheckListItem::CheckBox.
168
// All TagFilterViewItems are CheckBoxControllers. If they have no children,
169
// they should be of type CheckBox, but that is not possible with our way of adding items.
170
// When clicked, children-less items first change to the NoChange state, and a second
171
// click is necessary to set them to On and make the filter take effect.
172
// So set them to On if the condition is met.
173
if (!firstChild() && state() == NoChange)
179
((TagFilterView*)listView())->stateChanged(this);
182
int TagFilterViewItem::compare(QListViewItem* i, int column, bool ascending) const
187
TagFilterViewItem* dItem = dynamic_cast<TagFilterViewItem*>(i);
191
if (dItem && dItem->m_untagged)
194
return QListViewItem::compare(i, column, ascending);
197
void TagFilterViewItem::paintCell(QPainter* p, const QColorGroup & cg, int column, int width, int align)
201
FolderCheckListItem::paintCell(p, cg, column, width, align);
205
QFont f(listView()->font());
211
mcg.setColor(QColorGroup::Text, Qt::darkRed);
213
FolderCheckListItem::paintCell(p, mcg, column, width, align);
216
void TagFilterViewItem::setOpen(bool o)
218
QListViewItem::setOpen(o);
222
TAlbum* TagFilterViewItem::album() const
227
int TagFilterViewItem::id() const
229
return m_album ? m_album->id() : 0;
232
void TagFilterViewItem::setCount(int count)
238
int TagFilterViewItem::count()
243
bool TagFilterViewItem::untagged() const
163
248
// ---------------------------------------------------------------------
165
250
class TagFilterViewPrivate
367
451
d->timer->start(50, true);
370
void TagFilterView::contentsMouseMoveEvent(QMouseEvent *e)
372
QListView::contentsMouseMoveEvent(e);
374
if(e->state() == NoButton)
376
if(KGlobalSettings::changeCursorOverIcon())
378
QPoint vp = contentsToViewport(e->pos());
379
QListViewItem *item = itemAt(vp);
380
if (mouseInItemRect(item, vp.x()))
381
setCursor(KCursor::handCursor());
389
(d->dragStartPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
391
QPoint vp = contentsToViewport(e->pos());
392
TagFilterViewItem *item = dynamic_cast<TagFilterViewItem*>(itemAt(vp));
401
void TagFilterView::contentsMousePressEvent(QMouseEvent *e)
403
QPoint vp = contentsToViewport(e->pos());
404
TagFilterViewItem *item = dynamic_cast<TagFilterViewItem*>(itemAt(vp));
406
if(item && e->button() == RightButton)
408
bool isOn = item->isOn();
409
QListView::contentsMousePressEvent(e);
410
// Restore the status of checkbox.
415
QListView::contentsMousePressEvent(e);
417
if(item && e->button() == LeftButton)
419
d->dragStartPos = e->pos();
424
void TagFilterView::contentsMouseReleaseEvent(QMouseEvent *e)
426
QListView::contentsMouseReleaseEvent(e);
431
454
QDragObject* TagFilterView::dragObject()
433
456
TagFilterViewItem *item = dynamic_cast<TagFilterViewItem*>(dragItem());
437
TagDrag *t = new TagDrag(item->m_tag->id(), this);
460
TagDrag *t = new TagDrag(item->id(), this);
438
461
t->setPixmap(*item->pixmap(0));
443
TagFilterViewItem* TagFilterView::dragItem() const
448
466
bool TagFilterView::acceptDrop(const QDropEvent *e) const
450
468
QPoint vp = contentsToViewport(e->pos());
1188
1207
"Deleting this will also delete "
1189
1208
"the subtags. "
1190
1209
"Do you want to continue?",
1191
children).arg(tag->title()),
1193
KGuiItem(i18n("Delete"),"editdelete"));
1195
if(result == KMessageBox::Continue)
1198
if (!man->deleteTAlbum(tag, errMsg))
1199
KMessageBox::error(0, errMsg);
1210
children).arg(tag->title()));
1212
if(result != KMessageBox::Continue)
1217
LLongList assignedItems = man->albumDB()->getItemIDsInTag(tag->id());
1218
if (!assignedItems.isEmpty())
1220
message = i18n("Tag '%1' is assigned to one item. "
1221
"Do you want to continue?",
1222
"Tag '%1' is assigned to %n items. "
1223
"Do you want to continue?",
1224
assignedItems.count()).arg(tag->title());
1204
int result = KMessageBox::warningContinueCancel(0, i18n("Delete '%1' tag?")
1205
.arg(tag->title()),i18n("Delete Tag"),
1206
KGuiItem(i18n("Delete"), "editdelete"));
1208
if (result == KMessageBox::Continue)
1211
if (!man->deleteTAlbum(tag, errMsg))
1212
KMessageBox::error(0, errMsg);
1228
message = i18n("Delete '%1' tag?").arg(tag->title());
1231
int result = KMessageBox::warningContinueCancel(0, message,
1233
KGuiItem(i18n("Delete"),
1236
if (result == KMessageBox::Continue)
1239
if (!man->deleteTAlbum(tag, errMsg))
1240
KMessageBox::error(0, errMsg);