/*!
  Reads from the I/O device \a dev and parses it.
*/
void TMultipartFormData::parse(QIODevice *dev)
{
    if (!dev->isOpen()) {
        if (!dev->open(QIODevice::ReadOnly)) {
            return;
        }
    }

    while (!dev->atEnd()) {  // up to EOF
        TMimeHeader header = parseMimeHeader(dev);
        if (!header.isEmpty()) {
            QByteArray type = header.header("content-type");
            if (!type.isEmpty()) {
                if (!header.originalFileName().isEmpty()) {
                    QString contFile = writeContent(dev);
                    if (!contFile.isEmpty()) {
                        uploadedFiles << TMimeEntity(header, contFile);
                    }
                }
            } else {
                QByteArray name = header.dataName();
                QByteArray cont = parseContent(dev);

                QTextCodec *codec = Tf::app()->codecForHttpOutput();
                postParameters.insertMulti(codec->toUnicode(name), codec->toUnicode(cont));
            }
        }
    }
}
Esempio n. 2
0
QgsMessageBarItem *QgsMessageBarItem::setLevel( QgsMessageBar::MessageLevel level )
{
  mLevel = level;
  writeContent();
  emit styleChanged( mStyleSheet );
  return this;
}
Esempio n. 3
0
int  RJBufCopy( RJFILE *dest, RJFILE *src )
// copy src's rec_buf to dest' rec_buf
{
    int  i;
    for( i=RJ_TYPE; i<=RJ_DATA; i++ )
       if ( !writeContent(dest,i,readContent(src,i) )) return 0;
    return 1;
}
Esempio n. 4
0
/**
 * Encrypts and writes DB content to the given array.
 * In case of error emits a dbSaveError with error code and returns false.
 */
