//Set native commands setNative(){ nshInsert(&native,"set","set"); nshInsert(&native,"tes","tes"); nshInsert(&native,"alias","alias"); nshInsert(&native,"saila","saila"); nshInsert(&native,"echo","echo"); nshInsert(&native,"exit","exit"); nshInsert(&native, "where", "where"); //fill alias list for display nshInsert(&alias,"set","set"); nshInsert(&alias,"alias","alias"); nshInsert(&alias,"tes","tes"); nshInsert(&alias,"exit","exit"); nshInsert(&alias,"echo","echo"); nshInsert(&alias,"saila","saila"); nshInsert(&alias, "where", "where"); //Sets the home directory. Comment out when debugging. nshInsert(&var,"Path",setHomeDir()); }
// 是否需要改造treeview,是,所有界面需要手动书写 QJDMainWindow::QJDMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QJDMainWindow) { ui->setupUi(this); argu=new QJDArgu; // 获取环境变量中数据目录地址 if(argu->JD_FileType!="") { QStringList fileTypeList=argu->JD_FileType.split(","); settings.setValue("FileType",fileTypeList); } qDebug()<<"File typelist::"<<settings.value("FileType").toStringList(); if(argu->JD_FlowDataDir!="") { _HOME_DIR=argu->JD_FlowDataDir; } else { _HOME_DIR=settings.value("HOME").toString(); } settings.setValue("HOME",_HOME_DIR); canCreatNewFlow=false; pathLabel1=new QJDLabel; pathLabel1->setText("Address::"); pathLabel1->setMaximumHeight(10); pathLabel2=new QJDLabel; pathLabel2->setFrameShape(QFrame::Box); pathLabel2->setFrameShadow(QFrame::Raised); pathLabel2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); pathLabel2->setMaximumHeight(30); areaHeadWidget=new QJDAreaHeadWidget; areaWidget=new QJDAreaWidget(); areaWidget->setColumnCount(1); connect(areaWidget,SIGNAL(sigLevel(int)),this,SLOT(enableNew(int))); propertyWidget=new QJDPropertyWidget; mdiWidget=new QJDMdi; // connect with areawidget & funcationwidget tabWidget=new QJDTabWidget(); tabWidget->setIconSize(QSize(24,24)); // tabWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Expanding); QWidget *tab1=new QWidget; QGridLayout *gLayout1=new QGridLayout(tab1); gLayout1->addWidget(propertyWidget); tabWidget->addTab(tab1,QIcon(":/src/images/propertyviewer"),"Property Viewer"); QWidget *tab2=new QWidget; QGridLayout *gLayout2=new QGridLayout(tab2); gLayout2->addWidget(mdiWidget); tabWidget->addTab(tab2,QIcon(":/src/images/flowviewer"), "Flow Editor"); connect(tabWidget,SIGNAL(currentChanged(int)),this,SLOT(setWidgetVisible(int))); funcationHeadWidget=new QJDFuncationHeadWidget; funcationWidget=new QJDFuncationWidget(); areaSplitterWidget=new QWidget; funcationSplitterWidget=new QWidget; QVBoxLayout *areaLayout=new QVBoxLayout(areaSplitterWidget); QVBoxLayout *funcationLayout=new QVBoxLayout(funcationSplitterWidget); areaLayout->addWidget(areaHeadWidget); areaLayout->addWidget(areaWidget); funcationLayout->addWidget(funcationHeadWidget); funcationLayout->addWidget(funcationWidget); splitter=new QSplitter(this); splitter->setOrientation(Qt::Horizontal); splitter->setChildrenCollapsible(false); splitter->addWidget(areaSplitterWidget); splitter->addWidget(tabWidget); splitter->addWidget(funcationSplitterWidget); // areaSplitterWidget->show(); // tabWidget->show(); funcationSplitterWidget->hide(); areaWidget->setHome(_HOME_DIR); // area 必须先connect connect(areaWidget,SIGNAL(sigItemPath(QString)),pathLabel2,SLOT(setText(QString))); connect(areaWidget,SIGNAL(sigItemPath(QString)),propertyWidget,SLOT(setPropertyData(QString))); setHomeDir(_HOME_DIR); areaWidget->expandToDepth(1); QHBoxLayout *pathLayout=new QHBoxLayout; pathLayout->addWidget(pathLabel1); pathLayout->addWidget(pathLabel2); // QHBoxLayout *hLayout=new QHBoxLayout; // hLayout->addWidget(areaWidget); // hLayout->addWidget(tabWidget); // hLayout->addWidget(functionWidget); QVBoxLayout *vLayout=new QVBoxLayout; vLayout->addLayout(pathLayout); vLayout->addWidget(splitter); ui->centralWidget->setLayout(vLayout); // area connect(areaWidget,SIGNAL(sigActNewAreaClicked()),this,SLOT(on_actionNewArea_triggered())); connect(areaWidget,SIGNAL(sigActNewLineClicked()),this,SLOT(on_actionNewLine_triggered())); connect(areaWidget,SIGNAL(sigActNewFlowClicked()),this,SLOT(on_actionNewFlow_triggered())); connect(areaWidget,SIGNAL(sigActDelAreaClicked()),this,SLOT(on_actionDelArea_triggered())); connect(areaWidget,SIGNAL(sigActDelLineClicked()),this,SLOT(on_actionDelLine_triggered())); connect(areaWidget,SIGNAL(sigActDelFlowClicked()),this,SLOT(on_actionDelFlow_triggered())); connect(areaWidget,SIGNAL(sigActOpenFlowClicked()),this,SLOT(openFlowSlot())); connect(areaWidget,SIGNAL(sigActExcuteFlowClicked()),this,SLOT(excuteFlowSlot())); connect(areaWidget,SIGNAL(sigExistFlow()),this,SLOT(showExistFlow())); // funcation connect(funcationWidget,SIGNAL(sigFunDoubleClicked(QString,QString)),mdiWidget,SLOT(addFuncation(QString,QString))); // connect(funcationWidget,SIGNAL(sigFunDoubleClicked(QString,QString)),this,SLOT(copyFlowXML())); // head connect(areaHeadWidget,SIGNAL(sigRefreshClicked()),this,SLOT(refreshList())); connect(areaHeadWidget,SIGNAL(sigExpandClicked(int)),areaWidget,SLOT(expandToDepth(int))); connect(areaHeadWidget,SIGNAL(sigCollapseClicked()),areaWidget,SLOT(collapseAll())); connect(funcationHeadWidget,SIGNAL(sigExpandClicked(int)),funcationWidget,SLOT(expandToDepth(int))); connect(funcationHeadWidget,SIGNAL(sigCollapseClicked()),funcationWidget,SLOT(collapseAll())); /// mdi // connect(areaWidget,SIGNAL(),mdiWidget,SLOT(newSubWindow())); // connect(funcationWidget,SIGNAL(),mdiWidget,SLOT(addFlow())); // 必须添加流程后才能点击 ui->actionExcuteFlow->setEnabled(false); connect(mdiWidget,SIGNAL(subWindowActivated(QMdiSubWindow*)), this,SLOT(excuteDecide(QMdiSubWindow*))); showMaximized(); }
void QJDMainWindow::creatNewLine(QString lineName) { QString lowerCaseLineName; lowerCaseLineName=lineName.toLower(); lowerCaseLineName.simplified(); lowerCaseLineName.remove(" "); qDebug()<<"creatNewLine::"<<lineName<<lowerCaseLineName; // 所有大写阿,带空格的之类的统一小写,并且去空格 //1. 创建文件夹,需要获取当前area文件夹名称,通过当前的名称获取 QDir newDir; newDir.setPath(areaWidget->getAbsolutePath()); if(newDir.exists(lowerCaseLineName)) { QMessageBox::warning(this,"Warning!","Do not creat the same LINE again!"); return; } if(!newDir.mkdir(lowerCaseLineName)) qDebug()<<"Creat New Line Dir failed"; //2. 创建.Line Desc QFile newDesc; newDesc.setFileName(newDir.path()+"/"+lowerCaseLineName+"/DescName"); if(!newDesc.open(QFile::WriteOnly)) { qDebug()<<"creat new desc open failed"; } QTextStream ts(&newDesc); ts<<lineName<<"\n"; newDesc.close(); // 3. 创建Data文件夹 QDir dataDir; QString dataDirPath=areaWidget->getAbsolutePath()+"/"+lowerCaseLineName; dataDir.setPath(dataDirPath); if(dataDir.exists("Data")) { QMessageBox::warning(this,"Warning!","Can not creat the Data Dir for this LINE!"); return; } if(!dataDir.mkdir("Data")) qDebug()<<"Creat Line Data Dir failed"; QFile dataDesc; dataDesc.setFileName(dataDir.path()+"/Data/DescName"); if(!dataDesc.open(QFile::WriteOnly)) { qDebug()<<"creat data dir desc open failed"; } QTextStream datats(&dataDesc); datats<<"Data\n"; dataDesc.close(); // 4. 创建各个类型文件的文件夹 QStringList fileTypeList=settings.value("FileType").toStringList(); for(int i=0; i<fileTypeList.size(); i++) { QDir typeDir; QString typeDirPath=dataDirPath+"/Data"; typeDir.setPath(typeDirPath); if(typeDir.exists(fileTypeList.at(i))) { QMessageBox::warning(this,"Warning!","Can not creat the Same Type Dir for this LINE Data!"); return; } if(!typeDir.mkdir(fileTypeList.at(i))) qDebug()<<"Creat Line Data Dir failed"; } setHomeDir(getHomeDir()); areaWidget->expandToDepth(1); }
void QJDMainWindow::refreshList() { setHomeDir(getHomeDir()); areaWidget->expandToDepth(1); }