代码拉取完成,页面将自动刷新
#include "functable.h"
#include "ui_functable.h"
funcTable::funcTable(QWidget *parent) :
QDialog(parent),
ui(new Ui::funcTable)
{
ui->setupUi(this);
setWindowTitle("添加函数");
ui->nName->setValidator(new QRegExpValidator(QRegExp("[A-Za-z0-9]{0,20}")));
ui->nInput->setValidator(new QRegExpValidator(QRegExp("[A-Za-z0-9/,]*")));
ui->nOutput->setValidator(new QRegExpValidator(QRegExp("[A-Za-z0-9/,]*")));
}
void funcTable::setTable(){
ui->table->setColumnCount(4);
ui->table->setHorizontalHeaderLabels(QStringList()<<"函数名"<<"输入"<<"输出"<<"大小");
ui->table->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->table->setSelectionMode(QAbstractItemView::SingleSelection);
ui->table->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
createFunction = false;
functionName.clear();
}
void funcTable::setRows(int r){
ui->table->setRowCount(r);
}
void funcTable::setRow(int r , const char * f,const char * i,const char * o,const char * s){
ui->table->setItem(r,0,new QTableWidgetItem(f));
ui->table->setItem(r,1,new QTableWidgetItem(i));
ui->table->setItem(r,2,new QTableWidgetItem(o));
ui->table->setItem(r,3,new QTableWidgetItem(s));
}
void funcTable::getSelected(){
QList<QTableWidgetItem*> items = ui->table->selectedItems();
int count = items.count();
if(count>0){
int row = ui->table->row(items.at(0));
functionName = ui->table->model()->index(row,0).data().toString().toStdString();
}
}
funcTable::~funcTable(){
delete ui;
}
void funcTable::getNewFunc(){
auto name = ui->nName->text().simplified();
auto inputOri = ui->nInput->text().simplified();
auto outputOri = ui->nOutput->text().simplified();
input.clear();
output.clear();
createFunction = true;
if(name.isEmpty() || inputOri.isEmpty() || outputOri.isEmpty())
return;
auto inputls = inputOri.split(",");
for(auto ito:inputls){
auto inputs = ito.split(" ");
for(auto it:inputs){
if(!it.isEmpty()){
input.push_back(it.toStdString());
}
}
}
auto outputls = outputOri.split(",");
for(auto ito:outputls){
auto outputs = ito.split(" ");
for(auto it:outputs){
if(!it.isEmpty()){
output.push_back(it.toStdString());
}
}
}
functionName = name.toStdString();
}
void funcTable::on_buttonBox_accepted(){
createFunction = false;
functionName.clear();
if(ui->useNew->isChecked()){
getNewFunc();
}else{
getSelected();
}
}
void funcTable::on_buttonBox_rejected(){
createFunction = false;
functionName.clear();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。