Ejemplo n.º 1
0
void OnyxMainWindow::bookmarkModel(QStandardItemModel & model,
                                   QModelIndex & selected)
{
    CRFileHistRecord * rec = view_->getDocView()->getCurrentFileHistRecord();
    if ( !rec )
        return;
    LVPtrVector<CRBookmark> & list( rec->getBookmarks() );
    model.setColumnCount(2);
    int row = 0;
    for(int i  = 0; i < list.length(); ++i)
    {
        // skip cites
        CRBookmark * bmk = list[i];
        if (!bmk || (bmk->getType() == bmkt_comment || bmk->getType() == bmkt_correction))
            continue;

        QString t =cr2qt(view_->getDocView()->getPageText(true, list[i]->getBookmarkPage()));
        t.truncate(100);
        QStandardItem *title = new QStandardItem(t);
        title->setData((int)list[i]);
        title->setEditable(false);
        model.setItem(row, 0, title);

        int pos = list[i]->getPercent();
        QString str(tr("%1"));
        str = str.arg(pos);
        QStandardItem *page = new QStandardItem(str);
        page->setTextAlignment(Qt::AlignCenter);
        page->setEditable(false);
        model.setItem(row, 1, page);

        row++;
    }
}
Ejemplo n.º 2
0
bool ReaderViewNative::openRecentBook()
{
	CRLog::debug("ReaderViewNative::openRecentBook()");
	int index = 0;
	if ( _docview->isDocumentOpened() ) {
		CRLog::debug("ReaderViewNative::openRecentBook() : saving previous document state");
		_docview->swapToCache();
        _docview->getDocument()->updateMap();
	    _docview->savePosition();
		closeBook();
	    index = 1;
	}
    LVPtrVector<CRFileHistRecord> & files = _docview->getHistory()->getRecords();
    CRLog::info("ReaderViewNative::openRecentBook() : %d files found in history, startIndex=%d", files.length(), index);
    if ( index < files.length() ) {
        CRFileHistRecord * file = files.get( index );
        lString16 fn = file->getFilePathName();
        CRLog::info("ReaderViewNative::openRecentBook() : checking file %s", LCSTR(fn));
        // TODO: check error
        if ( LVFileExists(fn) ) {
            return loadDocument( fn );
        } else {
        	CRLog::error("file %s doesn't exist", LCSTR(fn));
        	return false;
        }
        //_docview->swapToCache();
    } else {
        CRLog::info("ReaderViewNative::openRecentBook() : no recent book found in history");
    }
    return false;
}
Ejemplo n.º 3
0
CRCitesMenu::CRCitesMenu(CRGUIWindowManager * wm, LVDocView * docview, int numItems, lvRect & rc)
    : CRFullScreenMenu( wm, MCMD_CITES_LIST, lString16(_("Citations")), numItems, rc )
    , _docview(docview)
{
    CRGUIAcceleratorTableRef acc = _wm->getAccTables().get("bookmarks");
    if ( acc.isNull() )
        acc = _wm->getAccTables().get("menu");
    setAccelerators( acc );
    setSkinName(lString16("#cites-list"), lString16("#bookmarks"));
    int mc = getSkin()->getMinItemCount();
    if ( _pageItems < mc )
        _pageItems = mc;
    CRFileHistRecord * rec = docview->getCurrentFileHistRecord();
    LVPtrVector < CRBookmark > &bookmarks = rec->getBookmarks();
    for ( int i=0; i < bookmarks.length(); i++ ) {
        CRBookmark * bmk = bookmarks[i];
        if (!bmk || ((bmk->getType() != bmkt_comment && bmk->getType() != bmkt_correction)))
            continue;
        ldomXPointer p = docview->getDocument()->createXPointer( bmk->getStartPos() );
        if ( p.isNull() )
            continue;
        int page = docview->getBookmarkPage( p );
        /// get bookmark position text
        if ( page<0 )
            continue;
        CRBookmarkMenuItem * item = new CRBookmarkMenuItem( this, i, bmk, page );
        addItem( item );
    }
#ifdef CR_POCKETBOOK
    citesDialog = this;
#endif
    if (_items.length() == 0)
        createDefaultItem();
}
Ejemplo n.º 4
0
bool CRFileHist::saveToStream( LVStream * targetStream )
{
    LVStreamRef streamref = LVCreateMemoryStream(NULL, 0, false, LVOM_WRITE);
    LVStream * stream = streamref.get();
    const char * xml_hdr = "\xef\xbb\xbf<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<FictionBookMarks>\r\n";
    const char * xml_ftr = "</FictionBookMarks>\r\n";
    //const char * crlf = "\r\n";
    *stream << xml_hdr;
    for ( int i=0; i<_records.length(); i++ ) {
        CRFileHistRecord * rec = _records[i];
        putTag( stream, 1, "file" );
        putTag( stream, 2, "file-info" );
        putTagValue( stream, 3, "doc-title", rec->getTitle() );
        putTagValue( stream, 3, "doc-author", rec->getAuthor() );
        putTagValue( stream, 3, "doc-series", rec->getSeries() );
        putTagValue( stream, 3, "doc-filename", rec->getFileName() );
        putTagValue( stream, 3, "doc-filepath", rec->getFilePath() );
        putTagValue( stream, 3, "doc-filesize", lString16::itoa( (unsigned int)rec->getFileSize() ) );
        putTag( stream, 2, "/file-info" );
        putTag( stream, 2, "bookmark-list" );
        putBookmark( stream, rec->getLastPos() );
        for ( int j=0; j<rec->getBookmarks().length(); j++) {
            CRBookmark * bmk = rec->getBookmarks()[j];
            putBookmark( stream, bmk );
        }
        putTag( stream, 2, "/bookmark-list" );
        putTag( stream, 1, "/file" );
    }
    *stream << xml_ftr;
    LVPumpStream( targetStream, stream );
    return true;
}
Ejemplo n.º 5
0
CRFileHistRecord * CRFileHist::savePosition( lString16 fpathname, size_t sz,
                            const lString16 & title,
                            const lString16 & author,
                            const lString16 & series,
                            ldomXPointer ptr )
{
    //CRLog::trace("CRFileHist::savePosition");
    lString16 name;
	lString16 path;
    splitFName( fpathname, path, name );
    CRBookmark bmk( ptr );
    //CRLog::trace("Bookmark created");
    int index = findEntry( name, path, (lvsize_t)sz );
    //CRLog::trace("findEntry exited");
    if ( index>=0 ) {
        makeTop( index );
        _records[0]->setLastPos( &bmk );
        _records[0]->setLastTime( (time_t)time(0) );
        return _records[0];
    }
    CRFileHistRecord * rec = new CRFileHistRecord();
    rec->setTitle( title );
    rec->setAuthor( author );
    rec->setSeries( series );
    rec->setFileName( name );
    rec->setFilePath( path );
    rec->setFileSize( (lvsize_t)sz );
    rec->setLastPos( &bmk );
    rec->setLastTime( (time_t)time(0) );

    _records.insert( 0, rec );
    //CRLog::trace("CRFileHist::savePosition - exit");
    return rec;
}
Ejemplo n.º 6
0
int CRBookmarkMenu::getDefaultSelectionIndex()
{
	if ( _goToMode )
		return -1;
    CRFileHistRecord * bookmarks = _docview->getCurrentFileHistRecord();
    for ( int i=0; i<_items.length(); i++ ) {
        CRBookmark * bm = bookmarks->getShortcutBookmark(i);
        if ( bm == NULL) 
			return i;
    }
    return -1;
}
Ejemplo n.º 7
0
BookmarkListDialog::BookmarkListDialog(QWidget *parent, CR3View * docView ) :
	QDialog(parent),
	m_ui(new Ui::BookmarkListDialog),
	_docview(docView)
{
	m_ui->setupUi(this);

	addAction(m_ui->actionRemoveBookmark);
	addAction(m_ui->actionRemoveAllBookmarks);
	QAction *actionSelect = m_ui->actionSelectBookmark;
	actionSelect->setShortcut(Qt::Key_Select);
	addAction(actionSelect);

	int i = 0;
	m_ui->tableWidget->horizontalHeader()->setResizeMode( i++, QHeaderView::ResizeToContents);
	m_ui->tableWidget->horizontalHeader()->setResizeMode( i++, QHeaderView::Stretch );
	m_ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
	m_ui->tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);

	CRFileHistRecord * rec = _docview->getDocView()->getCurrentFileHistRecord();
	if (!rec) return;
	LVPtrVector<CRBookmark> & list( rec->getBookmarks() );
	int curpercent = _docview->getDocView()->getPosPercent();
	int bestdiff = -1;
	int bestindex = -1;
	int y = 0;
	for ( int i=0; i<list.length(); i++ ) {
		CRBookmark * bm = list[i];
		if ( bm->getType() == bmkt_lastpos ) continue;
		int diff = bm->getPercent() - curpercent;
		if ( diff < 0 )
			diff = -diff;
		if ( bestindex==-1 || diff < bestdiff ) {
			bestindex = i;
			bestdiff = diff;
		}
		m_ui->tableWidget->setRowCount(y+1);
		{
			int i=0;
			_list.append( bm );
			m_ui->tableWidget->setItem( y, i++, new QTableWidgetItem(crpercent( bm->getPercent())));
			m_ui->tableWidget->setItem( y, i++, new QTableWidgetItem(limit(cr2qt(bm->getPosText()))));
			m_ui->tableWidget->verticalHeader()->setResizeMode(y, QHeaderView::ResizeToContents);
		}
		y++;
	}
	if (bestindex>=0) m_ui->tableWidget->selectRow(bestindex);

	m_ui->tableWidget->resizeColumnsToContents();
	m_ui->tableWidget->resizeRowsToContents();
}
Ejemplo n.º 8
0
void V3DocViewWin::openRecentBook( int index )
{
    _docview->savePosition();
    LVPtrVector<CRFileHistRecord> & files = _docview->getHistory()->getRecords();
    if ( index >= 1 && index < files.length() ) {
        CRFileHistRecord * file = files.get( index );
        lString16 fn = file->getFilePathName();
        // TODO: check error
        if ( LVFileExists(fn) ) {
            //showWaitIcon();
            loadDocument( fn );
        }
        //_docview->swapToCache();
    }
}
Ejemplo n.º 9
0
int CRFileHist::findEntry( const lString16 & fname, const lString16 & fpath, lvsize_t sz )
{
    CR_UNUSED(fpath);
    for ( int i=0; i<_records.length(); i++ ) {
        CRFileHistRecord * rec = _records[i];
        if ( rec->getFileName().compare(fname) )
            continue;
        if ( rec->getFileSize()!=sz ) {
            CRLog::warn("CRFileHist::findEntry() Filename matched %s but sizes are different %d!=%d", LCSTR(fname), sz, rec->getFileSize() );
            continue;
        }
        return i;
    }
    return -1;
}
Ejemplo n.º 10
0
 /// called on closing
 virtual void OnTagClose( const lChar16 * nsname, const lChar16 * tagname )
 {
     if ( lStr_cmp(nsname, "FictionBookMarks")==0 && state==in_fbm ) {
         state = in_xml;
     } else if ( lStr_cmp(tagname, "file")==0 && state==in_file ) {
         state = in_fbm;
         if ( _curr_file )
             _hist->getRecords().add( _curr_file );
         _curr_file = NULL;
     } else if ( lStr_cmp(tagname, "file-info")==0 && state==in_file_info ) {
         state = in_file;
     } else if ( lStr_cmp(tagname, "bookmark-list")==0 && state==in_bm_list ) {
         state = in_file;
     } else if ( lStr_cmp(tagname, "doc-title")==0 && state==in_title ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-author")==0 && state==in_author ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-series")==0 && state==in_series ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filename")==0 && state==in_filename ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filepath")==0 && state==in_filepath ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "doc-filesize")==0 && state==in_filesize ) {
         state = in_file_info;
     } else if ( lStr_cmp(tagname, "bookmark")==0 && state==in_bm ) {
         state = in_bm_list;
         if ( _curr_bookmark ) {
             if ( _curr_bookmark->getType() == bmkt_lastpos ) {
                 _curr_file->setLastPos(_curr_bookmark);
                 delete _curr_bookmark;
             } else {
                 _curr_file->getBookmarks().add(_curr_bookmark);
             }
             _curr_bookmark = NULL;
         }
     } else if ( lStr_cmp(tagname, "start-point")==0 && state==in_start_point ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "end-point")==0 && state==in_end_point ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "header-text")==0 && state==in_header_txt ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "selection-text")==0 && state==in_selection_txt ) {
         state = in_bm;
     } else if ( lStr_cmp(tagname, "comment-text")==0 && state==in_comment_txt ) {
         state = in_bm;
     }
 }
