Esempio n. 1
0
QWidget *MainWindow::createSourcesList()
{
    m_sourcesList = new DVRServersView(m_serverRepository);
    m_sourcesList->setMinimumHeight(220);
    m_sourcesList->setFrameStyle(QFrame::NoFrame);
    m_sourcesList->setAttribute(Qt::WA_MacShowFocusRect, false);
    m_sourcesList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_sourcesList->setMinimumWidth(140);

    DVRServersModel *model = new DVRServersModel(m_serverRepository, true, m_sourcesList);
    model->setOfflineDisabled(true);

    DVRServersProxyModel *proxyModel = new DVRServersProxyModel(model);
    proxyModel->setDynamicSortFilter(true);
    proxyModel->setHideDisabledCameras(true);
    proxyModel->setSourceModel(model);
    proxyModel->sort(0);

    m_sourcesList->setModel(proxyModel);

#ifdef Q_OS_MAC
    if (style()->inherits("QMacStyle"))
    {
        QLinearGradient grd(0, 0, 0, 1);
        grd.setCoordinateMode(QGradient::ObjectBoundingMode);
        grd.setColorAt(0, QColor(233, 237, 241));
        grd.setColorAt(1, QColor(209, 216, 223));

        QPalette p = m_sourcesList->palette();
        p.setBrush(QPalette::Base, QBrush(grd));
        m_sourcesList->setPalette(p);
    }
#endif

    return m_sourcesList;
}
EventsWindow::EventsWindow(QWidget *parent)
    : QWidget(parent, Qt::Window)
{
    setWindowTitle(tr("Bluecherry - Event Browser"));
    resize(QSize(900, 600));

    QBoxLayout *layout = new QHBoxLayout(this);
    QBoxLayout *filtersLayout = new QVBoxLayout;
    layout->addLayout(filtersLayout);

    createResultsView();

    /* Filters */
    m_sourcesView = new DVRServersView;
    EventSourcesModel *sourcesModel = new EventSourcesModel(bcApp->serverRepository(), m_sourcesView);

    DVRServersProxyModel *proxyModel = new DVRServersProxyModel(sourcesModel);
    proxyModel->setDynamicSortFilter(true);
    proxyModel->setSourceModel(sourcesModel);
    proxyModel->sort(0);

    m_sourcesView->setModel(proxyModel);
    m_sourcesView->setMaximumWidth(180);
    //m_sourcesView->setMaximumHeight(150);
    filtersLayout->addWidget(m_sourcesView);

    connect(sourcesModel, SIGNAL(checkedSourcesChanged(QMap<DVRServer*,QList<int>>)),
            m_resultsView->eventsModel(), SLOT(setFilterSources(QMap<DVRServer*,QList<int>>)));

    createDateFilter(filtersLayout);

#if 0 /* This is not useful currently. */
    QLabel *label = new QLabel(tr("Minimum Level"));
    label->setStyleSheet(QLatin1String("font-weight:bold;"));
    filtersLayout->addWidget(label);
    filtersLayout->addWidget(createLevelFilter());
#endif

    QLabel *label = new QLabel(tr("Type"));
    label->setStyleSheet(QLatin1String("font-weight:bold;"));
    filtersLayout->addWidget(label);
    filtersLayout->addWidget(createTypeFilter());

#if 0 /* Tags are not fully implemented yet */
    label = new QLabel(tr("Tags"));
    label->setStyleSheet(QLatin1String("font-weight:bold;"));
    filtersLayout->addWidget(label);
    filtersLayout->addWidget(createTags());
    filtersLayout->addWidget(createTagsInput());
#endif

    /* Splitter between results and playback */
    m_videoSplitter = new QSplitter(Qt::Vertical);
    layout->addWidget(m_videoSplitter, 1);

    /* Results */
    m_resultTabs = new QTabWidget;
    m_videoSplitter->addWidget(m_resultTabs);
    m_videoSplitter->setCollapsible(0, false);

    m_resultTabs->addTab(m_resultsView, tr("List"));
    m_resultTabs->addTab(createTimeline(), tr("Timeline"));

    /* Playback */
    m_eventViewer = new EventViewWindow;
    m_eventViewer->layout()->setMargin(0);
    m_eventViewer->hide();
    m_videoSplitter->addWidget(m_eventViewer);

    m_modelEventsCursor = new ModelEventsCursor();
    m_modelEventsCursor->setModel(m_resultsView->model());
    m_eventViewer->setEventsCursor(m_modelEventsCursor);
    connect(m_modelEventsCursor, SIGNAL(indexUpdated()), this, SLOT(cursorIndexUpdated()));

    /* Settings */
    QSettings settings;
    restoreGeometry(settings.value(QLatin1String("ui/events/geometry")).toByteArray());
    m_videoSplitter->restoreState(settings.value(QLatin1String("ui/events/videoSplitter")).toByteArray());
}