Differences From Artifact [dde1f9166d]:

  • File src/DocumentList.cxx — part of check-in [cc715c448e] at 2019-05-17 13:43:13 on branch error-messages — DocumentList: do not load documents in constructor by in `load` method. This allows to connect to signal of `DocumentList` before actually loading. This is important to catch `error` signals. (user: fifr size: 4995) [more...]

To Artifact [3992c5e85a]:

  • File src/DocumentList.cxx — part of check-in [520dd82f17] at 2019-05-20 09:17:35 on branch trunk — DocumentsList: ensure all slots are named `on...` (user: fifr size: 5007) [more...]

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);