mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:20:06 +00:00
Placefile URL readability updates
This commit is contained in:
parent
014ea9d39e
commit
36dd2945b0
5 changed files with 92 additions and 3 deletions
|
|
@ -3,6 +3,9 @@
|
|||
#include <scwx/qt/types/qt_types.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
|
|
@ -79,6 +82,7 @@ QVariant PlacefileModel::data(const QModelIndex& index, int role) const
|
|||
const auto& placefileName = p->placefileNames_.at(index.row());
|
||||
|
||||
if (role == Qt::ItemDataRole::DisplayRole ||
|
||||
role == Qt::ItemDataRole::ToolTipRole ||
|
||||
role == types::ItemDataRole::SortRole)
|
||||
{
|
||||
switch (index.column())
|
||||
|
|
@ -152,6 +156,27 @@ QVariant PlacefileModel::headerData(int section,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (role == Qt::ItemDataRole::SizeHintRole)
|
||||
{
|
||||
static const QFontMetrics fontMetrics(QApplication::font());
|
||||
|
||||
QSize contentsSize {};
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case static_cast<int>(Column::Url):
|
||||
contentsSize = fontMetrics.size(0, QString(15, 'W'));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (contentsSize != QSize {})
|
||||
{
|
||||
return contentsSize;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue