Replace indent to 4 spaces

This commit is contained in:
DoumanAsh 2015-04-11 14:26:25 +03:00 committed by sledgehammer999
parent 3873a36338
commit b286351305
3 changed files with 141 additions and 140 deletions

View file

@ -50,81 +50,81 @@ class QTimer;
QT_END_NAMESPACE
class SearchEngine : public QWidget, public Ui::search_engine{
Q_OBJECT
Q_DISABLE_COPY(SearchEngine)
Q_OBJECT
Q_DISABLE_COPY(SearchEngine)
private:
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
enum PluginColumn { PL_DL_LINK, PL_NAME, PL_SIZE, PL_SEEDS, PL_LEECHS, PL_ENGINE_URL, PL_DESC_LINK, NB_PLUGIN_COLUMNS };
public:
SearchEngine(MainWindow *mp_mainWindow);
~SearchEngine();
QString selectedCategory() const;
QString selectedEngine() const;
SearchEngine(MainWindow *mp_mainWindow);
~SearchEngine();
QString selectedCategory() const;
QString selectedEngine() const;
static qreal getPluginVersion(QString filePath) {
QFile plugin(filePath);
if (!plugin.exists()) {
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
return 0.0;
static qreal getPluginVersion(QString filePath) {
QFile plugin(filePath);
if (!plugin.exists()) {
qDebug("%s plugin does not exist, returning 0.0", qPrintable(filePath));
return 0.0;
}
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0.0;
}
qreal version = 0.0;
while (!plugin.atEnd()) {
QByteArray line = plugin.readLine();
if (line.startsWith("#VERSION: ")) {
line = line.split(' ').last().trimmed();
version = line.toFloat();
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
break;
}
}
return version;
}
if (!plugin.open(QIODevice::ReadOnly | QIODevice::Text)) {
return 0.0;
}
qreal version = 0.0;
while (!plugin.atEnd()) {
QByteArray line = plugin.readLine();
if (line.startsWith("#VERSION: ")) {
line = line.split(' ').last().trimmed();
version = line.toFloat();
qDebug("plugin %s version: %.2f", qPrintable(filePath), version);
break;
}
}
return version;
}
public slots:
void on_download_button_clicked();
void downloadTorrent(QString engine_url, QString torrent_url);
void giveFocusToSearchInput();
void on_download_button_clicked();
void downloadTorrent(QString engine_url, QString torrent_url);
void giveFocusToSearchInput();
protected slots:
// Search slots
void tab_changed(int);//to prevent the use of the download button when the tab is empty
void on_search_button_clicked();
void closeTab(int index);
void appendSearchResult(const QString &line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
void searchStarted();
void updateNova();
void selectMultipleBox(const QString &text);
void on_enginesButton_clicked();
void saveResultsColumnsWidth();
void downloadFinished(int exitcode, QProcess::ExitStatus);
void fillCatCombobox();
void fillEngineComboBox();
void searchTextEdited(QString);
// Search slots
void tab_changed(int);//to prevent the use of the download button when the tab is empty
void on_search_button_clicked();
void closeTab(int index);
void appendSearchResult(const QString &line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
void searchStarted();
void updateNova();
void selectMultipleBox(const QString &text);
void on_enginesButton_clicked();
void saveResultsColumnsWidth();
void downloadFinished(int exitcode, QProcess::ExitStatus);
void fillCatCombobox();
void fillEngineComboBox();
void searchTextEdited(QString);
private slots:
void on_goToDescBtn_clicked();
void on_goToDescBtn_clicked();
private:
// Search related
LineEdit* search_pattern;
QProcess *searchProcess;
QList<QProcess*> downloaders;
bool search_stopped;
bool no_search_results;
QByteArray search_result_line_truncated;
unsigned long nb_search_results;
SupportedEngines *supported_engines;
QTimer *searchTimeout;
QPointer<SearchTab> currentSearchTab;
QList<QPointer<SearchTab> > all_tab; // To store all tabs
const SearchCategories full_cat_names;
MainWindow *mp_mainWindow;
// Search related
LineEdit* search_pattern;
QProcess *searchProcess;
QList<QProcess*> downloaders;
bool search_stopped;
bool no_search_results;
QByteArray search_result_line_truncated;
unsigned long nb_search_results;
SupportedEngines *supported_engines;
QTimer *searchTimeout;
QPointer<SearchTab> currentSearchTab;
QList<QPointer<SearchTab> > all_tab; // To store all tabs
const SearchCategories full_cat_names;
MainWindow *mp_mainWindow;
};
#endif

View file

@ -42,101 +42,104 @@
SearchTab::SearchTab(SearchEngine *parent) : QWidget(), parent(parent)
{
box=new QVBoxLayout();
results_lbl=new QLabel();
resultsBrowser = new QTreeView();
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
box->addWidget(results_lbl);
box->addWidget(resultsBrowser);
box = new QVBoxLayout();
results_lbl = new QLabel();
resultsBrowser = new QTreeView();
resultsBrowser->setSelectionMode(QAbstractItemView::ExtendedSelection);
box->addWidget(results_lbl);
box->addWidget(resultsBrowser);
setLayout(box);
// Set Search results list model
SearchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS);
SearchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
SearchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
SearchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
SearchListModel->setHeaderData(SearchSortModel::LEECHS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
SearchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
setLayout(box);
// Set Search results list model
SearchListModel = new QStandardItemModel(0, SearchSortModel::NB_SEARCH_COLUMNS);
SearchListModel->setHeaderData(SearchSortModel::NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
SearchListModel->setHeaderData(SearchSortModel::SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
SearchListModel->setHeaderData(SearchSortModel::SEEDS, Qt::Horizontal, tr("Seeders", "i.e: Number of full sources"));
SearchListModel->setHeaderData(SearchSortModel::LEECHS, Qt::Horizontal, tr("Leechers", "i.e: Number of partial sources"));
SearchListModel->setHeaderData(SearchSortModel::ENGINE_URL, Qt::Horizontal, tr("Search engine"));
proxyModel = new SearchSortModel();
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(SearchListModel);
resultsBrowser->setModel(proxyModel);
proxyModel = new SearchSortModel();
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(SearchListModel);
resultsBrowser->setModel(proxyModel);
SearchDelegate = new SearchListDelegate();
resultsBrowser->setItemDelegate(SearchDelegate);
SearchDelegate = new SearchListDelegate();
resultsBrowser->setItemDelegate(SearchDelegate);
resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
resultsBrowser->hideColumn(SearchSortModel::DL_LINK); // Hide url column
resultsBrowser->hideColumn(SearchSortModel::DESC_LINK);
resultsBrowser->setRootIsDecorated(false);
resultsBrowser->setAllColumnsShowFocus(true);
resultsBrowser->setSortingEnabled(true);
resultsBrowser->setRootIsDecorated(false);
resultsBrowser->setAllColumnsShowFocus(true);
resultsBrowser->setSortingEnabled(true);
// Connect signals to slots (search part)
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
// Connect signals to slots (search part)
connect(resultsBrowser, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(downloadSelectedItem(const QModelIndex&)));
// Load last columns width for search results list
if (!loadColWidthResultsList()) {
resultsBrowser->header()->resizeSection(0, 275);
}
// Load last columns width for search results list
if (!loadColWidthResultsList()) {
resultsBrowser->header()->resizeSection(0, 275);
}
// Sort by Seeds
resultsBrowser->sortByColumn(SearchSortModel::SEEDS, Qt::DescendingOrder);
// Sort by Seeds
resultsBrowser->sortByColumn(SearchSortModel::SEEDS, Qt::DescendingOrder);
}
void SearchTab::downloadSelectedItem(const QModelIndex& index) {
QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::ENGINE_URL)).toString();
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
setRowColor(index.row(), "blue");
parent->downloadTorrent(engine_url, torrent_url);
QString engine_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::ENGINE_URL)).toString();
QString torrent_url = proxyModel->data(proxyModel->index(index.row(), SearchSortModel::DL_LINK)).toString();
setRowColor(index.row(), "blue");
parent->downloadTorrent(engine_url, torrent_url);
}
SearchTab::~SearchTab() {
delete box;
delete results_lbl;
delete resultsBrowser;
delete SearchListModel;
delete proxyModel;
delete SearchDelegate;
delete box;
delete results_lbl;
delete resultsBrowser;
delete SearchListModel;
delete proxyModel;
delete SearchDelegate;
}
QHeaderView* SearchTab::header() const {
return resultsBrowser->header();
return resultsBrowser->header();
}
bool SearchTab::loadColWidthResultsList() {
QString line = Preferences::instance()->getSearchColsWidth();
if (line.isEmpty())
return false;
QStringList width_list = line.split(' ');
if (width_list.size() > SearchListModel->columnCount())
return false;
unsigned int listSize = width_list.size();
for (unsigned int i=0; i<listSize; ++i) {
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
}
return true;
QString line = Preferences::instance()->getSearchColsWidth();
if (line.isEmpty())
return false;
QStringList width_list = line.split(' ');
if (width_list.size() > SearchListModel->columnCount())
return false;
unsigned int listSize = width_list.size();
for (unsigned int i=0; i<listSize; ++i) {
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
}
return true;
}
QLabel* SearchTab::getCurrentLabel()
{
return results_lbl;
return results_lbl;
}
QTreeView* SearchTab::getCurrentTreeView()
{
return resultsBrowser;
return resultsBrowser;
}
QSortFilterProxyModel* SearchTab::getCurrentSearchListProxy() const
{
return proxyModel;
return proxyModel;
}
QStandardItemModel* SearchTab::getCurrentSearchListModel() const
{
return SearchListModel;
return SearchListModel;
}
// Set the color of a row in data model

