Switch to unified view

a/dirbrowser/cdbrowser.cpp b/dirbrowser/cdbrowser.cpp
...
...
70
using namespace UPnPP;
70
using namespace UPnPP;
71
using namespace UPnPClient;
71
using namespace UPnPClient;
72
72
73
static const string minimFoldersViewPrefix("0$folders");
73
static const string minimFoldersViewPrefix("0$folders");
74
74
75
const std::string
76
CDBrowser::plContainerClass{"object.container.playlistContainer"};
77
75
void CDWebPage::javaScriptConsoleMessage(
78
void CDWebPage::javaScriptConsoleMessage(
76
#ifdef USING_WEBENGINE
79
#ifdef USING_WEBENGINE
77
    JavaScriptConsoleMessageLevel,
80
    JavaScriptConsoleMessageLevel,
78
#endif
81
#endif
79
    const QString& msg, int lineNum, const QString&)
82
    const QString& msg, int lineNum, const QString&)
...
...
341
    case 'S':
344
    case 'S':
342
    {
345
    {
343
        // Servers page server link click: browse clicked server root
346
        // Servers page server link click: browse clicked server root
344
    unsigned int cdsidx = atoi(scurl.c_str()+1);
347
    unsigned int cdsidx = atoi(scurl.c_str()+1);
345
        m_curpath.clear();
348
        m_curpath.clear();
346
        m_curpath.push_back(CtPathElt("0", "(servers)"));
349
        m_curpath.push_back(CtPathElt("0", "(servers)", false));
347
        if (!newCds(cdsidx)) {
350
        if (!newCds(cdsidx)) {
348
            return;
351
            return;
349
        }
352
        }
350
        m_cds->srv()->getSearchCapabilities(m_searchcaps);
353
        m_cds->srv()->getSearchCapabilities(m_searchcaps);
351
        emit sig_searchcaps_changed();
354
        emit sig_searchcaps_changed();
352
355
353
    browseContainer("0", m_msdescs[cdsidx].friendlyName);
356
    browseContainer("0", m_msdescs[cdsidx].friendlyName, false);
354
    }
357
    }
355
    break;
358
    break;
356
359
357
    case 'I':
360
    case 'I':
358
    {
361
    {
...
...
382
        if (i > m_entries.size()) {
385
        if (i > m_entries.size()) {
383
        LOGERR("CDBrowser::onLinkClicked: bad objid index: " << i 
386
        LOGERR("CDBrowser::onLinkClicked: bad objid index: " << i 
384
                   << " id count: " << m_entries.size() << endl);
387
                   << " id count: " << m_entries.size() << endl);
385
        return;
388
        return;
386
    }
389
    }
390
        UPnPClient::UPnPDirObject& e{m_entries[i]};
391
        bool isPlaylist = !e.getprop("upnp:class").compare(plContainerClass);
387
        if (m_lastbutton == Qt::MidButton) {
392
        if (m_lastbutton == Qt::MidButton) {
388
            // Open in new tab
393
            // Open in new tab
389
            vector<CtPathElt> npath(m_curpath);
394
            vector<CtPathElt> npath(m_curpath);
390
            npath.push_back(CtPathElt(m_entries[i].m_id, m_entries[i].m_title));
395
            npath.push_back(CtPathElt(e.m_id, e.m_title, isPlaylist));
391
            emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()),
396
            emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()),
392
                                       npath);
397
                                       npath);
393
        } else {
398
        } else {
394
            browseContainer(m_entries[i].m_id, m_entries[i].m_title);
399
            browseContainer(e.m_id, e.m_title, isPlaylist);
395
        }
400
        }
396
        return;
401
        return;
397
    }
402
    }
398
    break;
403
    break;
399
404
...
...
426
        m_curpath.clear();
431
        m_curpath.clear();
427
        m_msdescs.clear();
432
        m_msdescs.clear();
428
        m_cds.reset();
433
        m_cds.reset();
429
        initialPage();
434
        initialPage();
430
    } else {
435
    } else {
431
        string objid = m_curpath[i].objid;
436
        CtPathElt e{m_curpath[i]};
432
        string title = m_curpath[i].title;
433
        string ss = m_curpath[i].searchStr;
434
        QPoint scrollpos = m_curpath[i].scrollpos;
435
        m_curpath.erase(m_curpath.begin() + i, m_curpath.end());
437
        m_curpath.erase(m_curpath.begin() + i, m_curpath.end());
436
        if (m_lastbutton == Qt::MidButton) {
438
        if (m_lastbutton == Qt::MidButton) {
437
            vector<CtPathElt> npath(m_curpath);
439
            vector<CtPathElt> npath(m_curpath);
438
            npath.push_back(CtPathElt(objid, title, ss));
440
            npath.push_back(e);
439
            emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()),
441
            emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()),
440
                                       npath);
