Backup of the download manager

preferencesAboutTextFull
shibakaneki 13 years ago
parent ff0abb5306
commit a3af649cba
  1. BIN
      resources/images/download_close.png
  2. BIN
      resources/images/download_open.png
  3. 2
      resources/sankore.qrc
  4. 3
      resources/style.qss
  5. 8
      src/board/UBBoardController.cpp
  6. 49
      src/board/UBBoardPaletteManager.cpp
  7. 6
      src/board/UBBoardPaletteManager.h
  8. 1
      src/board/UBLibraryController.cpp
  9. 7
      src/core/UBDownloadManager.cpp
  10. 1
      src/core/UBDownloadManager.h
  11. 49
      src/gui/UBDockDownloadWidget.cpp
  12. 36
      src/gui/UBDockDownloadWidget.h
  13. 2
      src/gui/UBDownloadWidget.cpp
  14. 39
      src/gui/UBLibPathViewer.cpp
  15. 3
      src/gui/UBLibPathViewer.h
  16. 6
      src/gui/gui.pri

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

@ -335,5 +335,7 @@
<file>style.qss</file>
<file>images/teacher_open_disabled.png</file>
<file>images/libpalette/WebSearchCategory.svg</file>
<file>images/download_close.png</file>
<file>images/download_open.png</file>
</qresource>
</RCC>

@ -3,7 +3,8 @@ QWidget#documentNavigator,
QWidget#UBLibPathViewer,
QWidget#UBTeacherStudentAction,
QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties
QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget
{
background: #EEEEEE;
border-radius: 10px;

@ -726,6 +726,7 @@ void UBBoardController::lastScene()
void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const QSize& pSize, bool isBackground)
{
qDebug() << "something has been dropped on the board! Url is: " << url.toString();
QString sUrl = url.toString();
if(sUrl.startsWith("uniboardTool://"))
@ -766,14 +767,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
desc.size = pSize;
desc.isBackground = isBackground;
// INFO: DO NOT UNCOMMENT THE NEXT LINE! DEVELOPMENT IN PROGRESS
UBDownloadManager::downloadManager()->addFileToDownload(desc);
// UBHttpGet *http = new UBHttpGet(mActiveScene);
// showMessage(tr("Downloading content from %1").arg(url.toString()), true);
// connect(http, SIGNAL(downloadFinished(bool, QUrl, QString, QByteArray, QPointF, QSize, bool)),
// this, SLOT(downloadFinished(bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// http->get(url, pPos, pSize, isBackground);
}
}

