2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2018-2024 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
34 #include "base/settingvalue.h"
35 #include "gui/guiaddtorrentmanager.h"
36 #include "gui/guiapplicationcomponent.h"
38 #define ENGINE_URL_COLUMN 4
43 class QStandardItemModel
;
47 class SearchSortModel
;
50 template <typename T
> class SettingValue
;
54 class SearchJobWidget
;
57 class SearchJobWidget final
: public GUIApplicationComponent
<QWidget
>
60 Q_DISABLE_COPY_MOVE(SearchJobWidget
)
63 enum class NameFilteringMode
68 Q_ENUM(NameFilteringMode
)
79 SearchJobWidget(SearchHandler
*searchHandler
, IGUIApplication
*app
, QWidget
*parent
= nullptr);
80 ~SearchJobWidget() override
;
82 Status
status() const;
83 int visibleResultsCount() const;
84 LineEdit
*lineEditSearchResultsFilter() const;
89 void resultsCountUpdated();
93 void keyPressEvent(QKeyEvent
*event
) override
;
96 void displayColumnHeaderMenu();
100 void saveSettings() const;
102 void filterSearchResults(const QString
&name
);
103 void showFilterContextMenu();
104 void contextMenuEvent(QContextMenuEvent
*event
) override
;
105 void onItemDoubleClicked(const QModelIndex
&index
);
106 void searchFinished(bool cancelled
);
108 void appendSearchResults(const QList
<SearchResult
> &results
);
109 void updateResultsCount();
110 void setStatus(Status value
);
111 void downloadTorrent(const QModelIndex
&rowIndex
, AddTorrentOption option
= AddTorrentOption::Default
);
112 void addTorrentToSession(const QString
&source
, AddTorrentOption option
= AddTorrentOption::Default
);
113 void fillFilterComboBoxes();
114 NameFilteringMode
filteringMode() const;
115 QHeaderView
*header() const;
116 int visibleColumnsCount() const;
117 void setRowColor(int row
, const QColor
&color
);
118 void setRowVisited(int row
);
119 void onUIThemeChanged();
121 void downloadTorrents(AddTorrentOption option
= AddTorrentOption::Default
);
122 void openTorrentPages() const;
123 void copyTorrentURLs() const;
124 void copyTorrentDownloadLinks() const;
125 void copyTorrentNames() const;
126 void copyField(int column
) const;
128 static QString
statusText(Status st
);
130 Ui::SearchJobWidget
*m_ui
= nullptr;
131 SearchHandler
*m_searchHandler
= nullptr;
132 QStandardItemModel
*m_searchListModel
= nullptr;
133 SearchSortModel
*m_proxyModel
= nullptr;
134 LineEdit
*m_lineEditSearchResultsFilter
= nullptr;
135 Status m_status
= Status::Ongoing
;
136 bool m_noSearchResults
= true;
138 SettingValue
<NameFilteringMode
> m_nameFilteringMode
;
141 Q_DECLARE_METATYPE(SearchJobWidget::NameFilteringMode
)