| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2009-03-25 |
| 7 |
* Description : Tree View for album models |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2009-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> |
| 10 |
* SPDX-FileCopyrightText: 2010-2011 by Andi Clemens <andi dot clemens at gmail dot com> |
| 11 |
* SPDX-FileCopyrightText: 2014 by Mohamed_Anwer <m_dot_anwer at gmx dot com> |
| 12 |
* SPDX-FileCopyrightText: 2014 by Michael G. Hansen <mike at mghansen dot de> |
| 13 |
* SPDX-FileCopyrightText: 2009-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 14 |
* |
| 15 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 16 |
* |
| 17 |
* ============================================================ */ |
| 18 |
|
| 19 |
#include "albumtreeview.h" |
| 20 |
|
| 21 |
// Local includes |
| 22 |
|
| 23 |
#include "abstractalbumtreeview_p.h" |
| 24 |
|
| 25 |
namespace Digikam |
| 26 |
{ |
| 27 |
|
| 28 |
AlbumTreeView::AlbumTreeView(QWidget* const parent, Flags flags) |
| 29 |
: AbstractCheckableAlbumTreeView(parent, flags) |
| 30 |
{ |
| 31 |
setDragEnabled(true); |
| 32 |
setAcceptDrops(true); |
| 33 |
setRootIsDecorated(false); |
| 34 |
setDropIndicatorShown(false); |
| 35 |
setAutoExpandDelay(AUTOEXPANDDELAY); |
| 36 |
|
| 37 |
if (flags & CreateDefaultModel) |
| 38 |
{ |
| 39 |
setPAlbumModel(new AlbumModel(AlbumModel::IncludeRootAlbum, this)); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
void AlbumTreeView::setPAlbumModel(AlbumModel* const model) |
| 44 |
{ |
| 45 |
// changing model is not implemented |
| 46 |
|
| 47 |
if (m_albumModel) |
| 48 |
{ |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
AbstractCheckableAlbumTreeView::setAlbumModel(model); |
| 53 |
|
| 54 |
m_dragDropHandler = palbumModel()->dragDropHandler(); |
| 55 |
|
| 56 |
if (!m_dragDropHandler) |
| 57 |
{ |
| 58 |
m_dragDropHandler = new AlbumDragDropHandler(palbumModel()); |
| 59 |
|
| 60 |
model->setDragDropHandler(m_dragDropHandler); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
void AlbumTreeView::setCheckableAlbumFilterModel(CheckableAlbumFilterModel* const filterModel) |
| 65 |
{ |
| 66 |
AbstractCheckableAlbumTreeView::setAlbumFilterModel(filterModel); |
| 67 |
} |
| 68 |
|
| 69 |
AlbumModel* AlbumTreeView::palbumModel() const |
| 70 |
{ |
| 71 |
return dynamic_cast<AlbumModel*>(m_albumModel); |
| 72 |
} |
| 73 |
|
| 74 |
PAlbum* AlbumTreeView::currentPAlbum() const |
| 75 |
{ |
| 76 |
return dynamic_cast<PAlbum*> (m_albumFilterModel->albumForIndex(currentIndex())); |
| 77 |
} |
| 78 |
|
| 79 |
PAlbum* AlbumTreeView::palbumForIndex(const QModelIndex& index) const |
| 80 |
{ |
| 81 |
return dynamic_cast<PAlbum*> (m_albumFilterModel->albumForIndex(index)); |
| 82 |
} |
| 83 |
|
| 84 |
void AlbumTreeView::setCurrentAlbum(int albumId, bool selectInAlbumManager) |
| 85 |
{ |
| 86 |
PAlbum* const album = AlbumManager::instance()->findPAlbum(albumId); // cppcheck-suppress constVariablePointer |
| 87 |
setCurrentAlbums(QList<Album*>() << album, selectInAlbumManager); |
| 88 |
} |
| 89 |
|
| 90 |
} // namespace Digikam |
| 91 |
|
| 92 |
#include "moc_albumtreeview.cpp" |