@ -82,6 +82,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mpCachePropWidget(NULL)
, mpTeacherBarWidget(NULL)
, mpDesktopLibWidget(NULL)
, mpDownloadWidget(NULL)
{
setupPalettes();
connectPalettes();
@ -90,6 +91,11 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
UBBoardPaletteManager::~UBBoardPaletteManager()
{
if(NULL != mpDownloadWidget)
{
delete mpDownloadWidget;
mpDownloadWidget = NULL;
}
if(NULL != mpTeacherBarWidget)
{
delete mpTeacherBarWidget;
@ -182,7 +188,9 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD);
// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode)));
//------------------------------------------------//
mpDownloadWidget = new UBDockDownloadWidget();
mpDownloadWidget->registerMode(eUBDockPaletteWidget_BOARD);
// Add the dock palettes
mLeftPalette = new UBLeftPalette(mContainer);
@ -192,29 +200,24 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mLeftPalette->connectSignals();
//------------------------------------------------//
mRightPalette = new UBRightPalette(mContainer);
// RIGHT palette widgets
mRightPalette->registerWidget(mpLibWidget);
mRightPalette->addTab(mpLibWidget);
// ???
mRightPalette->registerWidget(mpCachePropWidget);
// mRightPalette->addTab(mpCachePropWidget);
// ???
// The cache widget will be visible only if a cache is put on the page
mRightPalette->registerWidget(mpCachePropWidget);
// The teacher bar widget will always be there
mRightPalette->registerWidget(mpTeacherBarWidget);
mRightPalette->addTab(mpTeacherBarWidget);
// The download widget will be part of the right palette but
// will become visible only when the first download starts
mRightPalette->registerWidget(mpDownloadWidget);
mRightPalette->connectSignals();
//------------------------------------------------//
changeMode(eUBDockPaletteWidget_BOARD, true);
//------------------------------------------------//
// Hide the tabs that must be hidden
mRightPalette->removeTab(mpDownloadWidget->name());
mRightPalette->removeTab(mpCachePropWidget->name());
// mLeftPalette->showTabWidget(0);
// mRightPalette->showTabWidget(0);
@ -1003,3 +1006,19 @@ void UBBoardPaletteManager::refreshPalettes()
mRightPalette->update();
mLeftPalette->update();
}
void UBBoardPaletteManager::startDownloads()
{
if(!mpDownloadWidget->isVisible())
{
mRightPalette->addTab(mpDownloadWidget);
}
}
void UBBoardPaletteManager::stopDownloads()
{
if(mpDownloadWidget->isVisible())
{
mRightPalette->removeTab(mpDownloadWidget->name());
}
}

@ -26,6 +26,7 @@
#include "gui/UBLibWidget.h"
#include "gui/UBCachePropertiesWidget.h"
#include "gui/UBTeacherBarWidget.h"
#include "gui/UBDockDownloadWidget.h"
#include "core/UBApplicationController.h"
@ -62,6 +63,8 @@ class UBBoardPaletteManager : public QObject
void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
void startDownloads();
void stopDownloads();
signals:
@ -134,7 +137,8 @@ class UBBoardPaletteManager : public QObject
UBCachePropertiesWidget* mpCachePropWidget;
/** The teacher bar widget */
UBTeacherBarWidget* mpTeacherBarWidget;
/** The download widget */
UBDockDownloadWidget* mpDownloadWidget;
// HACK: here we duplicate the lib widget for the desktop mode
// we MUST refactor the architecture in order to use only one
// lib widget!

@ -110,6 +110,7 @@ void UBLibraryController::createDirectory(QUrl& pDirPath)
void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory)
{
qDebug() << "routeItem: " << pItem;
QFileInfo itemToRoute(pItem);
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(itemToRoute.fileName());
QString destination("");

@ -251,6 +251,13 @@ void UBDownloadManager::updateFileCurrentSize(int id, qint64 received, qint64 to
onUpdateDownloadLists();
emit downloadFinished(id);
// Verify if all downloads are finished
if(mCrntDL.empty() && mPendingDL.empty())
{
emit allDownloadsFinished();
}
break;
}

@ -79,6 +79,7 @@ signals:
void downloadModalFinished();
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void cancelAllDownloads();
void allDownloadsFinished();
private slots:
void onUpdateDownloadLists();

@ -0,0 +1,49 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "UBDockDownloadWidget.h"
#include "core/UBApplication.h"
UBDockDownloadWidget::UBDockDownloadWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent, name)
, mpLayout(NULL)
, mpDLWidget(NULL)
{
mName = "DownloadWidget";
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
mIconToLeft = QPixmap(":images/download_open.png");
mIconToRight = QPixmap(":images/download_close.png");
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpDLWidget = new UBDownloadWidget(this);
mpLayout->addWidget(mpDLWidget);
}
UBDockDownloadWidget::~UBDockDownloadWidget()
{
if(NULL != mpDLWidget)
{
delete mpDLWidget;
mpDLWidget = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
}

@ -0,0 +1,36 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCKDOWNLOADWIDGET_H
#define UBDOCKDOWNLOADWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include "UBDockPaletteWidget.h"
#include "UBDownloadWidget.h"
class UBDockDownloadWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBDockDownloadWidget(QWidget* parent=0, const char* name="UBDockDownloadWidget");
~UBDockDownloadWidget();
private:
QVBoxLayout* mpLayout;
UBDownloadWidget* mpDLWidget;
};
#endif // UBDOCKDOWNLOADWIDGET_H

