title: How to override (re-implement) a member function in QFileSystemModel
body: <p>I've been struggling with this for a while.</p>
  
  <p>Qt's <code>QFileSystemModel</code> is really slow when fetching several hundred files because of a really bad icon fetching algorithm.</p>
  
  <p>I want to completely disable icons. They are fetched in <code>QFileSystemModel::data</code> method which is not virtual (the source of QFileSystemModel is available here: <a href="http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/dialogs/qfilesystemmodel.cpp" rel="nofollow">http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/dialogs/qfilesystemmodel.cpp</a>)</p>
  
  <p>This is the code I'm trying to run:</p>
  
  <pre><code>class FileModel : public QFileSystemModel {
      using QFileSystemModel::data;
  public:
      QVariant QFileSystemModel::data(const QModelIndex &amp;index, int role) const
      {
       // my own implementation here
      }
  }
  </code></pre>
  
  <p>but it fails with</p>
  
  <p><code>cannot define member function QFileSystemModel::data witin FileModel</code></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've managed to override the function and this is what I have now:</p>
  
  <pre><code>class FileModel : public QFileSystemModel {
  public:
      QVariant data(const QModelIndex &amp;index, int role) const
      {
      // Here goes Qt's implementation
      Q_D(const QFileSystemModel);
      if (!index.isValid() || index.model() != this)
          return QVariant();
      switch (role) {
      case Qt::EditRole:
      case Qt::DisplayRole:
          switch (index.column()) {
          case 0: return d-&gt;name(index);
          case 1: return d-&gt;size(index);
          case 2: return d-&gt;type(index);
          case 3: return d-&gt;time(index);
          default:
              qWarning("data: invalid display value column %d", index.column());
              break;
          }
          break;
      case FilePathRole:
          return filePath(index);
      case FileNameRole:
          return d-&gt;name(index);
      case Qt::DecorationRole:
          if (index.column() == 0) {
              QIcon icon = d-&gt;icon(index); // This is the part I need to change
              if (icon.isNull()) {
                  if (d-&gt;node(index)-&gt;isDir())
                      icon = d-&gt;fileInfoGatherer.iconProvider()-&gt;icon(QFileIconProvider::Folder);
                  else
                      icon = d-&gt;fileInfoGatherer.iconProvider()-&gt;icon(QFileIconProvider::File);
              }
              return icon;
          }
          break;
      case Qt::TextAlignmentRole:
          if (index.column() == 1)
              return Qt::AlignRight;
          break;
      case FilePermissions:
          int p = permissions(index);
          return p;
      }
      return QVariant();
  }
  };
  </code></pre>
  
  <p>However this code doesn't compile. This is the error I get:
  <code>'const QFileSystemModelPrivate* QFileSystemModel::d_func() const' is private</code></p>