-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBreakpointModel.cpp
47 lines (40 loc) · 1.19 KB
/
BreakpointModel.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
#include "BreakpointModel.h"
namespace visual_lldb {
BreakpointModel::BreakpointModel(QObject *parent)
: QAbstractTableModel(parent) {}
int BreakpointModel::rowCount(const QModelIndex &) const { return bps.size(); }
int BreakpointModel::columnCount(const QModelIndex &) const {
// File, Line
return 2;
}
QVariant BreakpointModel::data(const QModelIndex &index, int role) const {
if (role == Qt::DisplayRole) {
assert(index.row() < bps.size());
const auto &bp = bps.at(index.row());
switch (index.column()) {
case 0:
return QString(bp.filePath.c_str());
case 1:
return bp.lineNumber;
default:
assert(false);
break;
}
}
return QVariant();
}
void BreakpointModel::setBreakpoints(const std::vector<Breakpoint> &newBps) {
const size_t prevSize = bps.size();
bps = newBps;
int diff = bps.size() - prevSize;
if (diff > 0)
insertRows(prevSize, diff);
else if (diff < 0)
removeRows(bps.size(), diff);
emit layoutChanged();
// Emit changes.
QModelIndex topLeft = createIndex(0, 0);
QModelIndex bottomRight = createIndex(bps.size() - 1, 1);
emit dataChanged(topLeft, bottomRight, {Qt::DisplayRole});
}
} // namespace visual_lldb