Fixed bug with focus on search line
authorNikolay Tischenko <niktischenko@gmail.com>
Mon, 4 Oct 2010 14:13:27 +0000 (21:13 +0700)
committerNikolay Tischenko <niktischenko@gmail.com>
Mon, 4 Oct 2010 14:13:27 +0000 (21:13 +0700)
Extracted item renderer interface from track renderer

someplayer.pro
src/abstractitemrenderer.h [new file with mode: 0644]
src/libraryform.cpp
src/mainwindow.cpp
src/trackrenderer.cpp
src/trackrenderer.h

index 45c526d..c446198 100644 (file)
@@ -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 (file)
index 0000000..bc76582
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SomePlayer - An alternate music player for Maemo 5
+ * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
+ *
+ * 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 <QAbstractItemDelegate>
+#include <QPainter>
+
+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
index 2e30399..756baba 100644 (file)
@@ -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;
 }
 
index 549f238..8fe95e9 100644 (file)
@@ -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() {
index f3c0b8e..739646b 100644 (file)
@@ -24,7 +24,7 @@
 #include <QColor>
 
 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;
-}
index 056a0ba..8f6797e 100644 (file)
 #define TRACKRENDERER_H
 
 #include <QAbstractItemDelegate>
+#include "abstractitemrenderer.h"
 #include <QPainter>
 
-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