442
                                       npath);
441
        } else {
443
        } else {
442
            if (ss.empty()) {
444
            if (e.searchStr.empty()) {
443
                browseContainer(objid, title, scrollpos);
445
                browseContainer(e.objid, e.title, e.isPlaylist, e.scrollpos);
444
            } else {
446
            } else {
445
                search(objid, ss, scrollpos);
447
                search(e.objid, e.searchStr, e.scrollpos);
446
            }
448
            }
447
        }
449
        }
448
    }
450
    }
449
}
451
}
450
452
...
...
483
    if (m_curpath.size() >= 1) {
485
    if (m_curpath.size() >= 1) {
484
        curpathClicked(m_curpath.size() - 1);
486
        curpathClicked(m_curpath.size() - 1);
485
    }
487
    }
486
}
488
}
487
489
488
void CDBrowser::browseContainer(string ctid, string cttitle, QPoint scrollpos)
490
void CDBrowser::browseContainer(string ctid, string cttitle, bool ispl,
491
                                QPoint scrollpos)
489
{
492
{
490
    LOGDEB("CDBrowser::browseContainer: " << " ctid " << ctid << endl);
493
    LOGDEB("CDBrowser::browseContainer: " << " ctid " << ctid << endl);
491
    deleteReaders();
494
    deleteReaders();
492
495
493
    emit sig_now_in(this, QString::fromUtf8(cttitle.c_str()));
496
    emit sig_now_in(this, QString::fromUtf8(cttitle.c_str()));
...
...
497
        LOGERR("CDBrowser::browseContainer: server not set" << endl);
500
        LOGERR("CDBrowser::browseContainer: server not set" << endl);
498
        return;
501
        return;
499
    }
502
    }
500
    m_entries.clear();
503
    m_entries.clear();
501
504
502
    m_curpath.push_back(CtPathElt(ctid, cttitle));
505
    m_curpath.push_back(CtPathElt(ctid, cttitle, ispl));
503
506
504
    initContainerHtml();
507
    initContainerHtml();
505
    
508
    
506
    m_reader = new CDBrowseQO(m_cds->srv(), ctid, string(), this);
509
    m_reader = new CDBrowseQO(m_cds->srv(), ctid, string(), this);
507
510
...
...
525
        LOGERR("CDBrowser::search: server not set" << endl);
528
        LOGERR("CDBrowser::search: server not set" << endl);
526
        return;
529
        return;
527
    }
530
    }
528
    m_savedscrollpos = scrollpos;
531
    m_savedscrollpos = scrollpos;
529
    m_entries.clear();
532
    m_entries.clear();
530
    m_curpath.push_back(CtPathElt(objid, "(search)", iss));
533
    m_curpath.push_back(CtPathElt(objid, "(search)", false, iss));
531
    initContainerHtml(iss);
534
    initContainerHtml(iss);
532
535
533
    m_reader = new CDBrowseQO(m_cds->srv(), m_curpath.back().objid, iss, this);
536
    m_reader = new CDBrowseQO(m_cds->srv(), m_curpath.back().objid, iss, this);
