void RecentBooksDlg::on_actionRemoveBook_triggered()
{
    int cr = m_ui->tableWidget->currentRow();
    if(cr<0) cr=0;

    int firstItem = m_docview->getDocView()->isDocumentOpened() ? 1 : 0;
    LVPtrVector<CRFileHistRecord> & files = m_docview->getDocView()->getHistory()->getRecords();

    int row = getBookNum() + firstItem;
    if(row>files.length()) return;


    removeFile(files, row);

    SetPageCount();
    if(curPage>pageCount)
        curPage-=1;
    curPage-=1;


    // select row
    cr = (row-firstItem)*2-1;
    if((cr+firstItem)/2 >= files.length())
        cr = files.length()*2-3;
    if(cr<0) cr=1;

    ShowPage(1, cr);
}
Example #2
0
void RecentBooksDlg::accept()
{
    int bn = getBookNum();
    if ( bn >= 0 )
    {
        LVPtrVector<CRFileHistRecord>& files = docview->getDocView()->getHistory()->getRecords();
        fileName = cr2qt(files[bn]->getFilePathName());
        QDialog::accept();
    }
}
Example #3
0
void RecentBooksDlg::on_btnRemove_clicked()
{
    int bn = getBookNum();
    if ( bn >= 0 )
    {
        LVPtrVector<CRFileHistRecord>&
                files = docview->getDocView()->getHistory()->getRecords();

        int result = 0;
        int value  = docview->getOptions()->getIntDef(PROP_APP_UI_RECENT_REMOVE_FILES, 0);
        if ( value )
        {
            RecentRemoveDlg dlg(this);
            dlg.exec(false);
            result = dlg.getResult();
        }
        else
        {
            result = 1;
        }

        switch( result )
        {
        case 0:
        default:
            break;
        case 1:
            if ( bn > 0 || !docview->getDocView()->isDocumentOpened() )
            {
                files.remove(bn);
                ui->tableWidget->removeRow(bn);
            }
            break;
        case 2:
            if ( 0 == bn && docview->getDocView()->isDocumentOpened() )
            {
                docview->getDocView()->createDefaultDocument( qt2cr(tr("Removed")), qt2cr(tr("Document was removed") ) );
            }
            {
                QString fileName(cr2qt(files[bn]->getFilePathName()));
                files.remove(bn);
                ui->tableWidget->removeRow(bn);
                QFile::remove(fileName);
                docview->update();
            }
            break;
        }
    }
}
Example #4
0
void RecentBooksDlg::on_btnFolder_clicked()
{
    int bn = getBookNum();
    if ( bn >= 0 )
    {
        LVPtrVector<CRFileHistRecord>& files = docview->getDocView()->getHistory()->getRecords();
        QString path(cr2qt(files[bn]->getFilePath()));
        OpenFileDlg dlg( this, docview, path );
        if ( dlg.exec() && !dlg.fileName.isEmpty() )
        {
            fileName = dlg.fileName;
            QDialog::accept();
        }
    }
}
void RecentBooksDlg::on_actionSelectBook_triggered()
{
    openBook(getBookNum());
}