refs #745, removed unused hover code

(this was a trial to highlight the drop position, the callback function was kept)
This commit is contained in:
Klaus Basan
2016-08-26 23:07:36 +02:00
parent f506d780b9
commit 58faed5ea7
5 changed files with 13 additions and 54 deletions

View File

@@ -197,19 +197,6 @@ namespace BlackGui
return m_modelDestroyed;
}
void CListModelBaseNonTemplate::setHoveredRow(int row)
{
if (this->m_hoverRow == row) { return; }
this->m_hoverRow = row;
const int columns = columnCount();
if (columns < 1) { return; }
if (row < 0) { return; }
const QModelIndex topLeft(createIndex(row, 0));
const QModelIndex bottomRight(createIndex(row, columns - 1));
emit this->dataChanged(topLeft, bottomRight);
}
void CListModelBaseNonTemplate::clearHighlighting()
{
// can be overridden to delete highlighting
@@ -245,20 +232,6 @@ namespace BlackGui
connect(this, &CListModelBaseNonTemplate::dataChanged, this, &CListModelBaseNonTemplate::ps_onDataChanged);
}
bool CListModelBaseNonTemplate::isHoveredRow(int row) const
{
if (this->m_hoverRow < 0) { return false; }
if (row < 0) { return false; }
return row == this->m_hoverRow;
}
bool CListModelBaseNonTemplate::isHoveredRow(const QModelIndex &modelIndex) const
{
if (this->m_hoverRow < 0) { return false; }
if (!modelIndex.isValid()) { return false; }
return modelIndex.row() == this->m_hoverRow;
}
template <typename ObjectType, typename ContainerType, bool UseCompare>
CListModelBase<ObjectType, ContainerType, UseCompare>::CListModelBase(const QString &translationContext, QObject *parent)
: CListModelBaseNonTemplate(translationContext, parent)
@@ -316,16 +289,9 @@ namespace BlackGui
{
// check / init
if (!this->isValidIndex(index)) { return QVariant(); }
const int row = index.row();
const int col = index.column();
// Hover effect
if (role == Qt::BackgroundRole)
{
if (this->isHoveredRow(row))
{
return QBrush(Qt::red);
}
return CListModelBaseNonTemplate::data(index, role);
}
@@ -337,6 +303,8 @@ namespace BlackGui
if (!formatter || !formatter->supportsRole(role)) { return CListModelBaseNonTemplate::data(index, role); }
// index, updront checking
const int row = index.row();
const int col = index.column();
const BlackMisc::CPropertyIndex propertyIndex = this->columnToPropertyIndex(col);
if (static_cast<int>(CPropertyIndex::GlobalIndexLineNumber) == propertyIndex.frontCasted<int>())
{

View File

@@ -108,9 +108,6 @@ namespace BlackGui
//! Model about to be destroyed?
bool isModelDestroyed();
//! Hovered role
void setHoveredRow(int row);
//! Remove all highlighting
virtual void clearHighlighting();
@@ -167,14 +164,7 @@ namespace BlackGui
//! Helper method with template free signature
virtual int performUpdateContainer(const BlackMisc::CVariant &variant, bool sort) = 0;
//! Row to be hovered?
bool isHoveredRow(int row) const;
//! Row to be hovered?
bool isHoveredRow(const QModelIndex &modelIndex) const;
CColumns m_columns; //!< columns metadata
int m_hoverRow = -1; //!< hovered row number
int m_sortedColumn; //!< currently sorted column
bool m_modelDestroyed = false; //!< model is about to be destroyed
Qt::SortOrder m_sortOrder; //!< sort order (asc/desc)

View File

@@ -1172,15 +1172,9 @@ namespace BlackGui
template <class ModelClass, class ContainerType, class ObjectType>
void CViewBase<ModelClass, ContainerType, ObjectType>::mouseOverCallback(const QModelIndex &index, bool mouseOver)
{
if (mouseOver && index.isValid())
{
const int row = index.row();
this->m_model->setHoveredRow(row);
}
else
{
// this->m_model->setHoveredRow(-1);
}
// void
Q_UNUSED(index);
Q_UNUSED(mouseOver);
}
template <class ModelClass, class ContainerType, class ObjectType>