Exemplo n.º 1
0
void
PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
{
    if ( m_model )
    {
        disconnect( m_model, SIGNAL( loadingStarted() ), this, SIGNAL( loadingStarted() ) );
        disconnect( m_model, SIGNAL( loadingFinished() ), this, SIGNAL( loadingFinished() ) );
        disconnect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), this, SIGNAL( itemCountChanged( unsigned int ) ) );
        disconnect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), this, SLOT( onIndexPlayable( QModelIndex ) ) );
        disconnect( m_model, SIGNAL( indexResolved( QModelIndex ) ), this, SLOT( onIndexResolved( QModelIndex ) ) );
        disconnect( m_model, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), this, SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) );
        disconnect( m_model, SIGNAL( expandRequest( QPersistentModelIndex ) ), this, SLOT( expandRequested( QPersistentModelIndex ) ) );
        disconnect( m_model, SIGNAL( selectRequest( QPersistentModelIndex ) ), this, SLOT( selectRequested( QPersistentModelIndex ) ) );
    }

    m_model = sourceModel;
    if ( m_model )
    {
        connect( m_model, SIGNAL( loadingStarted() ), SIGNAL( loadingStarted() ) );
        connect( m_model, SIGNAL( loadingFinished() ), SIGNAL( loadingFinished() ) );
        connect( m_model, SIGNAL( itemCountChanged( unsigned int ) ), SIGNAL( itemCountChanged( unsigned int ) ) );
        connect( m_model, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexPlayable( QModelIndex ) ) );
        connect( m_model, SIGNAL( indexResolved( QModelIndex ) ), SLOT( onIndexResolved( QModelIndex ) ) );
        connect( m_model, SIGNAL( currentIndexChanged( QModelIndex, QModelIndex ) ), SLOT( onCurrentIndexChanged( QModelIndex, QModelIndex ) ) );
        connect( m_model, SIGNAL( expandRequest( QPersistentModelIndex ) ), SLOT( expandRequested( QPersistentModelIndex ) ) );
        connect( m_model, SIGNAL( selectRequest( QPersistentModelIndex ) ), SLOT( selectRequested( QPersistentModelIndex ) ) );
    }

    QSortFilterProxyModel::setSourceModel( m_model );
}
Exemplo n.º 2
0
QWidget *MainWindow::createRecentEvents()
{
    m_eventsView = new EventsView;
    m_eventsView->setContextMenuPolicy(Qt::CustomContextMenu);
    m_eventsView->setFrameStyle(QFrame::NoFrame);
    m_eventsView->setAttribute(Qt::WA_MacShowFocusRect, false);
    m_eventsView->setIncompletePlace(EventsProxyModel::IncompleteLast);

    m_eventsModel = new EventsModel(m_serverRepository, m_eventsView);

    EventsUpdater *updater = new EventsUpdater(m_serverRepository, m_eventsModel);
    connect(updater, SIGNAL(serverEventsAvailable(DVRServer*,QList<QSharedPointer<EventData>>)),
            m_eventsModel, SLOT(setServerEvents(DVRServer*,QList<QSharedPointer<EventData>>)));

    m_eventsView->setModel(m_eventsModel, updater->isUpdating());

    connect(updater, SIGNAL(loadingStarted()), m_eventsView, SLOT(loadingStarted()));
    connect(updater, SIGNAL(loadingFinished()), m_eventsView, SLOT(loadingFinished()));

    QSettings settings;
    updater->setUpdateInterval(settings.value(QLatin1String("ui/main/eventRefreshInterval"), 10000).toInt());
    updater->setLimit(50);

    m_eventsView->header()->restoreState(settings.value(QLatin1String("ui/main/eventsView")).toByteArray());

    connect(m_eventsView, SIGNAL(doubleClicked(QModelIndex)), m_eventsView, SLOT(openEvent(QModelIndex)));
    connect(m_eventsView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(eventsContextMenu(QPoint)));

	return m_eventsView;
}
Exemplo n.º 3
0
QWidget * EventsWindow::createResultsView()
{
    m_resultsView = new EventsView;
    connect(m_eventsUpdater, SIGNAL(loadingStarted()), m_resultsView, SLOT(loadingStarted()));
    connect(m_eventsUpdater, SIGNAL(loadingFinished()), m_resultsView, SLOT(loadingFinished()));

    EventsModel *eventsModel = new EventsModel(m_serverRepository, this);
    m_resultsView->setModel(eventsModel, m_eventsUpdater->isUpdating());

    connect(m_eventsUpdater, SIGNAL(serverEventsAvailable(DVRServer*,QList<EventData*>)),
            eventsModel, SLOT(setServerEvents(DVRServer*,QList<EventData*>)));

    m_resultsView->setFrameStyle(QFrame::NoFrame);
    m_resultsView->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(m_resultsView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(eventContextMenu(QPoint)));
    connect(m_resultsView, SIGNAL(doubleClicked(QModelIndex)), SLOT(showServerEvent(QModelIndex)));

    QSettings settings;
    m_resultsView->header()->restoreState(settings.value(QLatin1String("ui/events/viewHeader")).toByteArray());
    m_resultsView->header()->setSortIndicatorShown(true);
    m_resultsView->header()->setSortIndicator(EventsModel::DateColumn, Qt::DescendingOrder);
    connect(m_resultsView->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)),
            m_resultsView, SLOT(sortEvents(int,Qt::SortOrder)));

    return m_resultsView;
}
Exemplo n.º 4
0
void EventsModel::updateServer(DVRServer *server)
{
    if (!server && !(server = qobject_cast<DVRServer*>(sender())))
    {
        ServerRequestManager *srm = qobject_cast<ServerRequestManager*>(sender());
        if (srm)
            server = srm->server;
        else
            return;
    }

    if (!server->isOnline() || updatingServers.contains(server))
        return;

    updatingServers.insert(server);
    if (updatingServers.size() == 1)
        emit loadingStarted();

    EventsLoader *eventsLoader = new EventsLoader(server);
    eventsLoader->setLimit(serverEventsLimit);
    eventsLoader->setStartTime(m_filter.dateBegin);
    eventsLoader->setEndTime(m_filter.dateEnd);
    connect(eventsLoader, SIGNAL(eventsLoaded(bool,QList<EventData*>)), this, SLOT(eventsLoaded(bool,QList<EventData*>)));
    eventsLoader->loadEvents();
}
Exemplo n.º 5
0
void
PlayableProxyModel::setSourcePlayableModel( PlayableModel* sourceModel )
{
    if ( m_model )
    {
        disconnect( m_model, SIGNAL( loadingStarted() ), this, SIGNAL( loadingStarted() ) );
        disconnect( m_model, SIGNAL( loadingFinished() ), this, SIGNAL( loadingFinished() ) );
    }

    m_model = sourceModel;

    if ( m_model )
    {
        connect( m_model, SIGNAL( loadingStarted() ), SIGNAL( loadingStarted() ) );
        connect( m_model, SIGNAL( loadingFinished() ), SIGNAL( loadingFinished() ) );
    }

    QSortFilterProxyModel::setSourceModel( m_model );
}
Exemplo n.º 6
0
void EventsView::setModel(EventsModel *model)
{
    bool first = !this->model();
    QTreeView::setModel(model);

    if (first)
    {
        header()->setResizeMode(QHeaderView::Interactive);
        QFontMetrics fm(font());
        header()->resizeSection(EventsModel::LocationColumn, fm.width(QLatin1Char('X')) * 20);
        header()->resizeSection(EventsModel::DurationColumn,
                                fm.width(QLatin1String("99 minutes, 99 seconds")) + 25);
        header()->resizeSection(EventsModel::LevelColumn, fm.width(QLatin1String("Warning")) + 18);
    }

    connect(model, SIGNAL(loadingStarted()), SLOT(loadingStarted()));
    connect(model, SIGNAL(loadingFinished()), SLOT(loadingFinished()));
    connect(model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), SLOT(loadingFinished()));
    connect(model, SIGNAL(modelReset()), SLOT(loadingFinished()));

    if (model->isLoading())
        loadingStarted();
}
Exemplo n.º 7
0
OverlayWidget::OverlayWidget( QAbstractItemView* parent )
    : QWidget( parent ) // this is on purpose!
    , m_parent( parent )
    , m_itemView( parent )
{
    init();

    if ( m_itemView->model() )
    {
        connect( m_itemView->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( loadingStarted() ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( loadingFinished() ), SLOT( onViewChanged() ), Qt::UniqueConnection );
    }
Exemplo n.º 8
0
void
OverlayWidget::onViewModelChanged()
{
    if ( !m_itemView )
        return;

    if ( m_itemView->model() )
    {
        connect( m_itemView->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( loadingStarted() ), SLOT( onViewChanged() ), Qt::UniqueConnection );
        connect( m_itemView->model(), SIGNAL( loadingFinished() ), SLOT( onViewChanged() ), Qt::UniqueConnection );

        onViewChanged();
    }
Exemplo n.º 9
0
void AuthenticationMgr::doLogin(const QString &userName, const QString &passwd , bool isSave)
{
    LOG_METHOD;
    if(userName.isEmpty() || passwd.isEmpty())
    {
        emit loadingError("User info error");
        return;
    }

    mCatNameList.clear();
    mFinishedCatList.clear();
    mAllDataMap.clear();
    mCachedUrlList.clear();
    mCachedUrlInFile.clear();

    mCachedUrlInFile = readCachedUrl();

    mUserName = userName;

    //now only use file for recording use loginin infomation;
    QString qAppPath = QApplication::applicationDirPath();
    QString qXmlFileName = qAppPath + "/" + userName;

    if (QFile::exists(qXmlFileName))
    {
        qDebug()<<"user name exisiting";
        QFile::remove(qXmlFileName);
    }

    QString postStr = getLoginString(userName, passwd);

    mIsSaveUserInfo = isSave;

    QNetworkRequest req;

    QUrl url(GOOGLE_CLIENT_LOGIN_HTTP);
    req.setUrl(url);

    mReqType = EReqSID;

    emit loadingStarted();

    QNetworkReply *reply = mpNetAccessMgr->post(req,QByteArray(postStr.toAscii()));

    //the SSL Errors should be ignored;
    reply->ignoreSslErrors();

}
void EventsUpdater::updateServer(DVRServer *server)
{
    if (!server->isOnline() || m_updatingServers.contains(server))
        return;

    m_updatingServers.insert(server);
    if (m_updatingServers.size() == 1)
        emit loadingStarted();

    EventsLoader *eventsLoader = new EventsLoader(server);
    connect(eventsLoader, SIGNAL(eventsLoaded(DVRServer*,bool,QList<QSharedPointer<EventData> >)),
            this, SLOT(eventsLoaded(DVRServer*,bool,QList<QSharedPointer<EventData> >)));

    eventsLoader->setLimit(m_limit);
    eventsLoader->setStartTime(m_startTime);
    eventsLoader->setEndTime(m_endTime);
    eventsLoader->loadEvents();
}
Exemplo n.º 11
0
void Sonos::loadEmptyModels()
{
  QList<QPair<ListModel*, SONOS::LockGuard> > left;
  {
    SONOS::Locked<ManagedContents>::pointer mc = m_library.Get();
    for (ManagedContents::iterator it = mc->begin(); it != mc->end(); ++it)
      if (!it->model->m_loaded)
        left.push_back(qMakePair(it->model, SONOS::LockGuard(it->model->m_lock)));
  }
  emit loadingStarted();
  if (!left.empty())
  {
    while (!left.isEmpty())
    {
      QPair<ListModel*, SONOS::LockGuard> item = left.front();
      item.first->load();
      left.pop_front();
    }
  }
  emit loadingFinished();
}
Exemplo n.º 12
0
void Sonos::loadModel(ListModel* model)
{
  QPair<ListModel*, SONOS::LockGuard> item(0, SONOS::LockGuard());
  {
    SONOS::Locked<ManagedContents>::pointer mc = m_library.Get();
    for (ManagedContents::iterator it = mc->begin(); it != mc->end(); ++it)
      if (it->model == model)
      {
        item.first = it->model;
        item.second = SONOS::LockGuard(it->model->m_lock);
        break;
      }
  }
  if (item.first)
  {
    SONOS::DBG(DBG_INFO, "%s: %p (%s)\n", __FUNCTION__, item.first, item.first->m_root.toUtf8().constData());
    emit loadingStarted();
    item.first->m_pending = false; // accept add next request in queue
    item.first->load();
    emit loadingFinished();
  }
}
void MessageDefinitionLoader::threadStarted() {
  emit loadingStarted();
}