/*
* Cantata
*
* Copyright (c) 2011-2022 Craig Drummond
*
* ----
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "librarypage.h"
#include "mpd-interface/mpdconnection.h"
#include "mpd-interface/mpdstats.h"
#include "covers.h"
#include "settings.h"
#include "stdactions.h"
#include "customactions.h"
#include "support/messagebox.h"
#include "support/actioncollection.h"
#include "models/mpdlibrarymodel.h"
#include "widgets/menubutton.h"
#include "widgets/genrecombo.h"
#include
LibraryPage::LibraryPage(QWidget *p)
: SinglePageWidget(p)
{
genreCombo=new GenreCombo(this);
connect(StdActions::self()->addRandomAlbumToPlayQueueAction, SIGNAL(triggered()), SLOT(addRandomAlbum()));
connect(MPDConnection::self(), SIGNAL(updatingLibrary(time_t)), view, SLOT(updating()));
connect(MPDConnection::self(), SIGNAL(updatedLibrary()), view, SLOT(updated()));
connect(MPDConnection::self(), SIGNAL(updatingDatabase()), view, SLOT(updating()));
connect(MPDConnection::self(), SIGNAL(updatedDatabase()), view, SLOT(updated()));
connect(view, SIGNAL(itemsSelected(bool)), this, SLOT(controlActions()));
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
view->setModel(MpdLibraryModel::self());
connect(MpdLibraryModel::self(), SIGNAL(modelReset()), this, SLOT(modelReset()));
view->allowCategorized();
// Settings...
Configuration config(metaObject()->className());
view->setMode(ItemView::Mode_DetailedTree);
MpdLibraryModel::self()->load(config);
config.beginGroup(SqlLibraryModel::groupingStr(MpdLibraryModel::self()->topLevel()));
view->load(config);
view->setSearchToolTip(tr("Enter a string to search artist, album, title, etc. To filter based on year, add #year-range to search string - e.g.
"
"- #2000 return tracks from 2000
"
"- #1980-1989 return tracks from the 80's
"
"- Blah #2000 to search for string Blah and only return tracks from 2000
"
"
"));
showArtistImagesAction=new QAction(tr("Show Artist Images"), this);
showArtistImagesAction->setCheckable(true);
libraryAlbumSortAction=createMenuGroup(tr("Sort Albums"), QList