1 /************************************************************************
2 **
3 **  Copyright (C) 2019-2020 Kevin B. Hendricks, Stratford, Ontario, Canada
4 **  Copyright (C) 2012 Dave Heiland
5 **  Copyright (C) 2012 John Schember <john@nachtimwald.com>
6 **
7 **  This file is part of Sigil.
8 **
9 **  Sigil is free software: you can redistribute it and/or modify
10 **  it under the terms of the GNU General Public License as published by
11 **  the Free Software Foundation, either version 3 of the License, or
12 **  (at your option) any later version.
13 **
14 **  Sigil is distributed in the hope that it will be useful,
15 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 **  GNU General Public License for more details.
18 **
19 **  You should have received a copy of the GNU General Public License
20 **  along with Sigil.  If not, see <http://www.gnu.org/licenses/>.
21 **
22 *************************************************************************/
23 
24 #pragma once
25 #ifndef CSSFILESWIDGET_H
26 #define CSSFILESWIDGET_H
27 
28 #include <QtCore/QSharedPointer>
29 #include <QtWidgets/QAction>
30 #include <QtWidgets/QMenu>
31 
32 #include "ResourceObjects/Resource.h"
33 #include <QtCore/QHash>
34 #include <QtWidgets/QDialog>
35 #include <QtGui/QStandardItemModel>
36 #include <QPointer>
37 #include "BookManipulation/Book.h"
38 #include "Dialogs/ReportsWidgets/ReportsWidget.h"
39 
40 #include "ui_ReportsCSSFilesWidget.h"
41 
42 class QString;
43 class QStringList;
44 
45 class CSSFilesWidget : public ReportsWidget
46 {
47     Q_OBJECT
48 
49 public:
50     CSSFilesWidget();
51     ~CSSFilesWidget();
52 
53     void CreateReport(QSharedPointer<Book> book);
54 
55     void SetupTable(int sort_column = 1, Qt::SortOrder sort_order = Qt::AscendingOrder);
56 
57 signals:
58     void CloseDialog();
59     void DeleteFilesRequest(QStringList);
60     void OpenFileRequest(QString, int, int);
61 
62 private slots:
63     void ReadSettings();
64     void WriteSettings();
65 
66     void OpenContextMenu(const QPoint &point);
67 
68     void Sort(int logicalindex, Qt::SortOrder order);
69 
70     void FilterEditTextChangedSlot(const QString &text);
71 
72     void Delete();
73     void Save();
74     void DoubleClick();
75 
76 private:
77     void CreateContextMenuActions();
78     void SetupContextMenu(const QPoint &point);
79 
80     void connectSignalsSlots();
81 
82     QList<HTMLResource *> m_HTMLResources;
83     QList<CSSResource *> m_CSSResources;
84 
85     QSharedPointer<Book> m_Book;
86 
87     QStandardItemModel *m_ItemModel;
88 
89     QPointer<QMenu> m_ContextMenu;
90 
91     QAction *m_Delete;
92 
93     QString m_LastDirSaved;
94     QString m_LastFileSaved;
95 
96     Ui::CSSFilesWidget ui;
97 };
98 
99 #endif // CSSFILESWIDGET_H
100