mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-20 18:33:38 -04:00
Fixed hover misbehaviour over zim description
Clicking and hovering the description dropdown of zim no longer whites out. Replaced manual drawing with default handling as it is no longer necessary.
This commit is contained in:
parent
bc1107b076
commit
e63561161b
@ -193,15 +193,9 @@ void ContentManagerDelegate::paintBookState(QPainter *p, const QStyleOptionViewI
|
||||
|
||||
void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QRect r = option.rect;
|
||||
if (isDescriptionIndex(index)) {
|
||||
// additional info
|
||||
QRect nRect = r;
|
||||
auto viewWidth = KiwixApp::instance()->getContentManager()->getView()->getView()->width();
|
||||
nRect.setWidth(viewWidth);
|
||||
painter->drawText(nRect, Qt::AlignLeft | Qt::AlignVCenter, index.data(Qt::UserRole+1).toString());
|
||||
return;
|
||||
}
|
||||
if (isDescriptionIndex(index))
|
||||
return QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
QStyleOptionViewItem eOpt = option;
|
||||
if (index.column() == 1) {
|
||||
auto bFont = painter->font();
|
||||
|
@ -60,10 +60,13 @@ QVariant ContentManagerModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
|
||||
const auto col = index.column();
|
||||
const bool isThumbnailRequest = col == 0 && role == Qt::DecorationRole;
|
||||
const bool otherDataRequest = col != 0 && (role == Qt::DisplayRole || role == Qt::UserRole+1 );
|
||||
const bool isThumbnailRequest =
|
||||
!isDescriptionIndex(index) && col == 0 && role == Qt::DecorationRole;
|
||||
const bool isDescriptionRequest =
|
||||
isDescriptionIndex(index) && col == 0 && role == Qt::DisplayRole;
|
||||
const bool otherDataRequest = col != 0 && role == Qt::DisplayRole;
|
||||
|
||||
if ( !isThumbnailRequest && !otherDataRequest )
|
||||
if ( !isThumbnailRequest && !otherDataRequest && !isDescriptionRequest )
|
||||
return QVariant();
|
||||
|
||||
const auto item = static_cast<Node*>(index.internalPointer());
|
||||
|
@ -20,6 +20,7 @@ ContentManagerView::ContentManagerView(QWidget *parent)
|
||||
mp_ui->stackedWidget->setCurrentIndex(0);
|
||||
|
||||
connect(mp_ui->m_view, &QTreeView::clicked, this, &ContentManagerView::onClicked);
|
||||
connect(mp_ui->m_view, &QTreeView::expanded, this, &ContentManagerView::onExpanded);
|
||||
}
|
||||
|
||||
ContentManagerView::~ContentManagerView()
|
||||
@ -49,3 +50,9 @@ void ContentManagerView::onClicked(QModelIndex index)
|
||||
mp_ui->m_view->expand(zeroColIndex);
|
||||
}
|
||||
}
|
||||
|
||||
void ContentManagerView::onExpanded(QModelIndex index)
|
||||
{
|
||||
if (!mp_ui->m_view->isFirstColumnSpanned(0, index))
|
||||
mp_ui->m_view->setFirstColumnSpanned(0, index, true);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
public slots:
|
||||
void showLoader(bool show);
|
||||
void onClicked(QModelIndex index);
|
||||
void onExpanded(QModelIndex index);
|
||||
|
||||
private:
|
||||
Ui::contentmanagerview *mp_ui;
|
||||
|
@ -36,7 +36,7 @@ int DescriptionNode::columnCount() const
|
||||
|
||||
QVariant DescriptionNode::data(int column)
|
||||
{
|
||||
if (column == 1)
|
||||
if (column == 0)
|
||||
return m_desc;
|
||||
return QVariant();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user