-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathdlgmissing.cpp
More file actions
115 lines (95 loc) · 3.71 KB
/
Copy pathdlgmissing.cpp
File metadata and controls
115 lines (95 loc) · 3.71 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "library/missing_hidden/dlgmissing.h"
#include <QItemSelection>
#include "controllers/keyboard/keyboardeventfilter.h"
#include "library/library.h"
#include "library/missing_hidden/missingtablemodel.h"
#include "moc_dlgmissing.cpp"
#include "util/assert.h"
#include "widget/wlibrary.h"
#include "widget/wtracktableview.h"
DlgMissing::DlgMissing(
WLibrary* parent,
UserSettingsPointer pConfig,
Library* pLibrary,
KeyboardEventFilter* pKeyboard)
: QWidget(parent),
Ui::DlgMissing(),
m_pTrackTableView(
new WTrackTableView(
this,
pConfig,
pLibrary,
parent->getTrackTableBackgroundColorOpacity())) {
setupUi(this);
m_pTrackTableView->installEventFilter(pKeyboard);
// Install our own trackTable
QBoxLayout* box = qobject_cast<QBoxLayout*>(layout());
VERIFY_OR_DEBUG_ASSERT(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
} else {
box->removeWidget(m_pTrackTablePlaceholder);
m_pTrackTablePlaceholder->hide();
box->insertWidget(1, m_pTrackTableView);
}
m_pMissingTableModel = new MissingTableModel(this, pLibrary->trackCollectionManager());
m_pTrackTableView->loadTrackModel(m_pMissingTableModel);
connect(btnPurge, &QPushButton::clicked, m_pTrackTableView, &WTrackTableView::slotPurge);
connect(btnSelect, &QPushButton::clicked, this, &DlgMissing::selectAll);
connect(btnRelocate,
&QPushButton::clicked,
this,
&DlgMissing::slotRelocateTrack);
connect(m_pTrackTableView->selectionModel(),
&QItemSelectionModel::selectionChanged,
this,
&DlgMissing::selectionChanged);
connect(m_pTrackTableView, &WTrackTableView::trackSelected, this, &DlgMissing::trackSelected);
connect(pLibrary, &Library::setTrackTableFont, m_pTrackTableView, &WTrackTableView::setTrackTableFont);
connect(pLibrary, &Library::setTrackTableRowHeight, m_pTrackTableView, &WTrackTableView::setTrackTableRowHeight);
connect(pLibrary, &Library::setSelectedClick, m_pTrackTableView, &WTrackTableView::setSelectedClick);
}
DlgMissing::~DlgMissing() {
// 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_pMissingTableModel;
}
void DlgMissing::onShow() {
m_pMissingTableModel->select();
activateButtons(false);
}
void DlgMissing::onSearch(const QString& text) {
m_pMissingTableModel->search(text);
}
QString DlgMissing::currentSearch() {
return m_pMissingTableModel->currentSearch();
}
void DlgMissing::selectAll() {
m_pTrackTableView->selectAll();
}
void DlgMissing::slotRelocateTrack() {
const QModelIndexList indices = m_pTrackTableView->selectionModel()->selectedRows();
if (indices.count() != 1) {
return;
}
m_pMissingTableModel->relocateTrack(indices.first());
}
void DlgMissing::activateButtons(int numRowsSelected) {
btnPurge->setEnabled(numRowsSelected >= 1);
btnRelocate->setEnabled(numRowsSelected == 1);
}
void DlgMissing::selectionChanged([[maybe_unused]] const QItemSelection& selected,
[[maybe_unused]] const QItemSelection& deselected) {
activateButtons(m_pTrackTableView->selectionModel()->selectedRows().count());
}
bool DlgMissing::hasFocus() const {
return m_pTrackTableView->hasFocus();
}
void DlgMissing::saveCurrentViewState() {
m_pTrackTableView->saveCurrentViewState();
};
bool DlgMissing::restoreCurrentViewState() {
return m_pTrackTableView->restoreCurrentViewState();
};
void DlgMissing::setFocus() {
m_pTrackTableView->setFocus();
}