static int sizegen(int i, Dir *d, void *v) { vlong path; Fid *fid; XFont *f; int j; fid = v; path = fid->qid.path; if(i == 0) { path += Qfontfile - Qsizedir; goto Done; } i--; f = &xfont[QFONT(path)]; load(f); for(j=0; j<nelem(f->range); j++) { if(f->range[j] == 0) continue; if(i == 0) { path += Qsubfontfile - Qsizedir; path += qpath(0, 0, 0, 0, j); goto Done; } i--; } return -1; Done: dostat(path, nil, d); return 0; }
static int rootgen(int i, Dir *d, void *v) { if(i >= nxfont) return -1; dostat(qpath(Qfontdir, i, 0, 0, 0), nil, d); return 0; }
static int fontgen(int i, Dir *d, void *v) { vlong path; Fid *f; f = v; path = f->qid.path; if(i >= 2*nelem(sizes)) return -1; dostat(qpath(Qsizedir, QFONT(path), sizes[i/2], i&1, 0), nil, d); return 0; }
Node* Archive::FindNode(const char* path) { QString qpath(path); QStringList elems = qpath.split('/', QString::SkipEmptyParts); // Skip empty parts to avoid looking up the root Node* ptr = root_; for (QList<QString>::iterator it = elems.begin(); it < elems.end(); it++) { ptr = ptr->GetChildByName((*it).toStdString()); if (ptr == NULL) { return NULL; } } return ptr; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); // QTextCodec::setCodecForTr(codec); // QTextCodec::setCodecForLocale(QTextCodec::codecForLocale()); // QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale()); qRegisterMetaType<cv::Mat>("Mat"); qRegisterMetaType<cv::Mat>("cv::Mat&"); qRegisterMetaType<std::string>("string"); QtTrajectoryAnalysis w; if( !w.loadData()){ QMessageBox::information(0, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("服务初始化失败!")); a.quit(); return -1; } QString qpath(argv[1]); std::string file = std::string((const char *)qpath.toLocal8Bit()); if (!w.loadImage(file)){ QMessageBox::information(0, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("请正确打开程序!")); a.quit(); return -1; } ////////批量处理 if( argc > 3){ QStringList files; for( int i = 1; i < argc -1; ++i){ files << QString::fromLocal8Bit(argv[i]); } w.setBatchInfo(files); } if( argc >2 ){ QString folder = QString::fromLocal8Bit(argv[argc-1]); w.setFolder(folder); } w.show(); return a.exec(); }
/* Constructor. * Fort settings file always lives in /home/<user>/.fort/ * directory. */ SettingsParser::SettingsParser() { char *path = getenv("HOME"); QString qpath(path); qpath = qpath + "/.fort/"; if(!QDir(qpath).exists()) { if(!QDir(qpath).mkdir(qpath)) { //If this fails something is badly wrong in the user system... QMessageBox::information(0,"Fort Password Manager", "Can't create directory " + qpath + ". Fatal."); } } qpath = qpath + "/" + FORT_CONFIG_FILE; _settingsPath = qpath; }
void Player::play(int tid, bool play, bool add_to_history) { cur_artist = artist_list->currentItem(); cur_album = album_list->currentRow() > 0 ? album_list->currentRow() : 0; cur_title = titles_list->currentRow() > 0 ? titles_list->currentRow() : 0; if (add_to_history) { history.push_back(HistoryItem(cur_artist, cur_album, cur_title, tid)); if (history.count() > 100) history.pop_front(); } sqlite3_stmt *trackQuery = 0; char *query = sqlite3_mprintf("SELECT `artist`, `year`, `album`, `track_number`, `title`, `path` FROM `tracks` WHERE `tid`=%u LIMIT 1", tid); prepare(query, &trackQuery, "Failed to Prepare `path` query: "); bool done = false; do { if (step(trackQuery, done, true, "Failed to Step `path` in play: ")) { char *path = sqlite3_mprintf("%s", sqlite3_column_text(trackQuery, 5)); //NOTE: why does sqlite3_column_text return an `unsigned char *`? who uses that?! QString qpath(path); sqlite3_free(path); if (play) { now_playing->setCurrentSource(qpath); now_playing->play(); tick(0); } else now_playing->enqueue(qpath); setQLabelText("%s", trackQuery, 0, mw_artist); setQLabelText("%s", trackQuery, 1, mw_year); setQLabelText("%s", trackQuery, 2, mw_album); setQLabelText("%s", trackQuery, 3, mw_track_number); setQLabelText("%s", trackQuery, 4, mw_title); mw_path->setText(qpath); setWindowTitle(mw_artist->text() + " - " + mw_title->text() + " | Projekt 7"); if (add_to_history) tray_icon->showMessage("Projekt 7 | Now Playing:", mw_artist->text() + " - " + mw_title->text(), QSystemTrayIcon::NoIcon, 5000); } } while (!done); }
static char* xwalk1(Fid *fid, char *name, Qid *qid) { int i, dotdot; vlong path; char *p; int a, n; XFont *f; path = fid->qid.path; dotdot = strcmp(name, "..") == 0; switch(QTYPE(path)) { default: NotFound: return "file not found"; case Qroot: if(dotdot) break; for(i=0; i<nxfont; i++) { if(strcmp(xfont[i].name, name) == 0) { path = qpath(Qfontdir, i, 0, 0, 0); goto Found; } } goto NotFound; case Qfontdir: if(dotdot) { path = Qroot; break; } n = strtol(name, &p, 10); if(n == 0) goto NotFound; a = 0; if(*p == 'a') { a = 1; p++; } if(*p != 0) goto NotFound; path += Qsizedir - Qfontdir + qpath(0, 0, n, a, 0); break; case Qsizedir: if(dotdot) { path = qpath(Qfontdir, QFONT(path), 0, 0, 0); break; } if(strcmp(name, "font") == 0) { path += Qfontfile - Qsizedir; break; } f = &xfont[QFONT(path)]; load(f); p = name; if(*p != 'x') goto NotFound; p++; n = strtoul(p, &p, 16); if(p != name+5 || n%SubfontSize != 0 || strcmp(p, ".bit") != 0 || !f->range[(n/SubfontSize) & SubfontMask]) goto NotFound; path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n/SubfontSize) & SubfontMask); break; } Found: dostat(path, qid, nil); fid->qid = *qid; return nil; }