changeset 81:5923d569167b

Make Header tooltips configurable
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 18 Jun 2015 17:48:28 +0200
parents d6f3a31e505e
children 9a03703622b8
files src/constants.h src/l10n/main_de_DE.ts src/libqxt/qxtcsvmodel.cpp src/metadataview.cpp src/metadataview.h
diffstat 5 files changed, 49 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/constants.h	Tue Jun 16 16:08:05 2015 +0200
+++ b/src/constants.h	Thu Jun 18 17:48:28 2015 +0200
@@ -127,4 +127,8 @@
 * @brief Default value for the detachable image. */
 #define DETACHABLE_IMAGE_DEFAULT false
 
+/**
+* @brief The configuration group for the tooltips. */
+#define TOOLTIP_CONFIG_GROUP "Tooltips"
+
 #endif // CONSTANTS_H
--- a/src/l10n/main_de_DE.ts	Tue Jun 16 16:08:05 2015 +0200
+++ b/src/l10n/main_de_DE.ts	Thu Jun 18 17:48:28 2015 +0200
@@ -113,7 +113,7 @@
 <context>
     <name>MetaDataView</name>
     <message>
-        <location filename="../metadataview.cpp" line="90"/>
+        <location filename="../metadataview.cpp" line="91"/>
         <source>Failed to parse file: &apos;%1&apos;</source>
         <translation>Die Datei &apos;%1&apos; konnte nicht eingelesen werden.</translation>
     </message>
@@ -126,22 +126,17 @@
         <translation>Geschwindigkeit:</translation>
     </message>
     <message>
-        <location filename="../pngplayer.cpp" line="104"/>
-        <source>RetraceIT Version:&lt;br/&gt;&lt;bold&gt;%1&lt;/bold&gt;</source>
-        <translation></translation>
-    </message>
-    <message>
-        <location filename="../pngplayer.cpp" line="138"/>
+        <location filename="../pngplayer.cpp" line="136"/>
         <source>Screenshot Nr.:</source>
         <translation>Screenshot Nr.:</translation>
     </message>
     <message>
-        <location filename="../pngplayer.cpp" line="140"/>
+        <location filename="../pngplayer.cpp" line="138"/>
         <source>Index Nr.:</source>
         <translation>Index Nr.:</translation>
     </message>
     <message>
-        <location filename="../pngplayer.cpp" line="141"/>
+        <location filename="../pngplayer.cpp" line="139"/>
         <source>Timestamp:</source>
         <translation>Zeitstempel:</translation>
     </message>
@@ -150,12 +145,12 @@
         <translation type="vanished">Unbekannt</translation>
     </message>
     <message>
-        <location filename="../pngplayer.cpp" line="150"/>
+        <location filename="../pngplayer.cpp" line="148"/>
         <source>%1 second per Picture</source>
         <translation>%1 Sekunde pro Bild</translation>
     </message>
     <message>
-        <location filename="../pngplayer.cpp" line="153"/>
+        <location filename="../pngplayer.cpp" line="151"/>
         <source>%1 seconds per Picture</source>
         <translation>%1 Sekunden pro Bild</translation>
     </message>
--- a/src/libqxt/qxtcsvmodel.cpp	Tue Jun 16 16:08:05 2015 +0200
+++ b/src/libqxt/qxtcsvmodel.cpp	Thu Jun 18 17:48:28 2015 +0200
@@ -45,12 +45,13 @@
 class QxtCsvModelPrivate : public QxtPrivate<QxtCsvModel>
 {
 public:
-    QxtCsvModelPrivate() : csvData(), header(), maxColumn(0), quoteMode(QxtCsvModel::DefaultQuoteMode)
+    QxtCsvModelPrivate() : csvData(), header(), header_tt(), maxColumn(0), quoteMode(QxtCsvModel::DefaultQuoteMode)
     {}
     QXT_DECLARE_PUBLIC(QxtCsvModel)
 
     QList<QStringList> csvData;
     QStringList header;
+    QStringList header_tt;
     int maxColumn;
     QxtCsvModel::QuoteMode quoteMode;
 };