bool PwDatabaseV3::save(QByteArray& outData) {
    QString saveErrorMessage = tr("Cannot save database", "An error message");

    outData.clear();

    // pack up the groups&entries
    setPhaseProgressBounds(SAVE_PROGRESS_PACK_DATA);
    QByteArray contentData;
    int groupCount, entryCount;
    ErrorCode err = writeContent(contentData, groupCount, entryCount);
    if (err != SUCCESS) {
        emit dbSaveError(saveErrorMessage, err);
        return false;
    }

    // now update the header (hash and counts)
    header.setGroupCount(groupCount);
    header.setEntryCount(entryCount);
    LOG("Saving %d groups and %d entries", groupCount, entryCount);

    QByteArray contentHash;
    CryptoManager* cm = CryptoManager::instance();
    if (cm->sha256(contentData, contentHash) != SB_SUCCESS) {
        emit dbSaveError(saveErrorMessage, CONTENT_HASHING_ERROR);
        return false;
    }
    header.setContentHash(contentHash);

    // update encryption seeds and transform the keys
    header.randomizeInitialVectors();
    setPhaseProgressBounds(SAVE_PROGRESS_KEY_TRANSFORM);
    PwDatabase::ErrorCode dbErr = transformKey(header.getMasterSeed(), header.getTransformSeed(),
            header.getTransformRounds(), combinedKey, masterKey);
    if (dbErr != PwDatabase::SUCCESS) {
        LOG("transformKey error while saving: %d", dbErr);
        emit dbSaveError(saveErrorMessage, dbErr);
        return false;
    }

    // write the header
    QDataStream outStream(&outData, QIODevice::WriteOnly);
    outStream.setByteOrder(QDataStream::LittleEndian);
    header.write(outStream);

    // encrypt the content
    setPhaseProgressBounds(SAVE_PROGRESS_ENCRYPTION);
    QByteArray encryptedContentData;
    err = encryptContent(contentData, encryptedContentData);
    Util::safeClear(contentData);
    if (err != SUCCESS) {
        LOG("encryptContent error while saving: %d", err);
        emit dbSaveError(saveErrorMessage, err);
        return false;
    }
    outData.append(encryptedContentData);
    return true;
}
Esempio n. 5
0
void SpiceInfo::writeContentFile(const QString &path)
{
    QFile file(path);
    if(!file.open(QFile::WriteOnly | QFile::Text))
    {
        qDebug() << __FILE__ << __LINE__ << "cannot open file.";
    }

    writeContent(&file);
}
bool ExtensionAgentResponse::sendContent(string content) {
	if (!addHeader("Content-Type", "text/html")) return false;
	if (!addHeader("Cache-Control", "no-cache")) return false;
	if (!addHeader("Pragma", "no-cache")) return false;
	if (!addHeader("Expires", "0")) return false;

	if (!startResponse(HTTP_STATUS_OK, "success", headers))
		return false;

	return writeContent(content.c_str(), content.size());
}
Esempio n. 7
0
//virtual
bool JsonGenerator::createOutput() {
    //let's not forget about json_utils.hpp
    std::string content = getTemplateContent("json_utils.hpp");
    registerOutputTemplate("json_utils", content);

    std::map<std::string, FTemplate>::iterator i = outputTemplates.begin();
    for(; i != outputTemplates.end(); ++i) {
        std::string fName = toFileName(i->first);
        writeContent(fName, i->second.getContent());
    }
    return true;
}
Esempio n. 8
0
QgsMessageBarItem::QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level, int duration, QWidget *parent )
    : QWidget( parent )
    , mTitle( QLatin1String( "" ) )
    , mText( QLatin1String( "" ) )
    , mLevel( level )
    , mDuration( duration )
    , mWidget( widget )
    , mUserIcon( QIcon() )
    , mLayout( nullptr )
{
  writeContent();
}
Esempio n. 9
0
QgsMessageBarItem::QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level, int duration, QWidget *parent )
    : QWidget( parent )
    , mTitle( title )
    , mText( text )
    , mLevel( level )
    , mDuration( duration )
    , mWidget( widget )
    , mUserIcon( QIcon() )
    , mLayout( nullptr )
{
  writeContent();
}
Esempio n. 10
0
void G3D::write(AbstractWriter& writer, const GeometrySoA& geometry, uint32_t vertexType) {
    if (writer.isOpen()) {
        if (vertexType == SoA) {
            writeHeader(writer, geometry.info);
            writeContent(writer, geometry);
        } else if (vertexType == AoS) {
            writeHeader(writer, geometry.info, &vertexType);
            writeIndices(writer, geometry.indices, geometry.info);
            auto vertices = convertVertices(geometry.vertexAttributes, geometry.info);
            writeVertices(writer, vertices, geometry.info);
        }
    }
}
Esempio n. 11
0
void GwfStreamWriter::writeNode( SCgObject *obj)
{
    writeStartElement("node");
    writeObjectAttributes(obj);
    writePosition(obj, "x", "y");

    SCgNode *node = static_cast<SCgNode*>(obj);

    writeAttribute("haveBus", node->bus() ? "true" : "false");

    writeContent(node);

    writeEndElement();//node
}
Esempio n. 12
0
int  RJ_write( RJFILE *rf )
{
    char    dt[20];
    SYSTEMTIME SystemTime;

    GetLocalTime( &SystemTime );
    getCompressClock(dt, &SystemTime);

    writeContent( rf, RJ_TIME, dt );
    sprintf(dt, "%4d%02d%02d", SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay);

    return  RJWrite( rf, dt );

} // end of RJ_write()
Esempio n. 13
0
QgsMessageBarItem *QgsMessageBarItem::setWidget( QWidget *widget )
{
  if ( mWidget )
  {
    QLayoutItem *item;
    item = mLayout->itemAt( 2 );
    if ( item->widget() == mWidget )
    {
      delete item->widget();
    }
  }
  mWidget = widget;
  writeContent();
  return this;
}
Esempio n. 14
0
int main(int argc,char** argv)
{
	//Error checking for the number of argument//
	if (argc !=3)
	{
		printf("Insufficent arguments");
		return -1;
	}
	//Error checking for existance of input//
	int size=loadArray(argv[1]);
	if(size==0)
        {
                printf("Unable to open the input file");
                return -1;
        }
	//Declaration of variables//
	int id, ngrade,search;
	//Display output//
	printf("Student Record\n");
	printArray(size);
	//Search ID and rewritng new grade//
	printf("\nEnter the ID of the student to search:");
	scanf("%d",&id);
	printf("Enter a grade of the student:");
	scanf("%d",&ngrade);
	// Checking for the existance of the id//
	if((search=searchArray(size,id,ngrade))==0)
	{
		printf("Student with id %d is not present in the class\n");
	}
	//Write a new file with the new revision//
	else
	{
		int x=writeContent(argv[2],size);
		//Print new output//
		printf("\nUpdated student record\n");
		printArray(size);
	}
	sortArray(size);
	//Bonus Part Sorting array//
	printf("\nBonus part\nPrinting sorted student record\n");
	printArray(size);

	return 0;	

}
Esempio n. 15
0
/*
 * ----------------------------------------------------------
 *            RJRead()
 * ----------------------------------------------------------
 */
