From c15766559633cb76caa48df1359144991281b6ca Mon Sep 17 00:00:00 2001
From: angelaschmid <angela.schmid@wolke7.net>
Date: Sat, 31 May 2014 15:21:24 +0200
Subject: [PATCH] MythNetvision: Add page navigation.
Implemented page navigation previous/next and 10 pages previous/next.
---
mythplugins/mythnetvision/mythnetvision/main.cpp | 5 +++
.../mythnetvision/mythnetvision/netsearch.cpp | 44 +++++++++++++++++++---
.../mythnetvision/mythnetvision/netsearch.h | 2 +
3 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/mythplugins/mythnetvision/mythnetvision/main.cpp b/mythplugins/mythnetvision/mythnetvision/main.cpp
index 4960ef3..cd9fe9a 100644
a
|
b
|
static void setupKeys(void) |
78 | 78 | "Internet Television Client - Search"), "", runNetVision); |
79 | 79 | REG_JUMP("MythNetTree", QT_TRANSLATE_NOOP("MythControls", |
80 | 80 | "Internet Television Client - Site/Tree View"), "", runNetTree); |
| 81 | |
| 82 | REG_KEY("Internet Video", "PAGELEFT", QT_TRANSLATE_NOOP("MythControls", |
| 83 | "Previous Page"), ",,<"); |
| 84 | REG_KEY("Internet Video", "PAGERIGHT", QT_TRANSLATE_NOOP("MythControls", |
| 85 | "Next Page"), ">,."); |
81 | 86 | } |
82 | 87 | |
83 | 88 | int mythplugin_init(const char *libversion) |
diff --git a/mythplugins/mythnetvision/mythnetvision/netsearch.cpp b/mythplugins/mythnetvision/mythnetvision/netsearch.cpp
index 20a8c00..0452da6 100644
a
|
b
|
bool NetSearch::keyPressEvent(QKeyEvent *event) |
177 | 177 | if (action == "MENU") |
178 | 178 | { |
179 | 179 | showMenu(); |
| 180 | } else if (action == "PAGELEFT" && m_pagenum > 1) |
| 181 | { |
| 182 | skipPagesBack(); |
| 183 | } else if (action == "PAGERIGHT" && m_searchResultList->GetCount() > 0 && m_pagenum + 10 < m_maxpage) |
| 184 | { |
| 185 | skipPagesForward(); |
| 186 | } else if (action == "PREVVIEW" && m_pagenum > 1) |
| 187 | { |
| 188 | getLastResults(); |
| 189 | } else if (action == "NEXTVIEW" && m_searchResultList->GetCount() > 0 && m_pagenum < m_maxpage) |
| 190 | { |
| 191 | getMoreResults(); |
180 | 192 | } |
181 | 193 | else |
182 | 194 | handled = false; |
… |
… |
void NetSearch::showMenu(void) |
258 | 270 | menuPopup->AddButton(tr("Delete"), SLOT(slotDeleteVideo())); |
259 | 271 | } |
260 | 272 | } |
261 | | |
262 | | if (m_pagenum > 1) |
263 | | menuPopup->AddButton(tr("Previous Page"), SLOT(getLastResults())); |
264 | | if (m_searchResultList->GetCount() > 0 && m_pagenum < m_maxpage) |
265 | | menuPopup->AddButton(tr("Next Page"), SLOT(getMoreResults())); |
266 | 273 | } |
267 | | menuPopup->AddButton(tr("Manage Search Scripts"), SLOT(runSearchEditor())); |
268 | 274 | |
| 275 | if (m_pagenum > 1) |
| 276 | menuPopup->AddButton(tr("Previous Page"), SLOT(getLastResults())); |
| 277 | if (m_searchResultList->GetCount() > 0 && m_pagenum < m_maxpage) |
| 278 | menuPopup->AddButton(tr("Next Page"), SLOT(getMoreResults())); |
| 279 | if (m_pagenum > 1) |
| 280 | menuPopup->AddButton(tr("Skip 10 Pages back"), SLOT(skipPagesBack())); |
| 281 | if (m_searchResultList->GetCount() > 0 && m_pagenum < m_maxpage) |
| 282 | menuPopup->AddButton(tr("Skip 10 Pages forward"), SLOT(skipPagesForward())); |
| 283 | |
| 284 | menuPopup->AddButton(tr("Manage Search Scripts"), SLOT(runSearchEditor())); |
269 | 285 | } |
270 | 286 | else |
271 | 287 | { |
… |
… |
void NetSearch::getMoreResults() |
386 | 402 | m_reply = m_netSearch->get(QNetworkRequest(req)); |
387 | 403 | } |
388 | 404 | |
| 405 | void NetSearch::skipPagesBack() |
| 406 | { |
| 407 | if (m_pagenum < 11) |
| 408 | m_pagenum = 2; |
| 409 | else |
| 410 | m_pagenum = m_pagenum - 10 + 1; |
| 411 | |
| 412 | getLastResults(); |
| 413 | } |
| 414 | |
| 415 | void NetSearch::skipPagesForward() |
| 416 | { |
| 417 | m_pagenum = m_pagenum + 10 - 1; |
| 418 | getMoreResults(); |
| 419 | } |
| 420 | |
389 | 421 | void NetSearch::searchFinished(void) |
390 | 422 | { |
391 | 423 | if (m_busyPopup) |
diff --git a/mythplugins/mythnetvision/mythnetvision/netsearch.h b/mythplugins/mythnetvision/mythnetvision/netsearch.h
index 140bce0..246cd80 100644
a
|
b
|
class NetSearch : public MythScreenType |
91 | 91 | void showMenu(void); |
92 | 92 | void getMoreResults(); |
93 | 93 | void getLastResults(); |
| 94 | void skipPagesBack(); |
| 95 | void skipPagesForward(); |
94 | 96 | void runSearchEditor(); |
95 | 97 | void doListRefresh(); |
96 | 98 | |