| 33 | using namespace dpfservice; |
| 34 | |
| 35 | QJsonArray parseFile(QStringList files) |
| 36 | { |
| 37 | QJsonArray result; |
| 38 | auto editorSrv = dpfGetService(EditorService); |
| 39 | |
| 40 | for (auto file : files) { |
| 41 | QJsonObject obj; |
| 42 | obj["name"] = QFileInfo(file).fileName(); |
| 43 | obj["language"] = support_file::Language::id(file); |
| 44 | |
| 45 | QString fileContent = editorSrv->fileText(file); |
| 46 | |
| 47 | if (fileContent.isEmpty()) { |
| 48 | QFile content(file); |
| 49 | if (content.open(QIODevice::ReadOnly)) { |
| 50 | obj["content"] = QString(content.read(20000)); |
| 51 | } |
| 52 | } else { |
| 53 | obj["content"] = QString(fileContent.mid(0, 20000)); |
| 54 | } |
| 55 | result.append(obj); |
| 56 | } |
| 57 | |
| 58 | return result; |
| 59 | } |
| 60 | |
| 61 | ChatManager *ChatManager::instance() |
| 62 | { |