Browse Source

Add "Copy description page URL" button in search tab

Closes #2371.
adaptive-webui-19844
Gabriele 10 years ago
parent
commit
4d66a0929c
  1. 10
      src/searchengine/search.ui
  2. 24
      src/searchengine/searchengine.cpp
  3. 1
      src/searchengine/searchengine.h

10
src/searchengine/search.ui

@ -118,6 +118,16 @@ @@ -118,6 +118,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyURLBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Copy description page URL</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">

24
src/searchengine/searchengine.cpp

@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
#include <QSortFilterProxyModel>
#include <QFileDialog>
#include <QDesktopServices>
#include <QClipboard>
#ifdef Q_OS_WIN
#include <stdlib.h>
@ -74,6 +75,7 @@ SearchEngine::SearchEngine(MainWindow* parent) @@ -74,6 +75,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
download_button->setIcon(GuiIconProvider::instance()->getIcon("download"));
goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl"));
enginesButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy"));
tabWidget->setTabsClosable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
// Boolean initialization
@ -159,10 +161,12 @@ void SearchEngine::tab_changed(int t) @@ -159,10 +161,12 @@ void SearchEngine::tab_changed(int t)
if (currentSearchTab->getCurrentSearchListModel()->rowCount()) {
download_button->setEnabled(true);
goToDescBtn->setEnabled(true);
copyURLBtn->setEnabled(true);
}
else {
download_button->setEnabled(false);
goToDescBtn->setEnabled(false);
copyURLBtn->setEnabled(false);
}
search_status->setText(currentSearchTab->status);
}
@ -529,6 +533,7 @@ void SearchEngine::appendSearchResult(const QString &line) @@ -529,6 +533,7 @@ void SearchEngine::appendSearchResult(const QString &line)
// Enable clear & download buttons
download_button->setEnabled(true);
goToDescBtn->setEnabled(true);
copyURLBtn->setEnabled(true);
}
void SearchEngine::closeTab(int index)
@ -554,6 +559,7 @@ void SearchEngine::closeTab(int index) @@ -554,6 +559,7 @@ void SearchEngine::closeTab(int index)
download_button->setEnabled(false);
goToDescBtn->setEnabled(false);
search_status->setText(tr("Stopped"));
copyURLBtn->setEnabled(false);
}
}
@ -586,3 +592,21 @@ void SearchEngine::on_goToDescBtn_clicked() @@ -586,3 +592,21 @@ void SearchEngine::on_goToDescBtn_clicked()
}
}
}
void SearchEngine::on_copyURLBtn_clicked()
{
QStringList urls;
QModelIndexList selectedIndexes = all_tab.at(tabWidget->currentIndex())->getCurrentTreeView()->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes) {
if (index.column() == SearchSortModel::NAME) {
QSortFilterProxyModel* model = all_tab.at(tabWidget->currentIndex())->getCurrentSearchListProxy();
const QString descUrl = model->data(model->index(index.row(), SearchSortModel::DESC_LINK)).toString();
if (!descUrl.isEmpty())
urls << descUrl.toUtf8();
}
}
if (!urls.empty()) {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(urls.join("\n"));
}
}

1
src/searchengine/searchengine.h

@ -109,6 +109,7 @@ protected slots: @@ -109,6 +109,7 @@ protected slots:
private slots:
void on_goToDescBtn_clicked();
void on_copyURLBtn_clicked();
private:
// Search related

Loading…
Cancel
Save