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}
Definition String.h:40
Definition VehicleDatabase.h:42
Definition VehicleTable.h:31
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Definition VehicleTable.cpp:35
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)
Definition VehicleTable.cpp:14
const std::function< void(uint04, PopupInfo)> & selectedCallback() const
Definition VehicleTable.h:42
void setYearSearchString(const uint04 &search_string)
Definition VehicleTable.cpp:20
void setSearchStrings(const String &make, const String &model, uint04 year)
Definition VehicleTable.cpp:25
std::function< void(uint04, PopupInfo)> m_selected_callback
Definition VehicleTable.h:54
VehicleTableFilterProxyModel(VehicleDatabase *model, QObject *parent=nullptr)
Definition VehicleTable.cpp:76
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Definition VehicleTable.cpp:39
void setMakeSearchString(const String &search_string)
Definition VehicleTable.cpp:9
String m_search_model
Definition VehicleTable.h:52
void sort(int column, Qt::SortOrder order=Qt::DescendingOrder) override
Definition VehicleTable.cpp:32
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
Definition VehicleTable.cpp:80
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition VehicleTable.cpp:48
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition VehicleTable.cpp:56
~VehicleTableModel()
Definition VehicleTable.h:19
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition VehicleTable.cpp:52
VehicleTableModel(VehicleDatabase *m_database, QObject *parent=nullptr)
Definition VehicleTable.cpp:45
Definition VehicleTable.h:57
QSize minimumSizeHint() const override
Definition VehicleTable.cpp:138
VehicleTableModel * m_model
Definition VehicleTable.h:70
VehicleTableView(VehicleDatabase *database, QWidget *parent=nullptr)
Definition VehicleTable.cpp:101
uint04 recordIndexFromSelection(const QModelIndex &selection_index) const
Definition VehicleTable.cpp:132
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:120
Definition BaseValues.hpp:272
Definition PopupInfo.h:10