qstring moorecoinunits::format(int unit, const camount& nin, bool fplus, separatorstyle separators) { // note: not using straight sprintf here because we do not want // localized number formatting. if(!valid(unit)) return qstring(); // refuse to format invalid unit qint64 n = (qint64)nin; qint64 coin = factor(unit); int num_decimals = decimals(unit); qint64 n_abs = (n > 0 ? n : -n); qint64 quotient = n_abs / coin; qint64 remainder = n_abs % coin; qstring quotient_str = qstring::number(quotient); qstring remainder_str = qstring::number(remainder).rightjustified(num_decimals, '0'); // use si-style thin space separators as these are locale independent and can't be // confused with the decimal marker. qchar thin_sp(thin_sp_cp); int q_size = quotient_str.size(); if (separators == separatoralways || (separators == separatorstandard && q_size > 4)) for (int i = 3; i < q_size; i += 3) quotient_str.insert(q_size - i, thin_sp); if (n < 0) quotient_str.insert(0, '-'); else if (fplus && n > 0) quotient_str.insert(0, '+'); return quotient_str + qstring(".") + remainder_str; }
qstring moorecoinunits::description(int unit) { switch(unit) { case btc: return qstring("moorecoins"); case mbtc: return qstring("milli-moorecoins (1 / 1" thin_sp_utf8 "000)"); case ubtc: return qstring("micro-moorecoins (1 / 1" thin_sp_utf8 "000" thin_sp_utf8 "000)"); default: return qstring("???"); } }
qstring moorecoinunits::name(int unit) { switch(unit) { case btc: return qstring("btc"); case mbtc: return qstring("mbtc"); case ubtc: return qstring::fromutf8("渭btc"); default: return qstring("???"); } }
void transactionview::exportclicked() { // csv is currently the only supported format qstring filename = guiutil::getsavefilename(this, tr("export transaction history"), qstring(), tr("comma separated file (*.csv)"), null); if (filename.isnull()) return; csvmodelwriter writer(filename); // name, column, role writer.setmodel(transactionproxymodel); writer.addcolumn(tr("confirmed"), 0, transactiontablemodel::confirmedrole); if (model && model->havewatchonly()) writer.addcolumn(tr("watch-only"), transactiontablemodel::watchonly); writer.addcolumn(tr("date"), 0, transactiontablemodel::daterole); writer.addcolumn(tr("type"), transactiontablemodel::type, qt::editrole); writer.addcolumn(tr("label"), 0, transactiontablemodel::labelrole); writer.addcolumn(tr("address"), 0, transactiontablemodel::addressrole); writer.addcolumn(moorecoinunits::getamountcolumntitle(model->getoptionsmodel()->getdisplayunit()), 0, transactiontablemodel::formattedamountrole); writer.addcolumn(tr("id"), 0, transactiontablemodel::txidrole); if(!writer.write()) { emit message(tr("exporting failed"), tr("there was an error trying to save the transaction history to %1.").arg(filename), cclientuiinterface::msg_error); } else { emit message(tr("exporting successful"), tr("the transaction history was successfully saved to %1.").arg(filename), cclientuiinterface::msg_information); } }
int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool) const { const QString string = fixSpacing(qstring(run)); QTextLayout layout(string, font()); QTextLine line = setupLayout(&layout, run); return line.xToCursor(position); }
int Font::offsetForPositionForComplexText(const TextRun& run, int position, bool includePartialGlyphs) const { QString string = qstring(run); QTextLayout layout(string, font()); QTextLine line = setupLayout(&layout, run); return line.xToCursor(position); }
// // INStatsManager::makeKey // // Make a key from a path and a lump name, even if the wad's not loaded. // void INStatsManager::getLevelKey(qstring &outstr, const char *path, const char *mapName) { outstr = path; outstr.normalizeSlashes(); outstr << "::" << qstring(mapName).toUpper(); }
bool PhotoFrameSource::deserializeFromPb(const PbPhotoFrameSource * pbSource) { assert(pbSource); // read the current resource id if (pbSource->has_current_resource_id()) skipTo(qstring(pbSource->current_resource_id())); return true; }
bool CmdTestMsg::v_processArguments( int argc, char** argv, af::Msg &msg) { std::string qstring( argv[0]); int count = atoi(argv[1]); af::MCTest mctest( count, qstring); for( int i = 0; i < count; i++) mctest.addString( af::itos(i) + ": " + qstring); msg.set( af::Msg::TTESTDATA, &mctest); if( Verbose ) msg.stdOutData(); return true; }
bool FlickrPhotoFrameSource::deserializeFromPb(const PbPhotoFrameSource * pbSource) { assert(pbSource); // deserialize the core photoframe source properties if (!RSSPhotoFrameSource::deserializeFromPb(pbSource)) return false; // read the group id, tag id, user id if (pbSource->HasExtension(PbFlickrPhotoFrameSource::group_id)) _groupId = qstring(pbSource->GetExtension(PbFlickrPhotoFrameSource::group_id)); if (pbSource->HasExtension(PbFlickrPhotoFrameSource::tag_id)) _tag = qstring(pbSource->GetExtension(PbFlickrPhotoFrameSource::tag_id)); if (pbSource->HasExtension(PbFlickrPhotoFrameSource::user_id)) _userId = qstring(pbSource->GetExtension(PbFlickrPhotoFrameSource::user_id)); createLocalCacheDirectory(); return true; }
// // INStatsManager::getLevelKey // // Create the semi-unique key for a given level. In order for this // to work, the wad being referenced must have been actually loaded // via -file or some other loading mechanism. // void INStatsManager::getLevelKey(qstring &outstr, const char *mapName) { int levelLump = wGlobalDir.checkNumForName(mapName); const char *fn = wGlobalDir.getLumpFileName(levelLump); if(!fn) return; // build it outstr << fn << "::" << qstring(mapName).toUpper(); }
/* Display the retrieved module search path */ static void showpath(struct pathhead *pathq) { char *s; if ((s = qstring(pathq)) == NULL) { errno = ENOMEM; err(1, "building path string"); } printf("%s\n", s); free(s); }
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const { if (!run.length()) return 0; const QString string = fixSpacing(qstring(run)); int w = QFontMetrics(font()).width(string); // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does) if (treatAsSpace(run[0])) w -= m_wordSpacing; return w + run.padding(); }
// // INStatsManager::getLevelKey // // Create the semi-unique key for the current level. // void INStatsManager::getLevelKey(qstring &outstr) { int levelLump = g_dir->checkNumForName(gamemapname); const char *fn = g_dir->getLumpFileName(levelLump); // really should not happen. if(!fn) return; // construct the unique key for this level outstr << fn << "::" << qstring(gamemapname).toUpper(); }
FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const { const QString string = fixSpacing(qstring(run)); QTextLayout layout(string, font()); QTextLine line = setupLayout(&layout, run); float x1 = line.cursorToX(from); float x2 = line.cursorToX(to); if (x2 < x1) qSwap(x1, x2); return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h); }
bool MMLContentHandler::endElement(const QString &/*namespaceURI*/, const QString &localName, const QString &/*qName*/) { if (debug) qDebug("endElement '%s'", (const char*)localName.toUtf8()); bool valid; valid = cur->validate(); if (!valid) { err = QString("Tag '")+localName+"' is not valid: " + qstring(cur->errorMsg()); } cur = cur->parentNode(); return valid; }
static int tabBlock( UThread* ut, QTabWidget* tab, const UCell* it, const UCell* label ) { LayoutInfo layout; QLayout* lo; QWidget* wid = new QWidget; if( ! (lo = ur_qtLayout( ut, layout, it )) ) return UR_THROW; wid->setLayout( lo ); tab->addTab( wid, qstring(label) ); return UR_OK; }
bool idaapi find_var(void *ud) { vdui_t &vu = *(vdui_t *)ud; // Determine the ctree item to highlight vu.get_current_item(USE_KEYBOARD); citem_t *highlight = vu.item.is_citem() ? vu.item.e : NULL; // highlight == NULL might happen if one chooses variable at local variables declaration statement if (highlight != NULL) { // the chosen item must be an expression and of 'variable' type if (highlight->is_expr() && (highlight->op == cot_obj)) { cexpr_t *highl_expr = (cexpr_t *)highlight; char expr_name[MAXSTR]; highlight->print1(expr_name, MAXSTR, NULL); tag_remove(expr_name, expr_name, sizeof(expr_name)); // initialize type rebuilder obj_fint_t obj_find; obj_find.vtbl_name = expr_name; // traverse the ctree structure obj_find.apply_to(&vu.cfunc->body, NULL); if (obj_find.bFound) { logmsg(DEBUG, obj_find.var_name.c_str()); // Using this horrible code to remove warnings on GCC 4.9.2. Fix this later. qstring temp_var2 = qstring(obj_find.var_name.c_str()); qstring &temp_var = temp_var2; reset_pointer_type(vu.cfunc, temp_var); vu.refresh_ctext(); } else { warning("Failed to find variable..."); logmsg(DEBUG, "Failed to find variable..."); } } } else { logmsg(DEBUG, "Invalid item is choosen"); } return true; }
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const { if (!run.length()) return 0; const QString string = fixSpacing(qstring(run)); QTextLayout layout(string, font()); QTextLine line = setupLayout(&layout, run); int w = int(line.naturalTextWidth()); // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does) if (treatAsSpace(run[0])) w -= m_wordSpacing; return w + run.padding(); }
void setclvar(unsigned char *s) /* set var=value from s */ { unsigned char *p; Cell *q; for (p=s; *p != '='; p++) ; *p++ = 0; p = qstring(p, '\0'); q = setsymtab(s, p, 0.0, STR, symtab); setsval(q, p); (void)is2number(0, q); dprintf( ("command line set %s to |%s|\n", s, p) ); }
bool MMLContentHandler::startElement(const QString &/*namespaceURI*/, const QString & localName, const QString &/*qName*/, const QXmlAttributes &atts ) { if (debug) qDebug("startElement '%s'", (const char*)localName.toUtf8()); // the root element must be a 'math' element, it this is absent, // we create one if (cur == doc && localName != "math") { MMLElement *e = doc->createElement("math"); cur->appendChild(e); cur = e; } bool ok = false; MMLElement *e = doc->createElement(domstring(localName)); if (e) { cur->appendChild(e); for (int i=0; e->attributesValid() && i<atts.length(); ++i) { QString v = atts.value(i).simplified(); e->setAttribute(atts.localName(i).toUtf8(), domstring(v)); } if (e->attributesValid()) { cur = e; ok = true; } else { err = qstring(e->errorMsg()); cur = NULL; } } else { err = qstring(doc->errorMsg()); qDebug("error: %s", (const char*)err.toUtf8()); // read failed: clear all cur = NULL; } return ok; }
bool PbPersistenceManager::loadScene(const QString& filePath) { if (!exists(filePath)) return false; PbBumpTop bumptop; // read the bumptop root from disk std::ifstream fileIn(filePath.utf16(), ios::binary); if (!bumptop.ParseFromIstream(&fileIn)) { fileIn.close(); return false; } fileIn.close(); // deserialize the header (for debugging mostly) if (bumptop.has_header()) { const PbHeader& header = bumptop.header(); QString buildStr; if (header.has_build()) buildStr = qstring(header.build()); unsigned int versionNumber = 0; if (header.has_version()) versionNumber = header.version(); } // deserialize the scene data if (bumptop.has_scene()) { if (!scnManager->deserializeFromPb(&bumptop.scene())) { assert(false); return false; } } // cross reference the files in the scene data with the files actually // in the working directory scnManager->crossReference(); sel->clear(); LOG("PbPersistenceManager::loadScene successful"); return true; }
void setclvar(char *s) /* set var=value from s */ { char *p; Cell *q; for (p=s; *p != '='; p++) ; *p++ = 0; p = qstring(p, '\0'); q = setsymtab(s, p, 0.0, STR, symtab); setsval(q, p); if (is_number(q->sval)) { q->fval = atof(q->sval); q->tval |= NUM; } dprintf( ("command line set %s to |%s|\n", s, p) ); }
bool LocalPhotoFrameSource::deserializeFromPb(const PbPhotoFrameSource * pbSource) { assert(pbSource); // deserialize the core photoframe source properties if (!PhotoFrameSource::deserializeFromPb(pbSource)) return false; // read the local file path if (pbSource->HasExtension(PbLocalPhotoFrameSource::file_path)) { QString filePath = qstring(pbSource->GetExtension(PbLocalPhotoFrameSource::file_path)); _localPath = QDir(filePath); } return true; }
/* Set the module search path after changing it */ static void setpath(struct pathhead *pathq) { char *newpath; if (miblen == 0) getmib(); if ((newpath = qstring(pathq)) == NULL) { errno = ENOMEM; err(1, "building path string"); } if (sysctl(mib, miblen, NULL, NULL, newpath, strlen(newpath)+1) == -1) err(1, "setting path: sysctl(%s)", pathctl); if (modpath != NULL) free(modpath); modpath = newpath; }
QString ConfigWindow::getcurrentTime() { char buffer[256]; time_t curtime; struct tm *loctime; /* Get the current time. */ curtime = time (NULL); /* Convert it to local time representation. */ loctime = localtime (&curtime); /* Print it out in a nice format. */ strftime (buffer, 256, "_%I_%M", loctime); QString qstring(buffer); return qstring; }
bool MMLContentHandler::characters(const QString &ch) { if (debug) qDebug("characters: %s", (const char*)ch.toUtf8()); bool valid = true; if (!ch.simplified().isEmpty()) { MMLText *t; MMLNode *n = cur->lastChild(); if (n && n->isText()) { t = static_cast<MMLText *>(n); t->appendData(domstring(ch)); } else { t = doc->createTextNode(domstring(ch)); cur->appendChild(t); } valid = cur->validate(); if (!valid) { err = qstring(cur->errorMsg()); } } return valid; }
//-------------------------------------------------------------------------- // input is valid only if n==0 int idaapi dosbox_debmod_t::dbg_process_get_info(int n, const char * /*input*/, process_info_t *info) { if ( n == 0 ) // initialize the list { // if ( !trk.get_process_list(proclist) ) return 0; #if 0 // commented out because we can not match file names with process names if ( input != NULL ) { // remove all unmatching processes from the list qstring inpbuf; input = qbasename(input); const char *end = strchr(input, '.'); if ( end != NULL ) { // ignore everything after '.' (remove extension) inpbuf = qstring(input, end-input); input = inpbuf.c_str(); } for ( int i=proclist.size()-1; i >= 0; i-- ) if ( strstr(proclist[i].name.c_str(), input) == NULL ) proclist.erase(proclist.begin()+i); } #endif } /* if ( n >= proclist.size() ) return 0; if ( info != NULL ) { proclist_entry_t &pe = proclist[n]; info->pid = pe.pid; qstrncpy(info->name, pe.name.c_str(), sizeof(info->name)); } */ return 1; }
int main( int argc, char *argv[] ) { const char *fs = NULL; char **eargv = NULL; int eargc; setlocale( LC_CTYPE, "" ); setlocale( LC_NUMERIC, "C" ); /* for parsing cmdline & prog */ cmdname = argv[0]; if( argc == 1 ) { fprintf( stderr, "usage: %s [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]\n", cmdname ); exit( 1 ); } signal( SIGFPE, fpecatch ); srand_seed = 1; srand( (unsigned)srand_seed ); yyin = NULL; symtab = makesymtab( NSYMTAB/NSYMTAB ); if( argc == 2 && argv[1][0] == '@' && argv[1][1] != '\0' ) { const char *env; env = getenv( &argv[1][1] ); if( env != NULL ) { eargc = ParseEnvVar( env, NULL, NULL ); // count parameters. eargv = malloc( eargc * sizeof( char * ) + strlen( env ) + 1 + eargc ); ParseEnvVar( env, eargv, (char *)( eargv + eargc ) ); argc = eargc; argv = eargv; } } while( argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0' ) { if( strcmp( argv[1], "-version" ) == 0 || strcmp( argv[1], "--version" ) == 0 ) { printf( "awk %s\n", version ); exit( 0 ); break; } if( strncmp( argv[1], "--", 2 ) == 0 ) { /* explicit end of args */ argc--; argv++; break; } switch( argv[1][1] ) { case 's': if( strcmp( argv[1], "-safe" ) == 0 ) safe = true; break; case 'f': /* next argument is program filename */ if( argv[1][2] != '\0' ) { /* arg is -fsomething */ if( npfile >= MAX_PFILE - 1 ) { FATAL( "too many -f options" ); } pfile[npfile++] = unquote( &argv[1][2] ); } else { /* arg is -f something */ argc--; argv++; if( argc <= 1 ) { FATAL( "no program filename" ); } if( npfile >= MAX_PFILE - 1 ) { FATAL( "too many -f options" ); } pfile[npfile++] = unquote( argv[1] ); } break; case 'F': /* set field separator */ if( argv[1][2] != '\0' ) { /* arg is -Fsomething */ if( argv[1][2] == 't' && argv[1][3] == '\0' ) { /* wart: t=>\t */ fs = "\t"; } else if( argv[1][2] != '\0' ) { fs = &argv[1][2]; } } else { /* arg is -F something */ argc--; argv++; if( argc > 1 && argv[1][0] == 't' && argv[1][1] == '\0' ) { /* wart: t=>\t */ fs = "\t"; } else if( argc > 1 && argv[1][0] != '\0' ) { fs = &argv[1][0]; } } if( fs == NULL || *fs == '\0' ) WARNING( "field separator FS is empty" ); break; case 'v': /* -v a=1 to be done NOW. one -v for each */ if( argv[1][2] != '\0' ) { /* arg is -vsomething */ char *p; p = unquote( &argv[1][2] ); if( isclvar( p ) ) { setclvar( p ); } else { FATAL( "invalid -v option argument: %s", p ); } } else { /* arg is -v something */ char *p; argc--; argv++; if( argc <= 1 ) { FATAL( "no variable name" ); } p = unquote( argv[1] ); if( isclvar( p ) ) { setclvar( p ); } else { FATAL( "invalid -v option argument: %s", p ); } } break; case 'd': dbg = atoi( &argv[1][2] ); if( dbg == 0 ) dbg = 1; printf( "awk %s\n", version ); break; default: WARNING( "unknown option %s ignored", argv[1] ); break; } argc--; argv++; } /* argv[1] is now the first argument */ if( npfile == 0 ) { /* no -f; first argument is program */ char *p; if( argc <= 1 ) { if( dbg ) exit( 0 ); FATAL( "no program given" ); } p = unquote( argv[1] ); dprintf(( "program = |%s|\n", p )); lexprog = p; argc--; argv++; } for( eargc = 1; eargc < argc; ++eargc ) { argv[eargc] = unquote( argv[eargc] ); } recinit( recsize ); syminit(); compile_time = 1; argv[0] = cmdname; /* put prog name at front of arglist */ dprintf(( "argc=%d, argv[0]=%s\n", argc, argv[0] )); arginit( argc, argv ); if( !safe ) envinit( environ ); yyparse(); setlocale( LC_NUMERIC, "" ); /* back to whatever it is locally */ if( fs ) *FS = qstring( fs, '\0' ); dprintf(( "errorflag=%d\n", errorflag )); if( errorflag == 0 ) { compile_time = 0; run( winner ); } else { bracecheck(); } return( errorflag ); }
void sendcoinsdialog::on_sendbutton_clicked() { if(!model || !model->getoptionsmodel()) return; qlist<sendcoinsrecipient> recipients; bool valid = true; for(int i = 0; i < ui->entries->count(); ++i) { sendcoinsentry *entry = qobject_cast<sendcoinsentry*>(ui->entries->itemat(i)->widget()); if(entry) { if(entry->validate()) { recipients.append(entry->getvalue()); } else { valid = false; } } } if(!valid || recipients.isempty()) { return; } fnewrecipientallowed = false; walletmodel::unlockcontext ctx(model->requestunlock()); if(!ctx.isvalid()) { // unlock wallet was cancelled fnewrecipientallowed = true; return; } // prepare transaction for getting txfee earlier walletmodeltransaction currenttransaction(recipients); walletmodel::sendcoinsreturn preparestatus; if (model->getoptionsmodel()->getcoincontrolfeatures()) // coin control enabled preparestatus = model->preparetransaction(currenttransaction, coincontroldialog::coincontrol); else preparestatus = model->preparetransaction(currenttransaction); // process preparestatus and on error generate message shown to user processsendcoinsreturn(preparestatus, moorecoinunits::formatwithunit(model->getoptionsmodel()->getdisplayunit(), currenttransaction.gettransactionfee())); if(preparestatus.status != walletmodel::ok) { fnewrecipientallowed = true; return; } camount txfee = currenttransaction.gettransactionfee(); // format confirmation message qstringlist formatted; foreach(const sendcoinsrecipient &rcp, currenttransaction.getrecipients()) { // generate bold amount string qstring amount = "<b>" + moorecoinunits::formathtmlwithunit(model->getoptionsmodel()->getdisplayunit(), rcp.amount); amount.append("</b>"); // generate monospace address string qstring address = "<span style='font-family: monospace;'>" + rcp.address; address.append("</span>"); qstring recipientelement; if (!rcp.paymentrequest.isinitialized()) // normal payment { if(rcp.label.length() > 0) // label with address { recipientelement = tr("%1 to %2").arg(amount, guiutil::htmlescape(rcp.label)); recipientelement.append(qstring(" (%1)").arg(address)); } else // just address { recipientelement = tr("%1 to %2").arg(amount, address); } } else if(!rcp.authenticatedmerchant.isempty()) // authenticated payment request { recipientelement = tr("%1 to %2").arg(amount, guiutil::htmlescape(rcp.authenticatedmerchant)); } else // unauthenticated payment request { recipientelement = tr("%1 to %2").arg(amount, address); } formatted.append(recipientelement); } qstring questionstring = tr("are you sure you want to send?"); questionstring.append("<br /><br />%1"); if(txfee > 0) { // append fee string if a fee is required questionstring.append("<hr /><span style='color:#aa0000;'>"); questionstring.append(moorecoinunits::formathtmlwithunit(model->getoptionsmodel()->getdisplayunit(), txfee)); questionstring.append("</span> "); questionstring.append(tr("added as transaction fee")); // append transaction size questionstring.append(" (" + qstring::number((double)currenttransaction.gettransactionsize() / 1000) + " kb)"); } // add total amount in all subdivision units questionstring.append("<hr />"); camount totalamount = currenttransaction.gettotaltransactionamount() + txfee; qstringlist alternativeunits; foreach(moorecoinunits::unit u, moorecoinunits::availableunits()) { if(u != model->getoptionsmodel()->getdisplayunit()) alternativeunits.append(moorecoinunits::formathtmlwithunit(u, totalamount)); } questionstring.append(tr("total amount %1 (= %2)") .arg(moorecoinunits::formathtmlwithunit(model->getoptionsmodel()->getdisplayunit(), totalamount)) .arg(alternativeunits.join(" " + tr("or") + " "))); qmessagebox::standardbutton retval = qmessagebox::question(this, tr("confirm send coins"), questionstring.arg(formatted.join("<br />")), qmessagebox::yes | qmessagebox::cancel, qmessagebox::cancel); if(retval != qmessagebox::yes) { fnewrecipientallowed = true; return; } // now send the prepared transaction walletmodel::sendcoinsreturn sendstatus = model->sendcoins(currenttransaction); // process sendstatus and on error generate message shown to user processsendcoinsreturn(sendstatus); if (sendstatus.status == walletmodel::ok) { accept(); coincontroldialog::coincontrol->unselectall(); coincontrolupdatelabels(); } fnewrecipientallowed = true; }