void OutlineModel::setDocument(Document *document) { if (m_doc != document) { if (m_doc) { QObject::disconnect(m_doc, SIGNAL(aboutToReset()), this, SLOT(reset())); } m_doc = document; if (m_doc) { QObject::connect(m_doc, SIGNAL(aboutToReset()), this, SLOT(reset())); } m_outline = document->outline(); emit documentChanged(); } }
Document::~Document() { // We need to emit those manually because init() emits them // and init() calls clearPages() // emitting the signals in clearPages() will cause a double emission of the signals. emit aboutToReset(); clearPages(); clearDocument(); }
void Document::init(const QString& filePath, const QString& mimeType) { m_filePath = filePath; emit filePathChanged(); m_mimeType = mimeType; emit mimeTypeChanged(); setState(Document::Loading); if (!m_pages.isEmpty()) { emit aboutToReset(); clearPages(); } clearDocument(); m_loader = new DocumentLoader; QObject::connect(m_loader, SIGNAL(done()), this, SLOT(loaderDone())); QObject::connect(m_loader, SIGNAL(error()), this, SLOT(loaderError())); QObject::connect(m_loader, SIGNAL(locked()), this, SLOT(loaderLocked())); m_loader->start(m_filePath, m_mimeType); }
void EntryAttachmentsModel::setEntryAttachments(EntryAttachments* entryAttachments) { beginResetModel(); if (m_entryAttachments) { m_entryAttachments->disconnect(this); } m_entryAttachments = entryAttachments; if (m_entryAttachments) { connect(m_entryAttachments, SIGNAL(keyModified(QString)), SLOT(attachmentChange(QString))); connect(m_entryAttachments, SIGNAL(aboutToBeAdded(QString)), SLOT(attachmentAboutToAdd(QString))); connect(m_entryAttachments, SIGNAL(added(QString)), SLOT(attachmentAdd())); connect(m_entryAttachments, SIGNAL(aboutToBeRemoved(QString)), SLOT(attachmentAboutToRemove(QString))); connect(m_entryAttachments, SIGNAL(removed(QString)), SLOT(attachmentRemove())); connect(m_entryAttachments, SIGNAL(aboutToBeReset()), SLOT(aboutToReset())); connect(m_entryAttachments, SIGNAL(reset()), SLOT(reset())); } endResetModel(); }