From e8148589f4a07960aab7f3473972d01f9fcc5ab4 Mon Sep 17 00:00:00 2001 From: Nikolay Tischenko Date: Mon, 4 Oct 2010 21:13:27 +0700 Subject: [PATCH] Fixed bug with focus on search line Extracted item renderer interface from track renderer --- someplayer.pro | 3 ++- src/abstractitemrenderer.h | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/libraryform.cpp | 1 + src/mainwindow.cpp | 2 +- src/trackrenderer.cpp | 10 +--------- src/trackrenderer.h | 19 ++++--------------- 6 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 src/abstractitemrenderer.h diff --git a/someplayer.pro b/someplayer.pro index 45c526d..c446198 100644 --- a/someplayer.pro +++ b/someplayer.pro @@ -218,7 +218,8 @@ HEADERS += src/mainwindow.h \ src/timerdialog.h \ src/equalizerdialog.h \ src/saveplaylistdialog.h \ - src/settingsdialog.h + src/settingsdialog.h \ + src/abstractitemrenderer.h FORMS += src/ui/mainwindow.ui \ src/ui/playerform.ui \ diff --git a/src/abstractitemrenderer.h b/src/abstractitemrenderer.h new file mode 100644 index 0000000..bc76582 --- /dev/null +++ b/src/abstractitemrenderer.h @@ -0,0 +1,45 @@ +/* + * SomePlayer - An alternate music player for Maemo 5 + * Copyright (C) 2010 Nikolay (somebody) Tischenko + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef ABSTRACTITEMRENDERER_H +#define ABSTRACTITEMRENDERER_H + +#include +#include + +class AbstractItemRenderer : public QAbstractItemDelegate +{ + Q_OBJECT +public: + explicit AbstractItemRenderer(QObject *parent = 0) : QAbstractItemDelegate(parent) {} + +signals: + +public slots: + void setActiveRow(int r) {_active_row = r;} + void setSearchRow(int r) {_search_row = r;} + int activeRow() {return _active_row;} + int searchRow() {return _search_row;} +protected: + int _active_row; + int _search_row; + +}; + +#endif // ABSTRACTITEMRENDERER_H diff --git a/src/libraryform.cpp b/src/libraryform.cpp index 2e30399..756baba 100644 --- a/src/libraryform.cpp +++ b/src/libraryform.cpp @@ -124,6 +124,7 @@ void LibraryForm::_dynamic_button() { _model->setItem(1, new QStandardItem("Most played")); _model->setItem(2, new QStandardItem("Never played")); _model->setItem(3, new QStandardItem("Recently added")); + ui->listLabel->setText("Dynamic playlists"); _state = STATE_DYNAMIC; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 549f238..8fe95e9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -189,12 +189,12 @@ void MainWindow::_toggle_search_line() { ui->searchLine->show(); ui->nextButton->show(); ui->prevButton->show(); + ui->searchLine->setFocus(Qt::MouseFocusReason); } } void MainWindow::showSearchPanel() { ui->searchButton->show(); - ui->searchLine->setFocus(); } void MainWindow::hideSearchPanel() { diff --git a/src/trackrenderer.cpp b/src/trackrenderer.cpp index f3c0b8e..739646b 100644 --- a/src/trackrenderer.cpp +++ b/src/trackrenderer.cpp @@ -24,7 +24,7 @@ #include TrackRenderer::TrackRenderer(QObject *parent) : - QAbstractItemDelegate(parent) + AbstractItemRenderer(parent) { } @@ -72,11 +72,3 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, QSize TrackRenderer::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const { return QSize(option.rect.width(), 80); } - -void TrackRenderer::setActiveRow(int r) { - _active_row = r; -} - -void TrackRenderer::setSearchRow(int r) { - _search_row = r; -} diff --git a/src/trackrenderer.h b/src/trackrenderer.h index 056a0ba..8f6797e 100644 --- a/src/trackrenderer.h +++ b/src/trackrenderer.h @@ -21,30 +21,19 @@ #define TRACKRENDERER_H #include +#include "abstractitemrenderer.h" #include -class TrackRenderer : public QAbstractItemDelegate +class TrackRenderer : public AbstractItemRenderer { - Q_OBJECT + Q_OBJECT public: - explicit TrackRenderer(QObject *parent = 0); + explicit TrackRenderer(QObject *parent = 0); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -signals: - -public slots: - void setActiveRow(int); - void setSearchRow(int); - int activeRow() {return _active_row;} - int searchRow() {return _search_row;} -private: - int _active_row; - int _search_row; - }; #endif // TRACKRENDERER_H -- 1.7.9.5