Skip to content
Snippets Groups Projects
Commit 3607ad17 authored by dt's avatar dt
Browse files

Fix opening files from search results didn't get the correct encoding.

Patch based on the analysis by Grigory Zagorodnev.

Task-number: 253974
parent 90a5f271
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <cctype> #include <cctype>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtCore/QFutureInterface> #include <QtCore/QFutureInterface>
#include <QtCore/QtConcurrentRun> #include <QtCore/QtConcurrentRun>
#include <QtCore/QRegExp> #include <QtCore/QRegExp>
...@@ -158,7 +157,7 @@ void runFileSearch(QFutureInterface<FileSearchResult> &future, ...@@ -158,7 +157,7 @@ void runFileSearch(QFutureInterface<FileSearchResult> &future,
int n = 0; int n = 0;
while (startOfLastLine[i] != '\n' && startOfLastLine[i] != '\r' && i < textLength && n++ < 256) while (startOfLastLine[i] != '\n' && startOfLastLine[i] != '\r' && i < textLength && n++ < 256)
res.append(startOfLastLine[i++]); res.append(startOfLastLine[i++]);
future.reportResult(FileSearchResult(QDir::toNativeSeparators(s), lineNr, QString(res), future.reportResult(FileSearchResult(s, lineNr, QString(res),
regionPtr - startOfLastLine, sa.length())); regionPtr - startOfLastLine, sa.length()));
++numMatches; ++numMatches;
} }
...@@ -204,7 +203,7 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResult> &future, ...@@ -204,7 +203,7 @@ void runFileSearchRegExp(QFutureInterface<FileSearchResult> &future,
line = stream.readLine(); line = stream.readLine();
int pos = 0; int pos = 0;
while ((pos = expression.indexIn(line, pos)) != -1) { while ((pos = expression.indexIn(line, pos)) != -1) {
future.reportResult(FileSearchResult(QDir::toNativeSeparators(s), lineNr, line, future.reportResult(FileSearchResult(s, lineNr, line,
pos, expression.matchedLength())); pos, expression.matchedLength()));
pos += expression.matchedLength(); pos += expression.matchedLength();
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <QtGui/QFont> #include <QtGui/QFont>
#include <QtGui/QColor> #include <QtGui/QColor>
#include <QtCore/QDir>
using namespace Find::Internal; using namespace Find::Internal;
...@@ -187,7 +188,7 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con ...@@ -187,7 +188,7 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
result = QColor(qRgb(245, 245, 245)); result = QColor(qRgb(245, 245, 245));
break; break;
case Qt::DisplayRole: case Qt::DisplayRole:
result = QString(file->fileName() result = QString(QDir::toNativeSeparators(file->fileName())
+ " (" + QString::number(file->childrenCount()) + ")"); + " (" + QString::number(file->childrenCount()) + ")");
break; break;
case ItemDataRoles::FileNameRole: case ItemDataRoles::FileNameRole:
......
...@@ -153,6 +153,7 @@ void SearchResultWindow::handleJumpToSearchResult(int index, const QString &file ...@@ -153,6 +153,7 @@ void SearchResultWindow::handleJumpToSearchResult(int index, const QString &file
ResultWindowItem *SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText, ResultWindowItem *SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength) int searchTermStart, int searchTermLength)
{ {
qDebug()<<"###"<<fileName;
m_widget->setCurrentWidget(m_searchResultTreeView); m_widget->setCurrentWidget(m_searchResultTreeView);
int index = m_items.size(); int index = m_items.size();
ResultWindowItem *item = new ResultWindowItem; ResultWindowItem *item = new ResultWindowItem;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment