aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-16 13:28:59 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-16 13:28:59 -0300
commit20849f014eafa7ed697fb65af139ce3ee0561605 (patch)
treef2ad19b21559fdf13e2db59b871951024ad2a331 /qt-ui/models.cpp
parentf9b4c6b889e2444533af1baabdee3687020c1e7b (diff)
downloadsubsurface-20849f014eafa7ed697fb65af139ce3ee0561605.tar.gz
Make the columns have a sane default width for 'type'
Make the columns on Cylinders edit and Wheight Edit to have sane values for 'type', this is needed because the old behavior was to set it fixed size, and the default fixed size was silly. this calculates a good predefined value taking the font size in consideration. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index dd8bac078..6d6459983 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -583,10 +583,20 @@ int WSInfoModel::rowCount(const QModelIndex& parent) const
return rows+1;
}
+const QString& WSInfoModel::biggerString() const
+{
+ return biggerEntry;
+}
+
WSInfoModel::WSInfoModel() : QAbstractTableModel(), rows(-1)
{
struct ws_info *info = ws_info;
- for (info = ws_info; info->name; info++, rows++);
+ for (info = ws_info; info->name; info++, rows++){
+ QString wsInfoName(info->name);
+ if( wsInfoName.count() > biggerEntry.count()){
+ biggerEntry = wsInfoName;
+ }
+ }
if (rows > -1) {
beginInsertRows(QModelIndex(), 0, rows);
@@ -616,6 +626,11 @@ TankInfoModel* TankInfoModel::instance()
return self;
}
+const QString& TankInfoModel::biggerString() const
+{
+ return biggerEntry;
+}
+
bool TankInfoModel::insertRows(int row, int count, const QModelIndex& parent)
{
beginInsertRows(parent, rowCount(), rowCount());
@@ -723,7 +738,13 @@ int TankInfoModel::rowCount(const QModelIndex& parent) const
TankInfoModel::TankInfoModel() : QAbstractTableModel(), rows(-1)
{
struct tank_info *info = tank_info;
- for (info = tank_info; info->name; info++, rows++);
+ for (info = tank_info; info->name; info++, rows++){
+ QString infoName(info->name);
+ if (infoName.count() > biggerEntry.count()){
+ biggerEntry = infoName;
+ }
+ }
+
if (rows > -1) {
beginInsertRows(QModelIndex(), 0, rows);
endInsertRows();