Finishing of attachments

This commit is contained in:
Jakub Melka
2019-12-03 19:24:43 +01:00
parent 159fc9f815
commit 5eed274863
6 changed files with 92 additions and 4 deletions

View File

@@ -296,7 +296,7 @@ private:
};
/// PDF document main class.
class PDFDocument
class PDFFORQTLIBSHARED_EXPORT PDFDocument
{
Q_DECLARE_TR_FUNCTIONS(pdf::PDFDocument)

View File

@@ -37,6 +37,7 @@ public:
const QDateTime& getCreationDate() const { return m_creationDate; }
const QDateTime& getModifiedDate() const { return m_modifiedDate; }
const QByteArray& getChecksum() const { return m_checksum; }
const PDFStream* getStream() const { return m_stream.getStream(); }
static PDFEmbeddedFile parse(const PDFDocument* document, PDFObject object);

View File

@@ -565,7 +565,8 @@ void PDFAttachmentsTreeItemModel::update()
auto it = subroots.find(fileTypeName);
if (it == subroots.cend())
{
subroot = new PDFAttachmentsTreeItem(nullptr, icon, fileTypeDescription, QString(), nullptr);
QIcon folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirIcon);
subroot = new PDFAttachmentsTreeItem(nullptr, qMove(folderIcon), fileTypeDescription, QString(), nullptr);
root->addCreatedChild(subroot);
subroots[fileTypeName] = subroot;
}
@@ -585,7 +586,32 @@ void PDFAttachmentsTreeItemModel::update()
Qt::ItemFlags PDFAttachmentsTreeItemModel::flags(const QModelIndex& index) const
{
return PDFTreeItemModel::flags(index);
if (!index.isValid())
{
return Qt::NoItemFlags;
}
if (rowCount(index) > 0)
{
return Qt::ItemIsEnabled;
}
if (index.column() == Title)
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemNeverHasChildren;
}
return Qt::ItemIsEnabled | Qt::ItemNeverHasChildren;
}
const PDFFileSpecification* PDFAttachmentsTreeItemModel::getFileSpecification(const QModelIndex& index) const
{
if (index.isValid())
{
return static_cast<const PDFAttachmentsTreeItem*>(index.internalPointer())->getFileSpecification();
}
return nullptr;
}
} // namespace pdf

View File

@@ -213,6 +213,8 @@ public:
virtual QVariant data(const QModelIndex& index, int role) const override;
virtual void update() override;
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
const PDFFileSpecification* getFileSpecification(const QModelIndex& index) const;
};
} // namespace pdf