void DWTAI_W (char *nam,// in: filter name int *ran, // in: filter length real *u, // in/out: data & transform real *s, // scratch space int *iv, // v-space lengths int *ia, // w-space starts int *lm) { // maximum level pqf *g,*h; // wavelet hpf & lpf static int call1=1; //printf("dwtai_w::dwtai_w(%s,%2d,{%6.3f,...},{%6.3f,...},{%2d,...},{%2d,...},%2d)\n",nam,*ran,*u,*s,*iv,*ia,*lm); if( *ran ) { h=qf(nam,*ran,0); // assign h g=qf(nam,*ran,1); // assign g // PrintFilter(nam,*ran,0,h); // PrintFilter(nam,*ran,1,g); dwtai(u,s,iv,ia,*lm,h,g); free(g->fp);free(g);free(h->fp);free(h); }else{ if( call1 ) { printf(" dwtai_w: abort because *ran==0.\n"); call1=0; abort(); } } }
void MainWindow::onPresetRm () { qDebug("%s", __FUNCTION__); QString const preset_name = m_dock_mgr.controlUI()->presetComboBox->currentText(); if (preset_name.isEmpty()) return; qDebug("removing preset_name=%s", preset_name.toStdString().c_str()); QString const fname = mkPresetPath(m_config.m_appdir, preset_name); qDebug("confirm to remove session file=%s", fname.toStdString().c_str()); QMessageBox msg_box; QPushButton * b_del = msg_box.addButton(tr("Yes, Delete"), QMessageBox::ActionRole); QPushButton * b_abort = msg_box.addButton(QMessageBox::Abort); msg_box.exec(); if (msg_box.clickedButton() == b_abort) return; QFile qf(fname); qf.remove(); removeStringFromHistory(preset_name, m_dock_mgr.controlUI()->presetComboBox, m_config.m_preset_history); m_config.saveHistory(m_appdir); m_dock_mgr.controlUI()->presetComboBox->setCurrentIndex(-1); }
// ### maybe move to qapplication_win QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/) { QString family = QT_WA_INLINE(QString::fromUtf16((ushort*)lf.lfFaceName), QString::fromLocal8Bit((char*)lf.lfFaceName)); QFont qf(family); qf.setItalic(lf.lfItalic); if (lf.lfWeight != FW_DONTCARE) { int weight; if (lf.lfWeight < 400) weight = QFont::Light; else if (lf.lfWeight < 600) weight = QFont::Normal; else if (lf.lfWeight < 700) weight = QFont::DemiBold; else if (lf.lfWeight < 800) weight = QFont::Bold; else weight = QFont::Black; qf.setWeight(weight); } int lfh = qAbs(lf.lfHeight); qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY)); qf.setUnderline(false); qf.setOverline(false); qf.setStrikeOut(false); return qf; }
bool ConvertMap::load() { static QRegExp reMap("^(.*):(.*)"); //makeMap(encoding()); //if map already exists, replace it QFile qf(QStandardPaths::locate(QStandardPaths::DataLocation, "encodings/" + encoding() + ".enc")); if(qf.open(QIODevice::ReadOnly)) { QTextStream stream(&qf); QTextCodec *codec = QTextCodec::codecForName(isoName().toLatin1()); if(codec) { stream.setCodec(codec); } while(!stream.atEnd()) { //parse the line if(stream.readLine().indexOf(reMap) != -1) { addPair(reMap.cap(1)[0], reMap.cap(2)); } } qf.close(); return true; } return false; }
Console::Console(QWidget *parent,bool oob) : EditWindow(parent, true) { // fileToolBar->removeAction(newAct); // fileToolBar->removeAction(openAct); // editToolBar->removeAction(cutAct); // editToolBar->removeAction(pasteAct); coreDumpAct = new QAction(QIcon(":/images/log.png"), tr("Core Dump"), this); coreDumpAct->setStatusTip(tr("Log simulator state to file")); connect(coreDumpAct, SIGNAL(triggered()), this, SIGNAL(coreDumpRequested())); fileToolBar->addAction(coreDumpAct); setStyleSheet("QToolBar {background-color : gray; color : black}"); textEdit->setReadOnly(true); textEdit->setStyleSheet("background-color : black; color : white;"); QFont qf("Consolas"); textEdit->setFont(qf); createStatusBar(oob); statusBar()->show(); // connect(SessionManager::instance(), SIGNAL(lazyNutCrash()), this, SLOT(coreDump())); }
CmdOutput::CmdOutput(QWidget *parent) : QPlainTextEdit(parent) { setStyleSheet("background-color : black; color : white;"); QFont qf("Courier"); setFont(qf); }
void ZipRW::SetFileText(QString ZipFile, QString File, QString Text) { QFile(ZipFile).rename(ZipFile + ".old"); QuaZip qz2(ZipFile); qz2.open(QuaZip::mdCreate); QuaZipFile qzf(&qz2); qzf.open(QFile::WriteOnly, QuaZipNewInfo(File)); qzf.write(Text.toLatin1()); qzf.close(); QuaZip qz(ZipFile + ".old"); qz.open(QuaZip::mdUnzip); QList<QuaZipFileInfo> lst = qz.getFileInfoList(); foreach (QuaZipFileInfo itm, lst) { if (itm.name != File) { qz.setCurrentFile(itm.name, QuaZip::csInsensitive); QuaZipFile qf(&qz); qf.open(QFile::ReadOnly); QByteArray ba = qf.readAll(); qf.close(); QuaZipFile qzf2(&qz2); qzf2.open(QFile::WriteOnly, QuaZipNewInfo(itm.name)); qzf2.write(ba); qzf2.close(); } } qz.close(); qz2.close(); QFile(ZipFile + ".old").remove(); }
Chord::Chord(const Event& e) : m_isUserChord(false) { std::string f; bool ok; ok = e.get<String>(RootPropertyName, f); if (ok) m_root = strtoqstr(f); ok = e.get<String>(ExtPropertyName, f); if (ok) { if (f.length() == 0) m_ext = QString::null; else m_ext = strtoqstr(f); } ok = e.get<String>(FingeringPropertyName, f); if (ok) { QString qf(strtoqstr(f)); QString errString; Fingering fingering = Fingering::parseFingering(qf, errString); setFingering(fingering); } }
void ZipRW::CpFileText(QString source, QString dest, QString File, QString Text) { QuaZip qz2(dest); qz2.open(QuaZip::mdCreate); QuaZipFile qzf(&qz2); qzf.open(QFile::WriteOnly, QuaZipNewInfo(File)); qzf.write(Text.toUtf8().data()); qzf.close(); QuaZip qz(source); qz.open(QuaZip::mdUnzip); QList<QuaZipFileInfo> lst = qz.getFileInfoList(); foreach (QuaZipFileInfo itm, lst) { if (itm.name != File) { qz.setCurrentFile(itm.name, QuaZip::csInsensitive); QuaZipFile qf(&qz); qf.open(QFile::ReadOnly); QByteArray ba = qf.readAll(); qf.close(); QuaZipFile qzf2(&qz2); qzf2.open(QFile::WriteOnly, QuaZipNewInfo(itm.name)); qzf2.write(ba); qzf2.close(); } } qz.close(); qz2.close(); }
bool MpvHandler::PlayFile(QString f) { if(f == QString()) // ignore if file doesn't exist return false; if(path == QString()) // web url { OpenFile(f); setFile(f); } else { QFile qf(path+f); if(qf.exists()) { OpenFile(path+f); setFile(f); Play(); } else { ShowText(tr("File no longer exists")); // tell the user return false; } } return true; }
bool MapWidget::saveMap(QString const & filename) const { QJsonObject jsn_map; QJsonObject jsn_tiles; QJsonArray jsn_cells; for(int i = 0; i < mTiles.size(); ++i) { QString index = QString("%1").arg(i); jsn_tiles.insert(index, QJsonValue(mTiles[i].fileName)); } for(QVector<int>::const_iterator it = mCells.begin(); it != mCells.end(); ++it) jsn_cells.push_back(QJsonValue(*it)); jsn_map.insert("rows", QJsonValue(mRows)); jsn_map.insert("cols", QJsonValue(mCols)); jsn_map.insert("tiles", jsn_tiles); jsn_map.insert("cells", jsn_cells); QJsonDocument jsn_doc(jsn_map); QByteArray jsn_out = filename.endsWith("json") ? jsn_doc.toJson() : jsn_doc.toBinaryData(); QFile qf(filename); if (!qf.open(QIODevice::WriteOnly | QIODevice::Truncate)) return false; if (-1 == qf.write(jsn_out)) { qf.close(); return false; } qf.close(); return true; }
void q1(char palavra[], int cont) { if(palavra[cont] == '\0') { qf(palavra, cont); } else if(palavra[cont] == '1') { q1(palavra, cont+1); } else if(palavra[cont] == '2') { qf(palavra, cont+1); } else { erro(); } }
void MainWindow::SaveSettings() { QFile qf("imageglue.ini"); if (qf.open(QIODevice::WriteOnly)) { QByteArray temp = gLastdir.toUtf8(); qf.write(temp); qf.close(); } }
QString ZipRW::FileText(QString ZipFile, QString File) { QuaZip qz(ZipFile); qz.open(QuaZip::mdUnzip); qz.setCurrentFile(File, QuaZip::csInsensitive); QuaZipFile qf(&qz); qf.open(QFile::ReadOnly); QString txt = qf.readAll(); qf.close(); qz.close(); return txt; }
bool combiner::load_spine_csv(QString filename) { //QList<spineunit> tmp_list; //qDebug()<<"in load spine csv"; QFile qf(filename); if (! qf.open(QIODevice::ReadOnly | QIODevice::Text)) return false; V3DLONG k=0; int skip_line_num=0; while (! qf.atEnd()) { char curline[2000]; qf.readLine(curline, sizeof(curline)); k++; if (curline[0]=='#') continue; QStringList qsl = QString(curline).trimmed().split(","); int qsl_count=qsl.size(); if (qsl_count<=10) {skip_line_num++;continue;} spineunit S; S.id=k; S.volume = qsl[2].toInt(); S.max_dis = qsl[3].toInt(); S.min_dis = qsl[4].toInt(); S.center_dis = qsl[5].toInt(); S.head_width = qsl[6].toFloat(); S.nearest_node = qsl[10].toInt(); if (nodegroup_map.find(S.nearest_node)==nodegroup_map.end()) //this node has not existed { QVector<spineunit> tmp_unit; tmp_unit.push_back(S); node_info one_node; one_node.spine_lut=tmp_unit; nodegroup_map.insert(S.nearest_node,one_node); } else { node_info exist_node = nodegroup_map.value(S.nearest_node); exist_node.spine_lut.push_back(S); nodegroup_map.insert(S.nearest_node,exist_node); } } if ((float)skip_line_num>0.6*k) return false; if (k<=1) return false; //qDebug()<<"in load_spine"; return true; }
void ParsedInteriorQoI::init (const GetPot& input, const MultiphysicsSystem& system, unsigned int /*qoi_num*/ ) { libMesh::ParsedFEMFunction<libMesh::Number> *qf (new libMesh::ParsedFEMFunction<libMesh::Number> (system, "")); this->qoi_functional.reset(qf); this->set_parameter(*qf, input, "QoI/ParsedInterior/qoi_functional", "DIE!"); }
void ConvertIOFile::writeText() { QFile qf(m_url.toLocalFile()); if(qf.open(QIODevice::WriteOnly)) { //read the file QTextStream stream(&qf); stream << m_text; qf.close(); } else { qWarning() << "Could not open " << m_url.toLocalFile(); } }
void DlgOpt::okClicked() { QString text; QFile qf(filename); if(qf.open(QIODevice::WriteOnly)) { QTextStream t( &qf ); t.setCodec(QTextCodec::codecForName("UTF-8")); t << edit1->toPlainText(); qf.close(); } accept(); }
real qf_swig(real* lb1, int len_lb1, real* nc1, int len_nc1, int* n1, int len_n1, real sigma, real c1, int lim1, real acc, real* trace, int len_trace, int* ifault, int len_ifault) { if ((len_lb1!=len_nc1) || (len_lb1!=len_n1) || (len_trace!=7) ||(len_ifault!=1)) { printf("Error, sizes: lb: %i, nc %i, n: %i, trace: %i, ifault: %i \n",(len_lb1,len_nc1,len_n1,len_trace,len_ifault)); return -1.0; } return qf(lb1, nc1, n1, len_nc1, sigma, c1, lim1, acc, trace, ifault); //printf("%.10f\n" ,result); //return result_qf; }
void PhononItem::setFileName(QString name) { QFile qf(name); if (!qf.exists()) { name = QString(); } m_loaded = false; m_timeSet = false; if (m_metaMedia != 0) { delete m_metaMedia; m_metaMedia = 0; } MetaDataObject::setFileName(name); }
// ### maybe move to qapplication_win QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/) { QString family = QString::fromWCharArray(lf.lfFaceName); QFont qf(family); qf.setItalic(lf.lfItalic); if (lf.lfWeight != FW_DONTCARE) qf.setWeight(weightFromInteger(lf.lfWeight)); int lfh = qAbs(lf.lfHeight); qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY)); qf.setUnderline(false); qf.setOverline(false); qf.setStrikeOut(false); return qf; }
void qf(char palavra[], int cont) { if(palavra[cont] == '\0') { printf("Palavra Aceita!"); } else if(palavra[cont] == '2') { qf(palavra, cont+1); } else { erro(); } }
void FastRunGui::on_edFullFileName_editingFinished() { std::string full_file_name = ui->edFullFileName->text().toStdString(); size_t sep = full_file_name.find_last_of('/'); std::string path = (sep==std::string::npos) ? "" : full_file_name.substr(0, sep); QFile qf(path.c_str()); if (!path.empty() && !qf.exists()) { ui->edFullFileName->setText( FullFileName().c_str() ); return; } _fileName = ds::StripPath(full_file_name); DDM::SetSaveDataDir(path); }
bool searchThread::checkLib(QString file) { qint64 siz; int r = -1; QFile qf(file); siz = qf.size(); if (qf.open(QIODevice::ReadOnly)) { uchar *p = qf.map(0, siz); r = QByteArray::fromRawData((char*)p, siz) .indexOf("C_GetFunctionList"); qf.unmap(p); qf.close(); } return r != -1; }
int main(){ unsigned int p=0,s=0; double v, a; int i=0; scanf("%d",&i); for(;i>0;i--) { scanf("%u%u",&p,&s); p=p/4; s=s/2; a=qf(-3,2*p,-s); v=a*a*(p-2*a); printf("%lfn",v); } return 0; }
void MainWindow::LoadSettings() { QString filename = QString::null; gLastdir = QString::null; QFile qf("imageglue.ini"); if (qf.open(QIODevice::ReadOnly)) { QByteArray temp(256, 0); if (qf.readLine(temp.data(), 255) > 0) { gLastdir = QString::fromUtf8(temp); gLastdir.replace("\n", ""); } qf.close(); } }
bool combiner::load_is_csv(QString filename) { //QList<isunit> tmp_list; //qDebug()<<"in load is csv"; QFile qf(filename); if (! qf.open(QIODevice::ReadOnly | QIODevice::Text)) return false; V3DLONG k=0; V3DLONG skip_line_num=0; while (! qf.atEnd()) { char curline[2000]; qf.readLine(curline, sizeof(curline)); k++; if (curline[0]=='#') continue; QStringList qsl = QString(curline).trimmed().split(","); int qsl_count=qsl.size(); if (qsl_count!=4) {skip_line_num++; continue;} isunit S; S.id=k; S.volume = qsl[1].toInt(); S.nearest_node = qsl[2].toInt(); S.on_dendrite=(bool)qsl[3].toInt(); if (nodegroup_map.find(S.nearest_node)==nodegroup_map.end()) //this node has not existed { node_info new_node; new_node.is_lut.push_back(S); nodegroup_map.insert(S.nearest_node,new_node); } else { node_info exist_node=nodegroup_map.value(S.nearest_node); exist_node.is_lut.push_back(S); nodegroup_map.insert(S.nearest_node,exist_node); } //tmp_list.append(S); } if (k<=1) return false; if ((float)skip_line_num>0.8*k) return false; //qDebug()<<"in load_isv"; return true; }
// ### maybe move to qapplication_win QFont qt_LOGFONTtoQFont(LOGFONT& lf, bool /*scale*/) { QString family = QString::fromWCharArray(lf.lfFaceName); #ifdef QT_ENABLE_FREETYPE_FOR_WIN // Substitute font by myself. // Windows return font family name which should be substituted from SystemParametersInfo(). // If we use GDI's font engine, Windows substitute font family. // If we use FreeType, FreeType don't do that, and we need to substitute font by myself. //std::cout << "family: " << family.toUtf8().data() << std::endl; { HKEY key; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes"), 0, KEY_READ, &key) == ERROR_SUCCESS) { int i = 0; TCHAR buff[MAX_PATH]; DWORD size = sizeof(buff) / sizeof(buff[0]); BYTE data[1024*4]; DWORD dataSize = sizeof(data)/sizeof(data[0]); DWORD type; while (RegEnumValue(key, i++, buff, &size, NULL, &type, data, &dataSize) == ERROR_SUCCESS) { QString subFamily = QString::fromWCharArray(buff); if (family.compare(subFamily) == 0) { if (type == REG_SZ) family = QString::fromWCharArray((WCHAR *)data); break; } size = sizeof(buff) / sizeof(buff[0]); dataSize = sizeof(data)/sizeof(data[0]); } } } //std::cout << "use family: " << family.toUtf8().data() << std::endl; #endif QFont qf(family); qf.setItalic(lf.lfItalic); if (lf.lfWeight != FW_DONTCARE) qf.setWeight(weightFromInteger(lf.lfWeight)); int lfh = qAbs(lf.lfHeight); qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY)); qf.setUnderline(false); qf.setOverline(false); qf.setStrikeOut(false); return qf; }
void DlgOpt::setFilename(const char *file) { QString line; QFile qf(file); filename = file; //printf("filename = %s\n",file); if(!filename.isEmpty()) { if(qf.open(QIODevice::ReadOnly)) { edit1->clear(); QTextStream ts( &qf ); ts.setCodec(QTextCodec::codecForName("UTF-8")); edit1->setPlainText( ts.readAll() ); qf.close(); } } }
int PluginXMLParser::parseFile(const QString& filename) { QFile qf(filename); if (!qf.open(IO_ReadOnly)) { return -1; } QDomDocument doc(filename); if (!doc.setContent(&qf)) { qf.close(); return -2; } qf.close(); _pluginData.clear(); return parseDOM(doc); }