void lastview( /* return to a previous view */ char *s ) { char buf[128]; char *fname; int success; VIEW nv; /* get parameters from a file */ if (nextword(buf, sizeof(buf), s) != NULL) { nv = stdview; if ((fname = getpath(buf, "", R_OK)) == NULL || (success = viewfile(fname, &nv, NULL)) == -1) { sprintf(errmsg, "cannot open \"%s\"", buf); error(COMMAND, errmsg); return; } if (!success) error(COMMAND, "wrong file format"); else newview(&nv); return; } if (oldview.type == 0) { /* no old view! */ error(COMMAND, "no previous view"); return; } nv = ourview; ourview = oldview; oldview = nv; newimage(NULL); }
int main( /* takes both the octree and the image */ int argc, char *argv[] ) { int i; char combuf[PATH_MAX]; progname = argv[0]; for (i = 1; i < argc-2; i++) if (!strcmp(argv[i], "-s")) slow++; else if (!strcmp(argv[i], "-T")) strcat(rtcom, " -oTp"); else break; if (i > argc-2) { fprintf(stderr, "Usage: %s [-s][-T] [rtrace args] octree picture\n", progname); exit(1); } picture = argv[argc-1]; /* get the viewing parameters */ if (viewfile(picture, &ourview, &ourres) <= 0 || setview(&ourview) != NULL) { fprintf(stderr, "%s: cannot get view from \"%s\"\n", progname, picture); exit(1); } /* open the display */ if ((theDisplay = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "%s: cannot open display; DISPLAY variable set?\n", progname); exit(1); } /* build input command */ sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom); for ( ; i < argc-1; i++) { strcat(combuf, " "); strcat(combuf, argv[i]); } /* start the damn thing */ if ((pin = popen(combuf, "r")) == NULL) exit(1); /* loop on input */ mainloop(); /* close pipe and exit */ pclose(pin); exit(0); }
void ViewTableListWidget::modifyViewTable() { QFile viewfile("viewtables.dat"); if (!viewfile.open(QIODevice::ReadWrite | QIODevice::Text)) { QMessageBox::warning(0,tr("警告"),tr("文件打开失败!"),tr("确定")); return; } QTextStream in(&viewfile); viewfile.resize(0); viewfile.seek(0); for(int i = 0; i < this->rowCount(); i++) { in<<item(i,0)->text()<<"*"<<item(i,2)->text()<<"*"<<item(i,3)->text()<<"\n"; } viewfile.close(); }
/************************************************************************** * *N display_library_contents * *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * List the tables in the Library level directory and display their * contents if selected. *E *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * library <input> == (library_type) VPF library structure. *E *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels DOS Turbo C *E *************************************************************************/ void display_library_contents( library_type library ) { char *filename, *libpath, *path, *libstr; libstr = (char *)vpfmalloc(128); libpath = (char *)vpfmalloc(255); filename = (char *)vpfmalloc(128); path = (char *)vpfmalloc(255); strcpy( libstr, "Library: " ); strcat( libstr, library.name ); strcpy(libpath,library.path); strcat(libpath,"*.*"); do { strcpy(filename,pickfile(libpath,0,libstr)); if (strcmp(filename,"")==0) break; strcpy( path, library.path ); strcat( path, filename ); rightjust(path); leftjust(path); strlwr(path); if (is_vpf_table(path)) { strlwr(path); if (strstr(path,".doc")) vpf_dump_doc_table(path,"temp.out"); else vpf_dump_table(path,"temp.out"); viewfile("temp.out", getmaxy()/3); unlink("temp.out"); } else { not_a_vpf_table(path); } } while (strcmp(filename,"") != 0); free(path); free(filename); free(libpath); free(libstr); }
/************************************************************************** * *N display_database_contents * *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * List the tables in the Database level directory and display their * contents if selected. *E *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * database <input> == (database_type) VPF database. *E *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels DOS Turbo C *E *************************************************************************/ void display_database_contents( database_type database ) { char *filename, *dbpath, *path, *dbstr; dbstr = (char *)vpfmalloc(128); dbpath = (char *)vpfmalloc(255); filename = (char *)vpfmalloc(128); path = (char *)vpfmalloc(255); strcpy( dbstr, "Database: " ); strcat( dbstr, database.name ); strcpy(dbpath,database.path); strcat(dbpath,"*.*"); do { strcpy(filename,pickfile(dbpath,0,dbstr)); if (strcmp(filename,"")==0) break; strcpy( path, database.path ); strcat( path, filename ); rightjust(path); strlwr(path); if (is_vpf_table(path)) { if (strstr(path,".doc")) vpf_dump_doc_table(path,"temp.out"); else vpf_dump_table(path,"temp.out"); viewfile("temp.out", getmaxy()/3); unlink("temp.out"); } else { not_a_vpf_table(path); } } while (strcmp(filename,"") != 0); free(path); free(filename); free(dbpath); free(dbstr); }
/* main, menu */ void view (void) { char buf [80]; register char *name = cur->d.cat[cur->d.curfile].name; register d; if (userview) { strcpy (buf, viewname); strcat (buf, " "); strcat (buf, name); VRestore (); syscmd (buf); VReopen (); VRedraw (); setdir (cur == left ? right : left, NULL); setdir (cur, NULL); return; } if ((d = open (name, 0)) < 0) { error ("Cannot open %s", name); return; } VIEWFILE viewfile(d, name); close (d); }
static void init( /* get view and find window */ char *pname, char *wname ) { extern Window xfindwind(); XWindowAttributes wa; XColor xc; XGCValues gcv; register int i; /* get the viewing parameters */ if (viewfile(pname, &ourview, &pres) <= 0 || setview(&ourview) != NULL) { fprintf(stderr, "%s: cannot get view from \"%s\"\n", progname, pname); exit(1); } /* open the display */ if ((theDisplay = XOpenDisplay(NULL)) == NULL) { fprintf(stderr, "%s: cannot open display; DISPLAY variable set?\n", progname); exit(1); } /* find our window */ if (wname == NULL) { /* remove directory prefix from name */ for (i = strlen(pname); i-- > 0; ) if (pname[i] == '/') break; wname = pname+i+1; i = 0; } else i = 1; gwind = xfindwind(theDisplay, rwind, wname, 4); if (gwind == None) { if (i) { fprintf(stderr, "%s: cannot find \"%s\" window\n", progname, wname); exit(2); } /* start ximage */ if (fork() == 0) { execlp(XIM, XIM, "-c", "256", pname, 0); perror(XIM); fprintf(stderr, "%s: cannot start %s\n", progname, XIM); kill(getppid(), SIGPIPE); _exit(1); } do sleep(8); while ((gwind=xfindwind(theDisplay,rwind,wname,4)) == None); } else XMapRaised(theDisplay, gwind); do { XGetWindowAttributes(theDisplay, gwind, &wa); sleep(6); } while (wa.map_state != IsViewable); if (wa.width != scanlen(&pres) || wa.height != numscans(&pres)) { fprintf(stderr, "%s: warning -- window seems to be the wrong size!\n", progname); if (pres.rt & YMAJOR) { pres.xr = wa.width; pres.yr = wa.height; } else { pres.xr = wa.height; pres.yr = wa.width; } } /* set graphics context */ gcv.font = XLoadFont(theDisplay, FONTNAME); if (gcv.font == 0) { fprintf(stderr, "%s: cannot load font \"%s\"\n", progname, FONTNAME); exit(1); } xc.red = col[0] >= 1.0 ? 65535 : (unsigned)(65536*col[0]); xc.green = col[1] >= 1.0 ? 65535 : (unsigned)(65536*col[1]); xc.blue = col[2] >= 1.0 ? 65535 : (unsigned)(65536*col[2]); xc.flags = DoRed|DoGreen|DoBlue; gcv.background = xc.green >= 32768 ? BlackPixel(theDisplay,DefaultScreen(theDisplay)) : WhitePixel(theDisplay,DefaultScreen(theDisplay)) ; if (XAllocColor(theDisplay, wa.colormap, &xc)) { gcv.foreground = xc.pixel; vecGC = XCreateGC(theDisplay,gwind, GCForeground|GCBackground|GCFont,&gcv); strGC = vecGC; } else { gcv.function = GXinvert; vecGC = XCreateGC(theDisplay,gwind,GCFunction,&gcv); gcv.foreground = xc.green < 32768 ? BlackPixel(theDisplay,DefaultScreen(theDisplay)) : WhitePixel(theDisplay,DefaultScreen(theDisplay)) ; strGC = XCreateGC(theDisplay,gwind, GCForeground|GCBackground|GCFont,&gcv); } }
int main(int argc, char *argv[]) { #define check(ol,al) if (argv[i][ol] || \ badarg(argc-i-1,argv+i+1,al)) \ goto badopt #define bool(olen,var) switch (argv[i][olen]) { \ case '\0': var = !var; break; \ case 'y': case 'Y': case 't': case 'T': \ case '+': case '1': var = 1; break; \ case 'n': case 'N': case 'f': case 'F': \ case '-': case '0': var = 0; break; \ default: goto badopt; } char *err; char *recover = NULL; char *outfile = NULL; char *zfile = NULL; int loadflags = ~IO_FILES; int seqstart = 0; int persist = 0; int duped1 = -1; int rval; int i; /* record start time */ tstart = time((time_t *)NULL); /* global program name */ progname = argv[0] = fixargv0(argv[0]); /* option city */ for (i = 1; i < argc; i++) { /* expand arguments */ while ((rval = expandarg(&argc, &argv, i)) > 0) ; if (rval < 0) { sprintf(errmsg, "cannot expand '%s'", argv[i]); error(SYSTEM, errmsg); } if (argv[i] == NULL || argv[i][0] != '-') break; /* break from options */ if (!strcmp(argv[i], "-version")) { puts(VersionID); quit(0); } if (!strcmp(argv[i], "-defaults") || !strcmp(argv[i], "-help")) { printdefaults(); quit(0); } rval = getrenderopt(argc-i, argv+i); if (rval >= 0) { i += rval; continue; } rval = getviewopt(&ourview, argc-i, argv+i); if (rval >= 0) { i += rval; continue; } /* rpict options */ switch (argv[i][1]) { case 'v': /* view file */ if (argv[i][2] != 'f') goto badopt; check(3,"s"); rval = viewfile(argv[++i], &ourview, NULL); if (rval < 0) { sprintf(errmsg, "cannot open view file \"%s\"", argv[i]); error(SYSTEM, errmsg); } else if (rval == 0) { sprintf(errmsg, "bad view file \"%s\"", argv[i]); error(USER, errmsg); } break; case 'p': /* pixel */ switch (argv[i][2]) { case 's': /* sample */ check(3,"i"); psample = atoi(argv[++i]); break; case 't': /* threshold */ check(3,"f"); maxdiff = atof(argv[++i]); break; case 'j': /* jitter */ check(3,"f"); dstrpix = atof(argv[++i]); break; case 'a': /* aspect */ check(3,"f"); pixaspect = atof(argv[++i]); break; case 'm': /* motion */ check(3,"f"); mblur = atof(argv[++i]); break; case 'd': /* aperture */ check(3,"f"); dblur = atof(argv[++i]); break; default: goto badopt; } break; case 'x': /* x resolution */ check(2,"i"); hresolu = atoi(argv[++i]); break; case 'y': /* y resolution */ check(2,"i"); vresolu = atoi(argv[++i]); break; case 'S': /* slave index */ check(2,"i"); seqstart = atoi(argv[++i]); break; case 'o': /* output file */ check(2,"s"); outfile = argv[++i]; break; case 'z': /* z file */ check(2,"s"); zfile = argv[++i]; break; case 'r': /* recover file */ if (argv[i][2] == 'o') { /* +output */ check(3,"s"); outfile = argv[i+1]; } else check(2,"s"); recover = argv[++i]; break; case 't': /* timer */ check(2,"i"); ralrm = atoi(argv[++i]); break; #ifdef PERSIST case 'P': /* persist file */ if (argv[i][2] == 'P') { check(3,"s"); persist = PARALLEL; } else { check(2,"s"); persist = PERSIST; } persistfile(argv[++i]); break; #endif case 'w': /* warnings */ rval = erract[WARNING].pf != NULL; bool(2,rval); if (rval) erract[WARNING].pf = wputs; else erract[WARNING].pf = NULL; break; case 'e': /* error file */ check(2,"s"); errfile = argv[++i]; break; default: goto badopt; } } err = setview(&ourview); /* set viewing parameters */ if (err != NULL) error(USER, err); /* initialize object types */ initotypes(); /* initialize urand */ if (rand_samp) { srandom((long)time(0)); initurand(0); } else { srandom(0L); initurand(2048); } /* set up signal handling */ sigdie(SIGINT, "Interrupt"); #ifdef SIGHUP sigdie(SIGHUP, "Hangup"); #endif sigdie(SIGTERM, "Terminate"); #ifdef SIGPIPE sigdie(SIGPIPE, "Broken pipe"); #endif #ifdef SIGALRM sigdie(SIGALRM, "Alarm clock"); #endif #ifdef SIGXCPU sigdie(SIGXCPU, "CPU limit exceeded"); sigdie(SIGXFSZ, "File size exceeded"); #endif /* open error file */ if (errfile != NULL) { if (freopen(errfile, "a", stderr) == NULL) quit(2); fprintf(stderr, "**************\n*** PID %5d: ", getpid()); printargs(argc, argv, stderr); putc('\n', stderr); fflush(stderr); } #ifdef NICE nice(NICE); /* lower priority */ #endif /* get octree */ if (i == argc) octname = NULL; else if (i == argc-1) octname = argv[i]; else goto badopt; if (seqstart > 0 && octname == NULL) error(USER, "missing octree argument"); /* set up output */ #ifdef PERSIST if (persist) { if (recover != NULL) error(USER, "persist option used with recover file"); if (seqstart <= 0) error(USER, "persist option only for sequences"); if (outfile == NULL) duped1 = dup(fileno(stdout)); /* don't lose our output */ openheader(); } else #endif if (outfile != NULL) openheader(); #ifdef _WIN32 SET_FILE_BINARY(stdout); if (octname == NULL) SET_FILE_BINARY(stdin); #endif readoct(octname, loadflags, &thescene, NULL); nsceneobjs = nobjects; if (loadflags & IO_INFO) { /* print header */ printargs(i, argv, stdout); printf("SOFTWARE= %s\n", VersionID); } marksources(); /* find and mark sources */ setambient(); /* initialize ambient calculation */ #ifdef PERSIST if (persist) { fflush(stdout); if (outfile == NULL) { /* reconnect stdout */ dup2(duped1, fileno(stdout)); close(duped1); } if (persist == PARALLEL) { /* multiprocessing */ preload_objs(); /* preload scene */ shm_boundary = (char *)malloc(16); strcpy(shm_boundary, "SHM_BOUNDARY"); while ((rval=fork()) == 0) { /* keep on forkin' */ pflock(1); pfhold(); tstart = time((time_t *)NULL); ambsync(); /* load new values */ } if (rval < 0) error(SYSTEM, "cannot fork child for persist function"); pfdetach(); /* parent will run then exit */ } } runagain: if (persist) { if (outfile == NULL) /* if out to stdout */ dupheader(); /* send header */ else /* if out to file */ duped1 = dup(fileno(stdout)); /* hang onto pipe */ } #endif /* batch render picture(s) */ rpict(seqstart, outfile, zfile, recover); /* flush ambient file */ ambsync(); #ifdef PERSIST if (persist == PERSIST) { /* first run-through */ if ((rval=fork()) == 0) { /* child loops until killed */ pflock(1); persist = PCHILD; } else { /* original process exits */ if (rval < 0) error(SYSTEM, "cannot fork child for persist function"); pfdetach(); /* parent exits */ } } if (persist == PCHILD) { /* wait for a signal then go again */ if (outfile != NULL) close(duped1); /* release output handle */ pfhold(); tstart = time((time_t *)NULL); /* reinitialize */ raynum = nrays = 0; goto runagain; } #endif quit(0); badopt: sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); return 1; /* pro forma return */ #undef check #undef bool }
int main(int argc, char *argv[]) { #define check(ol,al) if (argv[i][ol] || \ badarg(argc-i-1,argv+i+1,al)) \ goto badopt #define check_bool(olen,var) switch (argv[i][olen]) { \ case '\0': var = !var; break; \ case 'y': case 'Y': case 't': case 'T': \ case '+': case '1': var = 1; break; \ case 'n': case 'N': case 'f': case 'F': \ case '-': case '0': var = 0; break; \ default: goto badopt; } char *octnm = NULL; char *err; int rval; int i; /* global program name */ progname = argv[0] = fixargv0(argv[0]); /* set our defaults */ shadthresh = .1; shadcert = .25; directrelay = 0; vspretest = 128; srcsizerat = 0.; specthresh = .3; specjitter = 1.; maxdepth = 6; minweight = 1e-2; ambacc = 0.3; ambres = 32; ambdiv = 256; ambssamp = 64; /* option city */ for (i = 1; i < argc; i++) { /* expand arguments */ while ((rval = expandarg(&argc, &argv, i)) > 0) ; if (rval < 0) { sprintf(errmsg, "cannot expand '%s'", argv[i]); error(SYSTEM, errmsg); } if (argv[i] == NULL || argv[i][0] != '-') break; /* break from options */ if (!strcmp(argv[i], "-version")) { puts(VersionID); quit(0); } if (!strcmp(argv[i], "-defaults") || !strcmp(argv[i], "-help")) { printdefaults(); quit(0); } if (!strcmp(argv[i], "-devices")) { printdevices(); quit(0); } rval = getrenderopt(argc-i, argv+i); if (rval >= 0) { i += rval; continue; } rval = getviewopt(&ourview, argc-i, argv+i); if (rval >= 0) { i += rval; continue; } switch (argv[i][1]) { case 'n': /* # processes */ check(2,"i"); nproc = atoi(argv[++i]); if (nproc <= 0) error(USER, "bad number of processes"); break; case 'v': /* view file */ if (argv[i][2] != 'f') goto badopt; check(3,"s"); rval = viewfile(argv[++i], &ourview, NULL); if (rval < 0) { sprintf(errmsg, "cannot open view file \"%s\"", argv[i]); error(SYSTEM, errmsg); } else if (rval == 0) { sprintf(errmsg, "bad view file \"%s\"", argv[i]); error(USER, errmsg); } break; case 'b': /* grayscale */ check_bool(2,greyscale); break; case 'p': /* pixel */ switch (argv[i][2]) { case 's': /* sample */ check(3,"i"); psample = atoi(argv[++i]); break; case 't': /* threshold */ check(3,"f"); maxdiff = atof(argv[++i]); break; case 'e': /* exposure */ check(3,"f"); exposure = atof(argv[++i]); if (argv[i][0] == '+' || argv[i][0] == '-') exposure = pow(2.0, exposure); break; default: goto badopt; } break; case 'w': /* warnings */ rval = erract[WARNING].pf != NULL; check_bool(2,rval); if (rval) erract[WARNING].pf = wputs; else erract[WARNING].pf = NULL; break; case 'e': /* error file */ check(2,"s"); errfile = argv[++i]; break; case 'o': /* output device */ check(2,"s"); dvcname = argv[++i]; break; case 'R': /* render input file */ check(2,"s"); strcpy(rifname, argv[++i]); break; default: goto badopt; } } err = setview(&ourview); /* set viewing parameters */ if (err != NULL) error(USER, err); /* set up signal handling */ sigdie(SIGINT, "Interrupt"); sigdie(SIGTERM, "Terminate"); #if !defined(_WIN32) && !defined(_WIN64) sigdie(SIGHUP, "Hangup"); sigdie(SIGPIPE, "Broken pipe"); sigdie(SIGALRM, "Alarm clock"); #endif /* open error file */ if (errfile != NULL) { if (freopen(errfile, "a", stderr) == NULL) quit(2); fprintf(stderr, "**************\n*** PID %5d: ", getpid()); printargs(argc, argv, stderr); putc('\n', stderr); fflush(stderr); } #ifdef NICE nice(NICE); /* lower priority */ #endif /* get octree */ if (i == argc) octnm = NULL; else if (i == argc-1) octnm = argv[i]; else goto badopt; if (octnm == NULL) error(USER, "missing octree argument"); /* set up output & start process(es) */ SET_FILE_BINARY(stdout); ray_init(octnm); /* also calls ray_init_pmap() */ /* temporary shortcut, until winrview is refactored into a "device" */ #ifndef WIN_RVIEW rview(); /* run interactive viewer */ devclose(); /* close output device */ #endif /* PMAP: free photon maps */ ray_done_pmap(); #ifdef WIN_RVIEW return 1; #endif quit(0); badopt: sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); return 1; /* pro forma return */ #undef check #undef check_bool }
void ViewTableListWidget::createTableList() { QStringList filenameandsuffixs; QStringList usedfrequecys; QStringList accesstimes; QFile viewfile("viewtables.dat"); if (!viewfile.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::warning(0,tr("警告"),tr("文件打开失败!"),tr("确定")); return; } QTextStream in(&viewfile); while(!in.atEnd()) { QString str = in.readLine(); QStringList temp = str.split("*"); filenameandsuffixs.append(temp.at(0)); usedfrequecys.append(temp.at(1)); accesstimes.append(temp.at(2)); } viewfile.close(); qDebug()<<filenameandsuffixs; qDebug()<<usedfrequecys; qDebug()<<accesstimes; /* this->setRowCount(list.length()); this->setColumnCount(columnsize); int temprow = 0; for(int num = 0;num < 1 ; num++) { QFileInfoList::iterator i = list.begin(); QFileInfo tempinfo; while(i != list.end()) { tempinfo = *i; this->setItem(temprow,0,new QTableWidgetItem(QIcon("images/historicalcurve.jpg"),tempinfo.fileName())); this->setItem(temprow,1,new QTableWidgetItem(tempinfo.suffix())); this->setItem(temprow,2,new QTableWidgetItem("0")); this->setItem(temprow,3,new QTableWidgetItem(tempinfo.lastModified().toString("yyyy-MM-dd hh:mm"))); i++; temprow++; } }*/ this->setRowCount(filenameandsuffixs.count()); this->setColumnCount(columnsize); for(int i = 0; i < filenameandsuffixs.count(); i++) { QTableWidgetItem * item = new QTableWidgetItem(QIcon("images/historicalcurve.jpg"),filenameandsuffixs.at(i)); item->setToolTip(item->text()); this->setItem(i,0,item); QString tempstr = filenameandsuffixs.at(i); item = new QTableWidgetItem(tempstr.split(".").last()); this->setItem(i,1,item); item = new QTableWidgetItem(usedfrequecys.at(i)); item->setTextAlignment(Qt::AlignCenter); this->setItem(i,2,item); item = new QTableWidgetItem(accesstimes.at(i)); item->setTextAlignment(Qt::AlignCenter); this->setItem(i,3,new QTableWidgetItem(accesstimes.at(i))); } horizentitle = new QStringList; horizentitle->append(tr("名称")); horizentitle->append(tr("类型")); horizentitle->append(tr("次数")); horizentitle->append(tr("时间")); this->verticalHeader()->setVisible(false); this->setHorizontalHeaderLabels(*horizentitle);//设置表头标题 this->horizontalHeader()->setStretchLastSection(true);//设置满表宽度 this->horizontalHeader()->setHighlightSections(false); //this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); this->verticalHeader()->setDefaultSectionSize(20);//设置行距 //this->horizontalHeader()->resizeSection(0,150); this->horizontalHeader()->setFixedHeight(20); //this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); this->setFrameShape(QFrame::NoFrame);//设置无边框 this->setShowGrid(false);//显示无表格 this->setSelectionMode(QAbstractItemView::SingleSelection);//可多选Ctrl、Shift、 Ctrl+A都可以 this->setSelectionBehavior(QAbstractItemView::SelectRows);//设置按行选择 //this->setSelectionMode(QAbstractItemView::SingleSelection);//设置为仅可单行选择 this->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑 this->setIconSize(QSize(30,18)); this->setColumnHidden(1,true); this->setStyleSheet("selection-background-color:lightblue;"); }
void ViewTableListWidget::deleteView(bool flag) { int result = QMessageBox::warning(0,tr("警告"),tr("是否删除该视图?"),tr("是"),tr("否")); if(result == 1) return; if(!flag) { QMessageBox::warning(0,tr("警告"),tr("视图使用中,无法删除!"),tr("确定")); return; } QString viewfilename = item(curindex,0)->text(); if(viewfilename.isEmpty()) { QMessageBox::warning(0,tr("警告"),tr("视图为空!"),tr("确定")); return; } //判断有没有在房间管理里面被使用 QFile viewfile("viewaddtotree.dat"); if(viewfile.open(QIODevice::ReadWrite| QIODevice::Text)) { QTextStream ts(&viewfile); QString viewsstr = ts.readLine(); if(viewsstr.contains(viewfilename)) { QMessageBox::warning(0,tr("警告"),tr("视图已经在房间管理中使用,无法删除!"),tr("确定")); viewfile.close(); return; } } viewfile.close(); QString path = "view/"; QFile file(path+viewfilename); if(!file.exists())//是否要判断? { QMessageBox::critical(0,tr("错误"),tr("对应文件不存在,将删除无效控件!"),tr("确定")); this->removeRow(curindex);//是否? return; } if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::warning(0,tr("警告"),tr("文件打开失败!"),tr("确定")); return; } QTextStream in(&file); QString controlstr; int count = in.readLine().toInt(); while(count > 0) { controlstr = in.readLine(); QStringList controlinfo = controlstr.split("*"); unlinkControlToView(controlinfo.first()); --count; } file.remove(); this->removeRow(curindex); modifyViewTable(); if(islist) emit showlistmode(); else if(isicon) emit showiconmode(); }