Ejemplo n.º 11
0
void RecentBooksDlg::ShowPage(int updown, int selectRow)
{
    Device::forceFullScreenUpdate();

    if(updown>0) {
        if(curPage+1>pageCount) curPage=0;
        curPage+=1;
    } else {
        if(curPage-1<=0) curPage=pageCount+1;
        curPage-=1;
    }
    setWindowTitle(titleMask + " (" + QString::number(curPage) + "/" + QString::number(pageCount) + ")");

    int rc = m_docview->rowCount;
    int firstItem = m_docview->getDocView()->isDocumentOpened() ? 1 : 0;
    int startPos = ((curPage-1)*rc)+firstItem;
    LVPtrVector<CRFileHistRecord> & files = m_docview->getDocView()->getHistory()->getRecords();
    for(int k=startPos, index=0; index<rc*2; ++k, index+=2) {
        if(k<files.length()) {
            CRFileHistRecord * book = files.get(k);

            lString16 title = book->getTitle();
            lString16 author = book->getAuthor();
            lString16 series = book->getSeries();
            lString16 filename = book->getFileName();
            if(title.empty()) title = filename;
            QString fileExt = cr2qt(filename);
            fileExt = fileExt.mid(fileExt.lastIndexOf(".")+1);

            int fileSize = book->getFileSize();
            CRBookmark *bm = book->getLastPos();
            int percent = bm->getPercent();

            if(author.empty()) author = L"-";
            if(title.empty()) title = L"-";
            if(!series.empty()) series = L"(" + series + L")";

            QTableWidgetItem *item = m_ui->tableWidget->item(index, 0);
            item->setText(cr2qt(title));

            item = m_ui->tableWidget->item(index+1, 0);
            item->setText(cr2qt(author)+"\n"+cr2qt(series));

            item = m_ui->tableWidget->item(index+1, 1);
            item->setText(crpercent(percent) + "\n" + fileExt+" / "+crFileSize(fileSize));

            m_ui->tableWidget->showRow(index);
            m_ui->tableWidget->showRow(index+1);
        } else {
            m_ui->tableWidget->hideRow(index);
            m_ui->tableWidget->hideRow(index+1);
        }
    }
    // select first row
    if(m_ui->tableWidget->rowCount()>0)
        m_ui->tableWidget->selectRow(selectRow);
}
Ejemplo n.º 12
0
/// returns index of selected item, -1 if no item selected
int CRBookmarkMenu::getSelectedItemIndex()
{
    CRFileHistRecord * bookmarks = _docview->getCurrentFileHistRecord();
    int curPage = _docview->getCurPage();
    int n = bookmarks->getLastShortcutBookmark()+1;
    for ( int i=1; i<=n; i++ ) {
        CRBookmark * bm = bookmarks->getShortcutBookmark(i);
        int page = 0;
        if ( bm ) {
            ldomXPointer p = _docview->getDocument()->createXPointer( bm->getStartPos() );
            if ( !p.isNull() ) {
                /// get page number by bookmark
                page = _docview->getBookmarkPage( p );
                /// get bookmark position text
                if ( page>0 && page==curPage )
                    return i-1;
            }
        }
    }
    return -1;
}
Ejemplo n.º 13
0
CRBookmarkMenu::CRBookmarkMenu(CRGUIWindowManager * wm, LVDocView * docview, int numItems, lvRect & rc, bool goToMode)
    : CRFullScreenMenu( wm, MCMD_BOOKMARK_LIST, lString16(_("Bookmarks")), numItems, rc )
    , _docview(docview)
{
    CRFileHistRecord * bookmarks = docview->getCurrentFileHistRecord();
    CRGUIAcceleratorTableRef acc = _wm->getAccTables().get("bookmarks");
    if ( acc.isNull() )
        acc = _wm->getAccTables().get("menu");
    setAccelerators( acc );
    setSkinName(lString16("#bookmarks"));
    int mc = getSkin()->getMinItemCount();
    if ( _pageItems < mc )
        _pageItems = mc;
    int n = bookmarks->getLastShortcutBookmark()+1;
    n = (n + _pageItems - 1) / _pageItems * _pageItems;
    int minitems = (MIN_BOOKMARK_ITEMS + _pageItems - 1) / _pageItems * _pageItems;
    if ( n<minitems )
        n = minitems;
    for ( int i=1; i<=n; i++ ) {
        CRBookmark * bm = bookmarks->getShortcutBookmark(i);
        int page = 0;
        if ( bm ) {
            ldomXPointer p = docview->getDocument()->createXPointer( bm->getStartPos() );
            if ( !p.isNull() ) {
                /// get page number by bookmark
                page = docview->getBookmarkPage( p );
                /// get bookmark position text
                if ( page<0 )
                    bm = NULL;
            }
        }
        CRBookmarkMenuItem * item = new CRBookmarkMenuItem( this, i, bm, page );
        addItem( item );
    }
    setMode( goToMode );
#ifdef CR_POCKETBOOK
    bmkDialog = this;
#endif
}
Ejemplo n.º 14
0
void CRRecentBookMenuItem::Draw( LVDrawBuf & buf, lvRect & rc, CRRectSkinRef skin, CRRectSkinRef valueSkin, bool selected )
{
    if ( !_book ) {
        CRMenuItem::Draw( buf, rc, skin, valueSkin, selected );
        return;
    }
    lvRect itemBorders = skin->getBorderWidths();
    skin->draw( buf, rc );
    buf.SetTextColor( 0x000000 );
    buf.SetBackgroundColor( 0xFFFFFF );
    int imgWidth = 0;
    int hh = rc.bottom - rc.top - itemBorders.top - itemBorders.bottom;
    if ( !_image.isNull() ) {
        int w = _image->GetWidth();
        int h = _image->GetHeight();
        buf.Draw( _image, rc.left + hh/2-w/2 + itemBorders.left, rc.top + hh/2 - h/2 + itemBorders.top, w, h );
        imgWidth = w + 8;
    }
    lvRect textRect = rc;
    textRect.left += imgWidth;

    lString16 author = _book->getAuthor();
    lString16 title = _book->getTitle();
    lString16 series = _book->getSeries();
    if ( title.empty() )
        title = _book->getFileName();
    else if ( !series.empty() )
        title << " - " << series;

    lvRect posRect = textRect;
    if ( !author.empty() ) {
        posRect.bottom = posRect.top + skin->getFont()->getHeight() + itemBorders.top + itemBorders.bottom;
        textRect.top = posRect.bottom - itemBorders.bottom;
        skin->drawText( buf, posRect, author );
    }
    if ( !title.empty() )
        valueSkin->drawText( buf, textRect, title );
}
Ejemplo n.º 15
0
wxString HistList::OnGetItemText(long item, long column) const
{
    if ( _records && item>=0 && item<_records->length() ) {
        CRFileHistRecord * rec = (*_records)[item];
        lString16 data;
        switch ( column ) {
        case 0:
            data = rec->getLastTimeString();
            break;
        case 1:
            {
                lString16 fname = rec->getFileName();
                lString16 author = rec->getAuthor();
                lString16 title = rec->getTitle();
                lString16 series = rec->getSeries();
                if ( !series.empty() ) {
                    if ( !title.empty() )
                        title << " ";
                    title << series;
                }
                if ( !author.empty() && !title.empty() )
                    author << ". ";
                data << author << title;
                if ( data.empty() )
                    data = fname;
            }
            break;
        case 2:
            {
                data = lString16::itoa(rec->getLastPos()->getPercent()/100) + "%";
            }
            break;
        }
        return wxString(data.c_str());
    } else
        return wxString(wxT(""));
}
Ejemplo n.º 16
0
 /// called on text
 virtual void OnText( const lChar16 * text, int len, lUInt32 flags )
 {
     CR_UNUSED(flags);
     lString16 txt( text, len );
     switch (state) {
     case in_start_point:
         _curr_bookmark->setStartPos( txt );
         break;
     case in_end_point:
         _curr_bookmark->setEndPos( txt );
         break;
     case in_header_txt:
         _curr_bookmark->setTitleText( txt );
         break;
     case in_selection_txt:
         _curr_bookmark->setPosText( txt );
         break;
     case in_comment_txt:
         _curr_bookmark->setCommentText( txt );
         break;
     case in_author:
         _curr_file->setAuthor( txt );
         break;
     case in_title:
         _curr_file->setTitle( txt );
         break;
     case in_series:
         _curr_file->setSeries( txt );
         break;
     case in_filename:
         _curr_file->setFileName( txt );
         break;
     case in_filepath:
         _curr_file->setFilePath( txt );
         break;
     case in_filesize:
         _curr_file->setFileSize( txt.atoi() );
         break;
     default:
         break;
     }
 }
