Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
unknown 13 years ago
commit e66bb1bc62
  1. 18
      src/api/UBWidgetUniboardAPI.cpp
  2. 10
      src/api/UBWidgetUniboardAPI.h
  3. 4
      src/board/UBBoardController.cpp
  4. 2
      src/board/UBBoardController.h
  5. 1
      src/board/UBBoardPaletteManager.h
  6. 3
      src/board/UBLibraryController.h
  7. 13
      src/core/UBApplication.cpp
  8. 1
      src/core/UBApplication.h
  9. 2
      src/core/UBDownloadManager.cpp
  10. 78
      src/gui/UBLibItemProperties.cpp
  11. 5
      src/gui/UBLibItemProperties.h
  12. 23
      src/gui/UBLibWebView.cpp
  13. 5
      src/gui/UBLibWebView.h
  14. 29
      src/gui/UBLibraryWidget.cpp
  15. 3
      src/gui/UBLibraryWidget.h

@ -15,6 +15,7 @@
#include "UBWidgetUniboardAPI.h" #include "UBWidgetUniboardAPI.h"
#include <QWebView> #include <QWebView>
#include <QDomDocument>
#include "core/UB.h" #include "core/UB.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
@ -24,6 +25,7 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBDrawingController.h" #include "board/UBDrawingController.h"
#include "board/UBBoardPaletteManager.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
@ -410,6 +412,22 @@ void UBWidgetUniboardAPI::response(bool correct)
// TODO: Implement this method // TODO: Implement this method
} }
void UBWidgetUniboardAPI::sendFileMetadata(QString metaData)
{
// Build the QMap of metadata and send it to application
QMap<QString, QString> qmMetaDatas;
QDomDocument domDoc;
domDoc.setContent(metaData);
QDomElement rootElem = domDoc.documentElement();
QDomNodeList children = rootElem.childNodes();
for(int i=0; i<children.size(); i++){
QDomNode dataNode = children.at(i);
QDomElement keyElem = dataNode.firstChildElement("key");
QDomElement valueElem = dataNode.firstChildElement("value");
qmMetaDatas[keyElem.text()] = valueElem.text();
}
UBApplication::boardController->displayMetaData(qmMetaDatas);
}
UBDocumentDatastoreAPI::UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget) UBDocumentDatastoreAPI::UBDocumentDatastoreAPI(UBGraphicsW3CWidgetItem *graphicsWidget)
: UBW3CWebStorage(graphicsWidget) : UBW3CWebStorage(graphicsWidget)

@ -224,6 +224,16 @@ class UBWidgetUniboardAPI : public QObject
void returnStatus(const QString& method, const QString& status); void returnStatus(const QString& method, const QString& status);
void usedMethods(QStringList methods); void usedMethods(QStringList methods);
void response(bool correct); void response(bool correct);
/**
* Give the file metadata to Sankore. The format must be
* <metbadata>
* <key>File Size</<key>
* <value>1024</value>
* </metadata>
*/
void sendFileMetadata(QString metaData);
private: private:
QString uuid(); QString uuid();

@ -2028,3 +2028,7 @@ void UBBoardController::onDownloadModalFinished()
} }
void UBBoardController::displayMetaData(QMap<QString, QString> metadatas)
{
emit displayMetadata(metadatas);
}

@ -148,6 +148,7 @@ class UBBoardController : public QObject
void notifyCache(bool visible); void notifyCache(bool visible);
void notifyPageChanged(); void notifyPageChanged();
void displayMetaData(QMap<QString, QString> metadatas);
public slots: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
@ -218,6 +219,7 @@ class UBBoardController : public QObject
void pageChanged(); void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc); void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index); void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata);
protected: protected:
void setupViews(); void setupViews();

@ -66,7 +66,6 @@ class UBBoardPaletteManager : public QObject
void startDownloads(); void startDownloads();
void stopDownloads(); void stopDownloads();
signals: signals:
void connectToDocController(); void connectToDocController();
void signal_changeMode(eUBDockPaletteWidgetMode newMode); void signal_changeMode(eUBDockPaletteWidgetMode newMode);

@ -63,6 +63,8 @@ public:
void setMoveable(bool bState){mbMoveable = bState;} void setMoveable(bool bState){mbMoveable = bState;}
bool isDeletable() const {return mbDeletable;} bool isDeletable() const {return mbDeletable;}
void setDeletable(bool mState) {mbDeletable = mState;} void setDeletable(bool mState) {mbDeletable = mState;}
void setMetadata(QMap<QString, QString> metadatas){mMetadata = metadatas;}
QMap<QString, QString> metadatas(){return mMetadata;}
private: private:
eUBLibElementType mType; eUBLibElementType mType;
@ -73,6 +75,7 @@ private:
QString mExtension; QString mExtension;
bool mbMoveable; bool mbMoveable;
bool mbDeletable; bool mbDeletable;
QMap<QString, QString> mMetadata;
}; };
class UBChainedLibElement class UBChainedLibElement

