2010-04-01 01:11:45 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-04-01 01:11:45 +02:00
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "groupbydialog.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "ui_groupbydialog.h"
|
2010-04-01 01:11:45 +02:00
|
|
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
GroupByDialog::GroupByDialog(QWidget *parent)
|
2010-05-10 23:50:31 +02:00
|
|
|
: QDialog(parent),
|
|
|
|
ui_(new Ui_GroupByDialog)
|
2010-04-01 01:11:45 +02:00
|
|
|
{
|
2010-05-10 23:50:31 +02:00
|
|
|
ui_->setupUi(this);
|
2010-04-01 01:11:45 +02:00
|
|
|
Reset();
|
|
|
|
|
2010-05-09 02:10:26 +02:00
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_None, 0));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_Album, 1));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_Artist, 2));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_AlbumArtist, 3));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_Composer, 4));
|
2010-07-31 16:14:03 +02:00
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_FileType, 5));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_Genre, 6));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_Year, 7));
|
|
|
|
mapping_.insert(Mapping(LibraryModel::GroupBy_YearAlbum, 8));
|
2010-04-01 01:11:45 +02:00
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
connect(ui_->button_box->button(QDialogButtonBox::Reset), SIGNAL(clicked()),
|
2010-04-01 01:11:45 +02:00
|
|
|
SLOT(Reset()));
|
2010-05-17 02:47:43 +02:00
|
|
|
|
|
|
|
resize(sizeHint());
|
2010-04-01 01:11:45 +02:00
|
|
|
}
|
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
GroupByDialog::~GroupByDialog() {
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
2010-04-01 01:11:45 +02:00
|
|
|
void GroupByDialog::Reset() {
|
2010-05-10 23:50:31 +02:00
|
|
|
ui_->first->setCurrentIndex(2); // Artist
|
|
|
|
ui_->second->setCurrentIndex(1); // Album
|
|
|
|
ui_->third->setCurrentIndex(0); // None
|
2010-04-01 01:11:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void GroupByDialog::accept() {
|
2010-05-09 02:10:26 +02:00
|
|
|
emit Accepted(LibraryModel::Grouping(
|
2010-05-10 23:50:31 +02:00
|
|
|
mapping_.get<tag_index>().find(ui_->first->currentIndex())->group_by,
|
|
|
|
mapping_.get<tag_index>().find(ui_->second->currentIndex())->group_by,
|
|
|
|
mapping_.get<tag_index>().find(ui_->third->currentIndex())->group_by));
|
2010-04-01 01:11:45 +02:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
2010-05-09 02:10:26 +02:00
|
|
|
void GroupByDialog::LibraryGroupingChanged(const LibraryModel::Grouping& g) {
|
2010-05-10 23:50:31 +02:00
|
|
|
ui_->first->setCurrentIndex(mapping_.get<tag_group_by>().find(g[0])->combo_box_index);
|
|
|
|
ui_->second->setCurrentIndex(mapping_.get<tag_group_by>().find(g[1])->combo_box_index);
|
|
|
|
ui_->third->setCurrentIndex(mapping_.get<tag_group_by>().find(g[2])->combo_box_index);
|
2010-04-01 01:11:45 +02:00
|
|
|
}
|