| 1 |
/* ============================================================ |
| 2 |
* |
| 3 |
* This file is a part of digiKam project |
| 4 |
* https://www.digikam.org |
| 5 |
* |
| 6 |
* Date : 2010-10-09 |
| 7 |
* Description : A widget to select Physical or virtual albums with combo-box |
| 8 |
* |
| 9 |
* SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> |
| 10 |
* SPDX-FileCopyrightText: 2012-2026 by Gilles Caulier <caulier dot gilles at gmail dot com> |
| 11 |
* |
| 12 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 13 |
* |
| 14 |
* ============================================================ */ |
| 15 |
|
| 16 |
#include "albumselectors.h" |
| 17 |
|
| 18 |
// Qt includes |
| 19 |
|
| 20 |
#include <QApplication> |
| 21 |
#include <QLayout> |
| 22 |
#include <QLabel> |
| 23 |
#include <QCheckBox> |
| 24 |
#include <QToolButton> |
| 25 |
#include <QRadioButton> |
| 26 |
#include <QButtonGroup> |
| 27 |
#include <QIcon> |
| 28 |
#include <QMessageBox> |
| 29 |
|
| 30 |
// KDE includes |
| 31 |
|
| 32 |
#include <kconfiggroup.h> |
| 33 |
#include <ksharedconfig.h> |
| 34 |
#include <klocalizedstring.h> |
| 35 |
|
| 36 |
// Local includes |
| 37 |
|
| 38 |
#include "digikam_debug.h" |
| 39 |
#include "albummodel.h" |
| 40 |
#include "albummanager.h" |
| 41 |
#include "albumselectcombobox.h" |
| 42 |
#include "albumtreeview.h" |
| 43 |
#include "tagtreeview.h" |
| 44 |
#include "searchutilities.h" |
| 45 |
#include "thememanager.h" |
| 46 |
|
| 47 |
namespace Digikam |
| 48 |
{ |
| 49 |
|
| 50 |
class Q_DECL_HIDDEN ModelClearButton : public AnimatedClearButton // clazy:exclude=ctor-missing-parent-argument |
| 51 |
{ |
| 52 |
Q_OBJECT |
| 53 |
|
| 54 |
public: |
| 55 |
|
| 56 |
explicit ModelClearButton(AbstractCheckableAlbumModel* const model) |
| 57 |
{ |
| 58 |
setClearButtonPixmap(); |
| 59 |
stayVisibleWhenAnimatedOut(true); |
| 60 |
|
| 61 |
connect(this, SIGNAL(clicked()), |
| 62 |
model, SLOT(resetAllCheckedAlbums())); |
| 63 |
|
| 64 |
connect(ThemeManager::instance(), &ThemeManager::signalThemeChanged, |
| 65 |
this, [this]() |
| 66 |
{ |
| 67 |
setClearButtonPixmap(); |
| 68 |
} |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
void setClearButtonPixmap() |
| 73 |
{ |
| 74 |
setPixmap(QIcon::fromTheme(qApp->isLeftToRight() ? QLatin1String("edit-clear-locationbar-rtl") |
| 75 |
: QLatin1String("edit-clear-locationbar-ltr")) |
| 76 |
.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize))); |
| 77 |
} |
| 78 |
}; |
| 79 |
|
| 80 |
// ------------------------------------------------------------------------------------------ |
| 81 |
|
| 82 |
class Q_DECL_HIDDEN AlbumSelectors::Private |
| 83 |
{ |
| 84 |
public: |
| 85 |
|
| 86 |
Private() = default; |
| 87 |
|
| 88 |
public: |
| 89 |
|
| 90 |
const QString configUseWholeAlbumsEntry = QLatin1String("UseWholeAlbumsEntry"); |
| 91 |
const QString configUseWholeTagsEntry = QLatin1String("UseWholeTagsEntry"); |
| 92 |
const QString configAlbumTypeEntry = QLatin1String("AlbumTypeEntry"); |
| 93 |
|
| 94 |
QString configName; |
| 95 |
|
| 96 |
AlbumTreeViewSelectComboBox* albumSelectCB = nullptr; |
| 97 |
TagTreeViewSelectComboBox* tagSelectCB = nullptr; |
| 98 |
ModelClearButton* albumClearButton = nullptr; |
| 99 |
ModelClearButton* tagClearButton = nullptr; |
| 100 |
|
| 101 |
QToolButton* recursiveSelectionAlbum = nullptr; |
| 102 |
QToolButton* recursiveSelectionTags = nullptr; |
| 103 |
|
| 104 |
QCheckBox* wholeAlbums = nullptr; |
| 105 |
QCheckBox* wholeTags = nullptr; |
| 106 |
|
| 107 |
QTabWidget* tabWidget = nullptr; |
| 108 |
QWidget* albumWidget = nullptr; |
| 109 |
QWidget* tagWidget = nullptr; |
| 110 |
|
| 111 |
AlbumType selectionMode = All; |
| 112 |
|
| 113 |
bool allowRecursive = false; |
| 114 |
}; |
| 115 |
|
| 116 |
AlbumSelectors::AlbumSelectors(const QString& label, |
| 117 |
const QString& configName, |
| 118 |
QWidget* const parent, |
| 119 |
AlbumType albumType, |
| 120 |
bool allowRecursive) |
| 121 |
: QWidget(parent), |
| 122 |
d (new Private) |
| 123 |
{ |
| 124 |
d->allowRecursive = allowRecursive; |
| 125 |
d->configName = configName; |
| 126 |
setObjectName(d->configName); |
| 127 |
|
| 128 |
d->selectionMode = albumType; |
| 129 |
|
| 130 |
QVBoxLayout* const mainLayout = new QVBoxLayout(this); |
| 131 |
|
| 132 |
if (!label.isEmpty()) |
| 133 |
{ |
| 134 |
mainLayout->addWidget(new QLabel(label)); |
| 135 |
} |
| 136 |
|
| 137 |
switch (d->selectionMode) |
| 138 |
{ |
| 139 |
case All: |
| 140 |
{ |
| 141 |
d->tabWidget = new QTabWidget(this); |
| 142 |
|
| 143 |
initAlbumWidget(); |
| 144 |
d->tabWidget->insertTab(PhysAlbum, d->albumWidget, i18nc("@title", "Albums (All)")); |
| 145 |
|
| 146 |
initTagWidget(); |
| 147 |
d->tabWidget->insertTab(TagsAlbum, d->tagWidget, i18nc("@title", "Tags (0)")); |
| 148 |
|
| 149 |
mainLayout->addWidget(d->tabWidget); |
| 150 |
break; |
| 151 |
} |
| 152 |
|
| 153 |
case PhysAlbum: |
| 154 |
{ |
| 155 |
initAlbumWidget(); |
| 156 |
mainLayout->addWidget(d->albumWidget); |
| 157 |
break; |
| 158 |
} |
| 159 |
|
| 160 |
case TagsAlbum: |
| 161 |
{ |
| 162 |
initTagWidget(); |
| 163 |
mainLayout->addWidget(d->tagWidget); |
| 164 |
break; |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
mainLayout->setContentsMargins(QMargins()); |
| 169 |
} |
| 170 |
|
| 171 |
AlbumSelectors::~AlbumSelectors() |
| 172 |
{ |
| 173 |
delete d; |
| 174 |
} |
| 175 |
|
| 176 |
void AlbumSelectors::initAlbumWidget() |
| 177 |
{ |
| 178 |
d->albumWidget = new QWidget(this); |
| 179 |
d->wholeAlbums = new QCheckBox(i18nc("@option", "All albums"), d->albumWidget); |
| 180 |
d->recursiveSelectionAlbum = new QToolButton(d->albumWidget); |
| 181 |
d->recursiveSelectionAlbum->setToolTip(i18nc("@info", "Toggle recursive album selection.")); |
| 182 |
d->recursiveSelectionAlbum->setIcon(QIcon::fromTheme(QLatin1String("object-order-back"))); |
| 183 |
d->recursiveSelectionAlbum->setCheckable(true); |
| 184 |
d->recursiveSelectionAlbum->setChecked(true); |
| 185 |
|
| 186 |
if (!d->allowRecursive) |
| 187 |
{ |
| 188 |
d->recursiveSelectionAlbum->setVisible(false); |
| 189 |
d->recursiveSelectionAlbum->setChecked(false); |
| 190 |
} |
| 191 |
|
| 192 |
d->albumSelectCB = new AlbumTreeViewSelectComboBox(d->albumWidget); |
| 193 |
d->albumSelectCB->setToolTip(i18nc("@info:tooltip", "Select all albums that should be processed.")); |
| 194 |
d->albumSelectCB->setDefaultModel(); |
| 195 |
d->albumSelectCB->setRecursive(d->allowRecursive ? d->recursiveSelectionAlbum->isChecked() : false); |
| 196 |
d->albumSelectCB->setNoSelectionText(i18nc("@info", "No Album Selected")); |
| 197 |
/* |
| 198 |
d->albumSelectCB->setAddExcludeTristate(true); |
| 199 |
*/ |
| 200 |
d->albumSelectCB->addCheckUncheckContextMenuActions(); |
| 201 |
|
| 202 |
d->albumClearButton = new ModelClearButton(d->albumSelectCB->treeView()->checkableAlbumModel()); |
| 203 |
d->albumClearButton->setToolTip(i18nc("@info:tooltip", "Reset selected albums")); |
| 204 |
|
| 205 |
QHBoxLayout* l = new QHBoxLayout; |
| 206 |
l->addWidget(d->wholeAlbums); |
| 207 |
l->addStretch(10); |
| 208 |
l->addWidget(d->recursiveSelectionAlbum); |
| 209 |
|
| 210 |
QGridLayout* const pAlbumsGrid = new QGridLayout(d->albumWidget); |
| 211 |
pAlbumsGrid->addLayout(l, 0, 0, 1, 2); |
| 212 |
pAlbumsGrid->addWidget(d->albumSelectCB, 1, 0, 1, 1); |
| 213 |
pAlbumsGrid->addWidget(d->albumClearButton, 1, 1, 1, 1); |
| 214 |
pAlbumsGrid->setSpacing(0); |
| 215 |
pAlbumsGrid->setRowStretch(2, 10); |
| 216 |
|
| 217 |
connect(d->wholeAlbums, SIGNAL(toggled(bool)), |
| 218 |
this, SLOT(slotWholeAlbums(bool))); |
| 219 |
|
| 220 |
connect(d->wholeAlbums, SIGNAL(toggled(bool)), |
| 221 |
this, SIGNAL(signalSelectionChanged())); |
| 222 |
|
| 223 |
connect(d->recursiveSelectionAlbum, &QToolButton::toggled, |
| 224 |
d->recursiveSelectionAlbum, [this] (bool checked) |
| 225 |
{ |
| 226 |
d->albumSelectCB->setRecursive(checked); |
| 227 |
} |
| 228 |
); |
| 229 |
|
| 230 |
connect(d->albumSelectCB->treeView()->albumModel(), SIGNAL(checkStateChanged(Album*,Qt::CheckState)), |
| 231 |
this, SLOT(slotUpdateClearButtons())); |
| 232 |
|
| 233 |
d->albumSelectCB->treeView()->setObjectName(d->configName); |
| 234 |
d->albumSelectCB->treeView()->setEntryPrefix(QLatin1String("AlbumComboBox-")); |
| 235 |
d->albumSelectCB->treeView()->setRestoreCheckState(true); |
| 236 |
} |
| 237 |
|
| 238 |
void AlbumSelectors::initTagWidget() |
| 239 |
{ |
| 240 |
d->tagWidget = new QWidget(this); |
| 241 |
d->wholeTags = new QCheckBox(i18nc("@option", "All tags"), d->tagWidget); |
| 242 |
d->recursiveSelectionTags = new QToolButton(d->tagWidget); |
| 243 |
d->recursiveSelectionTags->setToolTip(i18nc("@info", "Toggle recursive tags selection.")); |
| 244 |
d->recursiveSelectionTags->setIcon(QIcon::fromTheme(QLatin1String("object-order-back"))); |
| 245 |
d->recursiveSelectionTags->setCheckable(true); |
| 246 |
d->recursiveSelectionTags->setChecked(true); |
| 247 |
|
| 248 |
if (!d->allowRecursive) |
| 249 |
{ |
| 250 |
d->recursiveSelectionTags->setVisible(false); |
| 251 |
d->recursiveSelectionTags->setChecked(false); |
| 252 |
} |
| 253 |
|
| 254 |
d->tagSelectCB = new TagTreeViewSelectComboBox(d->tagWidget); |
| 255 |
d->tagSelectCB->setToolTip(i18nc("@info:tooltip", "Select all tags that should be processed.")); |
| 256 |
d->tagSelectCB->setDefaultModel(); |
| 257 |
d->tagSelectCB->setRecursive(d->allowRecursive ? d->recursiveSelectionTags->isChecked() : false); |
| 258 |
d->tagSelectCB->setNoSelectionText(i18nc("@info", "No Tag Selected")); |
| 259 |
d->tagSelectCB->addCheckUncheckContextMenuActions(); |
| 260 |
|
| 261 |
d->tagClearButton = new ModelClearButton(d->tagSelectCB->treeView()->checkableAlbumModel()); |
| 262 |
d->tagClearButton->setToolTip(i18nc("@info:tooltip", "Reset selected tags")); |
| 263 |
|
| 264 |
QHBoxLayout* l = new QHBoxLayout; |
| 265 |
l->addWidget(d->wholeTags); |
| 266 |
l->addStretch(10); |
| 267 |
l->addWidget(d->recursiveSelectionTags); |
| 268 |
|
| 269 |
QGridLayout* const tAlbumsGrid = new QGridLayout(d->tagWidget); |
| 270 |
tAlbumsGrid->addLayout(l, 0, 0, 1, 2); |
| 271 |
tAlbumsGrid->addWidget(d->tagSelectCB, 1, 0, 1, 1); |
| 272 |
tAlbumsGrid->addWidget(d->tagClearButton, 1, 1, 1, 1); |
| 273 |
tAlbumsGrid->setSpacing(0); |
| 274 |
tAlbumsGrid->setRowStretch(2, 10); |
| 275 |
|
| 276 |
connect(d->wholeTags, SIGNAL(toggled(bool)), |
| 277 |
this, SIGNAL(signalSelectionChanged())); |
| 278 |
|
| 279 |
connect(d->wholeTags, SIGNAL(toggled(bool)), |
| 280 |
this, SLOT(slotWholeTags(bool))); |
| 281 |
|
| 282 |
connect(d->tagSelectCB->treeView()->albumModel(), SIGNAL(checkStateChanged(Album*,Qt::CheckState)), |
| 283 |
this, SLOT(slotUpdateClearButtons())); |
| 284 |
|
| 285 |
connect(d->recursiveSelectionTags, &QToolButton::toggled, |
| 286 |
d->recursiveSelectionTags, [this] (bool checked) |
| 287 |
{ |
| 288 |
d->tagSelectCB->setRecursive(checked); |
| 289 |
} |
| 290 |
); |
| 291 |
|
| 292 |
d->tagSelectCB->treeView()->setObjectName(d->configName); |
| 293 |
d->tagSelectCB->treeView()->setEntryPrefix(QLatin1String("TagComboBox-")); |
| 294 |
d->tagSelectCB->treeView()->setRestoreCheckState(true); |
| 295 |
} |
| 296 |
|
| 297 |
void AlbumSelectors::slotWholeAlbums(bool b) |
| 298 |
{ |
| 299 |
if ((d->selectionMode == PhysAlbum) || (d->selectionMode == All)) |
| 300 |
{ |
| 301 |
d->albumSelectCB->setEnabled(!b); |
| 302 |
d->albumClearButton->setEnabled(!b); |
| 303 |
d->albumSelectCB->setAllSelectedText(b); |
| 304 |
} |
| 305 |
|
| 306 |
updateTabText(); |
| 307 |
} |
| 308 |
|
| 309 |
void AlbumSelectors::slotWholeTags(bool b) |
| 310 |
{ |
| 311 |
if ((d->selectionMode == TagsAlbum) || (d->selectionMode == All)) |
| 312 |
{ |
| 313 |
d->tagSelectCB->setEnabled(!b); |
| 314 |
d->tagClearButton->setEnabled(!b); |
| 315 |
d->tagSelectCB->setAllSelectedText(b); |
| 316 |
} |
| 317 |
|
| 318 |
updateTabText(); |
| 319 |
} |
| 320 |
|
| 321 |
void AlbumSelectors::slotUpdateClearButtons() |
| 322 |
{ |
| 323 |
bool selectionChanged = false; |
| 324 |
|
| 325 |
if ((d->selectionMode == PhysAlbum) || (d->selectionMode == All)) |
| 326 |
{ |
| 327 |
d->albumClearButton->animateVisible(!d->albumSelectCB->model()->checkedAlbums().isEmpty()); |
| 328 |
selectionChanged = true; |
| 329 |
} |
| 330 |
|
| 331 |
if ((d->selectionMode == TagsAlbum) || (d->selectionMode == All)) |
| 332 |
{ |
| 333 |
d->tagClearButton->animateVisible(!d->tagSelectCB->model()->checkedAlbums().isEmpty()); |
| 334 |
selectionChanged = true; |
| 335 |
} |
| 336 |
|
| 337 |
if (selectionChanged) |
| 338 |
{ |
| 339 |
Q_EMIT signalSelectionChanged(); |
| 340 |
} |
| 341 |
|
| 342 |
updateTabText(); |
| 343 |
} |
| 344 |
|
| 345 |
bool AlbumSelectors::wholeAlbumsChecked() const |
| 346 |
{ |
| 347 |
return (d->wholeAlbums && d->wholeAlbums->isChecked()); |
| 348 |
} |
| 349 |
|
| 350 |
AlbumList AlbumSelectors::selectedAlbums() const |
| 351 |
{ |
| 352 |
AlbumList albums; |
| 353 |
|
| 354 |
if (wholeAlbumsChecked()) |
| 355 |
{ |
| 356 |
albums << AlbumManager::instance()->allPAlbums(); |
| 357 |
} |
| 358 |
else if (d->albumSelectCB) |
| 359 |
{ |
| 360 |
albums << d->albumSelectCB->model()->checkedAlbums(); |
| 361 |
} |
| 362 |
|
| 363 |
return albums; |
| 364 |
} |
| 365 |
|
| 366 |
QList<int> AlbumSelectors::selectedAlbumIds() const |
| 367 |
{ |
| 368 |
QList<int> albumIds; |
| 369 |
AlbumList albums = selectedAlbums(); |
| 370 |
|
| 371 |
for (const Album* const album : std::as_const(albums)) |
| 372 |
{ |
| 373 |
albumIds << album->id(); |
| 374 |
} |
| 375 |
|
| 376 |
return albumIds; |
| 377 |
} |
| 378 |
|
| 379 |
bool AlbumSelectors::wholeTagsChecked() const |
| 380 |
{ |
| 381 |
return d->wholeTags && d->wholeTags->isChecked(); |
| 382 |
} |
| 383 |
|
| 384 |
AlbumList AlbumSelectors::selectedTags() const |
| 385 |
{ |
| 386 |
AlbumList albums; |
| 387 |
|
| 388 |
if (wholeTagsChecked()) |
| 389 |
{ |
| 390 |
albums << AlbumManager::instance()->allTAlbums(); |
| 391 |
} |
| 392 |
else if (d->tagSelectCB) |
| 393 |
{ |
| 394 |
albums << d->tagSelectCB->model()->checkedAlbums(); |
| 395 |
} |
| 396 |
|
| 397 |
return albums; |
| 398 |
} |
| 399 |
|
| 400 |
QList<int> AlbumSelectors::selectedTagIds() const |
| 401 |
{ |
| 402 |
QList<int> tagIds; |
| 403 |
AlbumList tags = selectedTags(); |
| 404 |
|
| 405 |
for (const Album* const tag : std::as_const(tags)) |
| 406 |
{ |
| 407 |
tagIds << tag->id(); |
| 408 |
} |
| 409 |
|
| 410 |
return tagIds; |
| 411 |
} |
| 412 |
|
| 413 |
AlbumList AlbumSelectors::selectedAlbumsAndTags() const |
| 414 |
{ |
| 415 |
AlbumList albums; |
| 416 |
albums << selectedAlbums(); |
| 417 |
albums << selectedTags(); |
| 418 |
|
| 419 |
return albums; |
| 420 |
} |
| 421 |
|
| 422 |
void AlbumSelectors::setAlbumSelected(Album* const album, SelectionType type) |
| 423 |
{ |
| 424 |
if (d->albumWidget && album) |
| 425 |
{ |
| 426 |
if (type == SingleSelection) |
| 427 |
{ |
| 428 |
d->albumSelectCB->model()->resetCheckedAlbums(); |
| 429 |
} |
| 430 |
|
| 431 |
d->albumSelectCB->model()->setChecked(album, true); |
| 432 |
d->wholeAlbums->setChecked(false); |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
void AlbumSelectors::setTagSelected(Album* const album, SelectionType type) |
| 437 |
{ |
| 438 |
if (d->tagWidget && album) |
| 439 |
{ |
| 440 |
if (type == SingleSelection) |
| 441 |
{ |
| 442 |
d->tagSelectCB->model()->resetCheckedAlbums(); |
| 443 |
} |
| 444 |
|
| 445 |
d->tagSelectCB->model()->setChecked(album, true); |
| 446 |
d->wholeTags->setChecked(false); |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 450 |
void AlbumSelectors::setTypeSelection(int albumType) |
| 451 |
{ |
| 452 |
if (d->selectionMode == All) |
| 453 |
{ |
| 454 |
d->tabWidget->setCurrentIndex(albumType); |
| 455 |
} |
| 456 |
} |
| 457 |
|
| 458 |
int AlbumSelectors::typeSelection() const |
| 459 |
{ |
| 460 |
if (d->selectionMode == All) |
| 461 |
{ |
| 462 |
return d->tabWidget->currentIndex(); |
| 463 |
} |
| 464 |
else |
| 465 |
{ |
| 466 |
return d->selectionMode; |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
void AlbumSelectors::resetPAlbumSelection() |
| 471 |
{ |
| 472 |
d->albumSelectCB->model()->resetAllCheckedAlbums(); |
| 473 |
d->wholeAlbums->setChecked(false); |
| 474 |
slotWholeAlbums(wholeAlbumsChecked()); |
| 475 |
} |
| 476 |
|
| 477 |
void AlbumSelectors::resetTAlbumSelection() |
| 478 |
{ |
| 479 |
d->tagSelectCB->model()->resetAllCheckedAlbums(); |
| 480 |
d->wholeTags->setChecked(false); |
| 481 |
slotWholeTags(wholeTagsChecked()); |
| 482 |
} |
| 483 |
|
| 484 |
void AlbumSelectors::resetSelection() |
| 485 |
{ |
| 486 |
if (d->albumWidget) |
| 487 |
{ |
| 488 |
resetPAlbumSelection(); |
| 489 |
} |
| 490 |
|
| 491 |
if (d->tagWidget) |
| 492 |
{ |
| 493 |
resetTAlbumSelection(); |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
void AlbumSelectors::loadState() |
| 498 |
{ |
| 499 |
KSharedConfig::Ptr config = KSharedConfig::openConfig(); |
| 500 |
KConfigGroup group = config->group(d->configName); |
| 501 |
|
| 502 |
if (d->albumWidget) |
| 503 |
{ |
| 504 |
d->wholeAlbums->setChecked(group.readEntry(d->configUseWholeAlbumsEntry, true)); |
| 505 |
d->albumSelectCB->treeView()->loadState(); |
| 506 |
d->albumClearButton->animateVisible(!d->albumSelectCB->model()->checkedAlbums().isEmpty()); |
| 507 |
|
| 508 |
slotWholeAlbums(wholeAlbumsChecked()); |
| 509 |
d->albumSelectCB->updateText(); |
| 510 |
} |
| 511 |
|
| 512 |
if (d->tagWidget) |
| 513 |
{ |
| 514 |
d->wholeTags->setChecked(group.readEntry(d->configUseWholeTagsEntry, false)); |
| 515 |
d->tagSelectCB->treeView()->loadState(); |
| 516 |
d->tagClearButton->animateVisible(!d->tagSelectCB->model()->checkedAlbums().isEmpty()); |
| 517 |
|
| 518 |
slotWholeTags(wholeTagsChecked()); |
| 519 |
d->tagSelectCB->updateText(); |
| 520 |
} |
| 521 |
|
| 522 |
if (d->selectionMode == All) |
| 523 |
{ |
| 524 |
d->tabWidget->setCurrentIndex(group.readEntry(d->configAlbumTypeEntry, (int)PhysAlbum)); |
| 525 |
} |
| 526 |
} |
| 527 |
|
| 528 |
void AlbumSelectors::saveState() |
| 529 |
{ |
| 530 |
KSharedConfig::Ptr config = KSharedConfig::openConfig(); |
| 531 |
KConfigGroup group = config->group(d->configName); |
| 532 |
|
| 533 |
if (d->albumWidget) |
| 534 |
{ |
| 535 |
group.writeEntry(d->configUseWholeAlbumsEntry, wholeAlbumsChecked()); |
| 536 |
d->albumSelectCB->treeView()->saveState(); |
| 537 |
} |
| 538 |
|
| 539 |
if (d->tagWidget) |
| 540 |
{ |
| 541 |
group.writeEntry(d->configUseWholeTagsEntry, wholeTagsChecked()); |
| 542 |
d->tagSelectCB->treeView()->saveState(); |
| 543 |
} |
| 544 |
|
| 545 |
if (d->selectionMode == All) |
| 546 |
{ |
| 547 |
group.writeEntry(d->configAlbumTypeEntry, typeSelection()); |
| 548 |
} |
| 549 |
} |
| 550 |
|
| 551 |
void AlbumSelectors::updateTabText() |
| 552 |
{ |
| 553 |
if (d->selectionMode == All) |
| 554 |
{ |
| 555 |
d->tabWidget->tabBar()->setTabText(PhysAlbum, |
| 556 |
wholeAlbumsChecked() ? i18nc("@title", "Albums (All)") |
| 557 |
: i18nc("@title", "Albums (%1)", |
| 558 |
selectedAlbums().count())); |
| 559 |
d->tabWidget->tabBar()->setTabText(TagsAlbum, |
| 560 |
wholeTagsChecked() ? i18nc("@title", "Tags (All)") |
| 561 |
: i18nc("@title", "Tags (%1)", |
| 562 |
selectedTags().count())); |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
} // namespace Digikam |
| 567 |
|
| 568 |
#include "albumselectors.moc" |
| 569 |
|
| 570 |
#include "moc_albumselectors.cpp" |