-
Notifications
You must be signed in to change notification settings - Fork 2
/
drboardscontroller.cpp
148 lines (73 loc) · 3.16 KB
/
drboardscontroller.cpp
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <QDebug>
#include <QFileInfo>
#include <QApplication>
#include <QMutex>
#include "drboardscontroller.h"
#include "drboardstreemodel.h"
#include "drthreaditem.h"
#include "main.h"
#include "dr.h"
static QMutex mutex;
DRBoardsController::DRBoardsController(DRServerConnection* connection) :
DRConnectionController(connection)
{
this->boardsModel = new DRBoardsTreeModel(connection);
this->threadsModel = new QStandardItemModel();
this->connection->addDelegateForMessage(this, "wired.board.board_list");
this->connection->addDelegateForMessage(this, "wired.board.thread_list");
this->getBoards();
}
void DRBoardsController::connectReceiver(QObject *object) {
}
void DRBoardsController::disconnectReceiver(QObject *object) {
}
void DRBoardsController::getBoards() {
this->boardsModel->clearBoards();
// reload boards
wi_p7_message_t *message = wi_p7_message_with_name(WI_STR("wired.board.get_boards"), wc_spec);
this->connection->sendMessage(message);
}
void DRBoardsController::getThreads(DRBoardItem *board) {
board->clearThreads();
// reload thread
wi_p7_message_t *message = wi_p7_message_with_name(WI_STR("wired.board.get_threads"), wc_spec);
wi_p7_message_set_string_for_name(message, QSTOWS(board->path()), WI_STR("wired.board.board"));
this->connection->sendMessage(message);
}
void DRBoardsController::connectionSucceeded(DRServerConnection *connection) {
}
void DRBoardsController::connectionError(DRServerConnection *connection, DRError *error) {
}
void DRBoardsController::connectionClosed(DRServerConnection *connection, DRError *error) {
}
void DRBoardsController::receivedMessage(wi_p7_message_t *message, DRServerConnection *connection) {
if(wi_is_equal(wi_p7_message_name(message), WI_STR("wired.board.board_list"))) {
this->receivedBoard(message);
}
else if(wi_is_equal(wi_p7_message_name(message), WI_STR("wired.board.board_list.done"))) {
// signal to retore expanded state
}
else if(wi_is_equal(wi_p7_message_name(message), WI_STR("wired.board.thread_list"))) {
this->receivedThread(message);
}
else if(wi_is_equal(wi_p7_message_name(message), WI_STR("wired.board.thread_list.done"))) {
}
}
void DRBoardsController::receivedError(DRError *error, DRServerConnection *connection) {
}
void DRBoardsController::receivedBoard(wi_p7_message_t *message) {
QString path = WSTOQS(wi_p7_message_string_for_name(message, WI_STR("wired.board.board")));
DRBoardItem *board = this->boardsModel->boardForPath(path);
DRBoardItem *newBoard = this->boardsModel->addBoard(message, board);
if(newBoard != NULL)
this->getThreads(newBoard);
}
void DRBoardsController::receivedThread(wi_p7_message_t *message) {
QString boardPath = WSTOQS(wi_p7_message_string_for_name(message, WI_STR("wired.board.board")));
DRBoardItem *board = (DRBoardItem *)this->boardsModel->boardForPath(boardPath);
if(board == NULL)
return;
DRThreadItem *thread = new DRThreadItem(message, board, this->connection);
board->addThread(thread);
this->threadsModel->appendRow(new QStandardItem(thread->subject));
}