From 9f10dfe827c61f43949e8a14c0083423d51b3ca6 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Tue, 25 Aug 2015 11:42:05 +0200 Subject: [PATCH] Views refactoring, don't use RTTI --- src/aboutview.cpp | 2 +- src/aboutview.h | 2 +- src/channellistview.cpp | 76 ++++++++++++++++++++++++++++ src/channellistview.h | 51 +++++++++++++++++++ src/channelview.cpp | 102 +++++++++----------------------------- src/channelview.h | 12 ++--- src/downloadlistview.cpp | 4 +- src/downloadview.cpp | 2 +- src/downloadview.h | 2 +- src/homeview.cpp | 2 +- src/homeview.h | 2 +- src/mainwindow.cpp | 6 +-- src/mediaview.cpp | 4 +- src/mediaview.h | 2 +- src/playlistmodel.cpp | 4 +- src/playlistview.cpp | 8 +-- src/regionsview.cpp | 2 +- src/regionsview.h | 2 +- src/searchlineedit.h | 1 + src/searchview.cpp | 2 +- src/searchview.h | 2 +- src/searchwidget.h | 5 +- src/standardfeedsview.cpp | 2 +- src/standardfeedsview.h | 2 +- src/videoareawidget.cpp | 2 +- src/videomimedata.h | 2 + src/view.h | 10 +++- 27 files changed, 194 insertions(+), 119 deletions(-) create mode 100644 src/channellistview.cpp create mode 100644 src/channellistview.h diff --git a/src/aboutview.cpp b/src/aboutview.cpp index 69e227f..8548e86 100644 --- a/src/aboutview.cpp +++ b/src/aboutview.cpp @@ -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); diff --git a/src/aboutview.h b/src/aboutview.h index a8e7572..0e5e669 100644 --- a/src/aboutview.h +++ b/src/aboutview.h @@ -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 index 0000000..df6fe16 --- /dev/null +++ b/src/channellistview.cpp @@ -0,0 +1,76 @@ +/* $BEGIN_LICENSE + +This file is part of Minitube. +Copyright 2009, Flavio Tordini + +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 . + +$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 index 0000000..04863a8 --- /dev/null +++ b/src/channellistview.h @@ -0,0 +1,51 @@ +/* $BEGIN_LICENSE + +This file is part of Minitube. +Copyright 2009, Flavio Tordini + +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 . + +$END_LICENSE */ + +#ifndef CHANNELLISTVIEW_H +#define CHANNELLISTVIEW_H + +#include +#if QT_VERSION >= 0x050000 +#include +#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 diff --git a/src/channelview.cpp b/src/channelview.cpp index 414846a..6203dbe 100644 --- a/src/channelview.cpp +++ b/src/channelview.cpp @@ -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); } } diff --git a/src/channelview.h b/src/channelview.h index a108a4c..41fcf7a 100644 --- a/src/channelview.h +++ b/src/channelview.h @@ -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 statusActions; bool showUpdated; SortBy sortBy; - QString errorMessage; QAction *markAsWatchedAction; }; diff --git a/src/downloadlistview.cpp b/src/downloadlistview.cpp index 58c31a4..9275661 100644 --- a/src/downloadlistview.cpp +++ b/src/downloadlistview.cpp @@ -28,7 +28,7 @@ DownloadListView::DownloadListView(QWidget *parent) : QListView(parent) { } void DownloadListView::leaveEvent(QEvent * /* event */) { - DownloadModel *downloadModel = dynamic_cast(model()); + DownloadModel *downloadModel = qobject_cast(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(itemDelegate()); + PlaylistItemDelegate *delegate = qobject_cast(itemDelegate()); if (!delegate) return false; QRect buttonRect = delegate->downloadButtonRect(itemRect); diff --git a/src/downloadview.cpp b/src/downloadview.cpp index 2ad4763..6d0c75c 100644 --- a/src/downloadview.cpp +++ b/src/downloadview.cpp @@ -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); diff --git a/src/downloadview.h b/src/downloadview.h index dccbf9c..6b30286 100644 --- a/src/downloadview.h +++ b/src/downloadview.h @@ -32,7 +32,7 @@ class DownloadModel; class DownloadListView; class DownloadSettings; -class DownloadView : public QWidget, public View { +class DownloadView : public View { Q_OBJECT diff --git a/src/homeview.cpp b/src/homeview.cpp index 1d56c26..c64f891 100644 --- a/src/homeview.cpp +++ b/src/homeview.cpp @@ -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) { diff --git a/src/homeview.h b/src/homeview.h index c65a60d..fb412f4 100644 --- a/src/homeview.h +++ b/src/homeview.h @@ -32,7 +32,7 @@ class SearchView; class StandardFeedsView; class ChannelView; -class HomeView : public QWidget, public View { +class HomeView : public View { Q_OBJECT diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cecefd4..a77ac27 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -225,7 +225,7 @@ void MainWindow::lazyInit() { // Hack to give focus to searchlineedit QMetaObject::invokeMethod(views->currentWidget(), "appear"); - View* view = dynamic_cast (views->currentWidget()); + View* view = qobject_cast (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 (views->currentWidget()); + View* oldView = qobject_cast (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 (widget); + View* newView = qobject_cast (widget); if (newView) { widget->setEnabled(true); QHash metadata = newView->metadata(); diff --git a/src/mediaview.cpp b/src/mediaview.cpp index 3327534..7100009 100644 --- a/src/mediaview.cpp +++ b/src/mediaview.cpp @@ -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(videoSource); + YTSearch *search = qobject_cast(videoSource); return search->getSearchParams(); } return 0; diff --git a/src/mediaview.h b/src/mediaview.h index 468d32e..5402498 100644 --- a/src/mediaview.h +++ b/src/mediaview.h @@ -50,7 +50,7 @@ namespace The { QHash* globalActions(); } -class MediaView : public QWidget, public View { +class MediaView : public View { Q_OBJECT diff --git a/src/playlistmodel.cpp b/src/playlistmodel.cpp index 389f676..7fa95cc 100644 --- a/src/playlistmodel.cpp +++ b/src/playlistmodel.cpp @@ -270,7 +270,7 @@ void PlaylistModel::handleFirstVideo(Video *video) { static const int maxRecentElements = 10; - YTSearch *search = dynamic_cast(videoSource); + YTSearch *search = qobject_cast(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( data ); + const VideoMimeData* videoMimeData = qobject_cast( data ); if(!videoMimeData ) return false; QList droppedVideos = videoMimeData->videos(); diff --git a/src/playlistview.cpp b/src/playlistview.cpp index a5184a4..c0e1197 100644 --- a/src/playlistview.cpp +++ b/src/playlistview.cpp @@ -55,13 +55,13 @@ PlaylistView::PlaylistView(QWidget *parent) : QListView(parent), } void PlaylistView::itemEntered(const QModelIndex &index) { - PlaylistModel *listModel = dynamic_cast(model()); + PlaylistModel *listModel = qobject_cast(model()); if (listModel) listModel->setHoveredRow(index.row()); } void PlaylistView::leaveEvent(QEvent *event) { QListView::leaveEvent(event); - PlaylistModel *listModel = dynamic_cast(model()); + PlaylistModel *listModel = qobject_cast(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(model()); + PlaylistModel *listModel = qobject_cast(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(itemDelegate()); + PlaylistItemDelegate *delegate = qobject_cast(itemDelegate()); if (!delegate) return false; QRect rect = delegate->authorRect(itemIndex); diff --git a/src/regionsview.cpp b/src/regionsview.cpp index a6189aa..acac6fb 100644 --- a/src/regionsview.cpp +++ b/src/regionsview.cpp @@ -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); diff --git a/src/regionsview.h b/src/regionsview.h index 2caacd2..82cc7a2 100644 --- a/src/regionsview.h +++ b/src/regionsview.h @@ -29,7 +29,7 @@ $END_LICENSE */ struct YTRegion; -class RegionsView : public QWidget, public View { +class RegionsView : public View { Q_OBJECT diff --git a/src/searchlineedit.h b/src/searchlineedit.h index 81a1947..7128994 100644 --- a/src/searchlineedit.h +++ b/src/searchlineedit.h @@ -31,6 +31,7 @@ public: void emitTextChanged(const QString &text); QString text(); QLineEdit *getLineEdit(); + QWidget *toWidget() { return qobject_cast(this); } public slots: void returnPressed(); diff --git a/src/searchview.cpp b/src/searchview.cpp index ec58295..2f79703 100644 --- a/src/searchview.cpp +++ b/src/searchview.cpp @@ -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 diff --git a/src/searchview.h b/src/searchview.h index 568ffbe..01895eb 100644 --- a/src/searchview.h +++ b/src/searchview.h @@ -33,7 +33,7 @@ class YTSuggester; class ChannelSuggest; class Suggestion; -class SearchView : public QWidget, public View { +class SearchView : public View { Q_OBJECT diff --git a/src/searchwidget.h b/src/searchwidget.h index 4ab9cd0..07e9d4a 100644 --- a/src/searchwidget.h +++ b/src/searchwidget.h @@ -27,10 +27,7 @@ public: virtual void returnPressed() = 0; virtual QString text() = 0; virtual QLineEdit *getLineEdit() = 0; - - QWidget *toWidget() { - return dynamic_cast(this); - } + virtual QWidget *toWidget() = 0; signals: void textChanged(const QString &text); diff --git a/src/standardfeedsview.cpp b/src/standardfeedsview.cpp index 94a5314..799e54d 100644 --- a/src/standardfeedsview.cpp +++ b/src/standardfeedsview.cpp @@ -30,7 +30,7 @@ namespace The { QHash* globalActions(); } -StandardFeedsView::StandardFeedsView(QWidget *parent) : QWidget(parent), +StandardFeedsView::StandardFeedsView(QWidget *parent) : View(parent), layout(0) { QPalette p = palette(); p.setBrush(QPalette::Window, Qt::black); diff --git a/src/standardfeedsview.h b/src/standardfeedsview.h index 066035c..0f9e051 100644 --- a/src/standardfeedsview.h +++ b/src/standardfeedsview.h @@ -31,7 +31,7 @@ class VideoSource; struct YTCategory; class YTStandardFeed; -class StandardFeedsView : public QWidget, public View { +class StandardFeedsView : public View { Q_OBJECT diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp index 7999bce..6210614 100644 --- a/src/videoareawidget.cpp +++ b/src/videoareawidget.cpp @@ -155,7 +155,7 @@ void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) { void VideoAreaWidget::dropEvent(QDropEvent *event) { - const VideoMimeData* videoMimeData = dynamic_cast( event->mimeData() ); + const VideoMimeData* videoMimeData = qobject_cast( event->mimeData() ); if(!videoMimeData ) return; QList droppedVideos = videoMimeData->videos(); diff --git a/src/videomimedata.h b/src/videomimedata.h index 6abb788..81b55c1 100644 --- a/src/videomimedata.h +++ b/src/videomimedata.h @@ -26,6 +26,8 @@ $END_LICENSE */ class VideoMimeData : public QMimeData { + Q_OBJECT + public: VideoMimeData(); diff --git a/src/view.h b/src/view.h index e847f6e..5f0bdad 100644 --- a/src/view.h +++ b/src/view.h @@ -21,9 +21,17 @@ $END_LICENSE */ #ifndef VIEW_H #define VIEW_H -class View { +#include +#include +#include +#include + +class View : public QWidget { + + Q_OBJECT public: + View(QWidget *parent = 0) : QWidget(parent) { } virtual QHash metadata() { return QHash(); } virtual void appear() {} virtual void disappear() {} -- 2.39.5