0 Star 2 Fork 1

Cadaqs/XStudio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ConfigMgr.xcsm 5.15 KB
一键复制 编辑 原始数据 按行查看 历史
Cadaqs 提交于 2020-11-28 21:28 . 9233
//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;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/ixlang/XStudio.git
[email protected]:ixlang/XStudio.git
ixlang
XStudio
XStudio
master

搜索帮助