MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / dropEvent

Method dropEvent

gui/qt/tablewidget.cpp:7–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5TableWidget::TableWidget(QWidget *parent) : QTableWidget{parent} {}
6
7void TableWidget::dropEvent(QDropEvent *e) {
8 if(e->source() != this) {
9 e->ignore();
10 return;
11 }
12
13 int newrow = indexAt(e->pos()).row();
14 if (newrow < 0) {
15 newrow = rowCount();
16 }
17
18 blockSignals(true);
19
20 QList<QTableWidgetItem*> items = this->selectedItems();
21 if (items.isEmpty()) {
22 e->ignore();
23 return;
24 }
25
26 insertRow(newrow);
27 int oldrow = items.first()->row();
28 foreach(QTableWidgetItem *item, items) {
29 int col = item->column();
30 takeItem(oldrow, col);
31 setItem(newrow, col, item);
32 setCellWidget(newrow, col, cellWidget(oldrow, col));
33 }
34
35 removeRow(oldrow);
36 if (oldrow <= newrow) {
37 newrow--;
38 }
39 if (newrow < 0) {
40 newrow = 0;
41 }
42
43 blockSignals(false);
44 setCurrentCell(newrow, 0);
45}

Callers

nothing calls this directly

Calls 1

rowMethod · 0.80

Tested by

no test coverage detected