534
537
535
    connect(m_reader, SIGNAL(sliceAvailable(UPnPClient::UPnPDirContent*)),
538
    connect(m_reader, SIGNAL(sliceAvailable(UPnPClient::UPnPDirContent*)),
...
...
685
string DirObjCmp::nullstr;
688
string DirObjCmp::nullstr;
686
689
687
void CDBrowser::onBrowseDone(int)
690
void CDBrowser::onBrowseDone(int)
688
{
691
{
689
    //qDebug() <<"CDBrowser::onBrowseDone: " << m_entries.size() << " entries";
692
    //qDebug() <<"CDBrowser::onBrowseDone: " << m_entries.size() << " entries";
693
    bool inPlaylist = m_curpath.back().isPlaylist;
694
690
    if (!m_reader) {
695
    if (!m_reader) {
691
        qDebug() << "CDBrowser::onBrowseDone(int) no reader: cancelled";
696
        qDebug() << "CDBrowser::onBrowseDone(int) no reader: cancelled";
692
        return;
697
        return;
693
    }
698
    }
694
    if (m_autoclickcnt++ < 3 && m_entries.size() == 1 &&
699
    if (m_autoclickcnt++ < 3 && m_entries.size() == 1 &&
...
...
713
        }
718
        }
714
    }
719
    }
715
    int nct = 0;
720
    int nct = 0;
716
    char curinitial = 0;
721
    char curinitial = 0;
717
    m_alphamap.clear();
722
    m_alphamap.clear();
718
    if (!sortcrits.empty()) {
723
    if (!inPlaylist && !sortcrits.empty()) {
719
        DirObjCmp cmpo(sortcrits);
724
        DirObjCmp cmpo(sortcrits);
720
725
721
        sort(m_entries.begin(), m_entries.end(), cmpo);
726
        sort(m_entries.begin(), m_entries.end(), cmpo);
722
        initContainerHtml();
727
        initContainerHtml();
723
        QString html;
728
        QString html;
...
...
846
                m_popupobjtitle = qs2utf8s(value);
851
                m_popupobjtitle = qs2utf8s(value);
847
            } else if (!nm.compare("objidx")) {
852
            } else if (!nm.compare("objidx")) {
848
                m_popupidx = value.toInt();
853
                m_popupidx = value.toInt();
849
            } else if (!nm.compare("otype")) {
854
            } else if (!nm.compare("otype")) {
850
                m_popupotype = qs2utf8s(value);
855
                m_popupotype = qs2utf8s(value);
856
            } else if (!nm.compare("ispl")) {
857
                m_popupispl = value.toInt();
851
            } else {
858
            } else {
852
                LOGERR("onPopupJsDone: unknown key: " << qs2utf8s(nm) << endl);
859
                LOGERR("onPopupJsDone: unknown key: " << qs2utf8s(nm) << endl);
853
            }
860
            }
854
        }
861
        }
855
    }
862
    }
...
...
892
        m_popupobjtitle = qs2utf8s(el.toPlainText());
899
        m_popupobjtitle = qs2utf8s(el.toPlainText());
893
        if (el.hasAttribute("objidx"))
900
        if (el.hasAttribute("objidx"))
894
            m_popupidx = el.attribute("objidx").toInt();
901
            m_popupidx = el.attribute("objidx").toInt();
895
        else
902
        else
896
            m_popupidx = -1;
903
            m_popupidx = -1;
904
        if (el.hasAttribute("ispl"))
905
            m_popupispl = el.attribute("ispl").toInt();
906
        else
907
            m_popupispl = false;
897
        m_popupotype = qs2utf8s(el.attribute("class"));
908
        m_popupotype = qs2utf8s(el.attribute("class"));
898
        LOGDEB("Popup: " << " class " << m_popupotype << " objid " << 
909
        LOGDEB("Popup: " << " class " << m_popupotype << " objid " << 
899
               m_popupobjid << endl);
910
               m_popupobjid << endl);
900
    }
911
    }
901
    doCreatePopupMenu();
912
    doCreatePopupMenu();
902
#endif
913
#endif
903
}
914
}
904
915
905
void CDBrowser::doCreatePopupMenu()
916
void CDBrowser::doCreatePopupMenu()
906
{
917
{
918
    LOGDEB1("CDBrowser::doCreatePopupMenu: objid " << m_popupobjid <<
919
           " title " << m_popupobjtitle << " type " <<  m_popupotype <<
920
           " IDX " << m_popupidx << " ISPL " << m_popupispl << endl);
921
907
    QMenu *popup = new QMenu(this);
922
    QMenu *popup = new QMenu(this);
908
    QAction *act;
923
    QAction *act;
909
    QVariant v;
924
    QVariant v;
910
    if (m_curpath.size() != 0) {
925
    if (m_curpath.size() != 0) {
911
        // Back action
926
        // Back action
...
...
1087
        return;
1102
        return;
1088
    }
1103
    }
1089
1104
1090
    if (m_popupmode == PUP_OPEN_IN_NEW_TAB) {
1105
    if (m_popupmode == PUP_OPEN_IN_NEW_TAB) {
1091
        vector<CtPathElt> npath(m_curpath);
1106
        vector<CtPathElt> npath(m_curpath);
1092
        npath.push_back(CtPathElt(m_popupobjid, m_popupobjtitle));
1107
        npath.push_back(CtPathElt(m_popupobjid, m_popupobjtitle, m_popupispl));
1093
        emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()), npath);
1108
        emit sig_browse_in_new_tab(u8s2qs(m_cds->srv()->getDeviceId()), npath);
1094
        return;
1109
        return;
1095
    }
1110
    }
1096
1111
1097
    if (m_browsers)
1112
    if (m_browsers)