~s-cecilio/lenmus/v5.3

« back to all changes in this revision

Viewing changes to src/app/lenmus_document_frame.cpp

  • Committer: cecilios
  • Date: 2012-09-25 16:27:45 UTC
  • Revision ID: s.cecilio@gmail.com-20120925162745-v2wrglew137u08yb
Class BookReader renamed as BooksCollection and refactored. Created class BookReader

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
//    m_mergedIndex = LENMUS_NEW TextBookHelpMergedIndex;
120
120
//    TextBookHelpMergedIndex& merged = *m_mergedIndex;
121
121
//
122
 
//    const BookIndexArray& items = m_pBookReader->GetIndexArray();
 
122
//    const BookIndexArray& items = m_pBooksData->GetIndexArray();
123
123
//    size_t len = items.size();
124
124
//
125
125
//    TextBookHelpMergedIndexItem *history[128] = {NULL};
201
201
    , m_lomse(lomse)
202
202
    , m_left(NULL)
203
203
    , m_right(NULL)
204
 
    , m_pBookReader(NULL)
 
204
    , m_pBooksData(NULL)
205
205
{
206
206
}
207
207
 
208
208
//---------------------------------------------------------------------------------------
209
209
DocumentFrame::~DocumentFrame()
210
210
{
211
 
    delete m_pBookReader;
 
211
    delete m_pBooksData;
212
212
    delete m_left;
213
213
    delete m_right;
214
214
}
242
242
{
243
243
    m_left = LENMUS_NEW BookContentBox(this, this, m_appScope, wxID_ANY, wxDefaultPosition,
244
244
                                wxDefaultSize, 0, _T("The TOC"));
245
 
    m_left->CreateContents(m_pBookReader);
 
245
    m_left->CreateContents(m_pBooksData);
246
246
}
247
247
 
248
248
//---------------------------------------------------------------------------------------
288
288
   if (fIsBook)
289
289
    {
290
290
        //read book (.lmb)
291
 
        m_pBookReader = LENMUS_NEW BookReader();
292
 
        if (!m_pBookReader->AddBook(document))
 
291
        m_pBooksData = LENMUS_NEW BooksCollection();
 
292
        if (!m_pBooksData->add_book(document))
293
293
        {
294
294
            //TODO better error handling
295
295
            wxMessageBox(wxString::Format(_("Failed adding book %s"),
331
331
//---------------------------------------------------------------------------------------
332
332
void DocumentFrame::change_to_page(wxString& pagename)
333
333
{
334
 
    wxString fullpath = m_pBookReader->FindPageByName(pagename);
 
334
    wxString fullpath = m_pBooksData->find_page_by_name(pagename);
335
335
    if (fullpath != _T(""))
336
336
    {
337
337
        load_page( to_std_string(fullpath) );
366
366
 
367
367
    if (!filename.empty())
368
368
    {
369
 
        LdpZipReader reader(filename);
370
 
        int viewType = ViewFactory::k_view_vertical_book;
371
 
        string title = "test";
372
 
        m_right->display_document(reader, viewType, title);
 
369
        if (filename.find(".lmd"))
 
370
        {
 
371
            int viewType = ViewFactory::k_view_vertical_book;
 
372
            m_right->display_document(filename, viewType);
 
373
        }
 
374
        else
 
375
        {
 
376
            LdpZipReader reader(filename);
 
377
            int viewType = ViewFactory::k_view_vertical_book;
 
378
            string title = "test";
 
379
            m_right->display_document(reader, viewType, title);
 
380
        }
373
381
    }
374
382
}
375
383
 
376
384
//---------------------------------------------------------------------------------------
377
385
wxString DocumentFrame::get_path_for_toc_item(int iItem)
378
386
{
379
 
    const BookIndexArray& contents = m_pBookReader->GetContentsArray();
 
387
    return m_pBooksData->get_path_for_toc_item(iItem);
 
388
    const BookIndexArray& contents = m_pBooksData->GetContentsArray();
380
389
    if (!contents[iItem]->page.empty())
381
390
        return contents[iItem]->GetFullPath();
382
391
    else