Esempio 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);
}
Esempio n. 2
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);



}