int  RJRead( RJFILE *rf )
// untill empty
{
    int   i;
    char  *p;

    newRecord( rf );

    for( i=0; i<keynum; i++ )
       {
       if (!(cfg_readLine( rf->handle, rf->buffer, line_buf_size ))) return 0; // end
       if ( strnicmp( rf->buffer, FieldName[i].qkey, strlen(FieldName[i].qkey)) != 0 )
	   return 0;  // error journal record
       p = strchr( rf->buffer, '=' );
       if ( p == NULL )   return 0;
       p++;
       trim(p);
       writeContent( rf, 100+i, p );
       }
    return 1;
}
Esempio n. 16
0
/*!
    Closes the currently displayed widget.  If that is editor widget and the \a result
    is QDialog::Accepted the changes made in the editor will be saved.

    Closing the editor widget will return the document selector to the display, and closing
    the document selector will close the application.
*/
void NotesDemo::done( int result )
{
    if ( layout->currentWidget() == editor ) {
        // The current widget is the editor so finish editing the document and return to
        // the document selector. If the dialog was accepted write the changes to the
        // document, and commit the document QContent.
        if ( result == QDialog::Accepted ) {
            if ( !writeContent(editor->document(), &currentDocument ) ) {
                qWarning() << "Writing the content failed";
            } else if ( !currentDocument.commit() ) {
                qWarning() << "Committing the new content failed";
            }
        }

        editor->document()->clear();

        layout->setCurrentWidget( documentSelector );
    } else {
        // The current widget is the document selector, so close the dialog and the application.
        QDialog::done( result );
    }
}
Esempio n. 17
0
void 
MutilThreadWrite::writeFile()
{
	try{
	/*
		String direct = Path::getDirectoryName(_pathname);
		Directory directName(direct);
	    if (!directName.exists())	
		{
		
		}
		else
		{
		
		}

        String file= Path::getFileName(_pathname);
		File fileName(file);
		if (!fileName.exists())
		{
		
		}
		else
		{
		
		}
	*/
		StreamWriter writeContent(_pathname, false);
		writeContent.writeLine(_content);
	    writeContent.close();
	}
	catch(Exception &exc)	
	{
		cout << exc.toString().getCStr() << endl;
	}

}
Esempio n. 18
0
void G3D::write(const std::string & file, const GeometryAoS * const geometry, const uint32_t vertexType)
{
	std::fstream fs;
	fs.open(file.c_str(), std::fstream::out | std::fstream::binary | std::fstream::trunc);

	if (fs.is_open())
	{
		if (vertexType == AoS) 
		{
			writeHeader(fs, geometry->info);
			writeContent(fs, *geometry);
		}
		else if (vertexType == SoA)
		{
			writeHeader(fs, geometry->info, &vertexType);
			writeIndices(fs, geometry->indices, geometry->info);
			std::vector<float*> vertexAttributes;
			convertVertices(geometry->vertices, vertexAttributes, geometry->info);
			writeVertices(fs, vertexAttributes, geometry->info);
			cleanVertices(vertexAttributes);
		}
		fs.close();
	}
}
bool KNMusicPlaylistiTunesXMLParser::write(KNMusicPlaylistModel *playlist,
                                           const QString &filePath)
{
    //Generate the plist document.
    QDomDocument plistDocument;
    //Initial the plist element.
    QDomElement plistRoot=plistDocument.createElement("plist");
    plistRoot.setAttribute("version", "1.0");
    plistDocument.appendChild(plistRoot);

    //Initial the dict element.
    QDomElement dictElement=plistDocument.createElement("dict");
    plistRoot.appendChild(dictElement);
    appendDictValue(plistDocument, dictElement, "Major Version", 1);
    appendDictValue(plistDocument, dictElement, "Minor Version", 1);
    appendDictValue(plistDocument, dictElement, "Date",
                    QDateTime::currentDateTime());
    appendDictValue(plistDocument, dictElement, "Features", 5);
    appendDictValue(plistDocument, dictElement, "Show Content Ratings", true);

    //Generate database and song index list.
    QHash<QString, int> filePathIndex;
    QLinkedList<int> playlistIndexList;
    //Add paths to hash keys.
    for(int i=0; i<playlist->rowCount(); i++)
    {
        //Get current path.
        QString currentPath=playlist->rowProperty(i, FilePathRole).toString();
        //Check the path in the index hash.
        int currentIndex=filePathIndex.value(currentPath, -1);
        //If we never insert this path to the index,
        if(currentIndex==-1)
        {
            //Get the new index.
            currentIndex=i;
            //Insert the path to the hash.
            filePathIndex.insert(currentPath, currentIndex);
        }
        //Append the list.
        playlistIndexList.append(currentIndex);
    }

    //Output the database info to dict.
    //Initial the elements.
    QDomElement tracksKey=plistDocument.createElement("key"),
                tracksDict=plistDocument.createElement("dict");
    QDomText tracksKeyValue=plistDocument.createTextNode("Tracks");
    tracksKey.appendChild(tracksKeyValue);
    //Add to dict elements.
    dictElement.appendChild(tracksKey);
    dictElement.appendChild(tracksDict);
    //Write database info.
    QList<int> songIndexList=filePathIndex.values();
    while(!songIndexList.isEmpty())
    {
        int currentRow=songIndexList.takeFirst(),
                trackID=currentRow+100;
        //Generate current row key and dict.
        QDomElement trackKey=plistDocument.createElement("key"),
                    trackDict=plistDocument.createElement("dict");
        //Generate the track key value.
        QDomText trackKeyValue=
                plistDocument.createTextNode(QString::number(trackID));
        trackKey.appendChild(trackKeyValue);
        //Get the detail info.
        const KNMusicDetailInfo detailInfo=playlist->rowDetailInfo(currentRow);
        //Generate the dict.
        appendDictValue(plistDocument, trackDict, "Track ID",
                        trackID);
        appendDictValue(plistDocument, trackDict, "Name",
                        detailInfo.textLists[Name]);
        appendDictValue(plistDocument, trackDict, "Artist",
                        detailInfo.textLists[Artist]);
        appendDictValue(plistDocument, trackDict, "Album Artist",
                        detailInfo.textLists[AlbumArtist]);
        appendDictValue(plistDocument, trackDict, "Genre",
                        detailInfo.textLists[Genre]);
        appendDictValue(plistDocument, trackDict, "Kind",
                        detailInfo.textLists[Kind]);
        appendDictValue(plistDocument, trackDict, "Size",
                        detailInfo.size);
        appendDictValue(plistDocument, trackDict, "Total Time",
                        detailInfo.duration);
        appendDictValue(plistDocument, trackDict, "Track Number",
                        detailInfo.textLists[TrackNumber].toString().toInt());
        appendDictValue(plistDocument, trackDict, "Track Count",
                        detailInfo.textLists[TrackCount].toString().toInt());
        appendDictValue(plistDocument, trackDict, "Year",
                        detailInfo.textLists[Year].toString().toInt());
        appendDictValue(plistDocument, trackDict, "Date Modified",
                        detailInfo.dateModified);
        appendDictValue(plistDocument, trackDict, "Date Added",
                        detailInfo.dateAdded);
        appendDictValue(plistDocument, trackDict, "Bit Rate",
                        detailInfo.bitRate);
        appendDictValue(plistDocument, trackDict, "Sample Rate",
                        detailInfo.samplingRate);
        appendDictValue(plistDocument, trackDict, "Track Type", "File");
        QString fileLocate=QUrl::fromLocalFile(detailInfo.filePath).toString();
#ifdef Q_OS_WIN
        fileLocate.insert(7, "localhost");
#endif
        appendDictValue(plistDocument, trackDict, "Location",
                        QString(QUrl::toPercentEncoding(fileLocate, "/:")));
        appendDictValue(plistDocument, trackDict, "File Folder Count", -1);
        appendDictValue(plistDocument, trackDict, "Library Folder Count", -1);
        //Add the key and dict to track.
        tracksDict.appendChild(trackKey);
        tracksDict.appendChild(trackDict);
    }

    //Output the playlist info to dict.
    QDomElement playlistKey=plistDocument.createElement("key"),
            playlistArray=plistDocument.createElement("array");
    QDomText playlistKeyValue=plistDocument.createTextNode("Playlists");
    playlistKey.appendChild(playlistKeyValue);
    //Add the key and array to dict element.
    dictElement.appendChild(playlistKey);
    dictElement.appendChild(playlistArray);
    //Generate current playlist information.
    QDomElement playlistDict=plistDocument.createElement("dict");
    playlistArray.appendChild(playlistDict);
    //Set playlist information to the dict.
    appendDictValue(plistDocument, playlistDict, "Name", playlist->title());
    appendDictValue(plistDocument, playlistDict, "Playlist ID", "99");
    appendDictValue(plistDocument, playlistDict, "All Items", true);
    //Generate playlist items array.
    QDomElement playlistItemsKey=plistDocument.createElement("key"),
                playlistItemsArray=plistDocument.createElement("array");
    QDomText playlistItemsKeyValue=
                plistDocument.createTextNode("Playlist Items");
    playlistItemsKey.appendChild(playlistItemsKeyValue);
    //Add to current playlist dict.
    playlistDict.appendChild(playlistItemsKey);
    playlistDict.appendChild(playlistItemsArray);
    //Generate Track ID dicts.
    while(!playlistIndexList.isEmpty())
    {
        QDomElement currentTrackDict=plistDocument.createElement("dict");
        appendDictValue(plistDocument,
                        currentTrackDict,
                        "Track ID",
                        100+playlistIndexList.takeFirst());
        //Add the dict to the array.
        playlistItemsArray.appendChild(currentTrackDict);
    }
    return writeContent(filePath,
                        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE "
                        "plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
                        " \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
                        + plistDocument.toString(4));
}
Esempio n. 20
0
QgsMessageBarItem* QgsMessageBarItem::setText( const QString& text )
{
  mText = text;
  writeContent();
  return this;
}
Esempio n. 21
0
QgsMessageBarItem *QgsMessageBarItem::setTitle( const QString& title )
{
  mTitle = title;
  writeContent();
  return this;
}
/**
 * @brief 导出Step数据到文件
 */
