-
Notifications
You must be signed in to change notification settings - Fork 3
/
carlist.h
58 lines (49 loc) · 1.36 KB
/
carlist.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef CARLIST_H
#define CARLIST_H
#include <QDialog>
#include <QTime>
#include <QTimer>
#include <QList>
#include <QRunnable>
#include <QAbstractTableModel>
#include "car.h"
#include <functional>
namespace Ui {
class CarList;
}
class Car;
class Adapter: public QAbstractTableModel {
public:
explicit Adapter(QObject* parent, QList<Car*>* list);
int columnCount(const QModelIndex &parent = QModelIndex()) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QList<Car*>* getCarList();
void update();
private:
QStringList header;
QList<Car*>* m_list;
QTimer *timer;
};
class CarList : public QDialog
{
Q_OBJECT
public:
~CarList();
void setAdapter(Adapter* adapter);
static CarList* newInstance(QWidget* parent);
static CarList* getInstance();
void closeEvent(QCloseEvent *e);
void mouseEvent(const QModelIndex& index);
signals:
void onCloseButtonClicked(void);
private:
static CarList* m_instance;
explicit CarList(QWidget *parent = 0);
QList<Car*>* m_carList;
Ui::CarList *ui;
};
void sort(QList<Car*>::iterator s, QList<Car*>::iterator e,
std::function<bool (const Car*, const Car*)> comp);
#endif // CARLIST_H