title: Convert data from QSqlTableModel to human form in QTableView (enum -> String)
body: <p>I'm using a QSqlTableModel to get the data from the required table, and I'm rendering it in the GUI using QTableView. 
  The problem that I have now is that I want to change different fields (convert them) from the existing value to another one (enum -> String).
  For example an existing value of 1 should be displaied as ERROR in the column of QTableView.</p>
  
  <p>My understanding (correct me if I'm wrong) is that I should use delegates. </p>
  
  <p><code>backupTableView-&gt;setItemDelegateForColumn(4, new StatusFormatDelegate());</code></p>
  
  <p>Column that should be changed in this case is #4.</p>
  
  <p>Is there another way to implement this and in both cases (yes/no) could I get an example?</p>
  
  <p>P.S. The data shouldn't be editable.</p>
  
  <p>Until now the StatusFormatDelegate should be something like this: </p>
  
  <pre><code>class StatusFormatDelegate : public QStyledItemDelegate
  {
  public:
      StatusFormatDelegate (quint64 dataFromQTableView, QObject *parent = 0) :
    QStyledItemDelegate(parent),
    columnData_(dataFromQTableView)
   {
   }
  
   virtual QString displayText(const QVariant &amp; value, const QLocale &amp; locale ) const
   {
    Q_UNUSED(locale);
    switch(columnData_){
    case JobStatus_Failed:        return "Failed";
    case JobStatus_Finished:      return "Finished";
    case JobStatus_InProgress:    return "In progress";
    case JobStatus_NotStarted:    return "Not started";
    default:                      return "Unknown type";
    }
   }
  
  private:
   quint64 columnData_;
  
  };
  </code></pre>
  
  <p>This is the method that creates the Model -> View </p>
  
  <pre><code>void TransferHistory::fillBackUpPageFromDb()
  {
      connectToDb();
      QSqlTableModel *model = new QSqlTableModel(this, db);
      model-&gt;setTable("backup_history");
      model-&gt;setEditStrategy(QSqlTableModel::OnManualSubmit);
      model-&gt;select();
      model-&gt;setHeaderData(0, Qt::Horizontal, tr("Id"));
      model-&gt;setHeaderData(1, Qt::Horizontal, tr("File"));
      model-&gt;setHeaderData(2, Qt::Horizontal, tr("Size"));
      model-&gt;setHeaderData(3, Qt::Horizontal, tr("Back-up Time"));
      model-&gt;setHeaderData(4, Qt::Horizontal, tr("Status"));
  
      ui-&gt;backupTableView = new QTableView(this-&gt;ui-&gt;tabWidget-&gt;currentWidget());
      ui-&gt;backupTableView-&gt;setModel(model);
      ui-&gt;backupTableView-&gt;hideColumn(0);
      ui-&gt;backupTableView-&gt;setShowGrid(false);
      ui-&gt;backupTableView-&gt;setSortingEnabled(true);
      int width = ui-&gt;tabWidget-&gt;currentWidget()-&gt;width();
      ui-&gt;backupTableView-&gt;setFixedSize(ui-&gt;tabWidget-&gt;currentWidget()-&gt;size());
  
      **ui-&gt;backupTableView-&gt;setItemDelegateForColumn(4, new StatusFormatDelegate(someData, this));**
      ui-&gt;backupTableView-&gt;setColumnWidth(1, static_cast&lt;int&gt;(FILECOLUMNWIDTH_PERCENT * width));
      ui-&gt;backupTableView-&gt;setColumnWidth(2, static_cast&lt;int&gt;(SIZECOLUMNWIDTH_PERCENT * width));
      ui-&gt;backupTableView-&gt;setColumnWidth(3, static_cast&lt;int&gt;(TIMECOLUMN_PERCENT * width));
      ui-&gt;backupTableView-&gt;setColumnWidth(4, static_cast&lt;int&gt;(STATUSCOLUMN_PERCENT * width) - qApp-&gt;style()-&gt;pixelMetric(QStyle::PM_ScrollBarExtent) - 2);
      ui-&gt;backupTableView-&gt;show();
  }
  </code></pre>