用户信息增加到信息输出栏
This commit is contained in:
parent
e196860206
commit
ff9fe1fc90
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -90,7 +90,9 @@
|
||||
"qcombobox": "cpp",
|
||||
"qlistwidget": "cpp",
|
||||
"qgroupbox": "cpp",
|
||||
"unordered_set": "cpp"
|
||||
"unordered_set": "cpp",
|
||||
"csignal": "cpp",
|
||||
"set": "cpp"
|
||||
},
|
||||
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition",
|
||||
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition",
|
||||
|
||||
Binary file not shown.
117
build/.ninja_log
117
build/.ninja_log
@ -3,69 +3,76 @@
|
||||
7467 11761 7625226031231442 CMakeFiles/ctai.dir/src/ctai_parsestring.cpp.obj a7b9c7c27f09d2d2
|
||||
7460 13107 7625226031167985 CMakeFiles/ctai.dir/src/ctai_cmd.cpp.obj 9283b8e99a8aaac0
|
||||
7478 12469 7625226031344445 CMakeFiles/ctai.dir/src/ctai_tabbar.cpp.obj 35441b03d6ed42c6
|
||||
5039 48093 7625236696832670 CMakeFiles/ctai.dir/ctai_autogen/mocs_compilation.cpp.obj e347e488b3f7bdf
|
||||
4946 49440 7625378283810995 CMakeFiles/ctai.dir/ctai_autogen/mocs_compilation.cpp.obj e347e488b3f7bdf
|
||||
17 271 7624406980833829 qrc_res.cpp 9794859fafc6825
|
||||
11761 27811 7625226074178138 CMakeFiles/ctai.dir/src/sui.cpp.obj 62600b24a26e62c1
|
||||
17 5039 7625236695790442 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
47780 60064 7625229535004130 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
20 4945 7625378282638606 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
49440 59749 7625378728738772 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
7096 13484 7624392729149768 CMakeFiles/ctai.dir/src/ctai_session_table.cpp.obj 5bacfc2db149ebf7
|
||||
17 5039 7625236695790442 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
7462 41186 7625226031186496 CMakeFiles/ctai.dir/src/ctai_curl.cpp.obj fcfee72ebd436b69
|
||||
17 5039 7625236695790442 ctai_autogen/timestamp da3870ebc94b983e
|
||||
5043 36859 7625236696870189 CMakeFiles/ctai.dir/src/ctai_msg_table.cpp.obj d5f943362cb1824b
|
||||
20 4945 7625378282638606 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
5460 32424 7625338166333098 CMakeFiles/ctai.dir/src/ctai_curl.cpp.obj fcfee72ebd436b69
|
||||
20 4945 7625378282638606 ctai_autogen/timestamp da3870ebc94b983e
|
||||
4950 38657 7625378283838423 CMakeFiles/ctai.dir/src/ctai_msg_table.cpp.obj d5f943362cb1824b
|
||||
12469 38682 7625226081243748 CMakeFiles/ctai.dir/src/sui_base_ex.cpp.obj 1394551dd9df8e22
|
||||
12954 29954 7625226086103060 CMakeFiles/ctai.dir/src/sui_title.cpp.obj b2aaa7db0ee20801
|
||||
5045 42353 7625236696895233 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
5041 46362 7625236696852657 CMakeFiles/ctai.dir/src/ctai.cpp.obj 3f2a5605474560c6
|
||||
4952 43759 7625378283865971 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
4948 47704 7625378283828389 CMakeFiles/ctai.dir/src/ctai.cpp.obj 3f2a5605474560c6
|
||||
7476 12546 7625226031323242 CMakeFiles/ctai.dir/src/ctai_switch_control.cpp.obj a4bdc9e7afd693e6
|
||||
13107 19557 7625226087623377 CMakeFiles/ctai.dir/qrc_res.cpp.obj e5933d51f0b4b61f
|
||||
5049 40863 7625236696932380 CMakeFiles/ctai.dir/src/ctai_tabwidget.cpp.obj 30048396fe45a344
|
||||
4957 42522 7625378283900796 CMakeFiles/ctai.dir/src/ctai_tabwidget.cpp.obj 30048396fe45a344
|
||||
18489 19694 7625226141459392 CMakeFiles/ctai.dir/sui.rc.obj ba94315dae7b8c27
|
||||
267 47779 7625229059864899 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
4959 38241 7625378283938220 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
7092 13031 7624392729099354 CMakeFiles/ctai.dir/src/ctai_session_docker.cpp.obj 215fc89727d9e8c1
|
||||
17 5039 7625236695790442 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
20 4945 7625378282638606 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
17 271 7624406980833829 F:/SourceCode/ctai/build/qrc_res.cpp 9794859fafc6825
|
||||
12546 18489 7625226082021822 CMakeFiles/ctai.dir/src/sui_sys_style.cpp.obj 1472cbef2eb3486
|
||||
5047 41913 7625236696914321 CMakeFiles/ctai.dir/src/ctai_session_widget.cpp.obj 8c93ec888621ab29
|
||||
5054 42263 7625236696990526 CMakeFiles/ctai.dir/src/main.cpp.obj 92e0a8f8e94288b6
|
||||
19 243 7625238334384495 ctai_autogen/timestamp da3870ebc94b983e
|
||||
19 243 7625238334384495 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
19 243 7625238334384495 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
19 243 7625238334384495 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
25 268 7625238636381415 ctai_autogen/timestamp da3870ebc94b983e
|
||||
25 268 7625238636381415 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
25 268 7625238636381415 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
25 268 7625238636381415 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
268 52239 7625238638811110 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
52239 65499 7625239158528151 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
21 284 7625240528911197 ctai_autogen/timestamp da3870ebc94b983e
|
||||
21 284 7625240528911197 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
21 284 7625240528911197 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
21 284 7625240528911197 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
284 25431 7625240531541103 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
25431 36666 7625240782993337 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
18 4862 7625244517455825 ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4862 7625244517455825 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
18 4862 7625244517455825 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4862 7625244517455825 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
4876 37403 7625244518730194 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
4867 37745 7625244518645165 CMakeFiles/ctai.dir/src/ctai_msg_table.cpp.obj d5f943362cb1824b
|
||||
4873 41738 7625244518710181 CMakeFiles/ctai.dir/src/ctai_tabwidget.cpp.obj 30048396fe45a344
|
||||
4871 42421 7625244518685144 CMakeFiles/ctai.dir/src/ctai_session_widget.cpp.obj 8c93ec888621ab29
|
||||
4869 42684 7625244518665143 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
4878 42852 7625244518755266 CMakeFiles/ctai.dir/src/main.cpp.obj 92e0a8f8e94288b6
|
||||
4865 46613 7625244518612432 CMakeFiles/ctai.dir/src/ctai.cpp.obj 3f2a5605474560c6
|
||||
4862 48452 7625244518594862 CMakeFiles/ctai.dir/ctai_autogen/mocs_compilation.cpp.obj e347e488b3f7bdf
|
||||
48452 59576 7625244954495870 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
23 298 7625245093754714 ctai_autogen/timestamp da3870ebc94b983e
|
||||
23 298 7625245093754714 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
23 298 7625245093754714 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
23 298 7625245093754714 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
298 26111 7625245096514071 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
26111 38025 7625245354643839 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
18 296 7625246620511726 ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 296 7625246620511726 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
18 296 7625246620511726 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 296 7625246620511726 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
296 24823 7625246623296309 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
24823 35792 7625246868564322 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
4955 43280 7625378283883401 CMakeFiles/ctai.dir/src/ctai_session_widget.cpp.obj 8c93ec888621ab29
|
||||
4961 43917 7625378283955768 CMakeFiles/ctai.dir/src/main.cpp.obj 92e0a8f8e94288b6
|
||||
22 247 7625378934980250 ctai_autogen/timestamp da3870ebc94b983e
|
||||
22 247 7625378934980250 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
22 247 7625378934980250 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
22 247 7625378934980250 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
248 26467 7625378937238432 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
26467 38691 7625379199441832 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
18 4859 7625384309120525 ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4859 7625384309120525 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
18 4859 7625384309120525 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4859 7625384309120525 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
21 253 7625384559896174 ctai_autogen/timestamp da3870ebc94b983e
|
||||
21 253 7625384559896174 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
21 253 7625384559896174 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
21 253 7625384559896174 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
268 33711 7625384562362325 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
258 34023 7625384562261333 CMakeFiles/ctai.dir/src/ctai_msg_table.cpp.obj d5f943362cb1824b
|
||||
265 38212 7625384562342155 CMakeFiles/ctai.dir/src/ctai_tabwidget.cpp.obj 30048396fe45a344
|
||||
263 38714 7625384562306750 CMakeFiles/ctai.dir/src/ctai_session_widget.cpp.obj 8c93ec888621ab29
|
||||
260 39076 7625384562278729 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
270 39408 7625384562382335 CMakeFiles/ctai.dir/src/main.cpp.obj 92e0a8f8e94288b6
|
||||
256 43108 7625384562243819 CMakeFiles/ctai.dir/src/ctai.cpp.obj 3f2a5605474560c6
|
||||
253 44565 7625384562215196 CMakeFiles/ctai.dir/ctai_autogen/mocs_compilation.cpp.obj e347e488b3f7bdf
|
||||
44565 54974 7625385005334711 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
18 4822 7625386887650474 ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4822 7625386887650474 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
18 4822 7625386887650474 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
18 4822 7625386887650474 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
4840 38760 7625386888978158 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
4828 38780 7625386888855579 CMakeFiles/ctai.dir/src/ctai_msg_table.cpp.obj d5f943362cb1824b
|
||||
4838 42493 7625386888943188 CMakeFiles/ctai.dir/src/ctai_tabwidget.cpp.obj 30048396fe45a344
|
||||
4834 43192 7625386888903484 CMakeFiles/ctai.dir/src/ctai_session_widget.cpp.obj 8c93ec888621ab29
|
||||
4843 43655 7625386888995558 CMakeFiles/ctai.dir/src/main.cpp.obj 92e0a8f8e94288b6
|
||||
4831 43821 7625386888877578 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
4826 47499 7625386888830311 CMakeFiles/ctai.dir/src/ctai.cpp.obj 3f2a5605474560c6
|
||||
4823 49541 7625386888805425 CMakeFiles/ctai.dir/ctai_autogen/mocs_compilation.cpp.obj e347e488b3f7bdf
|
||||
49541 71958 7625387335982102 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
26 274 7625390610564331 ctai_autogen/timestamp da3870ebc94b983e
|
||||
26 274 7625390610564331 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
26 274 7625390610564331 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
26 274 7625390610564331 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
275 26936 7625390613063576 CMakeFiles/ctai.dir/src/ctai_textedit.cpp.obj 10751092db60a69f
|
||||
19 10901 7625390964476538 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
31 295 7625393475094109 ctai_autogen/timestamp da3870ebc94b983e
|
||||
31 295 7625393475094109 ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
31 295 7625393475094109 F:/SourceCode/ctai/build/ctai_autogen/timestamp da3870ebc94b983e
|
||||
31 295 7625393475094109 F:/SourceCode/ctai/build/ctai_autogen/mocs_compilation.cpp da3870ebc94b983e
|
||||
295 28029 7625393477732797 CMakeFiles/ctai.dir/src/ctai_session_info.cpp.obj 10a736dff755075d
|
||||
28029 39977 7625393755065579 F:/SourceCode/ctai/release/ctai.exe b586bbd8722aa11a
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
release/ctai.exe
BIN
release/ctai.exe
Binary file not shown.
@ -12,6 +12,11 @@
|
||||
#define QSN(str) (QString::number)(str)
|
||||
#endif
|
||||
|
||||
typedef enum msg_mode{
|
||||
SYSTEM,
|
||||
USER
|
||||
}msg_type;
|
||||
|
||||
typedef struct curl_opts
|
||||
{
|
||||
bool ssl_state = true;
|
||||
@ -31,7 +36,12 @@ typedef struct model_data{
|
||||
std::string send_content_header = "Content-Type: application/json";
|
||||
std::string send_accept_header = "Accept: application/json";
|
||||
std::string send_user_data;
|
||||
std::string postback_model_data;
|
||||
std::string send_user_time;
|
||||
std::string send_user_id;
|
||||
std::string send_user_ico;
|
||||
std::string postback_model_data;
|
||||
msg_type msg_type_mode;
|
||||
std::string send_system_ico;
|
||||
bool postback_stream_mode = false;
|
||||
std::string postback_time;
|
||||
std::string postback_server_model;
|
||||
|
||||
@ -5,7 +5,6 @@ ctai_msg_table::ctai_msg_table(QWidget *parent)
|
||||
{
|
||||
setSpacing(1);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
connect(this, &QListWidget::itemClicked, this, &ctai_msg_table::on_item_clicked);
|
||||
}
|
||||
|
||||
ctai_msg_table::~ctai_msg_table()
|
||||
@ -19,11 +18,17 @@ ctai_msg_table::~ctai_msg_table()
|
||||
|
||||
void ctai_msg_table::add_message(const model_data &message)
|
||||
{
|
||||
QString send_id = QSL(message.postback_send_id);
|
||||
QString send_id;
|
||||
if(message.msg_type_mode==SYSTEM)
|
||||
{
|
||||
send_id= QSL(message.postback_send_id);
|
||||
|
||||
}else{
|
||||
send_id= QSL(message.send_user_id);
|
||||
}
|
||||
// 检查是否存在相同send_id的消息
|
||||
auto it = message_map_.find(send_id);
|
||||
if (it != message_map_.end())
|
||||
if (it != message_map_.end()&& it->second.first->msg_type_mode==SYSTEM)
|
||||
{
|
||||
// 存在相同send_id,追加内容
|
||||
model_data *stored_data = it->second.first;
|
||||
@ -48,11 +53,10 @@ void ctai_msg_table::add_message(const model_data &message)
|
||||
{
|
||||
// 新消息
|
||||
model_data *new_data = new model_data(message);
|
||||
|
||||
|
||||
// 创建新的消息显示widget
|
||||
ctai_textedit *message_widget = new ctai_textedit();
|
||||
ctai_textedit *message_widget = new ctai_textedit(new_data->msg_type_mode);
|
||||
message_widget->add_message(*new_data);
|
||||
|
||||
// 创建并添加到列表
|
||||
QListWidgetItem *item = create_message_item(message_widget);
|
||||
addItem(item);
|
||||
@ -127,18 +131,6 @@ QListWidgetItem *ctai_msg_table::create_message_item(ctai_textedit *message_widg
|
||||
return item;
|
||||
}
|
||||
|
||||
void ctai_msg_table::on_item_clicked(QListWidgetItem *item)
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
ctai_textedit *message_widget = qobject_cast<ctai_textedit *>(itemWidget(item));
|
||||
if (message_widget)
|
||||
{
|
||||
// 可以在这里处理消息被点击的事件
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctai_textedit *ctai_msg_table::current_message() const
|
||||
{
|
||||
QListWidgetItem *current_item = currentItem();
|
||||
|
||||
@ -21,10 +21,6 @@ public:
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_item_clicked(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
// 存储消息的map
|
||||
std::map<QString, std::pair<model_data*, QListWidgetItem*>> message_map_;
|
||||
|
||||
@ -8,6 +8,7 @@ ctai_session_info::ctai_session_info()
|
||||
}
|
||||
ctai_session_info::~ctai_session_info()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ctai_session_info::init_layout()
|
||||
@ -147,7 +148,7 @@ void ctai_session_info::ctai_session_set_steam_mode(bool state)
|
||||
{
|
||||
qDebug() << "steam mode:" << state;
|
||||
m_stream_switch->setToggle(state);
|
||||
user_model_data.postback_stream_mode = state;
|
||||
m_stream_mode=state;
|
||||
}
|
||||
void ctai_session_info::ctai_session_user_sending()
|
||||
{
|
||||
@ -158,11 +159,19 @@ void ctai_session_info::ctai_session_user_sending()
|
||||
}
|
||||
else
|
||||
{
|
||||
user_model_data.msg_type_mode = USER;
|
||||
user_model_data.send_user_id=QUuid::createUuid().toString(QUuid::WithoutBraces).toStdString();
|
||||
user_model_data.send_user_data=m_session_user_edit_info->toPlainText().toStdString();
|
||||
user_model_data.send_user_time=(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz")).toStdString();
|
||||
m_session_systeam_info->add_message(user_model_data);
|
||||
QFuture<void> future = QtConcurrent::run([=]()
|
||||
{
|
||||
user_model_data.send_user_data=m_session_user_edit_info->toPlainText().toStdString();
|
||||
m_curl->send_post_response(user_model_data,curl_opt); });
|
||||
user_model_data.msg_type_mode = SYSTEM;
|
||||
user_model_data.postback_stream_mode=m_stream_mode;
|
||||
m_curl->send_post_response(user_model_data,curl_opt);
|
||||
});
|
||||
btn_disable_enable(false);
|
||||
m_session_user_edit_info->clear();
|
||||
ctai_session_curl_state_tips("正在获取结果...");
|
||||
}
|
||||
}
|
||||
@ -72,6 +72,7 @@ private:
|
||||
model_data user_model_data;
|
||||
curl_opts curl_opt;
|
||||
std::string current_info_time;
|
||||
bool m_stream_mode = false;
|
||||
private slots:
|
||||
void ctai_session_user_sending();
|
||||
void ctai_session_postback_info(model_data resp_data);
|
||||
|
||||
@ -1,109 +1,113 @@
|
||||
#include "ctai_textedit.h"
|
||||
|
||||
ctai_textedit::ctai_textedit()
|
||||
ctai_textedit::ctai_textedit(msg_type msg_type_mode)
|
||||
{
|
||||
init_layout();
|
||||
connect_signals();
|
||||
init_layout(msg_type_mode);
|
||||
}
|
||||
ctai_textedit::~ctai_textedit()
|
||||
{
|
||||
}
|
||||
void ctai_textedit::init_layout()
|
||||
void ctai_textedit::init_layout(msg_type msg_type_mode)
|
||||
{
|
||||
// 主垂直布局
|
||||
mainLayout = new QVBoxLayout();
|
||||
// 1. 消息头垂直
|
||||
headerLayout = new QVBoxLayout();
|
||||
//消息头水平
|
||||
header_info_Layout=new QHBoxLayout();
|
||||
// 消息头水平
|
||||
header_info_Layout = new QHBoxLayout();
|
||||
m_msg_header_ico = new QPushButton();
|
||||
m_msg_header_ico->setObjectName("m_msg_header_ico");
|
||||
m_msg_header = new QLineEdit();
|
||||
m_msg_header->setObjectName("text_msg_header");
|
||||
m_msg_header->setReadOnly(true);
|
||||
m_msg_header->setReadOnly(true);
|
||||
header_info_Layout->addWidget(m_msg_header_ico);
|
||||
header_info_Layout->addWidget(m_msg_header);
|
||||
header_info_Layout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->addLayout(header_info_Layout);
|
||||
|
||||
// 2. Tokens显示区
|
||||
tokenLayout = new QHBoxLayout();
|
||||
m_msg_tokens = new QLineEdit();
|
||||
m_msg_tokens->setAlignment(Qt::AlignCenter);
|
||||
m_msg_tokens->setObjectName("text_msg_tokens");
|
||||
m_msg_tokens->setReadOnly(true);
|
||||
tokenLayout->addWidget(m_msg_tokens);
|
||||
tokenLayout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->addLayout(tokenLayout);
|
||||
// 3.消息功能区
|
||||
header_opts_Layout=new QHBoxLayout();
|
||||
m_msg_del= new QPushButton();
|
||||
m_msg_copy= new QPushButton();
|
||||
m_msg_save = new QPushButton();
|
||||
m_msg_menu = new QPushButton();
|
||||
m_msg_fold = new QPushButton();
|
||||
m_msg_del->setObjectName("m_msg_del");
|
||||
m_msg_copy->setObjectName("m_msg_copy");
|
||||
m_msg_save->setObjectName("m_msg_save");
|
||||
m_msg_menu->setObjectName("m_msg_menu");
|
||||
m_msg_fold->setObjectName("m_msg_fold");
|
||||
m_msg_fold->setIcon(QIcon(":res/img/btn/btn_info_up.png"));
|
||||
header_opts_Layout->addItem(sparcer_item);
|
||||
header_opts_Layout->addWidget(m_msg_del);
|
||||
header_opts_Layout->addWidget(m_msg_copy);
|
||||
header_opts_Layout->addWidget(m_msg_save);
|
||||
header_opts_Layout->addWidget(m_msg_menu);
|
||||
header_opts_Layout->addWidget(m_msg_fold);
|
||||
header_opts_Layout->addItem(sparcer_item);
|
||||
header_opts_Layout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->addLayout(header_opts_Layout);
|
||||
// 4.分割线区域
|
||||
QFrame* hLine = new QFrame;
|
||||
hLine->setFrameShape(QFrame::HLine); // 关键属性
|
||||
hLine->setFrameShadow(QFrame::Sunken); // 凹陷效果
|
||||
hLine->setLineWidth(2); // 线宽
|
||||
headerLayout->addWidget(hLine);
|
||||
headerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
if (msg_type_mode == SYSTEM)
|
||||
{
|
||||
// 2. Tokens显示区
|
||||
tokenLayout = new QHBoxLayout();
|
||||
m_msg_tokens = new QLineEdit();
|
||||
m_msg_tokens->setAlignment(Qt::AlignCenter);
|
||||
m_msg_tokens->setObjectName("text_msg_tokens");
|
||||
m_msg_tokens->setReadOnly(true);
|
||||
tokenLayout->addWidget(m_msg_tokens);
|
||||
tokenLayout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->addLayout(tokenLayout);
|
||||
// 3.消息功能区
|
||||
|
||||
header_opts_Layout = new QHBoxLayout();
|
||||
m_msg_del = new QPushButton();
|
||||
m_msg_copy = new QPushButton();
|
||||
m_msg_save = new QPushButton();
|
||||
m_msg_menu = new QPushButton();
|
||||
m_msg_fold = new QPushButton();
|
||||
m_msg_del->setObjectName("m_msg_del");
|
||||
m_msg_copy->setObjectName("m_msg_copy");
|
||||
m_msg_save->setObjectName("m_msg_save");
|
||||
m_msg_menu->setObjectName("m_msg_menu");
|
||||
m_msg_fold->setObjectName("m_msg_fold");
|
||||
m_msg_fold->setIcon(QIcon(":res/img/btn/btn_info_up.png"));
|
||||
header_opts_Layout->addItem(sparcer_item);
|
||||
header_opts_Layout->addWidget(m_msg_del);
|
||||
header_opts_Layout->addWidget(m_msg_copy);
|
||||
header_opts_Layout->addWidget(m_msg_save);
|
||||
header_opts_Layout->addWidget(m_msg_menu);
|
||||
header_opts_Layout->addWidget(m_msg_fold);
|
||||
header_opts_Layout->addItem(sparcer_item);
|
||||
header_opts_Layout->setContentsMargins(0, 0, 0, 0);
|
||||
headerLayout->addLayout(header_opts_Layout);
|
||||
}
|
||||
|
||||
// 4. 历史信息QTextEdit
|
||||
historyLayout=new QVBoxLayout();
|
||||
historyLayout = new QVBoxLayout();
|
||||
m_msg_history = new QTextBrowser(this);
|
||||
m_msg_history->setOpenExternalLinks(true); // 允许打开外部链接
|
||||
m_msg_history->setOpenLinks(true); // 允许打开链接
|
||||
m_msg_history->setOpenExternalLinks(true); // 允许打开外部链接
|
||||
m_msg_history->setOpenLinks(true); // 允许打开链接
|
||||
m_msg_history->setTextInteractionFlags(
|
||||
Qt::TextSelectableByMouse |
|
||||
Qt::TextSelectableByKeyboard |
|
||||
Qt::TextSelectableByMouse |
|
||||
Qt::TextSelectableByKeyboard |
|
||||
Qt::LinksAccessibleByMouse |
|
||||
Qt::LinksAccessibleByKeyboard
|
||||
);
|
||||
Qt::LinksAccessibleByKeyboard);
|
||||
m_msg_history->setObjectName("m_msg_history");
|
||||
m_msg_history->setReadOnly(true);
|
||||
historyLayout->addWidget(m_msg_history);
|
||||
historyLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
|
||||
// 5.分割线区域
|
||||
QFrame *hLine = new QFrame;
|
||||
hLine->setFrameShape(QFrame::HLine); // 关键属性
|
||||
hLine->setFrameShadow(QFrame::Sunken); // 凹陷效果
|
||||
hLine->setLineWidth(2); // 线宽
|
||||
// 设置样式表
|
||||
m_msg_history->setStyleSheet(
|
||||
"QTextBrowser {"
|
||||
" background-color: transparent;"
|
||||
" border: none;"
|
||||
" padding: 5px;"
|
||||
"}"
|
||||
);
|
||||
|
||||
"}");
|
||||
|
||||
// 设置字体
|
||||
QFont font = m_msg_history->font();
|
||||
font.setPointSize(10); // 设置字体大小
|
||||
font.setPointSize(10); // 设置字体大小
|
||||
m_msg_history->setFont(font);
|
||||
|
||||
// 组合布局
|
||||
mainLayout->addLayout(headerLayout);
|
||||
mainLayout->addLayout(historyLayout);
|
||||
mainLayout->addItem(bottom_spacer);
|
||||
mainLayout->addLayout(historyLayout);
|
||||
mainLayout->addItem(bottom_spacer);
|
||||
mainLayout->addWidget(hLine);
|
||||
mainLayout->setStretch(0, 2);
|
||||
mainLayout->setStretch(1, 8);
|
||||
mainLayout->setSpacing(1);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(mainLayout);
|
||||
if (msg_type_mode == SYSTEM)
|
||||
{
|
||||
connect_signals();
|
||||
}
|
||||
}
|
||||
void ctai_textedit::connect_signals()
|
||||
{
|
||||
@ -117,41 +121,61 @@ void ctai_textedit::connect_signals()
|
||||
void ctai_textedit::on_fold_clicked()
|
||||
{
|
||||
m_is_folded = !m_is_folded;
|
||||
|
||||
if (m_is_folded) {
|
||||
|
||||
if (m_is_folded)
|
||||
{
|
||||
m_msg_history->setMaximumHeight(0);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_msg_history->setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
}
|
||||
|
||||
|
||||
// 更新按钮图标
|
||||
m_msg_fold->setIcon(QIcon(m_is_folded ? ":res/img/btn/btn_info_up.png" : ":res/img/btn/btn_info_down.png"));
|
||||
}
|
||||
void ctai_textedit::add_message(const model_data &message)
|
||||
{
|
||||
|
||||
m_s_g_type=message.msg_type_mode;
|
||||
stream_message(message);
|
||||
emit content_height_changed();
|
||||
}
|
||||
int ctai_textedit::get_content_height() const
|
||||
{
|
||||
int _height;
|
||||
// 计算实际需要的总高度
|
||||
int header_height = headerLayout->sizeHint().height();
|
||||
int history_height = m_msg_history->document()->size().height();
|
||||
int token_height = tokenLayout->sizeHint().height();
|
||||
|
||||
// 添加一些边距
|
||||
return header_height + history_height + token_height + mainLayout->spacing() * 2;
|
||||
}void ctai_textedit::stream_message(const model_data &message)
|
||||
if(m_s_g_type==SYSTEM)
|
||||
{
|
||||
int token_height = tokenLayout->sizeHint().height();
|
||||
_height=header_height + history_height + token_height + mainLayout->spacing() * 2;
|
||||
}else{
|
||||
_height=header_height+history_height+mainLayout->spacing()*2;
|
||||
}
|
||||
return _height;
|
||||
}
|
||||
void ctai_textedit::stream_message(const model_data &message)
|
||||
{
|
||||
m_msg_header->setText("ID:" + QSL(message.postback_send_id) + " | FP:" + QSL(message.postback_system_fingerprint) + " | Time" + QSL(message.postback_time));
|
||||
m_msg_tokens->setText("prompt tokens:" + QSN(message.postback_prompt_tokens) +" | "+
|
||||
"completion tokens:" + QSN(message.postback_completion_tokens) +" | "+
|
||||
"total tokens:" + QSN(message.postback_total_tokens) +" | "+
|
||||
"prompt cache hit tokens:" + QSN(message.postback_prompt_cache_hit_tokens) +" | "+
|
||||
"prompt cache miss tokens:" + QSN(message.postback_prompt_cache_miss_tokens));
|
||||
|
||||
m_msg_history->setHtml(QSL(message.postback_model_data));
|
||||
QString disp_data;
|
||||
QString disp_header;
|
||||
if (message.msg_type_mode == SYSTEM)
|
||||
{
|
||||
disp_header = "ID:" + QSL(message.postback_send_id) + " | FP:" + QSL(message.postback_system_fingerprint) + " | Time" + QSL(message.postback_time);
|
||||
m_msg_tokens->setText("prompt tokens:" + QSN(message.postback_prompt_tokens) + " | " +
|
||||
"completion tokens:" + QSN(message.postback_completion_tokens) + " | " +
|
||||
"total tokens:" + QSN(message.postback_total_tokens) + " | " +
|
||||
"prompt cache hit tokens:" + QSN(message.postback_prompt_cache_hit_tokens) + " | " +
|
||||
"prompt cache miss tokens:" + QSN(message.postback_prompt_cache_miss_tokens));
|
||||
disp_data = QSL(message.postback_model_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
disp_header = "ID:" + QSL(message.send_user_id) + " | Time:" + QSL(message.send_user_time);
|
||||
disp_data = QSL(message.send_user_data);
|
||||
}
|
||||
m_msg_header->setText(disp_header);
|
||||
m_msg_history->setHtml(disp_data);
|
||||
}
|
||||
void ctai_textedit::on_delete_clicked()
|
||||
{
|
||||
@ -170,16 +194,17 @@ void ctai_textedit::on_copy_clicked()
|
||||
void ctai_textedit::on_save_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("保存消息"), "",
|
||||
tr("文本文件 (*.txt);;所有文件 (*)"));
|
||||
|
||||
tr("保存消息"), "",
|
||||
tr("文本文件 (*.txt);;所有文件 (*)"));
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QMessageBox::warning(this, tr("保存失败"),
|
||||
tr("无法保存文件 %1:\n%2").arg(fileName).arg(file.errorString()));
|
||||
tr("无法保存文件 %1:\n%2").arg(fileName).arg(file.errorString()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -192,23 +217,28 @@ void ctai_textedit::on_save_clicked()
|
||||
void ctai_textedit::on_menu_clicked()
|
||||
{
|
||||
QMenu menu(this);
|
||||
|
||||
|
||||
// 添加菜单项
|
||||
QAction *actCopy = menu.addAction(tr("复制"));
|
||||
QAction *actSave = menu.addAction(tr("保存"));
|
||||
menu.addSeparator();
|
||||
QAction *actDelete = menu.addAction(tr("删除"));
|
||||
|
||||
|
||||
// 显示菜单
|
||||
QPoint pos = m_msg_menu->mapToGlobal(m_msg_menu->rect().bottomRight());
|
||||
QAction *act = menu.exec(pos);
|
||||
|
||||
|
||||
// 处理菜单选择
|
||||
if (act == actCopy) {
|
||||
if (act == actCopy)
|
||||
{
|
||||
on_copy_clicked();
|
||||
} else if (act == actSave) {
|
||||
}
|
||||
else if (act == actSave)
|
||||
{
|
||||
on_save_clicked();
|
||||
} else if (act == actDelete) {
|
||||
}
|
||||
else if (act == actDelete)
|
||||
{
|
||||
on_delete_clicked();
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ class ctai_textedit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ctai_textedit();
|
||||
ctai_textedit(msg_type msg_type_mode);
|
||||
~ctai_textedit();
|
||||
void add_message(const model_data &message);
|
||||
int get_content_height() const;
|
||||
@ -46,31 +46,30 @@ signals:
|
||||
void delete_requested(); // 请求删除此消息
|
||||
|
||||
private:
|
||||
void init_layout();
|
||||
void init_layout(msg_type msg_type_mode);
|
||||
void stream_message(const model_data &message);
|
||||
void stream_message_ex(const model_data &message);
|
||||
void connect_signals(); // 连接信号和槽
|
||||
|
||||
private:
|
||||
QSpacerItem *sparcer_item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
QVBoxLayout *mainLayout;
|
||||
QVBoxLayout *headerLayout;
|
||||
QHBoxLayout *header_info_Layout;
|
||||
QVBoxLayout *historyLayout;
|
||||
QHBoxLayout *tokenLayout;
|
||||
QHBoxLayout *header_opts_Layout;
|
||||
QVBoxLayout *mainLayout={};
|
||||
QVBoxLayout *headerLayout={};
|
||||
QHBoxLayout *header_info_Layout={};
|
||||
QVBoxLayout *historyLayout={};
|
||||
QHBoxLayout *tokenLayout={};
|
||||
QHBoxLayout *header_opts_Layout={};
|
||||
|
||||
|
||||
QPushButton *m_msg_header_ico;
|
||||
QLineEdit *m_msg_header;
|
||||
QLineEdit *m_msg_tokens;
|
||||
QTextBrowser *m_msg_history;
|
||||
QPushButton *m_msg_del;
|
||||
QPushButton *m_msg_copy;
|
||||
QPushButton *m_msg_save;
|
||||
QPushButton *m_msg_menu;
|
||||
QPushButton *m_msg_fold; // 折叠按钮
|
||||
QPushButton *m_msg_header_ico={};
|
||||
QLineEdit *m_msg_header={};
|
||||
QLineEdit *m_msg_tokens={};
|
||||
QTextBrowser *m_msg_history={};
|
||||
QPushButton *m_msg_del={};
|
||||
QPushButton *m_msg_copy={};
|
||||
QPushButton *m_msg_save={};
|
||||
QPushButton *m_msg_menu={};
|
||||
QPushButton *m_msg_fold={}; // 折叠按钮
|
||||
bool m_is_folded = false; // 折叠状态
|
||||
msg_type m_s_g_type;
|
||||
QSpacerItem *bottom_spacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user