Ejemplo n.º 1
0
void MainWindow::refreshTabWidget()
{
    //int x1=ui->listWidget->currentRow();
   // int x2=ui->listWidget_2->currentRow();
    //先获得分类和,下面的过滤信息
    QString kind = ui->listWidget->currentItem()->text();
    if(kind == "All")
        kind = "";
    if(kind == "Favorite")
        kind = "true";
    if(kind == "Unsorted")
        kind = "unsorted";
    QString filter = ui->listWidget_2->currentItem()->text();
    //if(!myDao){
    myDao = Dao::getInstance();
    //}
    vector<PDFObject*> pdfVector;
    if(filter=="All"){
        pdfVector = myDao->getAllDocs(kind.toStdString());
    }else if(ui->comboBox->currentIndex()==0){
        pdfVector = myDao->getDocByAuthor(filter.toStdString(),kind.toStdString());
    }else if(ui->comboBox->currentIndex()==1){
        pdfVector = myDao->getDocByTag(filter.toStdString(),kind.toStdString());
    }else if(ui->comboBox->currentIndex()==2){
        pdfVector = myDao->getDocByKeyword(filter.toStdString(),kind.toStdString());
    }

    for(int i=0; i<pdfVector.size();i++){
        PDFObject *temp = pdfVector[i];
        int newRowIdx = ui->tableWidget->rowCount();
        ui->tableWidget->insertRow(newRowIdx);
        ui->tableWidget->setItem(newRowIdx,0,new QTableWidgetItem(QString::number(temp->getPdfID())));//数据库存储ID
        if(temp->getAuthorsList().size()>0)
            ui->tableWidget->setItem(newRowIdx,1,new QTableWidgetItem(QString::fromStdString(temp->getAuthorsList().at(0))));//作者列表
        else
            ui->tableWidget->setItem(newRowIdx,1,new QTableWidgetItem(""));//作者列表
        ui->tableWidget->setItem(newRowIdx,2,new QTableWidgetItem(QString::fromStdString(temp->getSubject())));//标题
        QString abstract = QString::fromStdString(temp->getAbstract());
        ui->tableWidget->setItem(newRowIdx,3,new QTableWidgetItem(abstract));//摘要
        ui->tableWidget->setItem(newRowIdx,4,new QTableWidgetItem(QString::fromStdString(temp->getPath())));//路径
        ui->tableWidget->setItem(newRowIdx,5,new QTableWidgetItem(QString::fromStdString(temp->getIssue())));//期刊
    }
    //ui->listWidget->setCurrentRow(x1);
    //ui->listWidget->setCurrentRow(x2);
    //设置id列隐藏
//    ui->tableWidget->setColumnHidden(0,true);
//    ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    //ui->tableWidget->horizontalHeader()->setTextElideMode();
    //ui->tableWidget->setColumnWidth(1,130);
    //QToolBar * textEditorToolbar = new QToolBar(this);
    //ui->tabWidget->removeTab(1);
}
Ejemplo n.º 2
0
METHOD_RETURN_TYPE PDFObjectDriver::ToPDFArray(const ARGS_TYPE& args)
{
    CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;
    
    PDFObject* anObject = ObjectWrap::Unwrap<PDFObjectDriver>(args.This())->GetObject();
    if(anObject->GetType() != PDFObject::ePDFObjectArray)
        SET_FUNCTION_RETURN_VALUE(UNDEFINED);
    
	Handle<Value> newInstance = PDFArrayDriver::GetNewInstance();
    ObjectWrap::Unwrap<PDFArrayDriver>(newInstance->ToObject())->TheObject = anObject;
    SET_FUNCTION_RETURN_VALUE(newInstance);
}
Ejemplo n.º 3
0
METHOD_RETURN_TYPE PDFObjectDriver::ToNumber(const ARGS_TYPE& args)
{
    CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;
    
    PDFObject* anObject = ObjectWrap::Unwrap<PDFObjectDriver>(args.This())->GetObject();
    if(anObject->GetType() == PDFObject::ePDFObjectInteger)
    {
        SET_FUNCTION_RETURN_VALUE(NEW_NUMBER(((PDFInteger*)anObject)->GetValue()));
    }
    else if(anObject->GetType() == PDFObject::ePDFObjectReal)
    {
        SET_FUNCTION_RETURN_VALUE(NEW_NUMBER(((PDFReal*)anObject)->GetValue()));
        
    }
    else
        SET_FUNCTION_RETURN_VALUE(UNDEFINED);
}
Ejemplo n.º 4
0
void MainWindow::initTabWidget()
{

    //先获得分类和,下面的过滤信息

    //if(!myDao){
        myDao = Dao::getInstance();
    //}

    vector<PDFObject*> pdfVector;

    pdfVector = myDao->getAllDocs("");


    for(int i=0; i<pdfVector.size();i++){
        PDFObject *temp = pdfVector[i];
        int newRowIdx = ui->tableWidget->rowCount();
        ui->tableWidget->insertRow(newRowIdx);
        ui->tableWidget->setItem(newRowIdx,0,new QTableWidgetItem(QString::number(temp->getPdfID())));//数据库存储ID
        if(temp->getAuthorsList().size()>0)
            ui->tableWidget->setItem(newRowIdx,1,new QTableWidgetItem(QString::fromStdString(temp->getAuthorsList().at(0))));//作者列表
        else
            ui->tableWidget->setItem(newRowIdx,1,new QTableWidgetItem(""));
        ui->tableWidget->setItem(newRowIdx,2,new QTableWidgetItem(QString::fromStdString(temp->getSubject())));//标题
        QString abstract = QString::fromStdString(temp->getAbstract());
        ui->tableWidget->setItem(newRowIdx,3,new QTableWidgetItem(abstract));//摘要
        ui->tableWidget->setItem(newRowIdx,4,new QTableWidgetItem(QString::fromStdString(temp->getPath())));//路径
        ui->tableWidget->setItem(newRowIdx,5,new QTableWidgetItem(QString::fromStdString(temp->getIssue())));//期刊
    }
    //设置id列隐藏
    ui->tableWidget->setColumnHidden(0,true);
    ui->tableWidget->setColumnHidden(3,true);
    ui->tableWidget->setColumnHidden(4,true);
    ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    //ui->tableWidget->horizontalHeader()->setTextElideMode();
    //ui->tableWidget->setColumnWidth(1,130);
    //QToolBar * textEditorToolbar = new QToolBar(this);
    //ui->tabWidget->removeTab(1);



}
Ejemplo n.º 5
0
METHOD_RETURN_TYPE PDFObjectDriver::ToString(const ARGS_TYPE& args)
{
    CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;
    
    PDFObject* anObject = ObjectWrap::Unwrap<PDFObjectDriver>(args.This())->GetObject();
    std::string result;
    
    switch(anObject->GetType())
    {
        case PDFObject::ePDFObjectName:
            result = ((PDFName*)anObject)->GetValue();
            break;
        case PDFObject::ePDFObjectLiteralString:
            result = ((PDFLiteralString*)anObject)->GetValue();
            break;
        case PDFObject::ePDFObjectHexString:
            result = ((PDFHexString*)anObject)->GetValue();
            break;
        case PDFObject::ePDFObjectReal:
            result = Double(((PDFReal*)anObject)->GetValue()).ToString();
            break;
        case PDFObject::ePDFObjectInteger:
            result = LongLong(((PDFInteger*)anObject)->GetValue()).ToString();
            break;
        case PDFObject::ePDFObjectSymbol:
            result = ((PDFSymbol*)anObject)->GetValue();
            break;
        case PDFObject::ePDFObjectBoolean:
            result = ((PDFBoolean*)anObject)->GetValue() ? "true":"false";
            break;
        default:
            result = PDFObject::scPDFObjectTypeLabel[anObject->GetType()];
    }
    SET_FUNCTION_RETURN_VALUE(NEW_STRING(result.c_str()));

}
Ejemplo n.º 6
0
PDFObject* PDFObjectParser::ParseNewObject(IPDFParserExtender* inParserExtender)
{
	PDFObject* pdfObject = NULL;
	std::string token;

	do
	{
		if(!GetNextToken(token))
			break;

		// based on the parsed token, and parhaps some more, determine the type of object
		// and how to parse it.

		// Boolean
		if(IsBoolean(token))
		{
			pdfObject = ParseBoolean(token);
			break;
		} 
		// Literal String
		else if(IsLiteralString(token))
		{
			pdfObject = ParseLiteralString(token,inParserExtender);
			break;
		}
		// Hexadecimal String
		else if(IsHexadecimalString(token))
		{
			pdfObject = ParseHexadecimalString(token,inParserExtender);
			break;
		}
		// NULL
		else if (IsNull(token))
		{
			pdfObject = new PDFNull();
			break;
		}
		// Name
		else if(IsName(token))
		{
			pdfObject = ParseName(token);
			break;
		}
		// Number (and possibly an indirect reference)
		else if(IsNumber(token))
		{	
			pdfObject = ParseNumber(token);
			
			// this could be an indirect reference in case this is a positive integer
			// and the next one is also, and then there's an "R" keyword
			if(pdfObject && 
				(pdfObject->GetType() == PDFObject::ePDFObjectInteger) && 
				((PDFInteger*)pdfObject)->GetValue() > 0)
			{
				// try parse version
				std::string numberToken;
				if(!GetNextToken(numberToken)) // k. no next token...cant be reference
					break;

				if(!IsNumber(numberToken)) // k. no number, cant be reference
				{
					SaveTokenToBuffer(numberToken);
					break;
				}

				PDFObject* versionObject = ParseNumber(numberToken); 
				bool isReference = false;
				do
				{
					if(!versionObject || 
                       (versionObject->GetType() != PDFObject::ePDFObjectInteger) ||
						((PDFInteger*)versionObject)->GetValue() < 0) // k. failure to parse number, or no non-negative, cant be reference
					{
						SaveTokenToBuffer(numberToken);
						break;
					}

					// try parse R keyword
					std::string keywordToken;
					if(!GetNextToken(keywordToken)) // k. no next token...cant be reference
						break;

					if(keywordToken != scR) // k. not R...cant be reference
					{
						SaveTokenToBuffer(numberToken);
						SaveTokenToBuffer(keywordToken);
						break;
					}

					isReference = true;
				}while(false);

				// if passed all these, then this is a reference
				if(isReference)
				{
					PDFObject* referenceObject = new PDFIndirectObjectReference(
														(ObjectIDType)((PDFInteger*)pdfObject)->GetValue(),
														(unsigned long)((PDFInteger*)versionObject)->GetValue());
					delete pdfObject;
					pdfObject = referenceObject;
				}
				delete versionObject;
			}
			break;
		}
		// Array
		else if(IsArray(token))
		{
			pdfObject = ParseArray(inParserExtender);
			break;
		}
		// Dictionary
		else if (IsDictionary(token))
		{
			pdfObject = ParseDictionary(inParserExtender);

			if(pdfObject)
			{
				// could be a stream. will be if the next token is the "stream" keyword
				if(!GetNextToken(token))
					break;

				if(scStream == token) 
				{
					// yes, found a stream. record current position as the position where the stream starts. 
					// [tokenizer took care that the posiiton should be that way with a special case]
					pdfObject = new PDFStreamInput((PDFDictionary*)pdfObject,mCurrentPositionProvider->GetCurrentPosition());
				}
				else
				{
					SaveTokenToBuffer(token);
				}
			}

			break;
		}
		// Symbol (legitimate keyword or error. determine if error based on semantics)
		else
			pdfObject = new PDFSymbol(token);
	}while(false);


	return pdfObject;

}