examples/assistant/simpletextviewer/findfiledialog.cpp
branchRCL_3
changeset 5 d3bac044e0f0
parent 4 3b1da2848fc7
equal deleted inserted replaced
4:3b1da2848fc7 5:d3bac044e0f0
   100 
   100 
   101     QFile file(path + fileName);
   101     QFile file(path + fileName);
   102     if (file.open(QIODevice::ReadOnly)) {
   102     if (file.open(QIODevice::ReadOnly)) {
   103         QString data(file.readAll());
   103         QString data(file.readAll());
   104 
   104 
   105         if (fileName.endsWith(".html"))
   105         if (fileName.endsWith(QLatin1String(".html")))
   106             currentEditor->setHtml(data);
   106             currentEditor->setHtml(data);
   107         else
   107         else
   108             currentEditor->setPlainText(data);
   108             currentEditor->setPlainText(data);
   109     }
   109     }
   110     close();
   110     close();
   117             foundFilesTree->topLevelItemCount() > 0);
   117             foundFilesTree->topLevelItemCount() > 0);
   118 }
   118 }
   119 
   119 
   120 void FindFileDialog::findFiles()
   120 void FindFileDialog::findFiles()
   121 {
   121 {
   122     QRegExp filePattern(fileNameComboBox->currentText() + "*");
   122     QRegExp filePattern(fileNameComboBox->currentText() + '*');
   123     filePattern.setPatternSyntax(QRegExp::Wildcard);
   123     filePattern.setPatternSyntax(QRegExp::Wildcard);
   124 
   124 
   125     QDir directory(directoryComboBox->currentText());
   125     QDir directory(directoryComboBox->currentText());
   126 
   126 
   127     QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks);
   127     QStringList allFiles = directory.entryList(QDir::Files | QDir::NoSymLinks);
   128     QStringList matchingFiles;
   128     QStringList matchingFiles;
   129 
   129 
   130     foreach (QString file, allFiles) {
   130     foreach (const QString &file, allFiles) {
   131         if (filePattern.exactMatch(file))
   131         if (filePattern.exactMatch(file))
   132             matchingFiles << file;
   132             matchingFiles << file;
   133     }
   133     }
   134     showFiles(matchingFiles);
   134     showFiles(matchingFiles);
   135 }
   135 }