1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include "QItemSelection"
#include "dlghidden.h"
#include "library/hiddentablemodel.h"
#include "widget/wtracktableview.h"
DlgHidden::DlgHidden(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection, MixxxKeyboard* pKeyboard)
: QWidget(parent),
Ui::DlgHidden(),
m_pTrackTableView(
new WTrackTableView(this, pConfig, pTrackCollection, false)) {
setupUi(this);
m_pTrackTableView->installEventFilter(pKeyboard);
// Install our own trackTable
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
box->removeWidget(m_pTrackTablePlaceholder);
m_pTrackTablePlaceholder->hide();
box->insertWidget(1, m_pTrackTableView);
m_pHiddenTableModel = new HiddenTableModel(this, pTrackCollection);
m_pTrackTableView->loadTrackModel(m_pHiddenTableModel);
connect(btnUnhide, SIGNAL(clicked()),
m_pTrackTableView, SLOT(slotUnhide()));
connect(btnUnhide, SIGNAL(clicked()),
this, SLOT(clicked()));
connect(btnPurge, SIGNAL(clicked()),
m_pTrackTableView, SLOT(slotPurge()));
connect(btnPurge, SIGNAL(clicked()),
this, SLOT(clicked()));
connect(btnSelect, SIGNAL(clicked()),
this, SLOT(selectAll()));
connect(m_pTrackTableView->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this,
SLOT(selectionChanged(const QItemSelection&, const QItemSelection&)));
connect(m_pTrackTableView, SIGNAL(loadCoverArt(CoverInfo, bool)),
this, SIGNAL(loadCoverArt(CoverInfo, bool)));
}
DlgHidden::~DlgHidden() {
// Delete m_pTrackTableView before the table model. This is because the
// table view saves the header state using the model.
delete m_pTrackTableView;
delete m_pHiddenTableModel;
}
void DlgHidden::onShow() {
m_pHiddenTableModel->select();
// no buttons can be selected
activateButtons(false);
}
void DlgHidden::onSearch(const QString& text) {
m_pHiddenTableModel->search(text);
}
void DlgHidden::clicked() {
// all marked tracks are gone now anyway
onShow();
}
void DlgHidden::selectAll() {
m_pTrackTableView->selectAll();
}
void DlgHidden::activateButtons(bool enable) {
btnPurge->setEnabled(enable);
btnUnhide->setEnabled(enable);
}
void DlgHidden::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) {
Q_UNUSED(deselected);
activateButtons(!selected.indexes().isEmpty());
}
|