]> git.sesse.net Git - kdenlive/commitdiff
Fix online resources page browsing
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 30 Dec 2011 01:12:16 +0000 (02:12 +0100)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Fri, 30 Dec 2011 01:12:16 +0000 (02:12 +0100)
src/utils/freesound.cpp
src/utils/freesound.h
src/widgets/freesound_ui.ui

index 1ac1b2a7fde1c5cbe749d5deff8b31bcb2bb2d60..9a81e9e08559e9436938d2f23735cd7e8f3d2645 100644 (file)
@@ -78,6 +78,9 @@ FreeSound::FreeSound(const QString & folder, QWidget * parent) :
     }
     connect(Solid::Networking::notifier(), SIGNAL(shouldConnect()), this, SLOT(slotOnline()));
     connect(Solid::Networking::notifier(), SIGNAL(shouldDisconnect()), this, SLOT(slotOffline()));
+    connect(page_next, SIGNAL(clicked()), this, SLOT(slotNextPage()));
+    connect(page_prev, SIGNAL(clicked()), this, SLOT(slotPreviousPage()));
+    connect(page_number, SIGNAL(valueChanged(int)), this, SLOT(slotStartSearch(int)));
 }
 
 FreeSound::~FreeSound()
@@ -85,24 +88,25 @@ FreeSound::~FreeSound()
     if (m_previewProcess) delete m_previewProcess;
 }
 
-void FreeSound::slotStartSearch()
+void FreeSound::slotStartSearch(int page)
 {
     m_result.clear();
     m_currentPreview.clear();
     m_currentUrl.clear();
     page_number->blockSignals(true);
-    page_number->setValue(0);
+    page_number->setValue(page);
     page_number->blockSignals(false);
     QString uri;
     if (m_service == FREESOUND) {
         uri = "http://www.freesound.org/api/sounds/search/?q=";
         uri.append(search_text->text());
+        if (page > 1) uri.append("&p=" + QString::number(page));
         uri.append("&api_key=a1772c8236e945a4bee30a64058dabf8");
     }
     else if (m_service == OPENCLIPART) {
         uri = "http://openclipart.org/api/search/?query=";
         uri.append(search_text->text());
-        //water&page=4
+        if (page > 1) uri.append("&page=" + QString::number(page));
     }
     KIO::TransferJob *job = KIO::get(KUrl(uri));
     connect (job, SIGNAL(  data(KIO::Job *, const QByteArray & )), this, SLOT(slotDataIsHere(KIO::Job *,const QByteArray &)));
@@ -301,3 +305,15 @@ void FreeSound::slotOffline()
     search_info->setText(i18n("You need to be online\n for searching"));
 }
 
+void FreeSound::slotNextPage()
+{
+    int ix = page_number->value();
+    if (search_results->count() > 0) page_number->setValue(ix + 1);
+}
+
+void FreeSound::slotPreviousPage()
+{
+    int ix = page_number->value();
+    if (ix > 1) page_number->setValue(ix - 1);
+}
+
index 297dfcccddb0ad166677ce56792a1c8912c609ab..940220e10078f64a30409651f6900240e4e8ee8b 100644 (file)
@@ -41,7 +41,7 @@ public:
 
 
 private slots:
-    void slotStartSearch();
+    void slotStartSearch(int page = 0);
     void slotDataIsHere(KIO::Job *,const QByteArray & data );
     void slotShowResults();
     void slotUpdateCurrentSound();
@@ -52,6 +52,8 @@ private slots:
     void slotChangeService();
     void slotOnline();
     void slotOffline();
+    void slotNextPage();
+    void slotPreviousPage();
 
 private:
     QString m_folder;
index 82cd7267ba5c9fa2673634a8513e1d55483272d1..5c62926a35acf6b05ff481d4a2f3087f74f63426 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>250</width>
-    <height>227</height>
+    <width>360</width>
+    <height>229</height>
    </rect>
   </property>
   <property name="windowTitle">
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
+     <property name="prefix">
+      <string>page </string>
+     </property>
+     <property name="minimum">
+      <number>1</number>
+     </property>
     </widget>
    </item>
    <item row="3" column="3">
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="4">
-    <widget class="QLabel" name="search_info">
-     <property name="text">
-      <string/>
-     </property>
-    </widget>
-   </item>
-   <item row="4" column="4">
-    <widget class="QDialogButtonBox" name="ButtonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Close</set>
-     </property>
-    </widget>
+   <item row="4" column="0" colspan="5">
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <widget class="QLabel" name="search_info">
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="ButtonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Close</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>