From 0eb128ec0447c1cc7c993bb9a4a4491e77f0e895 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Thu, 24 May 2012 14:33:32 +0200 Subject: [PATCH] removed unused classes --- Sankore_3.1.pro | 1 - src/board/UBBoardView.cpp | 10 +- src/customWidgets/UBActionableWidget.cpp | 65 ----- src/customWidgets/UBActionableWidget.h | 45 --- src/customWidgets/UBDraggableLabel.cpp | 39 --- src/customWidgets/UBDraggableLabel.h | 23 -- src/customWidgets/UBDraggableMedia.cpp | 42 --- src/customWidgets/UBDraggableMedia.h | 19 -- src/customWidgets/UBMediaWidget.cpp | 335 ----------------------- src/customWidgets/UBMediaWidget.h | 127 --------- src/customWidgets/UBWidgetList.cpp | 229 ---------------- src/customWidgets/UBWidgetList.h | 69 ----- src/customWidgets/customWidgets.pri | 13 - 13 files changed, 2 insertions(+), 1015 deletions(-) delete mode 100644 src/customWidgets/UBActionableWidget.cpp delete mode 100644 src/customWidgets/UBActionableWidget.h delete mode 100644 src/customWidgets/UBDraggableLabel.cpp delete mode 100644 src/customWidgets/UBDraggableLabel.h delete mode 100644 src/customWidgets/UBDraggableMedia.cpp delete mode 100644 src/customWidgets/UBDraggableMedia.h delete mode 100644 src/customWidgets/UBMediaWidget.cpp delete mode 100644 src/customWidgets/UBMediaWidget.h delete mode 100644 src/customWidgets/UBWidgetList.cpp delete mode 100644 src/customWidgets/UBWidgetList.h delete mode 100644 src/customWidgets/customWidgets.pri diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro index 6e68e1c9..e156a983 100644 --- a/Sankore_3.1.pro +++ b/Sankore_3.1.pro @@ -52,7 +52,6 @@ include(src/tools/tools.pri) include(src/desktop/desktop.pri) include(src/web/web.pri) include(src/transition/transition.pri) -include(src/customWidgets/customWidgets.pri) include(src/interfaces/interfaces.pri) DEPENDPATH += src/pdf-merger diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 1e299fde..23bfab89 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -49,9 +49,6 @@ #include "document/UBDocumentProxy.h" -#include "customWidgets/UBDraggableLabel.h" -#include "customWidgets/UBDraggableMedia.h" - #include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsTriangle.h" @@ -813,14 +810,11 @@ void UBBoardView::dropEvent (QDropEvent *event) UBGraphicsWidgetItem* graphicsWidget = dynamic_cast(graphicsItemAtPos); if (graphicsWidget && graphicsWidget->acceptDrops()) { - graphicsWidget->processDropEvent(event); event->acceptProposedAction(); - } else if (!event->source() || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source()) - || dynamic_cast(event->source()) || dynamic_cast(event->source())) { - + } + else if (!event->source() || dynamic_cast(event->source()) || dynamic_cast(event->source())){ mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); event->acceptProposedAction(); } diff --git a/src/customWidgets/UBActionableWidget.cpp b/src/customWidgets/UBActionableWidget.cpp deleted file mode 100644 index 65e440a3..00000000 --- a/src/customWidgets/UBActionableWidget.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include - -#include "UBActionableWidget.h" - -UBActionableWidget::UBActionableWidget(QWidget *parent, const char *name):QWidget(parent) - , mShowActions(false) -{ - setObjectName(name); - mActions.clear(); - mCloseButtons.setIcon(QIcon(QPixmap(":images/close.svg"))); - mCloseButtons.setGeometry(0, 0, 2*ACTIONSIZE, ACTIONSIZE); - mCloseButtons.setVisible(false); - connect(&mCloseButtons, SIGNAL(clicked()), this, SLOT(onCloseClicked())); -} - -UBActionableWidget::~UBActionableWidget() -{ - -} - -void UBActionableWidget::addAction(eAction act) -{ - if(!mActions.contains(act)){ - mActions << act; - } -} - -void UBActionableWidget::removeAction(eAction act) -{ - if(mActions.contains(act)){ - mActions.remove(mActions.indexOf(act)); - } -} - -void UBActionableWidget::removeAllActions() -{ - mActions.clear(); -} - -void UBActionableWidget::setActionsVisible(bool bVisible) -{ - if(!mActions.empty() && mActions.contains(eAction_Close)){ - mCloseButtons.setVisible(bVisible); - } -} - -void UBActionableWidget::onCloseClicked() -{ - emit close(this); -} - -void UBActionableWidget::setActionsParent(QWidget *parent) -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(parent); - } -} - -void UBActionableWidget::unsetActionsParent() -{ - if(mActions.contains(eAction_Close)){ - mCloseButtons.setParent(this); - } -} diff --git a/src/customWidgets/UBActionableWidget.h b/src/customWidgets/UBActionableWidget.h deleted file mode 100644 index 683463df..00000000 --- a/src/customWidgets/UBActionableWidget.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef UBACTIONABLEWIDGET_H -#define UBACTIONABLEWIDGET_H - -#include -#include -#include -#include - -#define ACTIONSIZE 16 - -typedef enum{ - eAction_Close, - eAction_MoveUp, - eAction_MoveDown -}eAction; - -class UBActionableWidget : public QWidget -{ - Q_OBJECT -public: - UBActionableWidget(QWidget* parent=0, const char* name="UBActionableWidget"); - ~UBActionableWidget(); - void addAction(eAction act); - void removeAction(eAction act); - void removeAllActions(); - void setActionsVisible(bool bVisible); - -signals: - void close(QWidget* w); - -protected: - void setActionsParent(QWidget* parent); - void unsetActionsParent(); - QVector mActions; - QPushButton mCloseButtons; - -private slots: - void onCloseClicked(); - -private: - bool mShowActions; - -}; - -#endif // UBACTIONABLEWIDGET_H diff --git a/src/customWidgets/UBDraggableLabel.cpp b/src/customWidgets/UBDraggableLabel.cpp deleted file mode 100644 index 200205b9..00000000 --- a/src/customWidgets/UBDraggableLabel.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -#include "UBDraggableLabel.h" - - -UBDraggableLabel::UBDraggableLabel(QWidget *parent) : - QLabel(parent) -{ -} - -UBDraggableLabel::~UBDraggableLabel() -{ - //NOOP -} - -void UBDraggableLabel::loadImage(QString imagePath) -{ - mSourcePath = imagePath; - QPixmap pix = QPixmap(mSourcePath); - setPixmap(pix); - setScaledContents(true); -} - -void UBDraggableLabel::mousePressEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - QMimeData *mimeData = new QMimeData; - QList urls; - urls << QUrl::fromLocalFile(mSourcePath); - mimeData->setUrls(urls); - mimeData->setText(mSourcePath); - - - QDrag *drag = new QDrag(this); - drag->setMimeData(mimeData); - drag->start(); -} diff --git a/src/customWidgets/UBDraggableLabel.h b/src/customWidgets/UBDraggableLabel.h deleted file mode 100644 index 384b313e..00000000 --- a/src/customWidgets/UBDraggableLabel.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef UBDRAGGABLELABEL_H -#define UBDRAGGABLELABEL_H - -#include - -class UBDraggableLabel : public QLabel -{ - Q_OBJECT -public: - UBDraggableLabel(QWidget *parent = 0); - ~UBDraggableLabel(); - void loadImage(QString imagePath); -signals: - -public slots: - -protected: - QString mSourcePath; - void mousePressEvent(QMouseEvent *event); - -}; - -#endif // UBDRAGGABLELABEL_H diff --git a/src/customWidgets/UBDraggableMedia.cpp b/src/customWidgets/UBDraggableMedia.cpp deleted file mode 100644 index 4136f742..00000000 --- a/src/customWidgets/UBDraggableMedia.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include - -#include "UBDraggableMedia.h" - -UBDraggableMedia::UBDraggableMedia(eMediaType type, QWidget *parent, const char *name):UBMediaWidget(type, parent, name) -{ - removeAllActions(); -} - -UBDraggableMedia::~UBDraggableMedia() -{ - -} - -void UBDraggableMedia::mousePressEvent(QMouseEvent* ev) -{ - if(Qt::LeftButton == ev->button()){ - mDragStartPos = ev->pos(); - } -} - -void UBDraggableMedia::mouseMoveEvent(QMouseEvent* ev) -{ - if(!(ev->buttons() & Qt::LeftButton)){ - return; - } - if((ev->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance()){ - return; - } - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - - QList urls; - urls << QUrl(mFilePath); - mimeData->setText(mFilePath); - mimeData->setUrls(urls); - - drag->setMimeData(mimeData); - - drag->exec(Qt::CopyAction | Qt::MoveAction); -} diff --git a/src/customWidgets/UBDraggableMedia.h b/src/customWidgets/UBDraggableMedia.h deleted file mode 100644 index b45c9391..00000000 --- a/src/customWidgets/UBDraggableMedia.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef UBDRAGGABLEMEDIA_H -#define UBDRAGGABLEMEDIA_H - -#include "UBMediaWidget.h" - -class UBDraggableMedia : public UBMediaWidget -{ -public: - UBDraggableMedia(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBDraggableMedia"); - ~UBDraggableMedia(); -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseMoveEvent(QMouseEvent* ev); - -private: - QPoint mDragStartPos; -}; - -#endif // UBDRAGGABLEMEDIA_H diff --git a/src/customWidgets/UBMediaWidget.cpp b/src/customWidgets/UBMediaWidget.cpp deleted file mode 100644 index 4bef693b..00000000 --- a/src/customWidgets/UBMediaWidget.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - * 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 3 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, see . - */ -#include "core/UBApplication.h" -#include "globals/UBGlobals.h" -#include "UBMediaWidget.h" - -/** - * \brief Constructor - * @param type as the media type - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaWidget::UBMediaWidget(eMediaType type, QWidget *parent, const char *name):UBActionableWidget(parent, name) - , mpMediaObject(NULL) - , mpVideoWidget(NULL) - , mpAudioOutput(NULL) - , mpPlayStopButton(NULL) - , mpPauseButton(NULL) - , mpSlider(NULL) - , mAutoUpdate(false) - , mGeneratingThumbnail(false) - , mBorder(5) - , mpMediaContainer(NULL) - , mpCover(NULL) -{ - setAttribute(Qt::WA_StyledBackground, true); - setStyleSheet(UBApplication::globalStyleSheet()); - - addAction(eAction_Close); - mType = type; - setLayout(&mLayout); - - mpPlayStopButton = new UBMediaButton(this); - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton = new UBMediaButton(this); - mpPauseButton->setPixmap(QPixmap(":images/pause.svg")); - mpPauseButton->setEnabled(false); - mpSlider = new QSlider(this); - mpSlider->setOrientation(Qt::Horizontal); - mpSlider->setMinimum(0); - mpSlider->setMaximum(0); - - mSeekerLayout.addWidget(mpPlayStopButton, 0); - mSeekerLayout.addWidget(mpPauseButton, 0); - mSeekerLayout.addWidget(mpSlider, 1); - mSeekerLayout.setContentsMargins(0, 0, 0, 0); - - connect(mpPlayStopButton, SIGNAL(clicked()), this, SLOT(onPlayStopClicked())); - connect(mpPauseButton, SIGNAL(clicked()), this, SLOT(onPauseClicked())); - connect(mpSlider, SIGNAL(valueChanged(int)), this, SLOT(onSliderChanged(int))); -} - -/** - * \brief Destructor - */ -UBMediaWidget::~UBMediaWidget() -{ - unsetActionsParent(); - DELETEPTR(mpSlider); - DELETEPTR(mpPauseButton); - DELETEPTR(mpPlayStopButton); - DELETEPTR(mpAudioOutput); - DELETEPTR(mpVideoWidget); - DELETEPTR(mpMediaObject); - DELETEPTR(mpCover); -} - -/** - * \brief Set the media file - * @param filePath as the media file path - */ -void UBMediaWidget::setFile(const QString &filePath) -{ - Q_ASSERT("" != filePath); - mFilePath = filePath; - mpMediaObject = new Phonon::MediaObject(this); - mpMediaObject->setTickInterval(TICK_INTERVAL); - connect(mpMediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onStateChanged(Phonon::State,Phonon::State))); - connect(mpMediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(onTotalTimeChanged(qint64))); - connect(mpMediaObject, SIGNAL(tick(qint64)), this, SLOT(onTick(qint64))); - mpMediaObject->setCurrentSource(Phonon::MediaSource(filePath)); - createMediaPlayer(); -} - -/** - * \brief Get the media type - * @returns the media type - */ -eMediaType UBMediaWidget::mediaType() -{ - return mType; -} - -void UBMediaWidget::showEvent(QShowEvent* event) -{ - if(!mpVideoWidget){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpVideoWidget, 0); - mMediaLayout.addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - mpMediaObject->play(); - mpMediaObject->stop(); - } - QWidget::showEvent(event); -} - -/** - * \brief Create the media player - */ -void UBMediaWidget::createMediaPlayer() -{ - mpMediaContainer = new QWidget(this); - mpMediaContainer->setObjectName("UBMediaVideoContainer"); - mpMediaContainer->setLayout(&mMediaLayout); - - if(eMediaType_Video == mType){ - mMediaLayout.setContentsMargins(10, 10, 25, 10); - if(isVisible()){ - mpVideoWidget = new Phonon::VideoWidget(this); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpVideoWidget, 0); - mMediaLayout.addStretch(1); - Phonon::createPath(mpMediaObject, mpVideoWidget); - adaptSizeToVideo(); - } - mpAudioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - }else if(eMediaType_Audio == mType){ - mMediaLayout.setContentsMargins(10, 10, 10, 10); - mpCover = new QLabel(mpMediaContainer); - mpMediaContainer->setStyleSheet(QString("background: none;")); - setAudioCover(":images/libpalette/soundIcon.svg"); - mpCover->setScaledContents(true); - mMediaLayout.addStretch(1); - mMediaLayout.addWidget(mpCover, 0); - mMediaLayout.addStretch(1); - mpAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); - Phonon::createPath(mpMediaObject, mpAudioOutput); - } - mLayout.addWidget(mpMediaContainer, 1); - mLayout.addLayout(&mSeekerLayout, 0); - setActionsParent(mpMediaContainer); -} - -/** - * \brief Adapt the widget size to the video in order to keep the good aspect ratio - */ -void UBMediaWidget::adaptSizeToVideo() -{ - if(NULL != mpMediaContainer){ - int origW = mpMediaContainer->width(); - int origH = mpMediaContainer->height(); - int newW = width(); - float scaleFactor = (float)origW/(float)newW; - int newH = origH/scaleFactor; - resize(newW, height() + newH); - } -} - -/** - * \brief Handle the media state change notification - * @param newState as the new state - * @param oldState as the old state - */ -void UBMediaWidget::onStateChanged(Phonon::State newState, Phonon::State oldState) -{ - if(!mGeneratingThumbnail){ - if(Phonon::LoadingState == oldState && Phonon::StoppedState == newState){ - if(eMediaType_Video == mType){ - // We do that here to generate the thumbnail of the video - mGeneratingThumbnail = true; - mpMediaObject->play(); - mpMediaObject->pause(); - mGeneratingThumbnail = false; - } - }else if(Phonon::PlayingState == oldState && Phonon::PausedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - }else if((Phonon::PausedState == oldState && Phonon::PlayingState == newState) || - (Phonon::StoppedState == oldState && Phonon::PlayingState == newState)){ - mpPlayStopButton->setPixmap(QPixmap(":images/stop.svg")); - mpPauseButton->setEnabled(true); - }else if(Phonon::PlayingState == oldState && Phonon::StoppedState == newState){ - mpPlayStopButton->setPixmap(QPixmap(":images/play.svg")); - mpPauseButton->setEnabled(false); - mpSlider->setValue(0); - } - } -} - -/** - * \brief Handles the total time change notification - * @param total as the new total time - */ -void UBMediaWidget::onTotalTimeChanged(qint64 total) -{ - mpSlider->setMaximum(total); -} - -/** - * \brief Handles the tick notification - * @param currentTime as the current time - */ -void UBMediaWidget::onTick(qint64 currentTime) -{ - mAutoUpdate = true; - mpSlider->setValue((int)currentTime); - mAutoUpdate = false; -} - -/** - * \brief Handles the seeker value change notification - * @param value as the new seeker value - */ -void UBMediaWidget::onSliderChanged(int value) -{ - if(!mAutoUpdate){ - mpMediaObject->seek(value); - } -} - -/** - * \brief Toggle Play-Stop - */ -void UBMediaWidget::onPlayStopClicked() -{ - switch(mpMediaObject->state()){ - case Phonon::PlayingState: - mpMediaObject->stop(); - break; - - case Phonon::StoppedState: - case Phonon::PausedState: - mpMediaObject->play(); - break; - default: - break; - } -} - -/** - * \brief Pause the media - */ -void UBMediaWidget::onPauseClicked() -{ - mpMediaObject->pause(); -} - -/** - * Get the border - * @returns the actual border - */ -int UBMediaWidget::border() -{ - return mBorder; -} - -/** - * \brief Handles the resize event - * @param ev as the resize event - */ -void UBMediaWidget::resizeEvent(QResizeEvent* ev) -{ - Q_UNUSED(ev); -} - -/** - * \brief Set the audio cover - * @param coverPath as the cover image file path - */ -void UBMediaWidget::setAudioCover(const QString &coverPath) -{ - if(NULL != mpCover){ - mpCover->setPixmap(QPixmap(coverPath)); - } -} - -// ----------------------------------------------------------------------------------------------------------- -/** - * \brief Constructor - * @param parent as the parent widget - * @param name as the object name - */ -UBMediaButton::UBMediaButton(QWidget *parent, const char *name):QLabel(parent) - , mPressed(false) -{ - setObjectName(name); - resize(UBMEDIABUTTON_SIZE, UBMEDIABUTTON_SIZE); - setStyleSheet(QString("padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;")); -} - -/** - * \brief Destructor - */ -UBMediaButton::~UBMediaButton() -{ - -} - -/** - * \brief Handles the mouse press notification - * @param ev as the mouse press event - */ -void UBMediaButton::mousePressEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - mPressed = true; -} - -/** - * \brief Handles the mouse release notification - * @param ev as the mouse release event - */ -void UBMediaButton::mouseReleaseEvent(QMouseEvent* ev) -{ - Q_UNUSED(ev); - if(mPressed){ - mPressed = false; - emit clicked(); - } -} diff --git a/src/customWidgets/UBMediaWidget.h b/src/customWidgets/UBMediaWidget.h deleted file mode 100644 index dbc85b78..00000000 --- a/src/customWidgets/UBMediaWidget.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 3 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, see . - */ -#ifndef UBMEDIAWIDGET_H -#define UBMEDIAWIDGET_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "interfaces/IResizeable.h" -#include "UBActionableWidget.h" - -#define UBMEDIABUTTON_SIZE 32 -#define TICK_INTERVAL 1000 - -/** - * \brief The media type - */ -typedef enum{ - eMediaType_Video, - eMediaType_Audio -}eMediaType; - -class UBMediaButton : public QLabel -{ - Q_OBJECT -public: - UBMediaButton(QWidget* parent=0, const char* name="UBMediaButton"); - ~UBMediaButton(); - -signals: - void clicked(); - -protected: - void mousePressEvent(QMouseEvent* ev); - void mouseReleaseEvent(QMouseEvent* ev); - -private: - /** And indicator of the press event in progress */ - bool mPressed; -}; - -class UBMediaWidget : public UBActionableWidget -{ - Q_OBJECT -public: - UBMediaWidget(eMediaType type = eMediaType_Video, QWidget* parent=0, const char* name="UBMediaWidget"); - ~UBMediaWidget(); - void setFile(const QString& filePath); - eMediaType mediaType(); - int border(); - void setAudioCover(const QString& coverPath); - void setUrl(const QString& url){mUrl = url;} - QString url(){return mUrl;} - -protected: - void resizeEvent(QResizeEvent* ev); - void showEvent(QShowEvent* event); - /** The current media file path */ - QString mFilePath; - -private slots: - void onPlayStopClicked(); - void onPauseClicked(); - void onStateChanged(Phonon::State newState, Phonon::State oldState); - void onTotalTimeChanged(qint64 total); - void onTick(qint64 currentTime); - void onSliderChanged(int value); - -private: - void createMediaPlayer(); - void adaptSizeToVideo(); - - /** The current media type */ - eMediaType mType; - /** The media object */ - Phonon::MediaObject* mpMediaObject; - /** The video renderer */ - Phonon::VideoWidget* mpVideoWidget; - /** The audio renderer */ - Phonon::AudioOutput* mpAudioOutput; - /** The principal layout of this widget */ - QVBoxLayout mLayout; - /** The seeker layout */ - QHBoxLayout mSeekerLayout; - /** The play-stop button */ - UBMediaButton* mpPlayStopButton; - /** The pause button */ - UBMediaButton* mpPauseButton; - /** The seeker slider */ - QSlider* mpSlider; - /** An indicator of the seeker auto update in progress */ - bool mAutoUpdate; - /** An indicator of the thumbnail generation in progress */ - bool mGeneratingThumbnail; - /** The border */ - int mBorder; - /** A widget that will contain the media */ - QWidget* mpMediaContainer; - /** The media layout */ - QHBoxLayout mMediaLayout; - /** The audio cover */ - QLabel* mpCover; - /** The media url */ - QString mUrl; -}; - -#endif // UBMEDIAWIDGET_H diff --git a/src/customWidgets/UBWidgetList.cpp b/src/customWidgets/UBWidgetList.cpp deleted file mode 100644 index a9e9a305..00000000 --- a/src/customWidgets/UBWidgetList.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include - -#include "globals/UBGlobals.h" -#include "UBWidgetList.h" - -UBWidgetList::UBWidgetList(QWidget* parent, eWidgetListOrientation orientation, const char* name):QScrollArea(parent) - , mCanRemove(true) - , mpLayout(NULL) - , mpContainer(NULL) - , mMargin(10) - , mListElementsSpacing(10) - , mpEmptyLabel(NULL) - , mpCurrentWidget(NULL) -{ - setObjectName(name); - mOrientation = orientation; - mpContainer = new QWidget(this); - mpEmptyLabel = new QLabel(this); - mpEmptyLabel->setObjectName("emptyString"); - mpEmptyLabel->setWordWrap(true); - mpEmptyLabel->setAlignment(Qt::AlignCenter); - - if(eWidgetListOrientation_Vertical == orientation){ - setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QVBoxLayout(mpContainer); - } - else{ - setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - mpLayout = new QHBoxLayout(mpContainer); - } - mpLayout->setContentsMargins(margin(), margin(), margin(), margin()); - mpContainer->setLayout(mpLayout); - setWidget(mpContainer); -} - -UBWidgetList::~UBWidgetList() -{ - DELETEPTR(mpEmptyLabel); - DELETEPTR(mpLayout); - DELETEPTR(mpContainer); -} - -void UBWidgetList::addWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - widget->setParent(mpContainer); - mpEmptyLabel->setVisible(false); - mWidgetInfo[widget] = widget->size(); - updateView(size()); - mpLayout->addWidget(widget); - - // This call is used only to refresh the size of the widgets - updateSizes(); - } -} - -void UBWidgetList::removeWidget(QWidget *widget) -{ - if(NULL != mpLayout && NULL != widget){ - mpLayout->removeWidget(widget); - mWidgetInfo.remove(widget); - widget->setVisible(false); - updateView(size()); - if(0 == mpLayout->count()){ - mpEmptyLabel->setVisible(true); - } - if(mpCurrentWidget == widget){ - mpCurrentWidget = NULL; - } - } -} - - -int UBWidgetList::scaleWidgets(QSize pSize) -{ - // to remove the first spacing that shouldn't be there. - int result = -mListElementsSpacing; - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - qreal scaleFactor = 0; - int newWidgetWidth = pSize.width(); - int newWidgetHeight = pSize.height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - scaleFactor = (float)mWidgetInfo[eachWidget].width() / (float)pSize.width(); - newWidgetHeight = mWidgetInfo[eachWidget].height()/scaleFactor; - result += newWidgetHeight; - eachWidget->setMinimumHeight(newWidgetHeight- 1); - eachWidget->setMaximumHeight(newWidgetHeight); - } - else{ - scaleFactor = (float)mWidgetInfo[eachWidget].height() / (float)pSize.height(); - newWidgetWidth = mWidgetInfo[eachWidget].width()/scaleFactor; - result += newWidgetWidth; - eachWidget->setMinimumWidth(newWidgetWidth - 1); - eachWidget->setMaximumWidth(newWidgetWidth); - } - //Adding a vertical/horizontal space between each element of the list - result += mListElementsSpacing; - } - return result; -} - -void UBWidgetList::scaleContainer(QSize pSize, int updateValue) -{ - if(eWidgetListOrientation_Vertical == mOrientation) - mpContainer->resize(pSize.width(), updateValue); - else - mpContainer->resize(updateValue, pSize.height()); -} - - -void UBWidgetList::updateView(QSize pSize) -{ - // Widgets on list are resized automatically to fit the mpcontainer. - // so if you want to keep the aspect ratio you have to calculate - // the sum of the new widget height and give it to the mpContainer. - // The container resize will trig the widgets resize and the good - // height permits to respect the aspect ratio. - int updatedValue = scaleWidgets(pSize); - scaleContainer(pSize,updatedValue); -} - - - -void UBWidgetList::resizeEvent(QResizeEvent *ev) -{ - Q_UNUSED(ev); - mpEmptyLabel->setGeometry((width() - mpEmptyLabel->width()) / 2, - (height() - mpEmptyLabel->height()) /2, - mpEmptyLabel->width(), - mpEmptyLabel->height()); - updateView(size()); - updateSizes(); -} - -void UBWidgetList::mousePressEvent(QMouseEvent *ev) -{ - Q_UNUSED(ev); - if(mCanRemove){ - QWidget* pWAt = widgetAt(ev->pos()); - if(NULL != mpCurrentWidget){ - if(pWAt != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(false); - update(); - } - } - mpCurrentWidget = dynamic_cast(pWAt); - if(NULL != mpCurrentWidget){ - mpCurrentWidget->setActionsVisible(true); - update(); - } - } - update(); -} - -QWidget* UBWidgetList::widgetAt(QPoint p) -{ - QWidget* pW = NULL; - pW = childAt(p); - if(NULL != pW){ - do{ - if( "UBTeacherStudentAction" == pW->objectName() || - "UBUrlWidget" == pW->objectName() || - "UBTBMediaPicture" == pW->objectName() || - "UBMediaWidget" == pW->objectName()){ - return pW; - }else{ - pW = pW->parentWidget(); - } - }while(NULL != pW && this != pW); - } - - return pW; -} - -void UBWidgetList::updateSizes() -{ - // Resize all the widgets - foreach(QWidget* eachWidget, mWidgetInfo.keys()){ - if(NULL != eachWidget){ - QSize originalSize = mWidgetInfo[eachWidget]; - int currentWidth = mpContainer->width(); - int currentHeight = mpContainer->height(); - if(eWidgetListOrientation_Vertical == mOrientation){ - if(verticalScrollBar()->isVisible()){ - currentWidth -= verticalScrollBar()->width(); - eachWidget->setStyleSheet(QString("margin-right:%0;").arg(verticalScrollBar()->width())); - } - float scaleFactor = (float)currentWidth/(float)originalSize.width(); - currentHeight = originalSize.height()*scaleFactor; - }else{ - if(horizontalScrollBar()->isVisible()){ - currentHeight -= horizontalScrollBar()->height(); - eachWidget->setStyleSheet(QString("padding-bottom:%0;").arg(horizontalScrollBar()->height())); - } - float scaleFactor = (float)currentHeight/(float)originalSize.height(); - currentWidth = originalSize.width()*scaleFactor; - } - - eachWidget->resize(currentWidth, currentHeight); - } - } -} - -void UBWidgetList::setMargin(int margin) -{ - mMargin = margin; -} - -int UBWidgetList::margin() -{ - return mMargin; -} - -void UBWidgetList::setEmptyText(const QString &text) -{ - if(NULL != mpEmptyLabel){ - mpEmptyLabel->setText(text); - } -} - -bool UBWidgetList::empty() -{ - return mWidgetInfo.empty(); -} diff --git a/src/customWidgets/UBWidgetList.h b/src/customWidgets/UBWidgetList.h deleted file mode 100644 index d2cd3a6c..00000000 --- a/src/customWidgets/UBWidgetList.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef UBWIDGETLIST_H -#define UBWIDGETLIST_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "interfaces/IResizeable.h" -#include "customWidgets/UBActionableWidget.h" - -typedef enum{ - eWidgetListOrientation_Vertical, - eWidgetListOrientation_Horizontal -}eWidgetListOrientation; - - -class UBWidgetList : public QScrollArea -{ - Q_OBJECT - - typedef struct - { - QSize size; - bool isResizable; - } sWidgetProperties; - -public: - UBWidgetList(QWidget* parent=0, eWidgetListOrientation orientation = eWidgetListOrientation_Vertical, const char* name = "UBWidgetList"); - ~UBWidgetList(); - void addWidget(QWidget* widget); - void removeWidget(QWidget* widget); - void setMargin(int margin); - void setEmptyText(const QString& text); - int margin(); - bool empty(); - void setListElementSpacing(int margin) { mListElementsSpacing = margin; } - int listElementsSpacing() {return mListElementsSpacing; } - -signals: - void closeWidget(QWidget* w); - -protected: - bool mCanRemove; - - void resizeEvent(QResizeEvent* ev); - void mousePressEvent(QMouseEvent* ev); - -private: - QWidget* widgetAt(QPoint p); - int scaleWidgets(QSize pSize); - void scaleContainer(QSize pSize, int updateValue); - void updateView(QSize pSize); - void updateSizes(); - QBoxLayout* mpLayout; - QWidget* mpContainer; - eWidgetListOrientation mOrientation; - int mMargin; - int mListElementsSpacing; - QMap mWidgetInfo; - QLabel* mpEmptyLabel; - UBActionableWidget* mpCurrentWidget; -}; - -#endif // UBWIDGETLIST_H diff --git a/src/customWidgets/customWidgets.pri b/src/customWidgets/customWidgets.pri deleted file mode 100644 index c531d4b3..00000000 --- a/src/customWidgets/customWidgets.pri +++ /dev/null @@ -1,13 +0,0 @@ - -HEADERS += src/customWidgets/UBWidgetList.h \ - src/customWidgets/UBDraggableLabel.h \ - src/customWidgets/UBMediaWidget.h \ - src/globals/UBGlobals.h \ - src/customWidgets/UBDraggableMedia.h \ - src/customWidgets/UBActionableWidget.h - -SOURCES += src/customWidgets/UBWidgetList.cpp \ - src/customWidgets/UBDraggableLabel.cpp \ - src/customWidgets/UBMediaWidget.cpp \ - src/customWidgets/UBDraggableMedia.cpp \ - src/customWidgets/UBActionableWidget.cpp