some changes for sDownloadFileDesc

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 4a051f2ac4
commit 3fed7dc808
  1. 19
      src/api/UBWidgetUniboardAPI.cpp
  2. 16
      src/api/UBWidgetUniboardAPI.h
  3. 29
      src/board/UBBoardView.cpp
  4. 6
      src/board/UBBoardView.h
  5. 44
      src/core/UBDownloadManager.cpp
  6. 27
      src/core/UBDownloadManager.h
  7. 4
      src/domain/UBGraphicsWidgetItem.cpp
  8. 1
      src/domain/UBGraphicsWidgetItem.h
  9. 1
      src/pdf-merger/pdfMerger.pri

@ -55,6 +55,7 @@ UBWidgetUniboardAPI::UBWidgetUniboardAPI(UBGraphicsScene *pScene, UBGraphicsWidg
mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget());
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget);
}
connect(UBDownloadManager::downloadManager(), SIGNAL(downloadFinished(bool,int,QUrl,QString,QByteArray)), this, SLOT(onDownloadFinished(bool,int,QUrl,QString,QByteArray)));
}
@ -451,7 +452,25 @@ QString UBWidgetUniboardAPI::downloadUrl(const QString &objectUrl, const QString
return result;
}
QString UBWidgetUniboardAPI::downloadWeb(const QString &objectUrl)
{
// When we fall there, it means that we are dropping something from the web to the board
sDownloadFileDesc desc;
desc.modal = true;
desc.url = objectUrl;
desc.currentSize = 0;
desc.name = QFileInfo(objectUrl).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download
registerIDWidget(UBDownloadManager::downloadManager()->addFileToDownload(desc));
return QString();
}
void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData)
{
Q_UNUSED(pData)
qDebug() << "got an ID" << id << pSuccess << sourceUrl << pContentTypeHeader;
}
UBDocumentDatastoreAPI::UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
: UBW3CWebStorage(graphicsWidget)

@ -245,6 +245,20 @@ class UBWidgetUniboardAPI : public QObject
* this method download the object on the widget directory and return the path of the downloaded object
*/
QString downloadUrl(const QString &objectUrl, const QString &extention = "");
QString downloadWeb(const QString &objectUrl);
private slots:
void onDownloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
private:
inline void registerIDWidget(int id){webDownloadIds.append(id);}
inline bool expectedID(int id) const {return webDownloadIds.contains(id);}
inline bool removeID(int id) {return webDownloadIds.removeAll(id);}
// void unregister
private:
@ -265,7 +279,7 @@ class UBWidgetUniboardAPI : public QObject
UBWidgetMessageAPI* mMessagesAPI;
UBDatastoreAPI* mDatastoreAPI;
QList<int> webDownloadIds;
};

@ -66,6 +66,7 @@ const QString htmlAlias = "html";
const QString tMainSection = "mimedata";
const QString tType = "type";
const QString tPath = "path";
const QString tMessage = "message";
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
: QGraphicsView (pParent)
@ -771,6 +772,24 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
writer.writeStartDocument();
writer.writeStartElement(tMainSection);
if (pMimeData->hasHtml()) {
QList<QUrl> urls = pMimeData->urls();
int index = 0;
foreach(const QUrl url, urls) {
// QPointF pos(pPos + QPointF(index * 15, index * 15));
// downloadURL(url, pos);
widget->downloadWeb(url.toString());
index++;
}
writer.writeTextElement(tMessage, "Downloading content process...");
writer.writeEndElement();
writer.writeEndDocument();
return mimeXml;
}
if (pMimeData->hasUrls()) {
QList<QUrl> urls = pMimeData->urls();
@ -806,7 +825,7 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
return mimeXml;
}
QString UBBoardView::fileExtention(const QString &filename)
QString UBBoardView::fileExtention(const QString &filename) const
{
int pos = filename.lastIndexOf(".");
if (pos != -1)
@ -814,7 +833,7 @@ QString UBBoardView::fileExtention(const QString &filename)
else
return QString();
}
QString UBBoardView::typeForExtention(const QString &extention)
QString UBBoardView::typeForExtention(const QString &extention) const
{
if (extention.isEmpty())
return QString();
@ -833,8 +852,12 @@ QString UBBoardView::typeForExtention(const QString &extention)
return result;
}
bool UBBoardView::isDropableData(const QMimeData *pMimeData)
bool UBBoardView::isDropableData(const QMimeData *pMimeData) const
{
if (pMimeData->hasHtml()) {
return true;
}
if (pMimeData->hasUrls()) {
if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) {
return true;

@ -89,7 +89,7 @@ class UBBoardView : public QGraphicsView
QList<QUrl> processMimeData(const QMimeData* pMimeData);
QString processMimeData(const QMimeData *pMimeData, UBGraphicsWidgetItem *widget);
bool isDropableData(const QMimeData *pMimeData);
bool isDropableData(const QMimeData *pMimeData) const;
UBBoardController* mController;
@ -118,8 +118,8 @@ class UBBoardView : public QGraphicsView
bool mVirtualKeyboardActive;
bool mOkOnWidget;
QString typeForExtention(const QString &extention);
QString fileExtention(const QString &filename);
QString typeForExtention(const QString &extention) const;
QString fileExtention(const QString &filename) const;
private slots:

@ -70,7 +70,7 @@ void UBDownloadManager::destroy()
* \brief Add a file to the download list
* @param desc as the given file description
*/
void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
int UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
{
// Set the ID for this download
desc.id = mLastID;
@ -89,6 +89,8 @@ void UBDownloadManager::addFileToDownload(sDownloadFileDesc desc)
UBApplication::boardController->paletteManager()->startDownloads();
emit fileAddedToDownload();
return desc.id;
}
/**
@ -194,23 +196,29 @@ void UBDownloadManager::onDownloadProgress(int id, qint64 received, qint64 total
*/
void UBDownloadManager::onDownloadFinished(int id, bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{
for(int i=0; i<mCrntDL.size(); i++)
{
sDownloadFileDesc desc = mCrntDL.at(i);
if(id == desc.id)
{
if(desc.modal)
{
// The downloaded file is modal so we must put it on the board
emit addDownloadedFileToBoard(pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
}
else
{
emit addDownloadedFileToLibrary(pSuccess, sourceUrl, pContentTypeHeader, pData);
}
break;
}
}
// Temporary data for dnd do not delete it please
Q_UNUSED(pPos)
Q_UNUSED(pSize)
Q_UNUSED(isBackground)
emit downloadFinished(pSuccess, id, sourceUrl, pContentTypeHeader, pData);
// for(int i=0; i<mCrntDL.size(); i++)
// {
// sDownloadFileDesc desc = mCrntDL.at(i);
// if(id == desc.id)
// {
// if(desc.modal)
// {
// // The downloaded file is modal so we must put it on the board
// emit addDownloadedFileToBoard(pSuccess, sourceUrl, pContentTypeHeader, pData, pPos, pSize, isBackground);
// }
// else
// {
// emit addDownloadedFileToLibrary(pSuccess, sourceUrl, pContentTypeHeader, pData);
// }
// break;
// }
// }
// Then do this
updateFileCurrentSize(id);

@ -19,6 +19,7 @@
#include <QString>
#include <QVector>
#include <QMutex>
#include <QDropEvent>
#include "UBDownloadThread.h"
@ -26,8 +27,26 @@
#define SIMULTANEOUS_DOWNLOAD 2 // Maximum 5 because of QNetworkAccessManager limitation!!!
typedef struct
enum eDestinations {
board //default for sDownloadFileDesc
, library
, graphicsWidget
};
struct sDownloadFileDesc
{
//creating constructor to make sure to have default values
sDownloadFileDesc() :
dest(board)
, id(0)
, totalSize(0)
, currentSize(0)
, modal(false)
, isBackground(false)
, widgetDrop(0)
{;}
eDestinations dest;
QString name;
int id;
int totalSize;
@ -37,7 +56,8 @@ typedef struct
QPointF pos; // For board drop only
QSize size; // For board drop only
bool isBackground; // For board drop only
}sDownloadFileDesc;
QDropEvent *widgetDrop; //For widget's drops
};
class UBDownloadHttpFile : public UBHttpGet
{
@ -66,7 +86,7 @@ public:
UBDownloadManager(QObject* parent=0, const char* name="UBDownloadManager");
~UBDownloadManager();
static UBDownloadManager* downloadManager();
void addFileToDownload(sDownloadFileDesc desc);
int addFileToDownload(sDownloadFileDesc desc);
QVector<sDownloadFileDesc> currentDownloads();
QVector<sDownloadFileDesc> pendingDownloads();
void cancelDownloads();
@ -78,6 +98,7 @@ signals:
void fileAddedToDownload();
void downloadUpdated(int id, qint64 crnt, qint64 total);
void downloadFinished(int id);
void downloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
void downloadModalFinished();
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground);
void addDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);

@ -258,6 +258,10 @@ QString UBGraphicsWidgetItem::downloadUrl(const QString &fileUrl, const QString
{
return mUniboardAPI->downloadUrl(fileUrl, extention);
}
QString UBGraphicsWidgetItem::downloadWeb(const QString &fileUrl)
{
return mUniboardAPI->downloadWeb(fileUrl);
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWidgetItem(parent)

@ -67,6 +67,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void remove();
void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl);
virtual void setOwnFolder(const QUrl &newFolder) {ownFolder = newFolder;}
virtual QUrl getOwnFolder() const {return ownFolder;}

@ -58,7 +58,6 @@ SOURCES += \
macx {
LIBS += -lz
}

Loading…
Cancel
Save