/*! If \a score is true, print the oom_score values for all the processes. Otherwise, print the oom_adj values for all the processes. \internal */ void OomPrivate::printOomValues(bool score) const { QDir proc("/proc"); QStringList procDirs; procDirs = proc.entryList(QDir::AllDirs,QDir::Name|QDir::Reversed); QString dir; QString oom_file; bool ok = false; foreach (dir,procDirs) { dir.toLong(&ok); //only want processes if (ok) { oom_file = QString("/proc/") + dir; if (score) oom_file = oom_file + QString("/oom_score"); else oom_file = oom_file + QString("/oom_adj"); QFile file(oom_file); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qLog(OOM) << "Unable to open " << oom_file; continue; } QTextStream in(&file); QString s = in.readAll(); long oom_value = s.toLong(&ok); if (score) qLog(OOM) << oom_file << "oom_score = " << oom_value; else qLog(OOM) << oom_file << "oom_adj = " << oom_value; } }
void XCLProcessor::performDecompress(QByteArray* ba, QVector<XCLProcessParameter> param, FileParserState& state) { //TODO: check parameters !! //Test code for zlibDeflateInflate XCLProcessParameter p=param.at(0); QString compressionMethod =p.getValue(state.index); p=param.at(1); QString startStr = p.getValue(state.index); p=param.at(2); QString endStr = p.getValue( state.index); _LENGTH start= startStr.toLong( ); _LENGTH end= endStr.toLong(); QByteArray head = ba->left(start); QByteArray body = ba->mid(start,end); QByteArray tail = ba->mid(end,ba->size()); XCLDataConverter convert; QVector<XCLFilter> filterChain; XCLFilter filter; filter.setFilterName("compression"); filter.setFilterValue("zlibDeflateInflate"); filterChain.append(filter); QByteArray cvalue=convert.filter(&body, filterChain); delete ba; ba =new QByteArray(); *ba+=head; *ba+=body; *ba+=tail; }
//Parsing torrent file void MiniServer::parseFile(QString filename) { QFile ifile(filename); QByteArray read1; ifile.open(QIODevice::ReadOnly); read1 = ifile.readLine(); while (read1.size() != 0) { QString command; int i = 0; QString read(read1); read.truncate(read.size()-1); while (read.at(i) != ' ') { command.append(read.at(i)); i++; } i++; if (!command.compare("name")) { //Reading name while (i < read.size()) { this->filename.append(read.at(i)); i++; } } else if (!command.compare("piece-length")) { //Reading piece length QString num; while (i < read.size()) { num.append(read.at(i)); i++; } this->pieceSize = (qint64)num.toLong(); } else if (!command.compare("size")) { //Reading piece size QString num; while (i < read.size()) { num.append(read.at(i)); i++; } this->size = (qint64)num.toLong(); } else if (!command.compare("piece-hash")) { //Reading number of piece hashes QString num; while (i < read.size()) { num.append(read.at(i)); i++; } qint64 pieces = (qint64)num.toLong(); int j = 0; for ( ; j < pieces; j++) { //Reading piece hashes read1 = ifile.readLine(); QString line(read1); line.truncate(line.size() - 1); this->pieceHashes.append(line); } } read1 = ifile.readLine(); } ifile.close(); }
void QDesignerToolBar::dropEvent( QDropEvent *e ) { if ( e->provides( "application/x-designer-actions" ) || e->provides( "application/x-designer-actiongroup" ) || e->provides( "application/x-designer-separator" ) ) e->accept(); else return; QString s; if ( e->provides( "application/x-designer-actiongroup" ) ) s = QString( e->encodedData( "application/x-designer-actiongroup" ) ); else if ( e->provides( "application/x-designer-separator" ) ) s = QString( e->encodedData( "application/x-designer-separator" ) ); else s = QString( e->encodedData( "application/x-designer-actions" ) ); indicator->hide(); QAction *a = 0; int index = actionList.findRef( *actionMap.find( insertAnchor ) ); if ( index != -1 && afterAnchor ) ++index; if ( !insertAnchor ) index = 0; if ( e->provides( "application/x-designer-actions" ) || e->provides( "application/x-designer-separator" ) ) { if ( e->provides( "application/x-designer-actions" ) ) a = (QDesignerAction*)s.toLong(); else a = (QSeparatorAction*)s.toLong(); } else { a = (QDesignerActionGroup*)s.toLong(); } if ( actionList.findRef( a ) != -1 ) { QMessageBox::warning( MainWindow::self, tr( "Insert/Move Action" ), tr( "Action '%1' has already been added to this toolbar.\n" "An Action may only occur once in a given toolbar." ). arg( a->name() ) ); return; } AddActionToToolBarCommand *cmd = new AddActionToToolBarCommand( tr( "Add Action '%1' to Toolbar '%2'" ). arg( a->name() ).arg( caption() ), formWindow, a, this, index ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); lastIndicatorPos = QPoint( -1, -1 ); }
long qt1lStrToLong(QString& Str) { //long Num = 0; //Str.ToLong(&Num); //return Num; return Str.toLong(); }
/*! \brief Konstruktor, ve kterem parametry prijimame id, pocet neprectenych polozek a cas nejnovejsi polozky */ Feed::Feed(QString id, QString title, QList<QString> label, QString firstItemMsec) { _id = id; _title = title; _labelList.append(label); _firstItemMsec = firstItemMsec.toLong(); _unreadCount = 0; }
int DMetadata::getItemPickLabel() const { if (getFilePath().isEmpty()) { return -1; } if (hasXmp()) { QString value = getXmpTagString("Xmp.digiKam.PickLabel", false); if (!value.isEmpty()) { bool ok = false; long pickId = value.toLong(&ok); if (ok && pickId >= NoPickLabel && pickId <= AcceptedLabel) { return pickId; } } } return -1; }
long QgsCoordinateReferenceSystem::getRecordCount() { sqlite3 *myDatabase; const char *myTail; sqlite3_stmt *myPreparedStatement; int myResult; long myRecordCount = 0; //check the db is available myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase ); if ( myResult != SQLITE_OK ) { QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) ); return 0; } // Set up the query to retrieve the projection information needed to populate the ELLIPSOID list QString mySql = "select count(*) from tbl_srs"; myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.toUtf8().length(), &myPreparedStatement, &myTail ); // XXX Need to free memory from the error msg if one is set if ( myResult == SQLITE_OK ) { if ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW ) { QString myRecordCountString = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ); myRecordCount = myRecordCountString.toLong(); } } // close the sqlite3 statement sqlite3_finalize( myPreparedStatement ); sqlite3_close( myDatabase ); return myRecordCount; }
void QLongSpinBox::setText(QString t) { m_value = t.toLong(); lineEdit()->setText(QString::number(m_value)); emit valueChanged(m_value); emit valueChanged(text()); }
Money::Money(QString Cash) { Cash.remove(QRegExp(" ")); gold = Cash.section(",",0,0).toLong(); QString pen = appendZero(Cash.section(",",1,1)); penny = pen.toLong(); }
void SetValue(void* Pointer, const QString &Value, int Type) { if (!Pointer) return; switch (Type) { case QMetaType::Char: *((char*)Pointer) = Value.isEmpty() ? 0 : Value.at(0).toLatin1(); return; case QMetaType::UChar: *((unsigned char*)Pointer) = Value.isEmpty() ? 0 :Value.at(0).toLatin1(); return; case QMetaType::QChar: *((QChar*)Pointer) = Value.isEmpty() ? 0 : Value.at(0); return; case QMetaType::Bool: *((bool*)Pointer) = ToBool(Value); return; case QMetaType::Short: *((short*)Pointer) = Value.toShort(); return; case QMetaType::UShort: *((ushort*)Pointer) = Value.toUShort(); return; case QMetaType::Int: *((int*)Pointer) = Value.toInt(); return; case QMetaType::UInt: *((uint*)Pointer) = Value.toUInt(); return; case QMetaType::Long: *((long*)Pointer) = Value.toLong(); return; case QMetaType::ULong: *((ulong*)Pointer) = Value.toULong(); return; case QMetaType::LongLong: *((qlonglong*)Pointer) = Value.toLongLong(); return; case QMetaType::ULongLong: *((qulonglong*)Pointer) = Value.toULongLong(); return; case QMetaType::Double: *((double*)Pointer) = Value.toDouble(); return; case QMetaType::Float: *((float*)Pointer) = Value.toFloat(); return; case QMetaType::QString: *((QString*)Pointer) = Value; return; case QMetaType::QByteArray: *((QByteArray*)Pointer) = Value.toUtf8(); return; case QMetaType::QTime: *((QTime*)Pointer) = QTime::fromString(Value, Qt::ISODate); return; case QMetaType::QDate: *((QDate*)Pointer) = QDate::fromString(Value, Qt::ISODate); return; case QMetaType::QDateTime: { QDateTime dt = QDateTime::fromString(Value, Qt::ISODate); dt.setTimeSpec(Qt::UTC); *((QDateTime*)Pointer) = dt; return; } default: break; } }
/*! Returns the application name of the process that has the biggest OOM score found in \a map. It reads the value in the oom_score file in /proc for each app/pid pair in \a map. \internal */ QString OomPrivate::procWithBiggestScore(const QMap<QString,int>& map) const { int biggest_score = -10000; QString oom_file; QString application(""); if (map.isEmpty()) return application; QMap<QString,int>::const_iterator i = map.constBegin(); while (i != map.constEnd()) { oom_file = QString("/proc/%1/oom_score").arg(i.value()); QFile file(oom_file); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qLog(OOM) << "Unable to open:" << oom_file; continue; } bool ok; QTextStream in(&file); QString s = in.readAll(); long oom_score = s.toLong(&ok); if (ok) { qLog(OOM) << oom_file << "oom_score =" << oom_score; if (oom_score > biggest_score) { biggest_score = oom_score; application = i.key(); } } ++i; } return application; }
void qsldb::viewCard(QString qsoid, int r) { QString len; unsigned long il; qy = "SELECT strlen FROM "+logFile+"card WHERE qsocid="+qsoid; len = db->GetOneField(qy); if(len.count()) { il = len.toLong(); QPixmap bild; qy = "SELECT qcard FROM "+logFile+"card WHERE qsocid="+qsoid; res = db->Real_Query(qy, qy.count()); res->Next(); rows = res->GetCurrentRow(); r = 1; bild.loadFromData((uchar*)rows->GetField(r),il); res->Close(); cardLabel->setPixmap(bild); cardLabel->adjustSize(); } else { s = path+"/log/icon/dl1hbd.jpg"; cardLabel->setPixmap(QPixmap(s)); cardLabel->adjustSize(); } }
IlwisTypes Domain::ilwType(const QString &value) { std::set<QString> booleans ={ "yes","no","true","false"}; if ( booleans.find(value.toLower()) != booleans.end()) return itBOOL; bool ok; ushort vu = value.toUShort(&ok); if ( ok && vu < 255) return itUINT8; if ( ok) return itUINT16; short vs = value.toShort(&ok); if ( ok && vs > -128 && vs < 128) return itINT8; if ( ok) return itINT16; value.toULong(&ok); if ( ok) return itUINT32; value.toLong(&ok); if ( ok) return itINT32; value.toLongLong(&ok); if ( ok) return itINT64; value.toDouble(&ok); if ( ok) return itDOUBLE; return IlwisObject::findType(value); }
void HttpDownload::slotResponseHeaderReceived( const QHttpResponseHeader & resp ){ QString contentLength = resp.value("Content-Length"); if( !contentLength.isEmpty() ){ long length = contentLength.toLong(); } //user define!! if(!this->fileName.isEmpty()) return; QString disposition = resp.value("Content-Disposition"); disposition.replace(" " ,"",Qt::CaseInsensitive); QStringList list = disposition.split(";"); QString fileName = ""; QRegExp exp = QRegExp("[ ]*[filename][ ]*=[ ]*.*"); exp.setCaseSensitivity(Qt::CaseInsensitive); for(int i = 0 ; i < list.size() ; i ++){ QString tempStr = list.value(i); if( tempStr.contains(exp)) { exp = QRegExp("[ ]*filename[ ]*=[ ]*"); exp.setCaseSensitivity(Qt::CaseInsensitive); fileName = tempStr.remove(exp); break; } } if(!fileName.isEmpty()){ this->fileName = fileName; } }
long Hoot::_toBytes(const QString& str) const { QString s = str; long multiplier = 1; if (s.endsWith("KB")) { multiplier = 1000; s = s.remove(s.size() - 2, 2); } else if (s.endsWith("MB")) { multiplier = 1000 * 1000; s = s.remove(s.size() - 2, 2); } else if (s.endsWith("GB")) { multiplier = 1000 * 1000 * 1000; s = s.remove(s.size() - 2, 2); } bool ok; long result = s.toLong(&ok) * multiplier; if (!ok) { throw HootException("Unable to parse max memory usage: " + s); } return result; }
void OsmApiDbReader::open(QString urlStr) { if (!isSupported(urlStr)) { throw HootException("An unsupported URL was passed in."); } _elementResultIterator.reset(); _selectElementType = ElementType::Node; QUrl url(urlStr); QString osmElemId = url.queryItemValue("osm-element-id"); QString osmElemType = url.queryItemValue("osm-element-type"); LOG_DEBUG("url path = "+url.path()); bool ok; _database.open(url); if(osmElemId.length() > 0 && osmElemType.length() > 0) { _osmElemId = osmElemId.toLong(&ok); _osmElemType = ElementType::fromString(osmElemType); } //using a transaction seems to make sense here, b/c we don't want to read a map being modified //in the middle of its modification caused by a changeset upload, which could cause the map to //be invalid as a whole _database.transaction(); _open = true; }
long Util::ApplicationConfig::getNumericValue ( QString key, std::auto_ptr<long> minValue, std::auto_ptr<long> maxValue, const long defaultValue ) { if (!_map.contains (key)) { return defaultValue; } QString value = getValue (key); bool ok = true; long result = value.toLong (&ok); if (!ok) { return defaultValue; } if ((minValue.get () != NULL) && (result < (*minValue))) { result = *minValue; } if ((maxValue.get () != NULL) && (result > (*maxValue))) { result = *maxValue; } return result; }
//! //! value changed //! void MEIntSliderPort::text2CB(const QString &text) { m_value = text.toLong(); sendParamMessage(); // inform parent widget that m_value has been changed node->setModified(true); }
QValidator::State QLongSpinBox::validate(QString &input, int &pos) const { long val = input.toLong(); if (val < m_min || val > m_max) { return QValidator::Intermediate; } return QValidator::Acceptable; }
void MessageReceiverTask::parseMessage( YMSGTransfer *t ) { kdDebug(YAHOO_RAW_DEBUG) ; int cnt = t->paramCount( 5 ); for( int i = 0; i < cnt; ++i ) { QString to = t->nthParam( 5, i ); QString timestamp = t->nthParamSeparated( 15, i, 4 ); QString utf8 = t->nthParamSeparated( 97, i, 4 ); QString from = t->nthParamSeparated( 1, i, 4 ).isEmpty() ? t->nthParam( 4, i ) : t->nthParamSeparated( 1, i, 4 ); QString msg = t->nthParamSeparated( 14, i, 4 ); QString sysmsg = t->nthParamSeparated( 16, i, 4 ); // The arrangement of the key->value pairs is different when there is only one message in the packet. // Separating by key "5" (sender) doesn't work in that case, because the "1" and "4" keys are sent before the "5" key if( cnt == 1 ) from = t->firstParam( 1 ).isEmpty() ? t->firstParam( 4 ) : t->firstParam( 1 ); if( !sysmsg.isEmpty() ) { client()->notifyError( "Server message received: ", sysmsg, Client::Error ); continue; } if( msg.isEmpty() ) { kdDebug(YAHOO_RAW_DEBUG) << "Got a empty message. Dropped." << endl; continue; } if( utf8.startsWith( "1" ) ) msg = QString::fromUtf8( msg.latin1() ); if( t->service() == Yahoo::ServiceSysMessage ) emit systemMessage( sysmsg ); else { if( msg.startsWith( "<ding>" ) ) emit gotBuzz( from, timestamp.toLong() ); else emit gotIm( from, msg, timestamp.toLong(), 0); } } }
int getMasterVolume(long* vol) { QString str = QString::fromStdString(exec("osascript -e \"output volume of (get volume settings)\"")); str.replace("\"", ""); str.replace("\n", ""); bool ok; *vol = str.toLong(&ok, 10); return ok; }
int DMetadata::getItemColorLabel() const { if (getFilePath().isEmpty()) { return -1; } if (hasXmp()) { QString value = getXmpTagString("Xmp.digiKam.ColorLabel", false); if (value.isEmpty()) { // Nikon NX use this XMP tags to store Color Labels value = getXmpTagString("Xmp.photoshop.Urgency", false); } if (!value.isEmpty()) { bool ok = false; long colorId = value.toLong(&ok); if (ok && colorId >= NoColorLabel && colorId <= WhiteLabel) { return colorId; } } // LightRoom use this tag to store color name as string. // Values are limited : see bug #358193. value = getXmpTagString("Xmp.xmp.Label", false); if (value == QLatin1String("Blue")) { return BlueLabel; } else if (value == QLatin1String("Green")) { return GreenLabel; } else if (value == QLatin1String("Red")) { return RedLabel; } else if (value == QLatin1String("Yellow")) { return YellowLabel; } else if (value == QLatin1String("Purple")) { return MagentaLabel; } } return -1; }
//比较数字型字符串 返回值: 0 相等 -1 小于 1 大于 -2 str1格式错误 2 str2格式错误 int CMisc::CompareStringNum(const QString& str1, const QString& str2) { bool bOk = false; long lNum1 = str1.toLong(&bOk); if(!bOk) return -2; long lNum2 = str2.toLong(&bOk); if(!bOk) return 2; if(lNum1 < lNum2) return -1; else if(lNum1 > lNum2) return 1; else return 0; }
void QLongSpinBox::fixup(QString &str) const { long val = str.toLong(); if (val < m_min) val = m_min; if (val > m_max) val = m_max; str = QString::number(val); }
void Widget::toLongFunction() { //! [73] QString str = "FF"; bool ok; long hex = str.toLong(&ok, 16); // hex == 255, ok == true long dec = str.toLong(&ok, 10); // dec == 0, ok == false //! [73] }
void tst_QAndroidJniObject::callStaticLongMethodClassName() { QString number = QString::number(123); QAndroidJniObject parameter = QAndroidJniObject::fromString(number); jlong returnValue = QAndroidJniObject::callStaticMethod<jlong>("java/lang/Long", "parseLong", "(Ljava/lang/String;)J", parameter.object<jstring>()); QCOMPARE(returnValue, jlong(number.toLong())); }
void ServicesDbReader::open(QString urlStr) { if (!isSupported(urlStr)) { throw HootException("An unsupported URL was passed in."); } QUrl url(urlStr); QString osmElemId = url.queryItemValue("osm-element-id"); QString osmElemType = url.queryItemValue("osm-element-type"); QStringList pList = url.path().split("/"); bool ok; bool ok2; QString mapName; _database.open(url); _mapId = pList[pList.size() - 1].toLong(&ok); if(osmElemId.length() > 0 && osmElemType.length() > 0) { _osmElemId = osmElemId.toLong(&ok2); _osmElemType = ElementType::fromString(osmElemType); } if (!ok) { if (_email == "") { throw HootException("If a map name is specified then the user email must also be specified " "via: " + emailKey()); } mapName = pList[pList.size() - 1]; long userId = _database.getUserId(_email); set<long> mapIds = _database.selectMapIds(mapName, userId); if (mapIds.size() != 1) { QString str = QString("Expected 1 map with the name '%1' but found %2 maps.").arg(mapName) .arg(mapIds.size()); throw HootException(str); } _mapId = *mapIds.begin(); } if (!_database.mapExists(_mapId)) { _database.close(); throw HootException("No map exists with ID: " + QString::number(_mapId)); } //using a transaction seems to make sense here, b/c we don't want to read a map being modified //in the middle of its modification caused by a changeset upload, which could cause the map to //be invalid as a whole _database.transaction(); _open = true; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QString strHwnd; strHwnd.append(argv[1]); ClientWindow w(NULL, (HWND)strHwnd.toLong()); w.show(); return a.exec(); }
void XDNet::slotReadBuffer() { long xmlSize; QString buffer; char ch; long read = 0; long totalread; QString str; do { buffer = ""; while((ch = m_socket->getch()) != 0) { buffer += ch; } xmlSize = buffer.toLong(); char data[xmlSize+1]; totalread = 0; int aa; while(totalread != xmlSize) { aa = m_socket->bytesAvailable(); read = m_socket->readBlock(&data[totalread], xmlSize-totalread); if(read == -1) { return; } // if(read == 0) break; if(read == 0) { m_socket->waitForMore (-1, 0L); } totalread += read; } data[xmlSize] = 0; // if(m_superglobalsCount == 9) { // std::cerr << "read: " << totalread << ", datalen: [" << xmlSize << "]>>>>\n" << data << "\n<<<\n" << std::endl; // } str.setAscii(data,xmlSize); processXML(str); } while(m_socket->bytesAvailable()); }