AAAAAAA
This commit is contained in:
parent
c4c82988ca
commit
c02fc1fd36
2 changed files with 18 additions and 2 deletions
|
@ -44,6 +44,16 @@ int HistoryModel::columnCount(const QModelIndex &parent) const
|
|||
return 11;
|
||||
}
|
||||
|
||||
void replaceAll(std::string& str, const std::string& from, const std::string& to) {
|
||||
if(from.empty())
|
||||
return;
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
|
||||
str.replace(start_pos, from.length(), to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
}
|
||||
|
||||
QVariant HistoryModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(history_mutex);
|
||||
|
@ -88,13 +98,17 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
|
|||
return QString::fromStdString(getRequestHeader(item));
|
||||
}
|
||||
case 8:{
|
||||
return QString::fromStdString(item.request_content);
|
||||
std::string tmp = item.request_content;
|
||||
replaceAll(tmp, "\\n", "\n");
|
||||
return QString::fromStdString(tmp);
|
||||
}
|
||||
case 9:{
|
||||
return QString::fromStdString(getResponseHeader(item));
|
||||
}
|
||||
case 10:{
|
||||
return QString::fromStdString(item.response_content);
|
||||
std::string tmp = item.response_content;
|
||||
replaceAll(tmp, "\\n", "\n");
|
||||
return QString::fromStdString(tmp);
|
||||
}
|
||||
}
|
||||
throw std::out_of_range("history model col");
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <filesystem>
|
||||
#include <QDebug>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
|
Loading…
Reference in a new issue