代码拉取完成,页面将自动刷新
//xlang Source, Name:ConfigMgr.xcsm
//Date: Tue Nov 11:29:36 2018
class ConfigMgr : QDialog {
QTreeWidget _listview;
QPushButton btnClone;
QPushButton btnDel;
QPushButton btnClose;
public XProperites proWnd;
public Project _curproject;
void onAttach() {
setWindowFlags(Constant.CustomizeWindowHint | Constant.WindowMinMaxButtonsHint | Constant.WindowCloseButtonHint);
_listview = (QTreeWidget)attachByName(new QTreeWidget(), "listConfig");
btnClone = (QPushButton)attachByName(new QPushButton(), "btnClone");
btnClone.setOnClickListener(
new onClickListener() {
void onClick(QObject obj, bool checked)override {
long [] items = _listview.getSelectedItems();
if (items == nilptr || items.length == 0) {
QMessageBox.Critical("错误", "请先选择一个现有配置", QMessageBox.Ok, QMessageBox.Ok);
return ;
}
String oldConfigName = _listview.getItemText(items[0], 0);
InputDialog.requestInput(new InputDialog.onInputListener() {
bool onInputOk(@NotNilptr String text)override {
if (Pattern.test(text, "^[A-Za-z0-9_]+$", Pattern.NOTEMPTY, true) == false) {
QMessageBox.Critical("错误", "配置名称不合法, 含有不允许的字符", QMessageBox.Ok, QMessageBox.Ok);
return false;
}
if (text.length() == 0) {
QMessageBox.Critical("错误", "配置名称不能为空", QMessageBox.Ok, QMessageBox.Ok);
return false;
}
if (false == _curproject.cloneConfigure(oldConfigName, text)) {
QMessageBox.Critical("错误", "无法克隆配置, 同名配置已存在或者找不到原有配置.", QMessageBox.Ok, QMessageBox.Ok);
} else {
loadConfigures();
}
return true;
}
bool onInputCancel()override {
return true;
}
String getTitle()override {
return "克隆配置";
}
String getTips()override {
return "输入新配置名称:";
}
String getDefault()override {
return oldConfigName;
}
});
}
});
btnDel = (QPushButton)attachByName(new QPushButton(), "btnDel");
btnDel.setOnClickListener(
new onClickListener() {
void onClick(QObject obj, bool checked)override {
long [] items = _listview.getSelectedItems();
if (items == nilptr || items.length == 0) {
QMessageBox.Critical("错误", "请先选择一个现有配置", QMessageBox.Ok, QMessageBox.Ok);
return ;
}
String oldConfigName = _listview.getItemText(items[0], 0);
Configure cif = _curproject.getCurrentConfig();
if (cif != nilptr && oldConfigName.equals(cif.getName())) {
QMessageBox.Critical("错误", "不能删除正在使用的配置", QMessageBox.Ok, QMessageBox.Ok);
return ;
}
_curproject.removeConfigure(oldConfigName);
loadConfigures();
}
});
btnClose = (QPushButton)attachByName(new QPushButton(), "btnClose");
btnClose.setOnClickListener(
new onClickListener() {
void onClick(QObject obj, bool checked)override {
ConfigMgr.this.close();
}
});
//_listview.setOnTreeViewItemEvent(listlistener);
String [] columns = {"名称"};
_listview.setColumns(columns);
loadConfigures();
/*setOnLayoutEventListener(new onLayoutEventListener(){
void onResize(QObject obj, int w, int h, int oldw, int oldh)override {
_listview.resize(w - 120, h - 20);
btnClone.move(w - 95, 20);
btnDel.move(w - 95, 60);
btnClose.move(w - 95, h - 50);
}
});*/
setWindowTitle(_curproject.getName() + " - 配置");
setWindowIcon("./res/toolbar/output.png");
setModal(true);
show();
}
void loadConfigures() {
/* _system_.consoleWrite("loadWindow");*/
_listview.clear();
Map.Iterator<String, Configure> iter = _curproject.configures.iterator();
while (iter.hasNext()) {
//String key = iter.getKey();
Configure cfg = iter.getValue();
iter.next();
if (cfg != nilptr){
_listview.addItem(nilptr, cfg.getName());
}
}
}
bool onClose()override {
proWnd.refreshConfigures();
XWorkspace.workspace.refreshConfigures();
return true;
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。