View file

@ -47,32 +47,30 @@ class QStandardItemModel;
QT_END_NAMESPACE
class SearchTab: public QWidget, public Ui::search_engine {
Q_OBJECT
Q_OBJECT
private:
QVBoxLayout *box;
QLabel *results_lbl;
QTreeView *resultsBrowser;
QStandardItemModel *SearchListModel;
SearchSortModel *proxyModel;
SearchListDelegate *SearchDelegate;
SearchEngine *parent;
QVBoxLayout *box;
QLabel *results_lbl;
QTreeView *resultsBrowser;
QStandardItemModel *SearchListModel;
SearchSortModel *proxyModel;
SearchListDelegate *SearchDelegate;
SearchEngine *parent;
protected slots:
void downloadSelectedItem(const QModelIndex& index);
void downloadSelectedItem(const QModelIndex& index);
public:
SearchTab(SearchEngine *parent);
~SearchTab();
bool loadColWidthResultsList();
QLabel * getCurrentLabel();
QStandardItemModel* getCurrentSearchListModel() const;
QSortFilterProxyModel* getCurrentSearchListProxy() const;
QTreeView * getCurrentTreeView();
void setRowColor(int row, QString color);
QHeaderView* header() const;
SearchTab(SearchEngine *parent);
~SearchTab();
bool loadColWidthResultsList();
QLabel * getCurrentLabel();
QStandardItemModel* getCurrentSearchListModel() const;
QSortFilterProxyModel* getCurrentSearchListProxy() const;
QTreeView * getCurrentTreeView();
void setRowColor(int row, QString color);
QHeaderView* header() const;
};
#endif