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()); mMessagesAPI = new UBWidgetMessageAPI(w3CGraphicsWidget->w3cWidget());
mDatastoreAPI = new UBDatastoreAPI(w3CGraphicsWidget); 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; 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) UBDocumentDatastoreAPI::UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
: UBW3CWebStorage(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 * 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 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: private:
@ -265,7 +279,7 @@ class UBWidgetUniboardAPI : public QObject
UBWidgetMessageAPI* mMessagesAPI; UBWidgetMessageAPI* mMessagesAPI;
UBDatastoreAPI* mDatastoreAPI; UBDatastoreAPI* mDatastoreAPI;
QList<int> webDownloadIds;
}; };

@ -66,6 +66,7 @@ const QString htmlAlias = "html";
const QString tMainSection = "mimedata"; const QString tMainSection = "mimedata";
const QString tType = "type"; const QString tType = "type";
const QString tPath = "path"; const QString tPath = "path";
const QString tMessage = "message";
UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent) UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent)
: QGraphicsView (pParent) : QGraphicsView (pParent)
@ -771,6 +772,24 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
writer.writeStartDocument(); writer.writeStartDocument();
writer.writeStartElement(tMainSection); 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()) { if (pMimeData->hasUrls()) {
QList<QUrl> urls = pMimeData->urls(); QList<QUrl> urls = pMimeData->urls();
@ -806,7 +825,7 @@ QString UBBoardView::processMimeData(const QMimeData *pMimeData, UBGraphicsWidge
return mimeXml; return mimeXml;
} }
QString UBBoardView::fileExtention(const QString &filename) QString UBBoardView::fileExtention(const QString &filename) const
{ {
int pos = filename.lastIndexOf("."); int pos = filename.lastIndexOf(".");
if (pos != -1) if (pos != -1)
@ -814,7 +833,7 @@ QString UBBoardView::fileExtention(const QString &filename)
else else
return QString(); return QString();
} }
QString UBBoardView::typeForExtention(const QString &extention) QString UBBoardView::typeForExtention(const QString &extention) const
{ {
if (extention.isEmpty()) if (extention.isEmpty())
return QString(); return QString();
@ -833,8 +852,12 @@ QString UBBoardView::typeForExtention(const QString &extention)
return result; return result;
} }
bool UBBoardView::isDropableData(const QMimeData *pMimeData) bool UBBoardView::isDropableData(const QMimeData *pMimeData) const
{ {
if (pMimeData->hasHtml()) {
return true;
}
if (pMimeData->hasUrls()) { if (pMimeData->hasUrls()) {
if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) { if (!typeForExtention(fileExtention(pMimeData->urls().at(0).toLocalFile())).isNull()) {
return true; return true;

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

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

@ -19,6 +19,7 @@
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <QMutex> #include <QMutex>
#include <QDropEvent>
#include "UBDownloadThread.h" #include "UBDownloadThread.h"
@ -26,8 +27,26 @@
#define SIMULTANEOUS_DOWNLOAD 2 // Maximum 5 because of QNetworkAccessManager limitation!!! #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; QString name;
int id; int id;
int totalSize; int totalSize;
@ -37,7 +56,8 @@ typedef struct
QPointF pos; // For board drop only QPointF pos; // For board drop only
QSize size; // For board drop only QSize size; // For board drop only
bool isBackground; // For board drop only bool isBackground; // For board drop only
}sDownloadFileDesc; QDropEvent *widgetDrop; //For widget's drops
};
class UBDownloadHttpFile : public UBHttpGet class UBDownloadHttpFile : public UBHttpGet
{ {
@ -66,7 +86,7 @@ public:
UBDownloadManager(QObject* parent=0, const char* name="UBDownloadManager"); UBDownloadManager(QObject* parent=0, const char* name="UBDownloadManager");
~UBDownloadManager(); ~UBDownloadManager();
static UBDownloadManager* downloadManager(); static UBDownloadManager* downloadManager();
void addFileToDownload(sDownloadFileDesc desc); int addFileToDownload(sDownloadFileDesc desc);
QVector<sDownloadFileDesc> currentDownloads(); QVector<sDownloadFileDesc> currentDownloads();
QVector<sDownloadFileDesc> pendingDownloads(); QVector<sDownloadFileDesc> pendingDownloads();
void cancelDownloads(); void cancelDownloads();
@ -78,6 +98,7 @@ signals:
void fileAddedToDownload(); void fileAddedToDownload();
void downloadUpdated(int id, qint64 crnt, qint64 total); void downloadUpdated(int id, qint64 crnt, qint64 total);
void downloadFinished(int id); void downloadFinished(int id);
void downloadFinished(bool pSuccess, int id, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData);
void downloadModalFinished(); void downloadModalFinished();
void addDownloadedFileToBoard(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground); 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); 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); return mUniboardAPI->downloadUrl(fileUrl, extention);
} }
QString UBGraphicsWidgetItem::downloadWeb(const QString &fileUrl)
{
return mUniboardAPI->downloadWeb(fileUrl);
}
UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent) UBGraphicsAppleWidgetItem::UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent)
: UBGraphicsWidgetItem(parent) : UBGraphicsWidgetItem(parent)

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

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

Loading…
Cancel
Save