API Documentation
Loading...
Searching...
No Matches
VehicleTable.h
Go to the documentation of this file.
1#pragma once
5#include <QObject>
6#include <QWidget>
7#include <QTableView>
8#include <QSortFilterProxyModel>
9#include <QAbstractTableModel>
10namespace NDEVR
11{
12
13 class VehicleTableModel final : public QAbstractTableModel
14 {
15 Q_OBJECT
16 public:
17 VehicleTableModel(VehicleDatabase* m_database, QObject* parent = nullptr);
18
21 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
22 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
23 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
24 //Qt::ItemFlags flags(const QModelIndex& index) const override;
25
26 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
27 protected:
29 };
30 class VehicleTableFilterProxyModel : public QSortFilterProxyModel
31 {
32 Q_OBJECT
33 public:
34 explicit VehicleTableFilterProxyModel(VehicleDatabase* model, QObject* parent = nullptr);
35 void setMakeSearchString(const String& search_string);
36 void setModelSearchString(const String& search_string);
37 void setYearSearchString(const uint04& search_string);
38 void setSearchStrings(const String& make, const String& model, uint04 year);
39 void sort(int column, Qt::SortOrder order = Qt::DescendingOrder) override;
40
41 void setSelectedCallback(const std::function<void(uint04, PopupInfo)>& callback) { m_selected_callback = callback; };
42 [[nodiscard]] const std::function<void(uint04, PopupInfo)>& selectedCallback() const { return m_selected_callback; };
43 signals:
45 protected:
46 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
47 virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
48
49 protected:
54 std::function<void(uint04, PopupInfo)> m_selected_callback;
55 };
56 class VehicleTableView : public QTableView
57 {
58 public:
59 explicit VehicleTableView(VehicleDatabase* database, QWidget* parent = nullptr);
60 [[nodiscard]] VehicleTableFilterProxyModel* filter() const { return m_filter; }
61 QSize minimumSizeHint() const override;
62 uint04 recordIndexFromSelection(const QModelIndex& selection_index) const;
63 //QSize minimumSizeHint() const override;
64 protected:
65 //void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles) override;
66 //void rowsInserted(const QModelIndex& parent, int start, int end) override;
67
68 protected:
71 };
72}
The core String class for the NDEVR API.
Definition String.h:69
Definition VehicleDatabase.h:42
Definition VehicleTable.h:31
String m_search_make
Definition VehicleTable.h:51
uint04 m_search_year
Definition VehicleTable.h:53
VehicleDatabase * m_database
Definition VehicleTable.h:50
void setModelSearchString(const String &search_string)
const std::function< void(uint04, PopupInfo)> & selectedCallback() const
Definition VehicleTable.h:42
void setYearSearchString(const uint04 &search_string)
void setSearchStrings(const String &make, const String &model, uint04 year)
std::function< void(uint04, PopupInfo)> m_selected_callback
Definition VehicleTable.h:54
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
VehicleTableFilterProxyModel(VehicleDatabase *model, QObject *parent=nullptr)
void setMakeSearchString(const String &search_string)
String m_search_model
Definition VehicleTable.h:52
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
void sort(int column, Qt::SortOrder order=Qt::DescendingOrder) override
void setSelectedCallback(const std::function< void(uint04, PopupInfo)> &callback)
Definition VehicleTable.h:41
Definition VehicleTable.h:14
VehicleDatabase * m_database
Definition VehicleTable.h:28
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
~VehicleTableModel()
Definition VehicleTable.h:19
int columnCount(const QModelIndex &parent=QModelIndex()) const override
VehicleTableModel(VehicleDatabase *m_database, QObject *parent=nullptr)
Definition VehicleTable.h:57
QSize minimumSizeHint() const override
VehicleTableModel * m_model
Definition VehicleTable.h:70
VehicleTableView(VehicleDatabase *database, QWidget *parent=nullptr)
uint04 recordIndexFromSelection(const QModelIndex &selection_index) const
VehicleTableFilterProxyModel * filter() const
Definition VehicleTable.h:60
VehicleTableFilterProxyModel * m_filter
Definition VehicleTable.h:69
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Class which is used to pass arguments and requests for creating a popup dialog or widget....
Definition PopupInfo.h:15