Ejemplo n.º 17
0
RecentBooksDlg::RecentBooksDlg(QWidget *parent, CR3View * docView )
    : Dialog(parent)
    , ui(new Ui::RecentBooksDlg)
    , docview(docView)
{
    ui->setupUi(this);

    QFont f(ui->tableWidget->font());
    f.setPointSize(docview->getOptions()->getIntDef("cr3.app.ui.recent.font.size", 12));
    ui->tableWidget->setFont(f);

    f = ui->lblPosition->font();
    f.setPointSize(f.pointSize()/2);
    ui->lblPosition->setFont(f);

    f = ui->lblTitle->font();
    f.setBold(true);
    ui->lblTitle->setFont(f);

    ui->tableWidget->setColumnCount(1);

    ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    ui->tableWidget->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
    ui->tableWidget->verticalHeader()->setResizeMode(QHeaderView::Custom);

    bool isVscroll = docview->getOptions()->getIntDef(PROP_APP_UI_RECENT_VSCROLLBAR, 1) != 0;
    ui->tableWidget->setVerticalScrollBarPolicy(isVscroll? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
    bool isHscroll = docview->getOptions()->getIntDef(PROP_APP_UI_RECENT_HSCROLLBAR, 1) != 0;
    ui->tableWidget->setHorizontalScrollBarPolicy(isHscroll? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);

    // fill rows
    QFont fontTitle = ui->tableWidget->font();
    fontTitle.setBold(true);

    QFont fontAuthor = ui->tableWidget->font();
    fontAuthor.setItalic(true);

    QFont fontInfo = ui->tableWidget->font();
    fontInfo.setItalic(true);
    fontInfo.setPointSize(fontInfo.pointSize()*2/3);

    QFontMetrics tfm(fontTitle);
    QFontMetrics afm(fontAuthor);

    int rowHeight = tfm.height() + afm.height();
    ui->tableWidget->verticalHeader()->setResizeMode(QHeaderView::Fixed);
    ui->tableWidget->verticalHeader()->setDefaultSectionSize(rowHeight);

    ui->tableWidget->setItemDelegate(new RecentBooksListDelegate(ui->tableWidget, fontTitle, fontAuthor));

    LVPtrVector<CRFileHistRecord>& files = docview->getDocView()->getHistory()->getRecords();

    // remove non-existing entries
    for( int k=0; k<files.length(); )
    {
        QString fn(cr2qt(files.get(k)->getFilePathName()));
        if (!QFile::exists(fn))
            files.remove(k);
        else
            ++k;
    }

    ui->tableWidget->setRowCount( files.length() );

    // insert items
    for( int index=0; index<files.length(); ++index )
    {
        CRFileHistRecord* book = files.get(index);

        RecentTableWidgetItem* titleItem = new RecentTableWidgetItem();
        titleItem->title   = cr2qt(book->getTitle());
        if ( titleItem->title.isEmpty() )
            titleItem->title = cr2qt(book->getFileName());
        titleItem->info  = cr2qt(book->getAuthor());
        if ( titleItem->info.isEmpty() )
            titleItem->info = "-";
        titleItem->percent = " " + crpercent(book->getLastPos()->getPercent());

        ui->tableWidget->setItem(index, 0, titleItem);
    }

    ui->navBar->setControls(ui->tableWidget, ui->lblPosition,
                            QSize( docview->getOptions()->getIntDef(PROP_APP_UI_SWIPES_X_WEIGHT, 1),
                                   docview->getOptions()->getIntDef(PROP_APP_UI_SWIPES_Y_WEIGHT, 1) ) );

    ui->tableWidget->setEditFocus(true);
    ui->tableWidget->setCurrentCell(0,0);

    QObject::connect( ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem*)), this, SLOT(onClicked(QTableWidgetItem*)) );
    QObject::connect( ui->tableWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(onClicked(QTableWidgetItem*)) );

    init();
}
Ejemplo n.º 18
0
void V3DocViewWin::showAboutDialog()
{
	_docview->savePosition();
	CRFileHistRecord * hist = _docview->getCurrentFileHistRecord();
    lString16 title = L"Cool Reader ";
#ifndef PACKAGE_VERSION
#define PACKAGE_VERSION CR_ENGINE_VERSION
#endif
    title << Utf8ToUnicode(lString8(PACKAGE_VERSION));

    lString8 txt;
    //=========================================================
    txt << "<table><col width=\"30%\"/><col width=\"70%\"/>\n";
    CRPropRef props = _docview->getDocProps();

    lString8 statusInfo;
	addPropLine( statusInfo, _("Current page"), lString16::itoa(_docview->getCurPage()+1) );
	addPropLine( statusInfo, _("Total pages"), lString16::itoa(_docview->getPageCount()) );
    addPropLine( statusInfo, _("Battery state"), _docview->getBatteryState()==-1 ? lString16(_("charging...")) : lString16::itoa(_docview->getBatteryState()) + L"%" );
	addPropLine( statusInfo, _("Current Time"), _docview->getTimeString() );
	// TODO:
	if ( hist ) {
		CRBookmark * lastpos = hist->getLastPos();
		if ( lastpos ) {
			addPropLine( statusInfo, _("Current chapter"), lastpos->getTitleText() );
		}
	}
    addInfoSection( txt, statusInfo, _("Status") );

    lString8 fileInfo;
    addPropLine( fileInfo, _("Archive name"), props->getStringDef(DOC_PROP_ARC_NAME) );
    addPropLine( fileInfo, _("Archive path"), props->getStringDef(DOC_PROP_ARC_PATH) );
    addPropLine( fileInfo, _("Archive size"), props->getStringDef(DOC_PROP_ARC_SIZE) );
    addPropLine( fileInfo, _("File name"), props->getStringDef(DOC_PROP_FILE_NAME) );
    addPropLine( fileInfo, _("File path"), props->getStringDef(DOC_PROP_FILE_PATH) );
    addPropLine( fileInfo, _("File size"), props->getStringDef(DOC_PROP_FILE_SIZE) );
    addPropLine( fileInfo, _("File format"), props->getStringDef(DOC_PROP_FILE_FORMAT) );
    addInfoSection( txt, fileInfo, _("File info") );

    lString8 bookInfo;
    addPropLine( bookInfo, _("Title"), props->getStringDef(DOC_PROP_TITLE) );
    addPropLine( bookInfo, _("Author(s)"), props->getStringDef(DOC_PROP_AUTHORS) );
    addPropLine( bookInfo, _("Series name"), props->getStringDef(DOC_PROP_SERIES_NAME) );
    addPropLine( bookInfo, _("Series number"), props->getStringDef(DOC_PROP_SERIES_NUMBER) );
    addPropLine( bookInfo, _("Date"), getDocText( getDocView()->getDocument(), "/FictionBook/description/title-info/date", ", " ) );
    addPropLine( bookInfo, _("Genres"), getDocText( getDocView()->getDocument(), "/FictionBook/description/title-info/genre", ", " ) );
    addPropLine( bookInfo, _("Translator"), getDocText( getDocView()->getDocument(), "/FictionBook/description/title-info/translator", ", " ) );
    addInfoSection( txt, bookInfo, _("Book info") );

    lString8 docInfo;
    addPropLine( docInfo, _("Document author"), getDocAuthors( getDocView()->getDocument(), "/FictionBook/description/document-info/author", " " ) );
    addPropLine( docInfo, _("Document date"), getDocText( getDocView()->getDocument(), "/FictionBook/description/document-info/date", " " ) );
    addPropLine( docInfo, _("Document source URL"), getDocText( getDocView()->getDocument(), "/FictionBook/description/document-info/src-url", " " ) );
    addPropLine( docInfo, _("OCR by"), getDocText( getDocView()->getDocument(), "/FictionBook/description/document-info/src-ocr", " " ) );
    addPropLine( docInfo, _("Document version"), getDocText( getDocView()->getDocument(), "/FictionBook/description/document-info/version", " " ) );
    addPropLine( docInfo, _("Change history"), getDocText( getDocView()->getDocument(), "/FictionBook/description/document-info/history", " " ) );
    addInfoSection( txt, docInfo, _("Document info") );

    lString8 pubInfo;
    addPropLine( pubInfo, _("Publication name"), getDocText( getDocView()->getDocument(), "/FictionBook/description/publish-info/book-name", " " ) );
    addPropLine( pubInfo, _("Publisher"), getDocText( getDocView()->getDocument(), "/FictionBook/description/publish-info/publisher", " " ) );
    addPropLine( pubInfo, _("Publisher city"), getDocText( getDocView()->getDocument(), "/FictionBook/description/publish-info/city", " " ) );
    addPropLine( pubInfo, _("Publication year"), getDocText( getDocView()->getDocument(), "/FictionBook/description/publish-info/year", " " ) );
    addPropLine( pubInfo, _("ISBN"), getDocText( getDocView()->getDocument(), "/FictionBook/description/publish-info/isbn", " " ) );
    addInfoSection( txt, pubInfo, _("Publication info") );

    addPropLine( txt, _("Custom info"), getDocText( getDocView()->getDocument(), "/FictionBook/description/custom-info", " " ) );

    txt << "</table>\n";

    //CRLog::trace(txt.c_str());
    //=========================================================
    txt = CRViewDialog::makeFb2Xml(txt);
    CRViewDialog * dlg = new CRViewDialog( _wm, title, txt, lvRect(), true, true );
    dlg->getDocView()->setVisiblePageCount(1);
    //int fs = _props->getIntDef( PROP_FILE_PROPS_FONT_SIZE, 26 );
    //dlg->getDocView()->setFontSize(fs);
    _wm->activateWindow( dlg );
}