aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/model/GpgKeyTableProxyModel.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-12-21 02:36:30 +0000
committersaturneric <[email protected]>2024-12-21 02:36:30 +0000
commit78d76b454769e0dcbaaeb7bbe30ec9d315b7388c (patch)
tree384c51fcbe9cf380e38add322708682718fec9af /src/ui/model/GpgKeyTableProxyModel.cpp
parentfix: symbols link error on mingw64 (diff)
downloadGpgFrontend-78d76b454769e0dcbaaeb7bbe30ec9d315b7388c.tar.gz
GpgFrontend-78d76b454769e0dcbaaeb7bbe30ec9d315b7388c.zip
fix: ResizeToContents behaviors of key list
Diffstat (limited to 'src/ui/model/GpgKeyTableProxyModel.cpp')
-rw-r--r--src/ui/model/GpgKeyTableProxyModel.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/ui/model/GpgKeyTableProxyModel.cpp b/src/ui/model/GpgKeyTableProxyModel.cpp
index 5fa5bea4..9dc98bcd 100644
--- a/src/ui/model/GpgKeyTableProxyModel.cpp
+++ b/src/ui/model/GpgKeyTableProxyModel.cpp
@@ -198,80 +198,4 @@ void GpgKeyTableProxyModel::slot_update_favorites_cache() {
}
}
-auto GpgKeyTableProxyModel::data(const QModelIndex &index,
- int role) const -> QVariant {
- if (role == Qt::FontRole) {
- return default_font_;
- }
-
- if (role == Qt::TextAlignmentRole) {
- return Qt::AlignCenter;
- }
-
- if (role == Qt::SizeHintRole) {
- const QVariant display_data = model_->data(index, Qt::DisplayRole);
- if (!display_data.isValid()) {
- return {};
- }
-
- const QString text = display_data.toString();
-
- QRect rect = default_metrics_.boundingRect(QRect{}, Qt::AlignCenter, text);
-
- const int horizontal_padding = 15;
- const int vertical_padding = 2;
-
-#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
- const int raw_width = default_metrics_.horizontalAdvance(text);
-#else
- const int raw_width = rect.width();
-#endif
-
- const int width =
- static_cast<int>(raw_width * 1.15) + horizontal_padding * 2;
- const int height = rect.height() + vertical_padding * 2;
-
- LOG_D() << "row text: " << text << "width: " << width;
-
- return QSize(width, height);
- }
-
- return sourceModel()->data(index, role);
-}
-
-auto GpgKeyTableProxyModel::headerData(int section, Qt::Orientation orientation,
- int role) const -> QVariant {
- if (role == Qt::FontRole) {
- return default_font_;
- }
-
- if (role == Qt::SizeHintRole) {
- const QVariant display_data =
- model_->headerData(section, orientation, Qt::DisplayRole);
- if (!display_data.isValid()) {
- return {};
- }
-
- const QString text = display_data.toString();
-
- QRect rect = default_metrics_.boundingRect(QRect{}, Qt::AlignCenter, text);
-
- const int horizontal_padding = 15;
- const int vertical_padding = 2;
-
-#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
- const int raw_width = default_metrics_.horizontalAdvance(text);
-#else
- const int raw_width = rect.width();
-#endif
-
- const int width =
- static_cast<int>(raw_width * 1.15) + horizontal_padding * 2;
- const int height = rect.height() + vertical_padding * 2;
-
- return QSize(width, height);
- }
-
- return sourceModel()->headerData(section, orientation, role);
-}
} // namespace GpgFrontend::UI \ No newline at end of file