@ -652,3 +652,16 @@ QString UBApplication::urlFromHtml(QString html)
return url; return url;
} }
bool UBApplication::isFromWeb(QString url)
{
bool res = true;
if( url.startsWith("uniboardTool://") ||
url.startsWith("file://") ||
url.startsWith("/")){
res = false;
}
return res;
}

@ -89,6 +89,7 @@ class UBApplication : public QtSingleApplication
bool isVerbose() { return mIsVerbose;} bool isVerbose() { return mIsVerbose;}
void setVerbose(bool verbose){mIsVerbose = verbose;} void setVerbose(bool verbose){mIsVerbose = verbose;}
static QString urlFromHtml(QString html); static QString urlFromHtml(QString html);
static bool isFromWeb(QString url);
signals: signals:

@ -297,7 +297,7 @@ void UBDownloadManager::startFileDownload(sDownloadFileDesc desc)
connect(http, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onDownloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool))); connect(http, SIGNAL(downloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)), this, SLOT(onDownloadFinished(int, bool, QUrl, QString, QByteArray, QPointF, QSize, bool)));
// We send here the request and store its reply in order to be able to cancel it if needed // We send here the request and store its reply in order to be able to cancel it if needed
mReplies[desc.id] = http->get(QUrl(desc.url)); mReplies[desc.id] = http->get(QUrl(desc.url), desc.pos, desc.size, desc.isBackground);
} }
/** /**

@ -17,6 +17,7 @@
#include "UBLibItemProperties.h" #include "UBLibItemProperties.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBDownloadManager.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
@ -38,6 +39,7 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid
, mpThumbnail(NULL) , mpThumbnail(NULL)
, mpOrigPixmap(NULL) , mpOrigPixmap(NULL)
, mpElement(NULL) , mpElement(NULL)
, mpItem(NULL)
{ {
setObjectName(name); setObjectName(name);
@ -81,8 +83,11 @@ UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWid
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;"));
mpLayout->addWidget(mpObjInfoLabel, 0); mpLayout->addWidget(mpObjInfoLabel, 0);
mpObjInfos = new QTextEdit(this); mpObjInfos = new QTreeWidget(this);
mpObjInfos->setReadOnly(true); mpObjInfos->setColumnCount(2);
mpObjInfos->header()->hide();
mpObjInfos->setAlternatingRowColors(true);
mpObjInfos->setRootIsDecorated(false);
mpObjInfos->setObjectName("DockPaletteWidgetBox"); mpObjInfos->setObjectName("DockPaletteWidgetBox");
mpObjInfos->setStyleSheet("background:white;"); mpObjInfos->setStyleSheet("background:white;");
mpLayout->addWidget(mpObjInfos, 1); mpLayout->addWidget(mpObjInfos, 1);
@ -173,8 +178,18 @@ void UBLibItemProperties::adaptSize()
*/ */
void UBLibItemProperties::onAddToPage() void UBLibItemProperties::onAddToPage()
{ {
if(UBApplication::isFromWeb(mpElement->path().toString())){
sDownloadFileDesc desc;
desc.isBackground = false;
desc.modal = true;
desc.name = QFileInfo(mpElement->path().toString()).fileName();
desc.url = mpElement->path().toString();
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}else{
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget());
libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement); libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement);
}
} }
/** /**
@ -182,7 +197,14 @@ void UBLibItemProperties::onAddToPage()
*/ */
void UBLibItemProperties::onAddToLib() void UBLibItemProperties::onAddToLib()
{ {
if(UBApplication::isFromWeb(mpElement->path().toString())){
sDownloadFileDesc desc;
desc.isBackground = false;
desc.modal = false;
desc.name = QFileInfo(mpElement->path().toString()).fileName();
desc.url = mpElement->path().toString();
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
} }
/** /**
@ -190,8 +212,18 @@ void UBLibItemProperties::onAddToLib()
*/ */
void UBLibItemProperties::onSetAsBackground() void UBLibItemProperties::onSetAsBackground()
{ {
if(UBApplication::isFromWeb(mpElement->path().toString())){
sDownloadFileDesc desc;
desc.isBackground = true;
desc.modal = true;
desc.name = QFileInfo(mpElement->path().toString()).fileName();
desc.url = mpElement->path().toString();
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}else{
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget()); UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget()->parentWidget());
libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement); libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement);
}
} }
/** /**
@ -210,20 +242,23 @@ void UBLibItemProperties::showElement(UBLibElement *elem)
mpElement = elem; mpElement = elem;
mpOrigPixmap = new QPixmap(QPixmap::fromImage(*elem->thumbnail())); mpOrigPixmap = new QPixmap(QPixmap::fromImage(*elem->thumbnail()));
mpThumbnail->setPixmap(QPixmap::fromImage(*elem->thumbnail()).scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(QPixmap::fromImage(*elem->thumbnail()).scaledToWidth(THUMBNAIL_WIDTH));
mpObjInfos->setText(elem->information()); populateMetadata();
} }
if(UBFileSystemUtils::mimeTypeFromFileName(elem->path().toLocalFile()).contains("image")) if(UBApplication::isFromWeb(elem->path().toString())){
{ mpAddToLibButton->show();
// Show the Set as background button if(elem->metadatas()["Type"].toLower().contains("image")){
mpAddToLibButton->hide();
mpSetAsBackgroundButton->show(); mpSetAsBackgroundButton->show();
} }else{
else
{
// TODO: if we are browsing ONLINE objects, we must show mpAddToLibButton !
mpSetAsBackgroundButton->hide(); mpSetAsBackgroundButton->hide();
}
}else{
mpAddToLibButton->hide(); mpAddToLibButton->hide();
if(UBFileSystemUtils::mimeTypeFromFileName(elem->path().toLocalFile()).contains("image")){
mpSetAsBackgroundButton->show();
}else{
mpSetAsBackgroundButton->hide();
}
} }
} }
@ -245,6 +280,25 @@ void UBLibItemProperties::showEvent(QShowEvent *event)
adaptSize(); adaptSize();
} }
void UBLibItemProperties::populateMetadata()
{
if(NULL != mpObjInfos){
mpObjInfos->clear();
QMap<QString, QString> metas = mpElement->metadatas();
QList<QString> lKeys = metas.keys();
QList<QString> lValues = metas.values();
for(int i=0; i< metas.size(); i++){
QStringList values;
values << lKeys.at(i);
values << lValues.at(i);
mpItem = new QTreeWidgetItem(values);
mpObjInfos->addTopLevelItem(mpItem);
}
mpObjInfos->resizeColumnToContents(0);
}
}
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget

@ -25,6 +25,7 @@
#include <QToolButton> #include <QToolButton>
#include <QAction> #include <QAction>
#include <QShowEvent> #include <QShowEvent>
#include <QTreeWidget>
#include "board/UBLibraryController.h" #include "board/UBLibraryController.h"
@ -61,6 +62,7 @@ private slots:
private: private:
void adaptSize(); void adaptSize();
void populateMetadata();
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout; QHBoxLayout* mpButtonLayout;
@ -68,11 +70,12 @@ private:
UBLibItemButton* mpAddToLibButton; UBLibItemButton* mpAddToLibButton;
UBLibItemButton* mpSetAsBackgroundButton; UBLibItemButton* mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel; QLabel* mpObjInfoLabel;
QTextEdit* mpObjInfos; QTreeWidget* mpObjInfos;
QLabel* mpThumbnail; QLabel* mpThumbnail;
QPixmap* mpOrigPixmap; QPixmap* mpOrigPixmap;
int maxThumbHeight; int maxThumbHeight;
UBLibElement* mpElement; UBLibElement* mpElement;
QTreeWidgetItem* mpItem;
}; };

@ -1,6 +1,7 @@
#include <QDomDocument> #include <QDomDocument>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "UBLibWebView.h" #include "UBLibWebView.h"
@ -10,6 +11,7 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)
, mpWebSettings(NULL) , mpWebSettings(NULL)
, mpLayout(NULL) , mpLayout(NULL)
, mpSankoreAPI(NULL)
{ {
setObjectName(name); setObjectName(name);
@ -21,6 +23,8 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
mpView = new QWebView(this); mpView = new QWebView(this);
mpView->setObjectName("SearchEngineView"); mpView->setObjectName("SearchEngineView");
mpSankoreAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene());
mpView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", mpSankoreAPI);
mpWebSettings = QWebSettings::globalSettings(); mpWebSettings = QWebSettings::globalSettings();
mpWebSettings->setAttribute(QWebSettings::JavaEnabled, true); mpWebSettings->setAttribute(QWebSettings::JavaEnabled, true);
@ -33,17 +37,21 @@ UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true); mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
mpLayout->addWidget(mpView); mpLayout->addWidget(mpView);
connect(mpView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
} }
UBLibWebView::~UBLibWebView() UBLibWebView::~UBLibWebView()
{ {
if(NULL != mpView) if(NULL != mpSankoreAPI){
{ delete mpSankoreAPI;
mpSankoreAPI = NULL;
}
if(NULL != mpView){
delete mpView; delete mpView;
mpView = NULL; mpView = NULL;
} }
if(NULL != mpLayout) if(NULL != mpLayout){
{
delete mpLayout; delete mpLayout;
mpLayout = NULL; mpLayout = NULL;
} }
@ -85,3 +93,10 @@ void UBLibWebView::setElement(UBLibElement *elem)
mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName))); mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName)));
} }
} }
void UBLibWebView::onLoadFinished(bool ok)
{
if(ok && NULL != mpSankoreAPI){
mpView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", mpSankoreAPI);
}
}

@ -7,6 +7,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "board/UBLibraryController.h" #include "board/UBLibraryController.h"
#include "api/UBWidgetUniboardAPI.h"
class UBLibWebView : public QWidget class UBLibWebView : public QWidget
{ {
@ -18,10 +19,14 @@ public:
void setElement(UBLibElement* elem); void setElement(UBLibElement* elem);
private slots:
void onLoadFinished(bool ok);
private: private:
QWebView* mpView; QWebView* mpView;
QWebSettings* mpWebSettings; QWebSettings* mpWebSettings;
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
UBWidgetUniboardAPI* mpSankoreAPI;
}; };
#endif // UBLIBWEBVIEW_H #endif // UBLIBWEBVIEW_H

@ -23,6 +23,7 @@
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "board/UBLibraryController.h" #include "board/UBLibraryController.h"
#include "board/UBBoardPaletteManager.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
@ -41,6 +42,7 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW
, mpCrntDir(NULL) , mpCrntDir(NULL)
, mpCrntElem(NULL) , mpCrntElem(NULL)
, mLibraryController(NULL) , mLibraryController(NULL)
, mpTmpElem(NULL)
{ {
setObjectName(name); setObjectName(name);
setSpacing(5); setSpacing(5);
@ -52,21 +54,22 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW
*/ */
UBLibraryWidget::~UBLibraryWidget() UBLibraryWidget::~UBLibraryWidget()
{ {
if(NULL != mLibraryController) if(NULL != mLibraryController){
{
delete mLibraryController; delete mLibraryController;
mLibraryController = NULL; mLibraryController = NULL;
} }
if(NULL != mpCrntDir) if(NULL != mpCrntDir){
{
delete mpCrntDir; delete mpCrntDir;
mpCrntDir = NULL; mpCrntDir = NULL;
} }
if(NULL != mpCrntElem) if(NULL != mpCrntElem){
{
delete mpCrntElem; delete mpCrntElem;
mpCrntElem = NULL; mpCrntElem = NULL;
} }
if(NULL != mpTmpElem){
delete mpTmpElem;
mpTmpElem = NULL;
}
} }
/** /**
@ -86,6 +89,7 @@ void UBLibraryWidget::init()
connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int))); connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int)));
connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool,QUrl,QString,QByteArray))); connect(UBDownloadManager::downloadManager(), SIGNAL(addDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool,QUrl,QString,QByteArray)));
connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata(QMap<QString,QString>)));
} }
/** /**
@ -715,3 +719,16 @@ void UBLibraryWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl
dir.rmdir("tmp"); // Due to Qt, the directoy will be removed only if it's empty :) dir.rmdir("tmp"); // Due to Qt, the directoy will be removed only if it's empty :)
} }
} }
void UBLibraryWidget::onDisplayMetadata(QMap<QString, QString> metadatas)
{
mpTmpElem = new UBLibElement();
mpTmpElem->setMetadata(metadatas);
mpTmpElem->setPath(QUrl(metadatas["Url"]));
// As the content comes from the web (and need a download), we will not display its thumbnail.
mpTmpElem->setThumbnail(QImage(":images/libpalette/notFound.png"));
// Display the properties view
emit propertiesRequested(mpTmpElem);
}

@ -73,6 +73,8 @@ protected:
private slots: private slots:
void onItemClicked(QGraphicsItem* pItem, int index); void onItemClicked(QGraphicsItem* pItem, int index);
void onSelectionChanged(); void onSelectionChanged();
void onDisplayMetadata(QMap<QString,QString> metadatas);
private: private:
@ -86,6 +88,7 @@ private:
UBLibElement* mpCrntDir; UBLibElement* mpCrntDir;
UBLibElement* mpCrntElem; UBLibElement* mpCrntElem;
UBLibElement* mpTmpElem;
QList<UBLibElement*> mCurrentElems; QList<UBLibElement*> mCurrentElems;
QList<UBLibElement*> mOrigCurrentElems; QList<UBLibElement*> mOrigCurrentElems;
QList<QGraphicsItem*> mItems; QList<QGraphicsItem*> mItems;

Loading…
Cancel
Save