summaryrefslogtreecommitdiffstats
path: root/searchdialog.h
blob: d469c2829e760046e0926bcac05a9b4833bb45e3 (plain)
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
/*
  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.
*/

#ifndef SEARCHDIALOG_H
#define SEARCHDIALOG_H

#include <QDialog>

#include "smview.h"

class QCheckBox;
class QLineEdit;
class QPushButton;
class QComboBox;
class SmTreeView;
class SmTreeModel;
class SmTreeItem;
class QTreeView;
class QSortFilterProxyModel;
class QStandardItemModel;
class QStandardItem;

class FilenamesAndMetadata : public QWidget {
    Q_OBJECT
    public:
        FilenamesAndMetadata(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::Widget);
        void writeSettings();
        void readSettings();

    signals:
        void searchResultClicked(int);

    private slots:
        void search();

    private:
        void appendChild(QVariant id, QVariant subject, QVariant name, QVariant sub, SmTreeItem *parent);
        void appendEmpty(SmTreeItem *parent);
        QLineEdit *mSearch;
        QTreeView *mResult;
        SmTreeModel *mModel;
        QSortFilterProxyModel *mProxy;
};

class ActorsAndMore : public QWidget {
    Q_OBJECT
    public:
        enum SearchTypes { Actor, Title };
        enum CustomRoles { IdRole = Qt::UserRole + 1 };
        ActorsAndMore(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::Widget);
        void writeSettings();
        void readSettings();

    public slots:
        void doSearch();
        void fetchData(const QModelIndex &cur, const QModelIndex &prev);
        void doDataActions(const QModelIndex &cur, const QModelIndex &prev);
        void doResultActions(const QModelIndex &cur, const QModelIndex &prev);
        void dataDoubleClicked(const QModelIndex &index);
        void collapseAllResult() { mResultView->collapseAll(); }
        void expandAllResult() { mResultView->expandAll(); }
        void collapseAllData() { mDataView->collapseAll(); }
        void expandAllData() { mDataView->expandAll(); }
        void deleteSeries();
        void deleteActor();
        void refreshActors();

    private:
        void searchActor(const QString &actor);
        void searchSubtitle(const QString &subtitle);
        void getGenresForActor(QStandardItem *actorItem);
        void getDataForActor(QModelIndex cur);
        void getDataForTitle(QModelIndex cur);
        QComboBox *mTypeSel;
        QLineEdit *mSearch;
        QStandardItemModel *mResultModel;
        QStandardItemModel *mDataModel;
        SmView *mResultView;
        SmView *mDataView;
        QAction *mDeleteActorA;
        QAction *mDeleteSeriesA;
};

class SearchDialog : public QDialog {
    Q_OBJECT
    public:
        SearchDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::Widget);
        void readSettings();
        void writeSettings();

    private:
        FilenamesAndMetadata *mFilenameAndMetadataW;
        ActorsAndMore *mActorsAndMoreW;
};


#endif // SEARCHDIALOG_H