void clsDataExport::on_btnStepExport_clicked()
{
    QString strFileName = QFileDialog::getSaveFileName(this,tr("Svae rec file information to CSV file"),
                                                       tmpDataDir,
                                                       tr("CSV file(*.csv)"));
    if(strFileName.isEmpty())
        return;

    tmpDataDir = QFileInfo(strFileName).absoluteDir().canonicalPath();
    saveSettings();
    QStringList steps = getSteps();
    QStringList components;
    if(rbStepAll->isChecked())
        components = getComponents(All);

    if(rbStepPass->isChecked())
        components = getComponents(Pass);

    if(rbStepFail->isChecked())
        components = getComponents(Fail);

    QStringList items, titles;

    titles <<tr("Component No.")<<tr("Step") <<tr("P/F")<<tr("Test1")<<tr("T1 Result")<<tr("T1 P/F")
          <<tr("Test2")<<tr("T2 Result")<<tr("T2 P/F")<<tr("Date and Time");
    items <<"ComponentNo"<<"mStepNumber"<<"ResultStatus"<<"mTerm1"<<"mT1Result"<<"T1Status"
         <<"mTerm2"<<"mT2Result"<<"T2Status"<<"CompTimeStamp";

    if(1)
    {
        if(chkStepFrequency->isChecked())
        {
            titles << tr("Frequency");
            items <<"mFrequency";
        }

        if(chkStepSpeed->isChecked())
        {
            titles << tr("Speed");
            items <<"mStepSpeed";
        }

        if(chkStepDriverLevel->isChecked())
        {
            titles <<tr("Drive Level");
            items <<"mDriveType" <<"mACLevel";
        }


        if(chkStepRange->isChecked())
        {
            titles << tr("Range");
            items<<"mStepRange";
        }

        if(chkStepEqucct)
        {
            titles << tr("Equ-CCT");
            items <<"mStepCCT";
        }
    }

    QStringList titles2;

    for(int i=0; i< steps.length(); i++)
    {
        titles2 << titles;
    }
    writeHeader(strFileName,titles2);

    //int:Step index, QList<QString>:一个Step的所有元件内容
    QMap <int, QList<QStringList> > res; //定义存储空间

    //进度显示
    QProgressDialog progress(tr("Generating data record.."), tr("Abort"), 0,
                             steps.length(), this);
    progress.setWindowTitle(this->windowTitle());
    progress.setWindowModality(Qt::WindowModal);
    progress.setWindowFlags(progress.windowFlags()&~Qt::WindowContextHelpButtonHint &~Qt::WindowCloseButtonHint);
    progress.setCancelButton(0);
    progress.setValue(0);
    progress.show();


    for( int i =0; i< steps.length(); i++)
    {
        QString tmpStep = steps.at(i); //步骤数

        QMap<int, clsQueryDetailSheet *> pool;

        QStringListIterator it(components);

        int index=0;
        QStringList compNo;
        while(it.hasNext())
        {
            compNo.append(it.next());

            if(compNo.length() == 20000)
            {
                clsQueryDetailSheet * tmpQT = new clsQueryDetailSheet();
                tmpQT->setQueryItems(items,compNo,tmpStep);
                tmpQT->setIndex(index);
                pool.insert(index, tmpQT);

                compNo.clear();
                index++;
            }
        }

        if(!compNo.isEmpty())
        {
            clsQueryDetailSheet * tmpQT = new clsQueryDetailSheet();
            tmpQT->setQueryItems(items,compNo,tmpStep);
            tmpQT->setIndex(index);
            pool.insert(index, tmpQT);
        }

        for(int ii=0; ii< pool.count(); ii++)
            pool.value(ii)->run();

        while(1)
        {
            bool status=false;

            for(int ii =0; ii< pool.count(); ii++)
            {
                status = status || pool.value(ii)->isRunning();
            }

            if(! status)
                break;

            qApp->processEvents();

            clsUserFunction::sleepMs(10);
        }

        QList<QStringList> tmpRes;

        for(int ii=0; ii< pool.count(); ii++)
        {
            tmpRes += pool.value(ii)->getRes();
        }

        res.insert(i,tmpRes);
        progress.setValue(i+1);
    }

    progress.setValue(steps.length());
    progress.accept();

    QList <QStringList> wholeThings;
    for(int i=0; i< components.length(); i++)
    {
        QStringList tmpList;
        for(int j=0; j<steps.length(); j++)
        {
            tmpList << res.value(j).at(i);
        }

        wholeThings.append(tmpList);
    }
    writeContent(strFileName,wholeThings);
}
Esempio n. 23
0
bool Fan::setSpeed(int speed) {
	return (writeContent(getPath() + "/" + getName() + "_output",
			itos(checkSpeed(speed))));
}
/**
 * @brief 导出Rec文件到数据
 */
