コード例 #1
0
ファイル: autodjfeature.cpp プロジェクト: sohet/mixxx
AutoDJFeature::AutoDJFeature(Library* pLibrary,
                             UserSettingsPointer pConfig,
                             PlayerManagerInterface* pPlayerManager,
                             TrackCollection* pTrackCollection)
        : LibraryFeature(pLibrary),
          m_pConfig(pConfig),
          m_pLibrary(pLibrary),
          m_pTrackCollection(pTrackCollection),
          m_crateDao(pTrackCollection->getCrateDAO()),
          m_playlistDao(pTrackCollection->getPlaylistDAO()),
          m_iAutoDJPlaylistId(-1),
          m_pAutoDJProcessor(NULL),
          m_pAutoDJView(NULL),
          m_autoDjCratesDao(pTrackCollection->getDatabase(),
                            pTrackCollection->getTrackDAO(),
                            pTrackCollection->getCrateDAO(),
                            pTrackCollection->getPlaylistDAO(),
                            pConfig) {
    m_iAutoDJPlaylistId = m_playlistDao.getPlaylistIdFromName(AUTODJ_TABLE);
    // If the AutoDJ playlist does not exist yet then create it.
    if (m_iAutoDJPlaylistId < 0) {
        m_iAutoDJPlaylistId = m_playlistDao.createPlaylist(
                AUTODJ_TABLE, PlaylistDAO::PLHT_AUTO_DJ);
    }
    qRegisterMetaType<AutoDJProcessor::AutoDJState>("AutoDJState");
    m_pAutoDJProcessor = new AutoDJProcessor(
            this, m_pConfig, pPlayerManager, m_iAutoDJPlaylistId, m_pTrackCollection);
    connect(m_pAutoDJProcessor, SIGNAL(loadTrackToPlayer(TrackPointer, QString, bool)),
            this, SIGNAL(loadTrackToPlayer(TrackPointer, QString, bool)));
    m_playlistDao.setAutoDJProcessor(m_pAutoDJProcessor);


    // Create the "Crates" tree-item under the root item.
    auto pRootItem = std::make_unique<TreeItem>(this);
    m_pCratesTreeItem = pRootItem->appendChild(tr("Crates"));
    m_pCratesTreeItem->setIcon(QIcon(":/images/library/ic_library_crates.png"));

    // Create tree-items under "Crates".
    constructCrateChildModel();

    m_childModel.setRootItem(std::move(pRootItem));

    // Be notified when the status of crates changes.
    connect(&m_crateDao, SIGNAL(added(int)),
            this, SLOT(slotCrateAdded(int)));
    connect(&m_crateDao, SIGNAL(renamed(int,QString)),
            this, SLOT(slotCrateRenamed(int,QString)));
    connect(&m_crateDao, SIGNAL(deleted(int)),
            this, SLOT(slotCrateDeleted(int)));
    connect(&m_crateDao, SIGNAL(autoDjChanged(int,bool)),
            this, SLOT(slotCrateAutoDjChanged(int,bool)));

    // Create context-menu items to allow crates to be added to, and removed
    // from, the auto-DJ queue.
    connect(&m_crateMapper, SIGNAL(mapped(int)),
            this, SLOT(slotAddCrateToAutoDj(int)));
    m_pRemoveCrateFromAutoDj = new QAction(tr("Remove Crate as Track Source"), this);
    connect(m_pRemoveCrateFromAutoDj, SIGNAL(triggered()),
            this, SLOT(slotRemoveCrateFromAutoDj()));
}
コード例 #2
0
ファイル: autodjfeature.cpp プロジェクト: CorgiMan/mixxx
AutoDJFeature::AutoDJFeature(QObject* parent,
                             ConfigObject<ConfigValue>* pConfig,
                             TrackCollection* pTrackCollection)
        : LibraryFeature(parent),
          m_pConfig(pConfig),
          m_pTrackCollection(pTrackCollection),
          m_crateDao(pTrackCollection->getCrateDAO()),
          m_playlistDao(pTrackCollection->getPlaylistDAO()),
          m_pAutoDJView(NULL)
#ifdef __AUTODJCRATES__
          , m_autoDjCratesDao(pTrackCollection->getDatabase(),
                              pTrackCollection->getTrackDAO(),
                              pTrackCollection->getCrateDAO(),
                              pTrackCollection->getPlaylistDAO(),
                              pConfig)
#endif // __AUTODJCRATES__
{
#ifdef __AUTODJCRATES__

    // Create the "Crates" tree-item under the root item.
    TreeItem* root = m_childModel.getItem(QModelIndex());
    m_pCratesTreeItem = new TreeItem(tr("Crates"), "", this, root);
    m_pCratesTreeItem->setIcon(QIcon(":/images/library/ic_library_crates.png"));
    root->appendChild(m_pCratesTreeItem);

    // Create tree-items under "Crates".
    constructCrateChildModel();

    // Be notified when the status of crates changes.
    connect(&m_crateDao, SIGNAL(added(int)),
            this, SLOT(slotCrateAdded(int)));
    connect(&m_crateDao, SIGNAL(renamed(int,QString)),
            this, SLOT(slotCrateRenamed(int,QString)));
    connect(&m_crateDao, SIGNAL(deleted(int)),
            this, SLOT(slotCrateDeleted(int)));
    connect(&m_crateDao, SIGNAL(autoDjChanged(int,bool)),
            this, SLOT(slotCrateAutoDjChanged(int,bool)));

    // Create context-menu items to allow crates to be added to, and removed
    // from, the auto-DJ queue.
    connect(&m_crateMapper, SIGNAL(mapped(int)),
            this, SLOT(slotAddCrateToAutoDj(int)));
    m_pRemoveCrateFromAutoDj = new QAction(tr("Remove"), this);
    connect(m_pRemoveCrateFromAutoDj, SIGNAL(triggered()),
            this, SLOT(slotRemoveCrateFromAutoDj()));

#endif // __AUTODJCRATES__
}