AudioBook Plugin: Actions, item selection

This commit is contained in:
Jakub Melka
2021-08-20 17:52:42 +02:00
parent 9daaa92e90
commit 1aa60dca40
24 changed files with 1652 additions and 40 deletions

View File

@ -18,6 +18,9 @@
#include "pdfdocumenttextfloweditormodel.h"
#include "pdfdocumenttextflow.h"
#include <QColor>
#include <QBrush>
namespace pdf
{
@ -97,6 +100,14 @@ QVariant PDFDocumentTextFlowEditorModel::data(const QModelIndex& index, int role
return QVariant();
}
if (role == Qt::BackgroundRole)
{
if (m_editor->isSelected(index.row()))
{
return QBrush(QColor(255, 255, 200));
}
}
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
switch (index.column())
@ -218,4 +229,27 @@ void PDFDocumentTextFlowEditorModel::endFlowChange()
endResetModel();
}
void PDFDocumentTextFlowEditorModel::setSelectionActivated(bool activate)
{
if (!m_editor || m_editor->isEmpty())
{
return;
}
m_editor->setSelectionActive(activate);
m_editor->deselect();
emit dataChanged(index(0, 0), index(rowCount(QModelIndex()) - 1, ColumnLast));
}
void PDFDocumentTextFlowEditorModel::selectByRectangle(QRectF rectangle)
{
if (!m_editor || m_editor->isEmpty())
{
return;
}
m_editor->selectByRectangle(rectangle);
emit dataChanged(index(0, 0), index(rowCount(QModelIndex()) - 1, ColumnLast));
}
} // namespace pdf