void clsDataExport::on_btnRecExport_clicked()
{
    QString strFileName = QFileDialog::getSaveFileName(this,tr("Svae rec file information to CSV file"),
                                                       tmpDataDir,
                                                       tr("CSV file(*.csv)"));
    if(strFileName.isEmpty())
        return;

    tmpDataDir = QFileInfo(strFileName).absoluteDir().canonicalPath();
    saveSettings();

    QString strFilter = " where 1=1";

    if(rbRecAll->isChecked())
        strFilter +=" ";

    if(rbRecPass->isChecked())
        strFilter += " and result =1 ";

    if(rbRecFail->isChecked())
        strFilter += " and result =0 ";

    QStringList items;
    QStringList titles;

    items << "CompNo" << "Result";
    titles <<tr("Component No.") <<tr("Result");
    if(chkRecTrigger->isChecked())
    {
        items <<"Trigger";
        titles<<tr("Trigger");
    }

    if(chkRecDateTime->isChecked())
    {
        items <<"DateAndTime";
        titles<<tr("Date and Time");
    }

    if(chkRecRecordCount->isChecked())
    {
        items <<"RecCount";
        titles<<tr("Record count");
    }

    writeHeader(strFileName,titles); //写入标题头

    QString strSelectContent = items.join(",");

    QString strSql = QString("Select %1 from MainSheet %2").arg(strSelectContent, strFilter);

    QSqlQuery query = clsDbOp::getInst()->execSql(strSql);

    QList< QStringList> contents;
    while(query.next())
    {
        QStringList contect;

        if(items.contains("CompNo"))
            contect<<  QString::number(query.value("CompNo").toInt());

        if(items.contains("Result"))
        {
            bool tmpBl = query.value("Result").toBool();
            contect <<(tmpBl ? tr("Pass"): tr("*Fail*"));
        }

        if(items.contains("Trigger"))
        {
            int intTrig = query.value("Trigger").toInt();
            contect << QString::number(intTrig);
        }

        if(items.contains("DateAndTime"))
        {
            contect << query.value("DateAndTime").toString();
        }

        if(items.contains("RecCount"))
        {
            int intRec = query.value("RecCount").toInt();
            contect<< QString::number(intRec);
        }
        contents<< contect;
    }
    writeContent(strFileName,contents);
}
Esempio n. 25
0
File: lab8.c Progetto: sts44b/cs1050
//call function main and gather inputs from the command line
int main (int argc, char* argv[]){
	
	//declare the variables to be used in this program
	int size, size2;
	int highest;
	int lowest;
	float avg;
	int findID;
	int id;
	int write;

	if (argc != 4)//check to make sure there are the appropriate number of parameters
	{
		printf("\nInsufficient arguments\n");
		return 0;
	}
   
	size = loadArray(argv[1]);//call function to load data from input file ints struct array

	if (size == 0){//if the input file cannout be opened quit program
      return 0;
	}
	
	highest = findHighestgrade(size);//call a function to find the highest grade in the class

	lowest = findLowestgrade(size);//call a function to find the lowest grade in the class

	avg = averageClassgrade(size);//call a funciton to calculate the average grade of the class
   
	printf("\n\nStudent record");
	printArray(size);//display the array of data gathered from the input file

	//display the results of the previous functions
	printf("\nThe student with the highest grade is %s with the grade %d", students[highest].name, students[highest].grade);
	printf("\nThe student with the lowest grade is %s with the grade %d\n", students[lowest].name, students[lowest].grade);
	printf("\nThe average grade for the class %.2f\n", avg);

	printf("\nEnter the ID of the student to search: ");
	scanf("%d", &id);//prompt user to enter an id number to search for
	
	findID = searchArray(size, id);//call function to find what student the id entered by the user pionts to

	if (findID == -1){
      printf("Student with the ID %d is not present in the class\n", id);//check to see if correct student number entered
	}
	else{
      printf("Student with the id %d is %s\n", students[findID].id, students[findID].name);//display the student searched for by the user
	}
	
	size2 = updateArray(argv[2], size);

   printf("\nUpdated student record");
   printArray(size + size2);

   sortArray(size + size2);

   printf("\nPrinting sorted student record");
   printArray(size + size2);

   write = writeContent(argv[3], (size + size2), highest, lowest, avg);//call the function to print data in the output file

   if (write == 0)
   {
      printf("\nUnable to open the output file\n");
   }
return 0; 
}//end function main