int main(int argc, char *argv[]) { int i, *a; historyItem *h; setHistoryLimit(15); for (i=0;i < 6; i++) { a = (int *)malloc(sizeof(int)); *a = i; h = newHistoryItem(a); addHistoryItem(h); } /* Start at the beginning */ setHistoryIndex(numHistoryItems()); while ((h = nextHistoryItem(0)) != NULL) { printf("h[%d]->a is %d\n", getHistoryIndex(), *(int *)h->data); } printf("Doing the reverse now...\n"); setHistoryIndex(3); for (i=0;i<6;i++) { h = prevHistoryItem(1); if (h) printf("h[%d]->a is %d\n", getHistoryIndex(), *(int *)h->data); } return 0; }
void MediaView::goForward() { if (canGoForward()) { int currentIndex = getHistoryIndex(); VideoSource *nextVideoSource = history.at(currentIndex + 1); setVideoSource(nextVideoSource, false); } }
/* Wrap determines whether or not we loop back to index 0 or not */ historyItem *nextHistoryItem(short wrap) { short index; if (nitems == 0) return NULL; index = getHistoryIndex(); setHistoryIndex(++index); index = getHistoryIndex(); /* We're at the last element and we don't want to wrap forward */ if (index == nitems && wrap == 0) return NULL; return history[index]; }
void MediaView::goBack() { if (history.size() > 1) { int currentIndex = getHistoryIndex(); if (currentIndex > 0) { VideoSource *previousVideoSource = history.at(currentIndex - 1); setVideoSource(previousVideoSource, false, true); } } }
historyItem *prevHistoryItem(short wrap) { short index; if (nitems == 0) return NULL; index = getHistoryIndex(); /* We're at the first element and we don't want to wrap backwards */ if (index == 0 && wrap == 0) return NULL; setHistoryIndex(--index); index = getHistoryIndex(); return history[index]; }
void MediaView::setVideoSource(VideoSource *videoSource, bool addToHistory, bool back) { Q_UNUSED(back); stopped = false; errorTimer->stop(); // qDebug() << "Adding VideoSource" << videoSource->getName() << videoSource; if (addToHistory) { int currentIndex = getHistoryIndex(); if (currentIndex >= 0 && currentIndex < history.size() - 1) { while (history.size() > currentIndex + 1) { VideoSource *vs = history.takeLast(); if (!vs->parent()) { qDebug() << "Deleting VideoSource" << vs->getName() << vs; vs->deleteLater(); } } } history.append(videoSource); } #ifdef APP_EXTRA if (history.size() > 1) Extra::slideTransition(playlistView->viewport(), playlistView->viewport(), back); #endif playlistModel->setVideoSource(videoSource); if (media->state() == Media::StoppedState) { QSettings settings; if (settings.value("manualplay", false).toBool()) { videoAreaWidget->showPickMessage(); } } sidebar->showPlaylist(); sidebar->getRefineSearchWidget()->setSearchParams(getSearchParams()); sidebar->hideSuggestions(); sidebar->getHeader()->updateInfo(); SearchParams *searchParams = getSearchParams(); bool isChannel = searchParams && !searchParams->channelId().isEmpty(); playlistView->setClickableAuthors(!isChannel); }
bool MediaView::canGoForward() { int currentIndex = getHistoryIndex(); return currentIndex >= 0 && currentIndex < history.size() - 1; }
bool MediaView::canGoBack() { return getHistoryIndex() > 0; }