]> git.sur5r.net Git - minitube/commitdiff
Views refactoring, don't use RTTI
authorFlavio Tordini <flavio.tordini@gmail.com>
Tue, 25 Aug 2015 09:42:05 +0000 (11:42 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Tue, 25 Aug 2015 09:42:05 +0000 (11:42 +0200)
27 files changed:
src/aboutview.cpp
src/aboutview.h
src/channellistview.cpp [new file with mode: 0644]
src/channellistview.h [new file with mode: 0644]
src/channelview.cpp
src/channelview.h
src/downloadlistview.cpp
src/downloadview.cpp
src/downloadview.h
src/homeview.cpp
src/homeview.h
src/mainwindow.cpp
src/mediaview.cpp
src/mediaview.h
src/playlistmodel.cpp
src/playlistview.cpp
src/regionsview.cpp
src/regionsview.h
src/searchlineedit.h
src/searchview.cpp
src/searchview.h
src/searchwidget.h
src/standardfeedsview.cpp
src/standardfeedsview.h
src/videoareawidget.cpp
src/videomimedata.h
src/view.h

index 69e227f3be9be58965bea8d4ec7363b1744d8f2a..8548e86b968efd053c58b63f023e65238233c5fc 100644 (file)
@@ -32,7 +32,7 @@ $END_LICENSE */
 #endif
 #include "fontutils.h"
 
-AboutView::AboutView(QWidget *parent) : QWidget(parent) {
+AboutView::AboutView(QWidget *parent) : View(parent) {
 
     QBoxLayout *hLayout = new QHBoxLayout(this);
     hLayout->setAlignment(Qt::AlignCenter);
index a8e7572c668f6e8e9070e9c0c8c0abd04c0e177c..0e5e66989c7a70141eacc25b2408e277db3a5d36 100644 (file)
@@ -28,7 +28,7 @@ $END_LICENSE */
 #include "view.h"
 #include "constants.h"
 
-class AboutView : public QWidget, public View {
+class AboutView : public View {
 
     Q_OBJECT
 
diff --git a/src/channellistview.cpp b/src/channellistview.cpp
new file mode 100644 (file)
index 0000000..df6fe16
--- /dev/null
@@ -0,0 +1,76 @@
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube 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 3 of the License, or
+(at your option) any later version.
+
+Minitube 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 Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
+#include "channellistview.h"
+#include "painterutils.h"
+
+ChannelListView::ChannelListView() {
+
+    setSelectionMode(QAbstractItemView::NoSelection);
+
+    // layout
+    setSpacing(15);
+    setFlow(QListView::LeftToRight);
+    setWrapping(true);
+    setResizeMode(QListView::Adjust);
+    setMovement(QListView::Static);
+    setUniformItemSizes(true);
+
+    // cosmetics
+    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+    setFrameShape(QFrame::NoFrame);
+    setAttribute(Qt::WA_MacShowFocusRect, false);
+
+    QPalette p = palette();
+    /*
+    p.setColor(QPalette::Base, p.window().color());
+    p.setColor(QPalette::Text, p.windowText().color());
+    */
+    p.setColor(QPalette::Disabled, QPalette::Base, p.base().color());
+    p.setColor(QPalette::Disabled, QPalette::Text, p.text().color());
+    setPalette(p);
+
+    verticalScrollBar()->setPageStep(3);
+    verticalScrollBar()->setSingleStep(1);
+
+    setMouseTracking(true);
+
+}
+
+void ChannelListView::mousePressEvent(QMouseEvent *event) {
+    if (event->button() == Qt::RightButton)
+        emit contextMenu(event->pos());
+    else
+        QListView::mousePressEvent(event);
+}
+
+void ChannelListView::mouseMoveEvent(QMouseEvent *event) {
+    QWidget::mouseMoveEvent(event);
+    const QModelIndex index = indexAt(event->pos());
+    if (index.isValid()) setCursor(Qt::PointingHandCursor);
+    else unsetCursor();
+}
+
+void ChannelListView::paintEvent(QPaintEvent *event) {
+    if (!errorMessage.isEmpty())
+        PainterUtils::centeredMessage(errorMessage, viewport());
+    else
+        QListView::paintEvent(event);
+}
diff --git a/src/channellistview.h b/src/channellistview.h
new file mode 100644 (file)
index 0000000..04863a8
--- /dev/null
@@ -0,0 +1,51 @@
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube 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 3 of the License, or
+(at your option) any later version.
+
+Minitube 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 Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
+#ifndef CHANNELLISTVIEW_H
+#define CHANNELLISTVIEW_H
+
+#include <QtGui>
+#if QT_VERSION >= 0x050000
+#include <QtWidgets>
+#endif
+
+class ChannelListView : public QListView {
+
+    Q_OBJECT
+
+public:
+    ChannelListView();
+    void setErrorMessage(const QString &value) { errorMessage = value; }
+    void clearErrorMessage() { errorMessage.clear(); }
+
+signals:
+    void contextMenu(QPoint point);
+
+protected:
+    void mousePressEvent(QMouseEvent *event);
+    void mouseMoveEvent(QMouseEvent *event);
+    void paintEvent(QPaintEvent *event);
+
+private:
+    QString errorMessage;
+
+};
+
+#endif // CHANNELLISTVIEW_H
index 414846a3f74b0ca692b136aad2fbc8b91c351177..6203dbeaea73213eed1dff8edbf3c900152170ab 100644 (file)
@@ -28,59 +28,35 @@ $END_LICENSE */
 #include "ytsearch.h"
 #include "channelaggregator.h"
 #include "aggregatevideosource.h"
-#include "painterutils.h"
 #include "mainwindow.h"
 #include "iconutils.h"
 #ifdef APP_EXTRA
 #include "extra.h"
 #endif
+#include "channellistview.h"
 
 static const char *sortByKey = "subscriptionsSortBy";
 static const char *showUpdatedKey = "subscriptionsShowUpdated";
 
-ChannelView::ChannelView(QWidget *parent) : QListView(parent),
+ChannelView::ChannelView(QWidget *parent) : View(parent),
     showUpdated(false),
     sortBy(SortByName) {
 
-    setItemDelegate(new ChannelItemDelegate(this));
-    setSelectionMode(QAbstractItemView::NoSelection);
+    QBoxLayout *layout = new QVBoxLayout(this);
+    layout->setMargin(0);
+    layout->setSpacing(0);
 
-    // layout
-    setSpacing(15);
-    setFlow(QListView::LeftToRight);
-    setWrapping(true);
-    setResizeMode(QListView::Adjust);
-    setMovement(QListView::Static);
-    setUniformItemSizes(true);
+    listView = new ChannelListView();
+    listView->setItemDelegate(new ChannelItemDelegate(this));
 
-    // cosmetics
-    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
-    setFrameShape(QFrame::NoFrame);
-    setAttribute(Qt::WA_MacShowFocusRect, false);
-
-    QPalette p = palette();
-    /*
-    p.setColor(QPalette::Base, p.window().color());
-    p.setColor(QPalette::Text, p.windowText().color());
-    */
-    p.setColor(QPalette::Disabled, QPalette::Base, p.base().color());
-    p.setColor(QPalette::Disabled, QPalette::Text, p.text().color());
-    setPalette(p);
-
-    verticalScrollBar()->setPageStep(3);
-    verticalScrollBar()->setSingleStep(1);
-
-    setMouseTracking(true);
+    channelsModel = new ChannelModel(this);
+    listView->setModel(channelsModel);
 
-    connect(this, SIGNAL(clicked(const QModelIndex &)),
-            SLOT(itemActivated(const QModelIndex &)));
-    connect(this, SIGNAL(entered(const QModelIndex &)),
-            SLOT(itemEntered(const QModelIndex &)));
+    connect(listView, SIGNAL(clicked(const QModelIndex &)), SLOT(itemActivated(const QModelIndex &)));
+    connect(listView, SIGNAL(contextMenu(QPoint)), SLOT(showContextMenu(QPoint)));
+    connect(listView, SIGNAL(viewportEntered()), channelsModel, SLOT(clearHover()));
 
-    channelsModel = new ChannelModel(this);
-    setModel(channelsModel);
-    connect(this, SIGNAL(viewportEntered()),
-            channelsModel, SLOT(clearHover()));
+    layout->addWidget(listView);
 
     setupActions();
 
@@ -182,29 +158,6 @@ void ChannelView::disappear() {
         MainWindow::instance()->showActionInStatusBar(action, false);
 }
 
-void ChannelView::mousePressEvent(QMouseEvent *event) {
-    if (event->button() == Qt::RightButton)
-        showContextMenu(event->pos());
-    else
-        QListView::mousePressEvent(event);
-}
-
-void ChannelView::mouseMoveEvent(QMouseEvent *event) {
-    QListView::mouseMoveEvent(event);
-    const QModelIndex index = indexAt(event->pos());
-    if (index.isValid()) setCursor(Qt::PointingHandCursor);
-    else unsetCursor();
-}
-
-void ChannelView::leaveEvent(QEvent *event) {
-    QListView::leaveEvent(event);
-    // channelsModel->clearHover();
-}
-
-void ChannelView::itemEntered(const QModelIndex &) {
-    // channelsModel->setHoveredRow(index.row());
-}
-
 void ChannelView::itemActivated(const QModelIndex &index) {
     ChannelModel::ItemTypes itemType = channelsModel->typeForIndex(index);
     if (itemType == ChannelModel::ItemChannel) {
@@ -230,7 +183,7 @@ void ChannelView::itemActivated(const QModelIndex &index) {
 }
 
 void ChannelView::showContextMenu(const QPoint &point) {
-    const QModelIndex index = indexAt(point);
+    const QModelIndex index = listView->indexAt(point);
     if (!index.isValid()) return;
 
     YTChannel *channel = channelsModel->channelForIndex(index);
@@ -261,21 +214,6 @@ void ChannelView::showContextMenu(const QPoint &point) {
     menu.exec(mapToGlobal(point));
 }
 
-void ChannelView::paintEvent(QPaintEvent *event) {
-    if (model()->rowCount() < 3) {
-        QString msg;
-        if (!errorMessage.isEmpty())
-            msg = errorMessage;
-        else if (showUpdated)
-            msg = tr("There are no updated subscriptions at this time.");
-        else
-            msg = tr("You have no subscriptions. "
-                     "Use the star symbol to subscribe to channels.");
-        PainterUtils::centeredMessage(msg, viewport());
-    } else QListView::paintEvent(event);
-    // PainterUtils::topShadow(viewport());
-}
-
 void ChannelView::toggleShowUpdated(bool enable) {
     showUpdated = enable;
     updateQuery(true);
@@ -285,7 +223,7 @@ void ChannelView::toggleShowUpdated(bool enable) {
 
 void ChannelView::updateQuery(bool transition) {
     Q_UNUSED(transition);
-    errorMessage.clear();
+    listView->clearErrorMessage();
     if (!Database::exists()) return;
 
     QString sql = "select user_id from subscriptions";
@@ -318,7 +256,15 @@ void ChannelView::updateQuery(bool transition) {
     channelsModel->setQuery(sql, Database::instance().getConnection());
     if (channelsModel->lastError().isValid()) {
         qWarning() << channelsModel->lastError().text();
-        errorMessage = channelsModel->lastError().text();
+        listView->setErrorMessage(channelsModel->lastError().text());
+    } else if (channelsModel->rowCount() < 3) {
+        QString msg;
+        if (showUpdated)
+            msg = tr("There are no updated subscriptions at this time.");
+        else
+            msg = tr("You have no subscriptions. "
+                     "Use the star symbol to subscribe to channels.");
+        listView->setErrorMessage(msg);
     }
 }
 
index a108a4c4b81865e9edf3ce9af662b548f3ea9c3e..41fcf7a3f1208cba8935e245c4c71695a19533b7 100644 (file)
@@ -29,8 +29,9 @@ $END_LICENSE */
 
 class VideoSource;
 class ChannelModel;
+class ChannelListView;
 
-class ChannelView : public QListView, public View {
+class ChannelView : public View {
 
     Q_OBJECT
 
@@ -44,12 +45,6 @@ public slots:
     void appear();
     void disappear();
 
-protected:
-    void mousePressEvent(QMouseEvent *event);
-    void mouseMoveEvent(QMouseEvent *event);
-    void leaveEvent(QEvent *event);
-    void paintEvent(QPaintEvent *event);
-
 private:
     enum SortBy {
         SortByName = 0,
@@ -60,7 +55,6 @@ private:
     };
 
 private slots:
-    void itemEntered(const QModelIndex &index);
     void itemActivated(const QModelIndex &index);
     void showContextMenu(const QPoint &point);
     void toggleShowUpdated(bool enable);
@@ -77,11 +71,11 @@ private slots:
 private:
     void setupActions();
 
+    ChannelListView *listView;
     ChannelModel *channelsModel;
     QList<QAction*> statusActions;
     bool showUpdated;
     SortBy sortBy;
-    QString errorMessage;
     QAction *markAsWatchedAction;
 
 };
index 58c31a4dc4c7bbb241d108a2fdd8c1ed6bb1c5d8..927566162dc8b929d8e16eac86a970306acc84ac 100644 (file)
@@ -28,7 +28,7 @@ DownloadListView::DownloadListView(QWidget *parent) : QListView(parent) {
 }
 
 void DownloadListView::leaveEvent(QEvent * /* event */) {
-    DownloadModel *downloadModel = dynamic_cast<DownloadModel *>(model());
+    DownloadModel *downloadModel = qobject_cast<DownloadModel *>(model());
     if (downloadModel) downloadModel->clearHover();
 }
 
@@ -69,7 +69,7 @@ bool DownloadListView::isHoveringPlayIcon(QMouseEvent *event) {
     const QRect itemRect = visualRect(itemIndex);
     // qDebug() << " itemRect.x()" <<  itemRect.x();
 
-    PlaylistItemDelegate *delegate = dynamic_cast<PlaylistItemDelegate *>(itemDelegate());
+    PlaylistItemDelegate *delegate = qobject_cast<PlaylistItemDelegate *>(itemDelegate());
     if (!delegate) return false;
 
     QRect buttonRect = delegate->downloadButtonRect(itemRect);
index 2ad4763fe05870fddd7e4b7547c4dc33f1b8f307..6d0c75cadaa70be9cfce5eed857539605374f044 100644 (file)
@@ -28,7 +28,7 @@ $END_LICENSE */
 #include "playlistitemdelegate.h"
 #include "segmentedcontrol.h"
 
-DownloadView::DownloadView(QWidget *parent) : QWidget(parent) {
+DownloadView::DownloadView(QWidget *parent) : View(parent) {
 
     QBoxLayout *layout = new QVBoxLayout(this);
     layout->setMargin(0);
index dccbf9c95a2705e2fa1055e837d39a0eb9becf68..6b30286be054d5f98c043313e6b20a56f9ee89de 100644 (file)
@@ -32,7 +32,7 @@ class DownloadModel;
 class DownloadListView;
 class DownloadSettings;
 
-class DownloadView : public QWidget, public View {
+class DownloadView : public View {
 
     Q_OBJECT
 
index 1d56c26553dd6d3d802895ccc313f36b16e858e7..c64f89181e0314415b8297a2086da19335d8f45b 100644 (file)
@@ -32,7 +32,7 @@ $END_LICENSE */
 #include "macutils.h"
 #endif
 
-HomeView::HomeView(QWidget *parent) : QWidget(parent),
+HomeView::HomeView(QWidget *parent) : View(parent),
     standardFeedsView(0),
     channelsView(0) {
 
index c65a60d34119754e663ffd6768fdc9a47eba9b9c..fb412f4993456eb4e2b54e9571834c4565aa9eb3 100644 (file)
@@ -32,7 +32,7 @@ class SearchView;
 class StandardFeedsView;
 class ChannelView;
 
-class HomeView : public QWidget, public View  {
+class HomeView : public View  {
 
     Q_OBJECT
 
index cecefd4e0af6fcd0a1c0e4edece612ed6573755f..a77ac272e2a470fc95249bf544350a38dadcb4bc 100644 (file)
@@ -225,7 +225,7 @@ void MainWindow::lazyInit() {
 
     // Hack to give focus to searchlineedit
     QMetaObject::invokeMethod(views->currentWidget(), "appear");
-    View* view = dynamic_cast<View *> (views->currentWidget());
+    View* view = qobject_cast<View *> (views->currentWidget());
     QString desc = view->metadata().value("description").toString();
     if (!desc.isEmpty()) showMessage(desc);
 
@@ -954,7 +954,7 @@ void MainWindow::showWidget(QWidget* widget, bool transition) {
         compactViewAct->toggle();
 
     // call hide method on the current view
-    View* oldView = dynamic_cast<View *> (views->currentWidget());
+    View* oldView = qobject_cast<View *> (views->currentWidget());
     if (oldView) {
         oldView->disappear();
         views->currentWidget()->setEnabled(false);
@@ -977,7 +977,7 @@ void MainWindow::showWidget(QWidget* widget, bool transition) {
     widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
     // call show method on the new view
-    View* newView = dynamic_cast<View *> (widget);
+    View* newView = qobject_cast<View *> (widget);
     if (newView) {
         widget->setEnabled(true);
         QHash<QString,QVariant> metadata = newView->metadata();
index 332753416f6984fafe20799359e1ae936635676d..7100009b106e957c4f508d61fbb3dd81efa73cce 100644 (file)
@@ -64,7 +64,7 @@ MediaView* MediaView::instance() {
     return i;
 }
 
-MediaView::MediaView(QWidget *parent) : QWidget(parent)
+MediaView::MediaView(QWidget *parent) : View(parent)
   , stopped(false)
   , downloadItem(0)
   #ifdef APP_SNAPSHOT
@@ -190,7 +190,7 @@ void MediaView::setMediaObject(Phonon::MediaObject *mediaObject) {
 SearchParams* MediaView::getSearchParams() {
     VideoSource *videoSource = playlistModel->getVideoSource();
     if (videoSource && videoSource->metaObject()->className() == QLatin1String("YTSearch")) {
-        YTSearch *search = dynamic_cast<YTSearch *>(videoSource);
+        YTSearch *search = qobject_cast<YTSearch *>(videoSource);
         return search->getSearchParams();
     }
     return 0;
index 468d32ef72ab90950adc25119f91d4a2abf161b7..54024987cab435c981916bb18a0cc50240c8b039 100644 (file)
@@ -50,7 +50,7 @@ namespace The {
 QHash<QString, QAction*>* globalActions();
 }
 
-class MediaView : public QWidget, public View {
+class MediaView : public View {
 
     Q_OBJECT
 
index 389f6762a133a07fcf117a487c279427d22adb46..7fa95ccfd1ccfe4d9aa6b953a61ce3ecb5eb952c 100644 (file)
@@ -270,7 +270,7 @@ void PlaylistModel::handleFirstVideo(Video *video) {
 
         static const int maxRecentElements = 10;
 
-        YTSearch *search = dynamic_cast<YTSearch *>(videoSource);
+        YTSearch *search = qobject_cast<YTSearch *>(videoSource);
         SearchParams *searchParams = search->getSearchParams();
 
         // save keyword
@@ -414,7 +414,7 @@ bool PlaylistModel::dropMimeData(const QMimeData *data,
     else
         beginRow = rowCount(QModelIndex());
 
-    const VideoMimeData* videoMimeData = dynamic_cast<const VideoMimeData*>( data );
+    const VideoMimeData* videoMimeData = qobject_cast<const VideoMimeData*>( data );
     if(!videoMimeData ) return false;
 
     QList<Video*> droppedVideos = videoMimeData->videos();
index a5184a47f13a38049bea2540bf1a45e1e9edcdf9..c0e1197e735227e666b0bb12eb83cb476453edb0 100644 (file)
@@ -55,13 +55,13 @@ PlaylistView::PlaylistView(QWidget *parent) : QListView(parent),
 }
 
 void PlaylistView::itemEntered(const QModelIndex &index) {
-    PlaylistModel *listModel = dynamic_cast<PlaylistModel *>(model());
+    PlaylistModel *listModel = qobject_cast<PlaylistModel *>(model());
     if (listModel) listModel->setHoveredRow(index.row());
 }
 
 void PlaylistView::leaveEvent(QEvent *event) {
     QListView::leaveEvent(event);
-    PlaylistModel *listModel = dynamic_cast<PlaylistModel *>(model());
+    PlaylistModel *listModel = qobject_cast<PlaylistModel *>(model());
     if (listModel) listModel->clearHover();
 }
 
@@ -99,7 +99,7 @@ void PlaylistView::mouseReleaseEvent(QMouseEvent *event) {
         } else if (isHoveringAuthor(event)) {
             emit authorPushed(index);
         } else if (isShowMoreItem(index)) {
-            PlaylistModel *listModel = dynamic_cast<PlaylistModel *>(model());
+            PlaylistModel *listModel = qobject_cast<PlaylistModel *>(model());
             listModel->searchMore();
             unsetCursor();
         }
@@ -114,7 +114,7 @@ bool PlaylistView::isHoveringAuthor(QMouseEvent *event) {
     const QRect itemRect = visualRect(itemIndex);
     // qDebug() << " itemRect.x()" <<  itemRect.x();
 
-    PlaylistItemDelegate *delegate = dynamic_cast<PlaylistItemDelegate *>(itemDelegate());
+    PlaylistItemDelegate *delegate = qobject_cast<PlaylistItemDelegate *>(itemDelegate());
     if (!delegate) return false;
 
     QRect rect = delegate->authorRect(itemIndex);
index a6189aa3faaced75b0e4283a7de680210b8a8b7b..acac6fb428d37603e0c9d238e22f7f4c2461ebea 100644 (file)
@@ -22,7 +22,7 @@ $END_LICENSE */
 #include "ytregions.h"
 #include "mainwindow.h"
 
-RegionsView::RegionsView(QWidget *parent) : QWidget(parent) {
+RegionsView::RegionsView(QWidget *parent) : View(parent) {
     QBoxLayout *l = new QVBoxLayout(this);
     l->setMargin(30);
     l->setSpacing(30);
index 2caacd2ad002f64eb69f2624b75beb417e047b28..82cc7a22c52f23256eb54e79e7c366309855dde8 100644 (file)
@@ -29,7 +29,7 @@ $END_LICENSE */
 
 struct YTRegion;
 
-class RegionsView : public QWidget, public View {
+class RegionsView : public View {
 
     Q_OBJECT
 
index 81a1947e63291499211e7fd5de27b4828fcd9497..7128994f4bab72b20602cd0a3f8d549f447094ff 100644 (file)
@@ -31,6 +31,7 @@ public:
     void emitTextChanged(const QString &text);
     QString text();
     QLineEdit *getLineEdit();
+    QWidget *toWidget() { return qobject_cast<QWidget*>(this); }
 
 public slots:
     void returnPressed();
index ec5829511df93dad736b665f057f2358bf6a0f98..2f79703f213392d3afa66cfef2717fc2a619d23e 100644 (file)
@@ -46,7 +46,7 @@ static const QString recentKeywordsKey = "recentKeywords";
 static const QString recentChannelsKey = "recentChannels";
 static const int PADDING = 30;
 
-SearchView::SearchView(QWidget *parent) : QWidget(parent) {
+SearchView::SearchView(QWidget *parent) : View(parent) {
 
 #if defined(APP_MAC) | defined(APP_WIN)
     // speedup painting since we'll paint the whole background
index 568ffbe787a518baf873196a6f64f5c6c06eaf5e..01895eb7147fcc9c20832ee44b1eea2cc5d0e78e 100644 (file)
@@ -33,7 +33,7 @@ class YTSuggester;
 class ChannelSuggest;
 class Suggestion;
 
-class SearchView : public QWidget, public View {
+class SearchView : public View {
 
     Q_OBJECT
 
index 4ab9cd031ae318b1e54b3c27a47efb759ae135c3..07e9d4abe3e13f2f213d141a36722103e97c2027 100644 (file)
@@ -27,10 +27,7 @@ public:
     virtual void returnPressed() = 0;
     virtual QString text() = 0;
     virtual QLineEdit *getLineEdit() = 0;
-
-    QWidget *toWidget() {
-        return dynamic_cast<QWidget*>(this);
-    }
+    virtual QWidget *toWidget() = 0;
 
 signals:
     void textChanged(const QString &text);
index 94a53145609447c35616bc2fde7c35ba6a63f145..799e54ddef9e7c2db09d1d793ce917f182602284 100644 (file)
@@ -30,7 +30,7 @@ namespace The {
 QHash<QString, QAction*>* globalActions();
 }
 
-StandardFeedsView::StandardFeedsView(QWidget *parent) : QWidget(parent),
+StandardFeedsView::StandardFeedsView(QWidget *parent) : View(parent),
     layout(0) {
     QPalette p = palette();
     p.setBrush(QPalette::Window, Qt::black);
index 066035c823cfde4a9e8a2f76e425392eaf4ec571..0f9e051180e280f288dfdee4cb979873ccc6b2e7 100644 (file)
@@ -31,7 +31,7 @@ class VideoSource;
 struct YTCategory;
 class YTStandardFeed;
 
-class StandardFeedsView : public QWidget, public View {
+class StandardFeedsView : public View {
 
     Q_OBJECT
 
index 7999bcedb864d1db999b55f9621dd5c4acd8bbeb..62106148c4560d16a6a88065b1138b007c577b06 100644 (file)
@@ -155,7 +155,7 @@ void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) {
 
 void VideoAreaWidget::dropEvent(QDropEvent *event) {
     
-    const VideoMimeData* videoMimeData = dynamic_cast<const VideoMimeData*>( event->mimeData() );
+    const VideoMimeData* videoMimeData = qobject_cast<const VideoMimeData*>( event->mimeData() );
     if(!videoMimeData ) return;
     
     QList<Video*> droppedVideos = videoMimeData->videos();
index 6abb788482b730ca40fba52f845a603b945da431..81b55c1d90683e22d49952109d381a399fe8a9b6 100644 (file)
@@ -26,6 +26,8 @@ $END_LICENSE */
 
 class VideoMimeData : public QMimeData {
 
+    Q_OBJECT
+
 public:
     VideoMimeData();
 
index e847f6e02ce73569404d05c94d83b5de813fe91e..5f0bdadfb069db612b466a734d901303634f9c15 100644 (file)
@@ -21,9 +21,17 @@ $END_LICENSE */
 #ifndef VIEW_H
 #define VIEW_H
 
-class View {
+#include <QWidget>
+#include <QHash>
+#include <QString>
+#include <QVariant>
+
+class View : public QWidget {
+
+    Q_OBJECT
 
 public:
+    View(QWidget *parent = 0) : QWidget(parent) { }
     virtual QHash<QString, QVariant> metadata() { return QHash<QString, QVariant>(); }
     virtual void appear() {}
     virtual void disappear() {}