Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-31103

QFileSystemModel need to better case insensitivity support

    XMLWordPrintable

Details

    Description

      Currently QFileSystemModel assumes all paths are properly capitalized as they are in the file system. If incorrectly capitalized path is given, duplicate nodes will result in QFileSystemModel.

      #include <QApplication>
      #include <QFileSystemModel>
      #include <QListView>
      #include <QHBoxLayout>
      #include <QDir>
      #include <QDebug>
      #include <QTimer>
      
      class Widget : public QWidget
      {
          Q_OBJECT
      
      public:
          Widget()
              :fileModel(new QFileSystemModel),fileView(new QListView)
          {
              QFile fileForTest("AaaBbbCcc.Dat");
              fileForTest.open(QFile::WriteOnly);
              fileForTest.close();
      
              fileModel->setRootPath(QDir::currentPath());
              fileView->setModel(fileModel);
              fileView->setRootIndex(fileModel->index(QDir::currentPath()));
      
              QHBoxLayout *box = new QHBoxLayout(this);
              box->addWidget(fileView);
      
              QTimer::singleShot(100, this, SLOT(output()));
          }
      
      private slots:
          void output()
          {
              int idx0 = fileModel->index("AaaBbbCcc.Dat").row();
              int idx1 = fileModel->index("aaabbbccc.dat").row();
              int idx2 = fileModel->index("AAABBBCCC.DAT").row();
      
              qDebug()<<idx0<<idx1<<idx2;
          }
      
      private:
          QFileSystemModel *fileModel;
          QListView *fileView;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          w.show();
          
          return a.exec();
      }
      
      #include "main.moc"
      
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              dbzhang800 debao zhang
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes