-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestionslistbtn.h
69 lines (57 loc) · 2 KB
/
questionslistbtn.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
59
60
61
62
63
64
65
66
67
68
69
#ifndef QUESTIONSLISTBTN_H
#define QUESTIONSLISTBTN_H
#include <QObject>
#include <QWidget>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QHash>
#include <QLabel>
#include <QSqlQuery>
class RowButton;
class QPushButton;
class QSignalMapper;
/*
* При создании списка отображаются элементы с parentId == 0 - реализовано как развертывание индекса 0
*
* Хэш видимых строк - нужен для определения объекта класса при клике на строку
* Список видимых строк-потомков - нужен для сворачивания строки
*
*/
class QuestionsListBtn : public QScrollArea
{
Q_OBJECT
QString table_name;
int table_id;
QLabel *lbl;
QString db_name;
int current_row;
QVBoxLayout *vbx_layout;
QWidget *scroll_widget;
QHash<int, RowButton*> hash_visible_btns;
void Expand(int sql_id);
void Collapse(int sql_id);
void highlightCurrent(int sql_id);
void setImage(int sql_id);
void deleteWidgetRows(int sql_id);
void deleteDBRecords(int sql_id);
void deleteOneRow(int sql_id);
void updateList();
bool hasChildrenSql(int sql_id) const;
// int rowCountSql(int sql_id) const;
int insertRowSql(int parent_id, const QString &question, const QByteArray *image);
RowButton *createChildRowButton(int id_sql, const QString &text, RowButton *parent_btn);
QSignalMapper *connectMapBtnId(QPushButton *btn, int id);
RowButton *addExpandBtn(int sql_id);
public:
QuestionsListBtn(QString table_name, int table_id, QLabel *lbl, QWidget *parent = nullptr);
int getCurrent() const { return current_row; }
void addRow(const QString &question, const QByteArray *image);
QByteArray getCurrentImage() const;
QString dbName() const;
private slots:
void slotClickExpand(int id);
void slotClickRow(int id);
public slots:
void slotDelete();
};
#endif // QUESTIONSLISTBTN_H