| 1 | /* | 
|---|
| 2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) | 
|---|
| 3 | * | 
|---|
| 4 | * This program is free software: you can redistribute it and/or modify | 
|---|
| 5 | * it under the terms of the GNU General Public License as published by | 
|---|
| 6 | * the Free Software Foundation, either version 3 of the License, or | 
|---|
| 7 | * (at your option) any later version. | 
|---|
| 8 | * | 
|---|
| 9 | * This program is distributed in the hope that it will be useful, | 
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 12 | * GNU General Public License for more details. | 
|---|
| 13 | * | 
|---|
| 14 | * You should have received a copy of the GNU General Public License | 
|---|
| 15 | * along with this program.  If not, see <https://www.gnu.org/licenses/>. | 
|---|
| 16 | */ | 
|---|
| 17 | #ifndef FILEPROPERTIESDIALOG_H | 
|---|
| 18 | #define FILEPROPERTIESDIALOG_H | 
|---|
| 19 |  | 
|---|
| 20 | #include <QAbstractListModel> | 
|---|
| 21 | #include <QDialog> | 
|---|
| 22 |  | 
|---|
| 23 | namespace Ui { | 
|---|
| 24 | class FilePropertiesDialog; | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | class FilePropertiesModel: public QAbstractListModel { | 
|---|
| 28 | Q_OBJECT | 
|---|
| 29 | public: | 
|---|
| 30 | explicit FilePropertiesModel(QObject* parent=nullptr); | 
|---|
| 31 |  | 
|---|
| 32 | // QAbstractItemModel interface | 
|---|
| 33 | public: | 
|---|
| 34 | int rowCount(const QModelIndex &parent) const override; | 
|---|
| 35 | QVariant data(const QModelIndex &index, int role) const override; | 
|---|
| 36 | }; | 
|---|
| 37 | class Editor; | 
|---|
| 38 | class FilePropertiesDialog : public QDialog | 
|---|
| 39 | { | 
|---|
| 40 | Q_OBJECT | 
|---|
| 41 |  | 
|---|
| 42 | public: | 
|---|
| 43 | explicit FilePropertiesDialog(Editor* activeEditor,QWidget *parent = nullptr); | 
|---|
| 44 | ~FilePropertiesDialog(); | 
|---|
| 45 |  | 
|---|
| 46 | private: | 
|---|
| 47 | void calcFile(Editor* editor, | 
|---|
| 48 | int& totalLines, | 
|---|
| 49 | int &, | 
|---|
| 50 | int &emptyLines, | 
|---|
| 51 | int &codeLines, | 
|---|
| 52 | int &includeLines); | 
|---|
| 53 | private: | 
|---|
| 54 | FilePropertiesModel mModel; | 
|---|
| 55 | Editor * mActiveEditor; | 
|---|
| 56 | private: | 
|---|
| 57 | Ui::FilePropertiesDialog *ui; | 
|---|
| 58 |  | 
|---|
| 59 | // QWidget interface | 
|---|
| 60 | protected: | 
|---|
| 61 | void showEvent(QShowEvent *event) override; | 
|---|
| 62 | private slots: | 
|---|
| 63 | void on_cbFiles_currentIndexChanged(int index); | 
|---|
| 64 | void on_btnOK_clicked(); | 
|---|
| 65 | }; | 
|---|
| 66 |  | 
|---|
| 67 | #endif // FILEPROPERTIESDIALOG_H | 
|---|
| 68 |  | 
|---|