@@ -139,7 +140,9 @@
 {
     if(section < qxt_d().header.count() && orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole))
         return qxt_d().header[section];
-    else
+    else if (section < qxt_d().header_tt.count() && role == Qt::ToolTipRole) {
+        return qxt_d().header_tt[section];
+    } else
         return QAbstractTableModel::headerData(section, orientation, role);
 }
 
@@ -267,12 +270,21 @@
   */
 bool QxtCsvModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant& value, int role)
 {
-    if(orientation != Qt::Horizontal) return false;                   // We don't support the vertical header
-    if(role != Qt::DisplayRole && role != Qt::EditRole) return false; // We don't support any other roles
     if(section < 0) return false;                                     // Bogus input
     while(section > qxt_d().header.size()) {
         qxt_d().header << QString();
     }
+    while(section >= qxt_d().header_tt.size()) {
+        qxt_d().header_tt << QString();
+    }
+    qDebug() << "Sect " << section  << " size " << qxt_d().header_tt.size();
+    if(orientation != Qt::Horizontal) return false;                   // We don't support the vertical header
+    if(role == Qt::ToolTipRole) {
+        qxt_d().header_tt[section] = value.toString();
+        emit headerDataChanged(Qt::Horizontal, section, section);
+        return true;
+    }
+    if(role != Qt::DisplayRole && role != Qt::EditRole) return false; // We don't support any other roles
     qxt_d().header[section] = value.toString();
     emit headerDataChanged(Qt::Horizontal, section, section);
     return true;
@@ -369,8 +381,10 @@
             row.insert(col, QString());
         }
     }
-    for(int i = 0; i < count ;i++)
+    for(int i = 0; i < count ;i++) {
         d_ptr.header.insert(col, QString());
+        d_ptr.header_tt.insert(col, QString());
+    }
     d_ptr.maxColumn += count;
     endInsertColumns();
     return true;
@@ -400,8 +414,10 @@
             d_ptr.csvData[i].removeAt(col);
         }
     }
-    for(int i = 0; i < count; i++)
+    for(int i = 0; i < count; i++) {
         d_ptr.header.removeAt(col);
+        d_ptr.header_tt.removeAt(col);
+    }
     emit endRemoveColumns();
     return true;
 }
--- a/src/metadataview.cpp	Tue Jun 16 16:08:05 2015 +0200
+++ b/src/metadataview.cpp	Thu Jun 18 17:48:28 2015 +0200
@@ -109,6 +109,7 @@
         qDebug() << "Failed to find displayDate column: " << displayDate;
         mDateColIdx = DATE_COLUMN_FALLBACK_IDX;
     }
+    setupHeaderTooltips();
     return QString();
 }
 
@@ -249,3 +250,16 @@
         }
     }
 }
+
+void MetaDataView::setupHeaderTooltips() {
+    QSettings settings;
+    settings.beginGroup(TOOLTIP_CONFIG_GROUP);
+    for (int i=0; i < mSortModel->columnCount(); i++) {
+        QString entry = mSortModel->headerData(i, Qt::Horizontal).toString();
+        QString toolTip = settings.value(entry).toString();
+        settings.setValue(entry, toolTip);
+        if (!mSortModel->setHeaderData(i, Qt::Horizontal, toolTip, Qt::ToolTipRole)) {
+            qDebug() << "Failed to set header data";
+        }
+    }
+}
--- a/src/metadataview.h	Tue Jun 16 16:08:05 2015 +0200
+++ b/src/metadataview.h	Thu Jun 18 17:48:28 2015 +0200
@@ -55,6 +55,9 @@
     /** @brief the data has been changed. Could be filter. */
     void dataChanged();
 
+    /** @brief load the configured header tooltips */
+    void setupHeaderTooltips();
+
 public slots:
     /** @brief selects the next row and emits a selection changed signal */
     void selectNextRow();
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)