@ -49,6 +49,7 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa
mpBttnLayout = new QHBoxLayout();
mpBttnLayout->addStretch(1);
mpCancelBttn = new QPushButton(tr("Cancel"), this);
mpCancelBttn->setObjectName("DockPaletteWidgetButton");
mpBttnLayout->addWidget(mpCancelBttn, 0);
mpLayout->addLayout(mpBttnLayout);
@ -175,6 +176,7 @@ void UBDownloadWidget::onDownloadUpdated(int id, qint64 crnt, qint64 total)
*/
void UBDownloadWidget::onDownloadFinished(int id)
{
Q_UNUSED(id);
// Refresh the file's list
onFileAddedToDownload();
}

@ -21,6 +21,8 @@
#include "board/UBBoardController.h"
#include "core/memcheck.h"
#include "core/UBDownloadManager.h"
#include "board/UBBoardPaletteManager.h"
/**
* \brief Constructor
@ -367,7 +369,7 @@ void UBFolderPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBPathScene::UBPathScene(QWidget* parent):QGraphicsScene(parent)
{
connect(UBDownloadManager::downloadManager(), SIGNAL(allDownloadsFinished()), this, SLOT(onAllDownloadsFinished()));
}
UBPathScene::~UBPathScene()
@ -457,7 +459,7 @@ void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
const QMimeData* pMimeData = event->mimeData();
if(0 == QString::compare(event->source()->metaObject()->className(), "UBLibraryWidget"))
if(NULL != event->source() && 0 == QString::compare(event->source()->metaObject()->className(), "UBLibraryWidget"))
{
UBLibElement* pTargetElement = elementFromPos(event->scenePos());
if(NULL != pTargetElement)
@ -480,6 +482,33 @@ void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
event->accept();
}
else if(NULL != event->mimeData() && event->mimeData()->hasUrls())
{
QList<QUrl> urls = event->mimeData()->urls();
foreach(QUrl eachUrl, urls)
{
QString sUrl = eachUrl.toString();
if(!sUrl.startsWith("uniboardTool://") && !sUrl.startsWith("file://") && !sUrl.startsWith("/"))
{
// The dropped URL comes from the web
qDebug() << "Dropped url: " << sUrl;
// Show the download palette if it is hidden
UBApplication::boardController->paletteManager()->startDownloads();
// Add the dropped url to the download list
sDownloadFileDesc desc;
desc.currentSize = 0;
desc.id = 0;
desc.isBackground = false;
desc.modal = false;
desc.name = QFileInfo(sUrl).fileName();
desc.totalSize = 0;
desc.url = sUrl;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
}
}
else
{
event->ignore();
@ -507,3 +536,9 @@ UBLibElement* UBPathScene::elementFromPos(QPointF p)
return pElem;
}
void UBPathScene::onAllDownloadsFinished()
{
// Hide the download tab
UBApplication::boardController->paletteManager()->stopDownloads();
}

@ -59,6 +59,9 @@ protected:
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
void dropEvent(QGraphicsSceneDragDropEvent *event);
private slots:
void onAllDownloadsFinished();
private:
UBLibElement* elementFromPos(QPointF p);
/** The drag start position */

@ -45,7 +45,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBCachePropertiesWidget.h \
src/gui/UBTeacherBarWidget.h \
src/gui/UBLibWebView.h \
src/gui/UBDownloadWidget.h
src/gui/UBDownloadWidget.h \
src/gui/UBDockDownloadWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
@ -93,7 +94,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBCachePropertiesWidget.cpp \
src/gui/UBTeacherBarWidget.cpp \
src/gui/UBLibWebView.cpp \
src/gui/UBDownloadWidget.cpp
src/gui/UBDownloadWidget.cpp \
src/gui/UBDockDownloadWidget.cpp
win32 {

Loading…
Cancel
Save