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; }
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); }
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 ); }
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("")); }