61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
-
-
-
-
+
+
+
+
|
} else {
return nullptr;
}
}
void DocumentList::addDocument(const QSharedPointer<Document>& doc)
{
connect(doc.data(), &Document::pagesChanged, this, &DocumentList::documentChanged);
connect(doc.data(), &Document::titleChanged, this, &DocumentList::documentChanged);
connect(doc.data(), &Document::creationTimeChanged, this, &DocumentList::documentChanged);
connect(doc.data(), &Document::statusChanged, this, &DocumentList::documentStatusChanged);
connect(doc.data(), &Document::pagesChanged, this, &DocumentList::onDocumentChanged);
connect(doc.data(), &Document::titleChanged, this, &DocumentList::onDocumentChanged);
connect(doc.data(), &Document::creationTimeChanged, this, &DocumentList::onDocumentChanged);
connect(doc.data(), &Document::statusChanged, this, &DocumentList::onDocumentStatusChanged);
connect(doc.data(), &Document::error, this, &DocumentList::error);
beginInsertRows({}, d->docs.size(), d->docs.size());
d->docs.push_back(doc);
endInsertRows();
emit latestDocumentChanged();
|
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
|
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
|
-
+
-
+
|
auto doc = d->docs.takeAt(docIndex);
doc->remove();
endRemoveRows();
emit latestDocumentChanged();
}
void DocumentList::documentChanged()
void DocumentList::onDocumentChanged()
{
auto sender = QObject::sender();
for (int i = 0; i < d->docs.size(); i++) {
auto& doc = d->docs.at(i);
if (doc.data() == sender) {
auto idx = index(i);
emit dataChanged(idx, idx, {ThumbnailsRole, TitleRole, CreationTimeRole, NumPagesRole});
}
}
}
void DocumentList::documentStatusChanged()
void DocumentList::onDocumentStatusChanged()
{
auto* doc = qobject_cast<Document*>(sender());
if (doc->status() == Document::Invalid) {
for (int i = 0; i < d->docs.size(); i++) {
if (d->docs.at(i) == doc) {
deleteDocument(i);
|