Merge pull request #2699 from pmzqla/copyurl-search

Add "Copy description page URL" button in search tab
This commit is contained in:
sledgehammer999 2015-08-04 18:45:31 +03:00
commit ea38e4da4d
3 changed files with 35 additions and 0 deletions

View File

@ -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">

View File

@ -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)
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)
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)
// 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)
download_button->setEnabled(false);
goToDescBtn->setEnabled(false);
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"));
}
}

View File

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