Sayonara Player
src
Gui
Utils
SearchableWidget
SearchableModel.h
1
/* AbstractSearchModel.h */
2
3
/* Copyright 2011-2019 Lucio Carreras
4
*
5
* This file is part of sayonara player
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#ifndef ABSTRACT_SEARCH_MODEL_H_
22
#define ABSTRACT_SEARCH_MODEL_H_
23
24
#include <QAbstractTableModel>
25
#include <QAbstractListModel>
26
#include <QMap>
27
#include <QString>
28
#include "Utils/Library/SearchMode.h"
29
30
// We need this for eventual disambiguation between the
31
// table itself and this interface
32
// in the Searchable View class
33
38
class
SearchableModelInterface
39
{
40
public
:
41
using
ExtraTriggerMap
=
QMap<QChar, QString>
;
42
43
virtual
ExtraTriggerMap
getExtraTriggers();
44
virtual
QModelIndexList search_results(
const
QString& substr)=0;
45
virtual
bool
has_items()
const
=0;
46
47
virtual ::Library::SearchModeMask search_mode()
const
final
;
48
49
protected
:
50
SearchableModelInterface
();
51
virtual
~
SearchableModelInterface
();
52
};
53
54
55
template
<
typename
Model>
56
class
SearchableModel
:
57
public
SearchableModelInterface
,
58
public
Model
59
{
60
public
:
61
SearchableModel
(QObject* parent=
nullptr
) :
62
SearchableModelInterface
(),
63
Model(parent)
64
{}
65
66
virtual
~
SearchableModel
() =
default
;
67
68
using
Model::rowCount;
69
70
virtual
bool
has_items()
const override
71
{
72
return
(rowCount() > 0);
73
}
74
};
75
76
77
using
SearchableTableModel
=
SearchableModel<QAbstractTableModel>
;
78
using
SearchableListModel
=
SearchableModel<QAbstractListModel>
;
79
80
#endif
SearchableModel
Definition:
SearchableModel.h:56
QMap
Definition:
org_mpris_media_player2_adaptor.h:21
SearchableModelInterface
The SearchableModelInterface class.
Definition:
SearchableModel.h:38
Generated on Thu Jan 30 2020 00:00:00 for Sayonara Player by
1.8.17