1
0

ImporterModel.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /******************************************************************************
  2. Copyright (C) 2019-2020 by Dillon Pentz <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <QAbstractTableModel>
  16. enum ImporterColumn {
  17. Selected,
  18. Name,
  19. Path,
  20. Program,
  21. Count
  22. };
  23. enum ImporterEntryRole { EntryStateRole = Qt::UserRole, NewPath, AutoPath, CheckEmpty };
  24. class ImporterModel : public QAbstractTableModel {
  25. Q_OBJECT
  26. friend class OBSImporter;
  27. public:
  28. ImporterModel(QObject *parent = 0) : QAbstractTableModel(parent) {}
  29. int rowCount(const QModelIndex &parent = QModelIndex()) const;
  30. int columnCount(const QModelIndex &parent = QModelIndex()) const;
  31. QVariant data(const QModelIndex &index, int role) const;
  32. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
  33. Qt::ItemFlags flags(const QModelIndex &index) const;
  34. bool setData(const QModelIndex &index, const QVariant &value, int role);
  35. private:
  36. struct ImporterEntry {
  37. QString path;
  38. QString program;
  39. QString name;
  40. bool selected;
  41. bool empty;
  42. };
  43. QList<ImporterEntry> options;
  44. void checkInputPath(int row);
  45. };