Browse Source

Merge pull request #2699 from pmzqla/copyurl-search

Add "Copy description page URL" button in search tab
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
ea38e4da4d
  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 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<spacer> <spacer>
<property name="orientation"> <property name="orientation">

24
src/searchengine/searchengine.cpp

@ -42,6 +42,7 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices> #include <QDesktopServices>
#include <QClipboard>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <stdlib.h> #include <stdlib.h>
@ -74,6 +75,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
download_button->setIcon(GuiIconProvider::instance()->getIcon("download")); download_button->setIcon(GuiIconProvider::instance()->getIcon("download"));
goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl")); goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl"));
enginesButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network")); enginesButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy"));
tabWidget->setTabsClosable(true); tabWidget->setTabsClosable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
// Boolean initialization // Boolean initialization
@ -159,10 +161,12 @@ void SearchEngine::tab_changed(int t)
if (currentSearchTab->getCurrentSearchListModel()->rowCount()) { if (currentSearchTab->getCurrentSearchListModel()->rowCount()) {
download_button->setEnabled(true); download_button->setEnabled(true);
goToDescBtn->setEnabled(true); goToDescBtn->setEnabled(true);
copyURLBtn->setEnabled(true);
} }
else { else {
download_button->setEnabled(false); download_button->setEnabled(false);
goToDescBtn->setEnabled(false); goToDescBtn->setEnabled(false);
copyURLBtn->setEnabled(false);
} }
search_status->setText(currentSearchTab->status); search_status->setText(currentSearchTab->status);
} }
@ -529,6 +533,7 @@ void SearchEngine::appendSearchResult(const QString &line)
// Enable clear & download buttons // Enable clear & download buttons
download_button->setEnabled(true); download_button->setEnabled(true);
goToDescBtn->setEnabled(true); goToDescBtn->setEnabled(true);
copyURLBtn->setEnabled(true);
} }
void SearchEngine::closeTab(int index) void SearchEngine::closeTab(int index)
@ -554,6 +559,7 @@ void SearchEngine::closeTab(int index)
download_button->setEnabled(false); download_button->setEnabled(false);
goToDescBtn->setEnabled(false); goToDescBtn->setEnabled(false);
search_status->setText(tr("Stopped")); search_status->setText(tr("Stopped"));
copyURLBtn->setEnabled(false);
} }
} }
@ -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:
private slots: private slots:
void on_goToDescBtn_clicked(); void on_goToDescBtn_clicked();
void on_copyURLBtn_clicked();
private: private:
// Search related // Search related

Loading…
Cancel
Save