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

preferencesAboutTextFull
Claudio Valerio 12 years ago
commit fe5bd6f52e
  1. 20
      resources/library/interactivities/Contraste.wgt/css/basic.css
  2. BIN
      resources/library/interactivities/Contraste.wgt/images/trgDown.png
  3. BIN
      resources/library/interactivities/Contraste.wgt/images/trgRight.png
  4. 52
      resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
  5. 56
      resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
  6. 57
      resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
  7. 1
      src/adaptors/UBSvgSubsetAdaptor.cpp
  8. 22
      src/api/UBWidgetUniboardAPI.cpp
  9. 4
      src/api/UBWidgetUniboardAPI.h
  10. 20
      src/board/UBBoardPaletteManager.cpp
  11. 11
      src/board/UBBoardPaletteManager.h
  12. 46
      src/board/UBBoardView.cpp
  13. 850
      src/board/UBLibraryController.cpp
  14. 185
      src/board/UBLibraryController.h
  15. 2
      src/board/board.pri
  16. 1
      src/core/UBApplicationController.cpp
  17. 5
      src/domain/UBGraphicsScene.cpp
  18. 8
      src/domain/UBGraphicsWebView.cpp
  19. 1
      src/domain/UBGraphicsWebView.h
  20. 54
      src/domain/UBGraphicsWidgetItem.cpp
  21. 5
      src/domain/UBGraphicsWidgetItem.h
  22. 25
      src/gui/UBFeaturesActionBar.cpp
  23. 19
      src/gui/UBFeaturesActionBar.h
  24. 22
      src/gui/UBFeaturesWidget.cpp
  25. 10
      src/gui/UBFeaturesWidget.h
  26. 534
      src/gui/UBLibActionBar.cpp
  27. 120
      src/gui/UBLibActionBar.h
  28. 321
      src/gui/UBLibItemProperties.cpp
  29. 82
      src/gui/UBLibItemProperties.h
  30. 189
      src/gui/UBLibNavigatorWidget.cpp
  31. 57
      src/gui/UBLibNavigatorWidget.h
  32. 582
      src/gui/UBLibPathViewer.cpp
  33. 148
      src/gui/UBLibPathViewer.h
  34. 89
      src/gui/UBLibWebView.cpp
  35. 32
      src/gui/UBLibWebView.h
  36. 230
      src/gui/UBLibWidget.cpp
  37. 97
      src/gui/UBLibWidget.h
  38. 704
      src/gui/UBLibraryWidget.cpp
  39. 124
      src/gui/UBLibraryWidget.h
  40. 12
      src/gui/gui.pri

@ -60,6 +60,7 @@ body{
.shadowDiv{ .shadowDiv{
width: 100%; width: 100%;
height: 100%;
display: none; display: none;
opacity: 0.7; opacity: 0.7;
background-color: black; background-color: black;
@ -67,7 +68,10 @@ body{
-webkit-border-radius: 3px; -webkit-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
border-radius: 3px; border-radius: 3px;
z-index: 100; z-index: 400;
position: absolute;
top: 0;
left: 0;
} }
.popupBack{ .popupBack{
@ -126,8 +130,6 @@ body{
} }
.readyTask{ .readyTask{
margin: 2px;
padding: 2px;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
@ -167,9 +169,11 @@ body{
height: 65%; height: 65%;
cursor: e-resize; cursor: e-resize;
position: absolute; position: absolute;
background: none; background-image: url(../images/trgRight.png);
background-position: center;
background-repeat: no-repeat;
right: -10px; right: -10px;
top: 20%; top: 18%;
} }
.bottomResize{ .bottomResize{
@ -177,9 +181,11 @@ body{
height: 10px; height: 10px;
cursor: n-resize; cursor: n-resize;
position: absolute; position: absolute;
background: none; background-image: url(../images/trgDown.png);
background-position: center;
background-repeat: no-repeat;
bottom: -10px; bottom: -10px;
left: 20%; left: 18%;
} }
/*new design*/ /*new design*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

@ -82,9 +82,9 @@ function init(){
.css("left",importArray[i].left); .css("left",importArray[i].left);
tmpReadyTask.appendTo("#data"); tmpReadyTask.appendTo("#data");
} }
}
$(document).disableTextSelect(); $(document).disableTextSelect();
} }
}
/* ------------- BUTTONS -------------*/ /* ------------- BUTTONS -------------*/
@ -182,10 +182,16 @@ function init(){
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
shadowDiv.show("fast", function(){ if($("#wgt_help").hasClass("open")){
$("#help").slideUp("100", function(){
$("#wgt_help").removeClass("open");
$("#data").show();
});
}
shadowDiv.show()
shadowOver = true; shadowOver = true;
popupBack.show("slow"); popupBack.show("slow");
});
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -203,7 +209,7 @@ function init(){
var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data"); var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data");
//divs for adding a new item //divs for adding a new item
var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("#data"); var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("html");
var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data"); var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data");
//input fields and buttons for a popup window //input fields and buttons for a popup window
@ -228,37 +234,39 @@ function init(){
}); });
cancelButton.click(function(){ cancelButton.click(function(){
$(document).enableTextSelect();
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
$(document).enableTextSelect();
}); });
}); });
okButton.click(function(){ okButton.click(function(){
$(document).enableTextSelect();
if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){ if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
addTask(expresionText.val(), resultText.val()); addTask(expresionText.val(), resultText.val());
exportToSankore(); exportToSankore();
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
$(document).enableTextSelect();
}) })
} }
}); });
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
// a work with dragging possibility // a work with dragging possibility
$("input:text, .style_select").mouseover(function(){ $("input:text").mouseover(function(){
$(document).enableTextSelect(); $(document).enableTextSelect();
}); });
$("input:text, .style_select").mouseout(function(){ $("input:text").mouseout(function(){
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -270,6 +278,8 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect();
}); });
$(".rightResize").live("mousedown",function(event){ $(".rightResize").live("mousedown",function(event){
@ -297,12 +307,24 @@ function init(){
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver){
if(resizeObj.x) var top = event.pageY - coords.top;
var left = event.pageX - coords.left;
var bottom = top + dragElement.height();
var right = left + dragElement.width();
if(resizeObj.x){
if(right < ($(window).width() - 54))
dragElement.width(event.pageX - dragElement.position().left); dragElement.width(event.pageX - dragElement.position().left);
else if(resizeObj.y) }
else if(resizeObj.y){
if(bottom < ($(window).height() - 54))
dragElement.height(event.pageY - dragElement.position().top); dragElement.height(event.pageY - dragElement.position().top);
else }
dragElement.css("top",event.pageY - coords.top).css("left", event.pageX - coords.left); else {
if((top > 54) && (bottom < ($(window).height() - 54)))
dragElement.css("top",event.pageY - coords.top);
if((left >= 54) && (right < ($(window).width() - 54)))
dragElement.css("left", event.pageX - coords.left);
}
} }
}); });
@ -463,4 +485,6 @@ function changeStyle(val){
$("body, html").addClass("without_radius"); $("body, html").addClass("without_radius");
break; break;
} }
if($("#wgt_edit").hasClass("selected"))
$(document).enableTextSelect();
} }

@ -23,9 +23,9 @@ var sankoreLang = {
cancel: "Отмена", cancel: "Отмена",
wgt_name: "Черный/желтый", wgt_name: "Черный/желтый",
reload: "Обновить", reload: "Обновить",
slate: "Узор", slate: "узор",
pad: "Планшет", pad: "планшет",
none: "Нет", none: "нет",
help: "Помощь", help: "Помощь",
help_content: "Пример текста помощи ..." help_content: "Пример текста помощи ..."
}; };
@ -182,10 +182,16 @@ function init(){
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
shadowDiv.show("fast", function(){ if($("#wgt_help").hasClass("open")){
$("#help").slideUp("100", function(){
$("#wgt_help").removeClass("open");
$("#data").show();
});
}
shadowDiv.show()
shadowOver = true; shadowOver = true;
popupBack.show("slow"); popupBack.show("slow");
});
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -203,7 +209,7 @@ function init(){
var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data"); var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data");
//divs for adding a new item //divs for adding a new item
var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("#data"); var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("html");
var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data"); var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data");
//input fields and buttons for a popup window //input fields and buttons for a popup window
@ -228,37 +234,39 @@ function init(){
}); });
cancelButton.click(function(){ cancelButton.click(function(){
$(document).enableTextSelect();
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
$(document).enableTextSelect();
}); });
}); });
okButton.click(function(){ okButton.click(function(){
$(document).enableTextSelect();
if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){ if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
addTask(expresionText.val(), resultText.val()); addTask(expresionText.val(), resultText.val());
exportToSankore(); exportToSankore();
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
$(document).enableTextSelect();
}) })
} }
}); });
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
// a work with dragging possibility // a work with dragging possibility
$("input:text, .style_select").mouseover(function(){ $("input:text").mouseover(function(){
$(document).enableTextSelect(); $(document).enableTextSelect();
}); });
$("input:text, .style_select").mouseout(function(){ $("input:text").mouseout(function(){
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -270,6 +278,8 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect();
}); });
$(".rightResize").live("mousedown",function(event){ $(".rightResize").live("mousedown",function(event){
@ -297,12 +307,24 @@ function init(){
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver){
if(resizeObj.x) var top = event.pageY - coords.top;
var left = event.pageX - coords.left;
var bottom = top + dragElement.height();
var right = left + dragElement.width();
if(resizeObj.x){
if(right < ($(window).width() - 54))
dragElement.width(event.pageX - dragElement.position().left); dragElement.width(event.pageX - dragElement.position().left);
else if(resizeObj.y) }
else if(resizeObj.y){
if(bottom < ($(window).height() - 54))
dragElement.height(event.pageY - dragElement.position().top); dragElement.height(event.pageY - dragElement.position().top);
else }
dragElement.css("top",event.pageY - coords.top).css("left", event.pageX - coords.left); else {
if((top > 54) && (bottom < ($(window).height() - 54)))
dragElement.css("top",event.pageY - coords.top);
if((left >= 54) && (right < ($(window).width() - 54)))
dragElement.css("left", event.pageX - coords.left);
}
} }
}); });
@ -463,4 +485,6 @@ function changeStyle(val){
$("body, html").addClass("without_radius"); $("body, html").addClass("without_radius");
break; break;
} }
if($("#wgt_edit").hasClass("selected"))
$(document).enableTextSelect();
} }

@ -23,9 +23,9 @@ var sankoreLang = {
cancel: "Cancel", cancel: "Cancel",
wgt_name: "Contrast", wgt_name: "Contrast",
reload: "Reload", reload: "Reload",
slate: "Wood", slate: "wood",
pad: "Pad", pad: "pad",
none: "None", none: "none",
help: "Help", help: "Help",
help_content: "This is an example of help content ..." help_content: "This is an example of help content ..."
}; };
@ -88,11 +88,14 @@ function init(){
/* ------------- BUTTONS -------------*/ /* ------------- BUTTONS -------------*/
if(window.sankore){
if(sankore.preference("by_style","")){ if(sankore.preference("by_style","")){
changeStyle(sankore.preference("by_style","")); changeStyle(sankore.preference("by_style",""));
$(".style_select").val(sankore.preference("by_style","")); $(".style_select").val(sankore.preference("by_style",""));
} else } else
changeStyle("3") changeStyle("3")
} else
changeStyle("3")
$("#wgt_display, #wgt_edit").click(function(event){ $("#wgt_display, #wgt_edit").click(function(event){
if(this.id == "wgt_display"){ if(this.id == "wgt_display"){
@ -182,10 +185,15 @@ function init(){
}); });
$("#wgt_add").click(function(){ $("#wgt_add").click(function(){
shadowDiv.show("fast", function(){ if($("#wgt_help").hasClass("open")){
$("#help").slideUp("100", function(){
$("#wgt_help").removeClass("open");
$("#data").show();
});
}
shadowDiv.show();
shadowOver = true; shadowOver = true;
popupBack.show("slow"); popupBack.show("slow");
});
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -203,7 +211,7 @@ function init(){
var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data"); var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data");
//divs for adding a new item //divs for adding a new item
var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("#data"); var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("html");
var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data"); var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data");
//input fields and buttons for a popup window //input fields and buttons for a popup window
@ -228,25 +236,25 @@ function init(){
}); });
cancelButton.click(function(){ cancelButton.click(function(){
$(document).enableTextSelect();
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
$(document).enableTextSelect();
}); });
}); });
okButton.click(function(){ okButton.click(function(){
$(document).enableTextSelect();
if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){ if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){
popupBack.hide("slow", function(){ popupBack.hide("slow", function(){
shadowDiv.hide("fast"); shadowDiv.hide();
shadowOver = false; shadowOver = false;
addTask(expresionText.val(), resultText.val()); addTask(expresionText.val(), resultText.val());
exportToSankore(); exportToSankore();
$("#resultText, #expresionText").val("") $("#resultText, #expresionText").val("")
.css("background-color", "#ffc"); .css("background-color", "#ffc");
$(document).enableTextSelect();
}) })
} }
}); });
@ -254,11 +262,11 @@ function init(){
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
// a work with dragging possibility // a work with dragging possibility
$("input:text, .style_select").mouseover(function(){ $("input:text").mouseover(function(){
$(document).enableTextSelect(); $(document).enableTextSelect();
}); });
$("input:text, .style_select").mouseout(function(){ $("input:text").mouseout(function(){
$(document).disableTextSelect(); $(document).disableTextSelect();
}); });
@ -270,6 +278,8 @@ function init(){
resizeObj.width = $(this).width(); resizeObj.width = $(this).width();
resizeObj.height = $(this).height(); resizeObj.height = $(this).height();
} }
if($("#wgt_display").hasClass("selected"))
$(document).disableTextSelect();
}); });
$(".rightResize").live("mousedown",function(event){ $(".rightResize").live("mousedown",function(event){
@ -297,12 +307,24 @@ function init(){
$("body").mousemove(function(event){ $("body").mousemove(function(event){
if(dragElement && !shadowOver){ if(dragElement && !shadowOver){
if(resizeObj.x) var top = event.pageY - coords.top;
var left = event.pageX - coords.left;
var bottom = top + dragElement.height();
var right = left + dragElement.width();
if(resizeObj.x){
if(right < ($(window).width() - 54))
dragElement.width(event.pageX - dragElement.position().left); dragElement.width(event.pageX - dragElement.position().left);
else if(resizeObj.y) }
else if(resizeObj.y){
if(bottom < ($(window).height() - 54))
dragElement.height(event.pageY - dragElement.position().top); dragElement.height(event.pageY - dragElement.position().top);
else }
dragElement.css("top",event.pageY - coords.top).css("left", event.pageX - coords.left); else {
if((top > 54) && (bottom < ($(window).height() - 54)))
dragElement.css("top",event.pageY - coords.top);
if((left >= 54) && (right < ($(window).width() - 54)))
dragElement.css("left", event.pageX - coords.left);
}
} }
}); });
@ -375,6 +397,7 @@ function init(){
}); });
} }
} }
if(window.sankore)
sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport)); sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport));
} }
} }
@ -463,4 +486,6 @@ function changeStyle(val){
$("body, html").addClass("without_radius"); $("body, html").addClass("without_radius");
break; break;
} }
if($("#wgt_edit").hasClass("selected"))
$(document).enableTextSelect();
} }

@ -1194,6 +1194,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); UBGraphicsStrokesGroup* strokesGroupItem = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item);
if(strokesGroupItem && strokesGroupItem->isVisible()){ if(strokesGroupItem && strokesGroupItem->isVisible()){
mXmlWriter.writeStartElement("g"); mXmlWriter.writeStartElement("g");
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(strokesGroupItem->uuid()));
QMatrix matrix = item->sceneMatrix(); QMatrix matrix = item->sceneMatrix();
if (!matrix.isIdentity()){ if (!matrix.isIdentity()){
mXmlWriter.writeAttribute("transform", toSvgTransform(matrix)); mXmlWriter.writeAttribute("transform", toSvgTransform(matrix));

@ -476,7 +476,7 @@ void UBWidgetUniboardAPI::enableDropOnWidget(bool enable)
} }
} }
void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event) void UBWidgetUniboardAPI::ProcessDropEvent(QGraphicsSceneDragDropEvent *event)
{ {
const QMimeData *pMimeData = event->mimeData(); const QMimeData *pMimeData = event->mimeData();
@ -485,11 +485,12 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
bool downloaded = false; bool downloaded = false;
QGraphicsView *tmpView = mGraphicsWidget->scene()->views().at(0); QGraphicsView *tmpView = mGraphicsWidget->scene()->views().at(0);
QPoint dropPoint(mGraphicsWidget->mapFromScene(tmpView->mapToScene(event->pos())).toPoint()); QPoint dropPoint(mGraphicsWidget->mapFromScene(tmpView->mapToScene(event->pos().toPoint())).toPoint());
Qt::DropActions dropActions = event->dropAction(); Qt::DropActions dropActions = event->possibleActions();
Qt::MouseButtons dropMouseButtons = event->mouseButtons(); Qt::MouseButtons dropMouseButtons = event->buttons();
Qt::KeyboardModifiers dropModifiers = event->keyboardModifiers(); Qt::KeyboardModifiers dropModifiers = event->modifiers();
QMimeData dropMimeData; QMimeData *dropMimeData = new QMimeData;
qDebug() << event->possibleActions();
if (pMimeData->hasHtml()) { //Dropping element from web browser if (pMimeData->hasHtml()) { //Dropping element from web browser
@ -510,7 +511,7 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
desc.name = QFileInfo(url).fileName(); desc.name = QFileInfo(url).fileName();
desc.totalSize = 0; // The total size will be retrieved during the download desc.totalSize = 0; // The total size will be retrieved during the download
desc.dropPoint = event->pos(); //Passing pure event point. No modifications desc.dropPoint = event->pos().toPoint(); //Passing pure event point. No modifications
desc.dropActions = dropActions; desc.dropActions = dropActions;
desc.dropMouseButtons = dropMouseButtons; desc.dropMouseButtons = dropMouseButtons;
desc.dropModifiers = dropModifiers; desc.dropModifiers = dropModifiers;
@ -542,12 +543,9 @@ void UBWidgetUniboardAPI::ProcessDropEvent(QDropEvent *event)
} }
qDebug() << destFileName; qDebug() << destFileName;
QString mimeText = createMimeText(downloaded, contentType, destFileName); QString mimeText = createMimeText(downloaded, contentType, destFileName);
dropMimeData.setData(tMimeText, mimeText.toAscii()); dropMimeData->setData(tMimeText, mimeText.toAscii());
QDropEvent readyEvent(dropPoint, dropActions, &dropMimeData, dropMouseButtons, dropModifiers); event->setMimeData(dropMimeData);
//sending event to destination either it had been downloaded or not
QApplication::sendEvent(mGraphicsWidget,&readyEvent);
readyEvent.acceptProposedAction();
} }
void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData) void UBWidgetUniboardAPI::onDownloadFinished(bool pSuccess, sDownloadFileDesc desc, QByteArray pData)

@ -16,7 +16,7 @@
#define UBWIDGETAPI_H #define UBWIDGETAPI_H
#include <QtCore> #include <QtCore>
#include <QDropEvent> #include <QGraphicsSceneDragDropEvent>
#include "UBW3CWidgetAPI.h" #include "UBW3CWidgetAPI.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
@ -246,7 +246,7 @@ class UBWidgetUniboardAPI : public QObject
* When an object is dropped on a widget, this one send us the informations to download it locally. * When an object is dropped on a widget, this one send us the informations to download it locally.
* 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
*/ */
void ProcessDropEvent(QDropEvent *); void ProcessDropEvent(QGraphicsSceneDragDropEvent *);
bool isDropableData(const QMimeData *pMimeData) const; bool isDropableData(const QMimeData *pMimeData) const;
private slots: private slots:

@ -82,12 +82,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mPendingPanButtonPressed(false) , mPendingPanButtonPressed(false)
, mPendingEraseButtonPressed(false) , mPendingEraseButtonPressed(false)
, mpPageNavigWidget(NULL) , mpPageNavigWidget(NULL)
//#ifdef USE_WEB_WIDGET
, mpLibWidget(NULL)
//#endif
, mpCachePropWidget(NULL) , mpCachePropWidget(NULL)
, mpDownloadWidget(NULL) , mpDownloadWidget(NULL)
, mpDesktopLibWidget(NULL)
, mpTeacherGuideWidget(NULL) , mpTeacherGuideWidget(NULL)
, mDownloadInProgress(false) , mDownloadInProgress(false)
{ {
@ -100,18 +96,11 @@ UBBoardPaletteManager::~UBBoardPaletteManager()
{ {
delete mAddItemPalette; delete mAddItemPalette;
if(NULL != mStylusPalette) if(NULL != mStylusPalette)
{ {
delete mStylusPalette; delete mStylusPalette;
mStylusPalette = NULL; mStylusPalette = NULL;
} }
if(NULL != mpDesktopLibWidget)
{
delete mpDesktopLibWidget;
mpDesktopLibWidget = NULL;
}
} }
void UBBoardPaletteManager::initPalettesPosAtStartup() void UBBoardPaletteManager::initPalettesPosAtStartup()
@ -135,10 +124,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget = new UBPageNavigationWidget(); mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget();
#endif
mpCachePropWidget = new UBCachePropertiesWidget(); mpCachePropWidget = new UBCachePropertiesWidget();
mpDownloadWidget = new UBDockDownloadWidget(); mpDownloadWidget = new UBDockDownloadWidget();
@ -719,8 +704,9 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mAddItemPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mAddItemPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->lower(); // Maybe threre is a reason to keep that functions but with them right palette in desktop mode is not interactable
mLeftPalette->lower(); // mRightPalette->lower();
// mLeftPalette->lower();
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {

@ -22,7 +22,6 @@
#include "gui/UBLeftPalette.h" #include "gui/UBLeftPalette.h"
#include "gui/UBRightPalette.h" #include "gui/UBRightPalette.h"
#include "gui/UBPageNavigationWidget.h" #include "gui/UBPageNavigationWidget.h"
#include "gui/UBLibWidget.h"
#include "gui/UBCachePropertiesWidget.h" #include "gui/UBCachePropertiesWidget.h"
#include "gui/UBDockDownloadWidget.h" #include "gui/UBDockDownloadWidget.h"
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
@ -136,11 +135,6 @@ class UBBoardPaletteManager : public QObject
/** The page navigator widget */ /** The page navigator widget */
UBPageNavigationWidget* mpPageNavigWidget; UBPageNavigationWidget* mpPageNavigWidget;
//#ifdef USE_WEB_WIDGET
/** The library widget */
UBLibWidget* mpLibWidget;
//#endif
/** The cache properties widget */ /** The cache properties widget */
UBCachePropertiesWidget* mpCachePropWidget; UBCachePropertiesWidget* mpCachePropWidget;
@ -148,11 +142,6 @@ class UBBoardPaletteManager : public QObject
/** The download widget */ /** The download widget */
UBDockDownloadWidget* mpDownloadWidget; 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!
UBLibWidget* mpDesktopLibWidget;
UBDockTeacherGuideWidget* mpTeacherGuideWidget; UBDockTeacherGuideWidget* mpTeacherGuideWidget;
bool mDownloadInProgress; bool mDownloadInProgress;

@ -1205,55 +1205,21 @@ UBBoardView::drawItems (QPainter *painter, int numItems,
void UBBoardView::dragMoveEvent(QDragMoveEvent *event) void UBBoardView::dragMoveEvent(QDragMoveEvent *event)
{ {
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); QGraphicsView::dragMoveEvent(event);
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget) {
if (graphicsWidget->acceptDrops()) {
if (!mOkOnWidget) {
if (!graphicsWidget->isDropableData(event->mimeData())) {
mOkOnWidget = false;
event->ignore();
return;
} else {
mOkOnWidget = true;
}
}
QPoint newPoint(graphicsWidget->mapFromScene(mapToScene(event->pos())).toPoint());
QDragMoveEvent newEvent(newPoint, event->dropAction(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
QApplication::sendEvent(graphicsWidget,&newEvent);
} else {
mOkOnWidget = false;
event->ignore();
}
} else {
event->acceptProposedAction(); event->acceptProposedAction();
mOkOnWidget = false;
}
} }
void UBBoardView::dropEvent (QDropEvent *event) void UBBoardView::dropEvent (QDropEvent *event)
{ {
mOkOnWidget = false; if (!itemAt(event->pos().x(),event->pos().y())) {
QGraphicsItem* graphicsItemAtPos = itemAt(event->pos().x(),event->pos().y()); if (!event->source() || dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<QWebView*>(event->source()) || dynamic_cast<UBTGMediaWidget*>(event->source()) || dynamic_cast<QListView *>(event->source()) || dynamic_cast<UBTGDraggableTreeItem*>(event->source())) {
UBGraphicsWidgetItem* graphicsWidget = dynamic_cast<UBGraphicsWidgetItem*>(graphicsItemAtPos);
if (graphicsWidget && graphicsWidget->acceptDrops()) {
graphicsWidget->processDropEvent(event);
event->acceptProposedAction();
} else if (!event->source()
|| dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source())
|| dynamic_cast<UBTGMediaWidget*>(event->source())
|| dynamic_cast<QListView *>(event->source())
|| dynamic_cast<UBTGDraggableTreeItem*>(event->source())) {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction(); event->acceptProposedAction();
} }
} }
else
QGraphicsView::dropEvent(event);
}
void void
UBBoardView::resizeEvent (QResizeEvent * event) UBBoardView::resizeEvent (QResizeEvent * event)

@ -1,850 +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 2 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 "UBLibraryController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "core/UBSettings.h"
#include "core/UBSetting.h"
#include "core/UBApplicationController.h"
#include "core/UBDownloadManager.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsMediaItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "tools/UBToolsManager.h"
#include "board/UBBoardView.h"
#include "UBBoardController.h"
#include "gui/UBThumbnailWidget.h"
#include "../core/UBSettings.h"
#include "core/memcheck.h"
static quint32 magicNumber = 0xACDCAFE0;
static QString favoriteVirtualPath = "$favorite$";
UBLibraryController::UBLibraryController(QWidget *pParentWidget) :
QObject(pParentWidget),
mParentWidget(pParentWidget),
mBoardController(UBApplication::boardController),
mLastItemOffsetIndex(0)
{
readFavoriteList();
mAudioStandardDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAudioDirectory());
mVideoStandardDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userVideoDirectory());
mPicturesStandardDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userImageDirectory());
mInteractiveUserDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userInteractiveDirectory());
mAnimationUserDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAnimationDirectory());
createInternalWidgetItems();
}
bool UBLibraryController::canItemsOnElementBeDeleted(UBLibElement *pElement)
{
return !pElement->path().toLocalFile().startsWith(UBSettings::settings()->applicationShapeLibraryDirectory()) &&
!pElement->path().toLocalFile().startsWith(UBSettings::settings()->applicationInteractivesDirectory()) &&
pElement->isDeletable();
}
void UBLibraryController::createInternalWidgetItems()
{
QStringList toolUris = UBToolsManager::manager()->allToolIDs();
foreach(QString toolUri, toolUris)
{
UBToolsManager::UBToolDescriptor tool = UBToolsManager::manager()->toolByID(toolUri);
UBLibElement *newTool = new UBLibElement(eUBLibElementType_InteractiveItem, QUrl(tool.id), tool.label);
QImage toolImage = tool.icon.toImage();
newTool->setThumbnail(toolImage);
newTool->setInformation(tool.label + " " + tool.version);
mInternalLibElements << newTool;
}
}
void UBLibraryController::createNewFolder(QString name, UBLibElement *parentElem)
{
Q_ASSERT(parentElem);
Q_ASSERT(parentElem->type() == eUBLibElementType_Folder);
QUrl qsPath = QUrl::fromLocalFile(parentElem->path().toLocalFile() + "/" + name);
createDirectory(qsPath);
}
void UBLibraryController::createDirectory(QUrl& pDirPath)
{
if(!QFileInfo(pDirPath.toLocalFile()).exists())
QDir().mkpath(pDirPath.toLocalFile());
}
QString UBLibraryController::getBaseDestinationForItem(QString& pItem)
{
QString destination("");
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(pItem);
if(mimetype.contains("audio"))
destination = mAudioStandardDirectoryPath.toLocalFile();
else if (mimetype.contains("video"))
destination = mVideoStandardDirectoryPath.toLocalFile();
else if (mimetype.contains("image"))
destination = mPicturesStandardDirectoryPath.toLocalFile();
else if (mimetype.contains("application")){
if (mimetype.contains("x-shockwave-flash"))
destination = mAnimationUserDirectoryPath.toLocalFile();
else
destination = mInteractiveUserDirectoryPath.toLocalFile();
}
return destination;
}
void UBLibraryController::routeDataItem(QString& pItem, QByteArray pData)
{
QString fileName = QFileInfo(pItem).fileName();
QString destination = getBaseDestinationForItem(pItem);
if(!destination.isEmpty()){
QString destinationPath = UBFileSystemUtils::normalizeFilePath(QString("%0/%1").arg(destination).arg(fileName));
QFile file(destinationPath);
if(file.open(QIODevice::WriteOnly)) {
file.write(pData);
file.close();
}
}
else
qWarning() << "no destination found for pItem " << pItem;
}
void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory)
{
QFileInfo itemToRoute(pItem);
QString destination = getBaseDestinationForItem(pItem);
if(!destination.isEmpty()){
if(!pMiddleDirectory.isEmpty()){
destination = destination + "/" + pMiddleDirectory;
QUrl url = QUrl::fromLocalFile(destination);
createDirectory(url);
}
destination = UBFileSystemUtils::normalizeFilePath(destination + "/" + itemToRoute.fileName());
UBFileSystemUtils::copyFile(QUrl(pItem).toLocalFile(), destination, false);
}
}
void UBLibraryController::importImageOnLibrary(QImage& pImage)
{
if(!pImage.isNull()){
QDateTime now = QDateTime::currentDateTime();
QString filePath = mPicturesStandardDirectoryPath.toLocalFile() + "/" + tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss") + ".png";
filePath = UBFileSystemUtils::normalizeFilePath(filePath);
pImage.save(filePath);
UBApplication::showMessage(tr("Added 1 Image to Library"));
emit updateItemsList();
}
}
void UBLibraryController::importItemOnLibrary(QString& pItemString)
{
pItemString.replace("\r","");
pItemString.replace("\n","");
QFileInfo itemToImport(pItemString);
bool isZip = false;
if(itemToImport.isDir() || (isZip = UBFileSystemUtils::isAZipFile(pItemString))){
if(pItemString.contains(".wgt",Qt::CaseInsensitive) || pItemString.contains(".wdgt",Qt::CaseInsensitive)){
QString destination = UBSettings::settings()->userInteractiveDirectory() + "/" + itemToImport.fileName();
if(isZip)
UBFileSystemUtils::expandZipToDir(pItemString,destination);
else{
if(pItemString.endsWith("/")) pItemString.chop(1);
UBFileSystemUtils::copyDir(pItemString, destination + QFileInfo(pItemString).fileName() + "/");
}
return;
}
QStringList allFiles = UBFileSystemUtils::allFiles(pItemString);
QString pathBeforeCurrentDir = pItemString;
pathBeforeCurrentDir.replace(UBFileSystemUtils::lastPathComponent(pathBeforeCurrentDir), "");
if(pathBeforeCurrentDir.endsWith("//"))
pathBeforeCurrentDir.chop(1);
foreach(QString eachFile, allFiles){
QString intermediateDirectory = eachFile;
intermediateDirectory = intermediateDirectory.remove(pathBeforeCurrentDir);
intermediateDirectory = intermediateDirectory.remove(QFileInfo(eachFile).fileName());
routeItem(eachFile,intermediateDirectory);
}
}
else{
if(pItemString.startsWith("uniboardTool://") || pItemString.startsWith("file://") || pItemString.startsWith("/"))
{
// The user dropped a local file
routeItem(pItemString);
}
else
{
// The user dropped a file from the web. We must download it.
sDownloadFileDesc desc;
desc.currentSize = 0;
desc.id = 0;
desc.isBackground = false;
desc.modal = false;
desc.name = QFileInfo(pItemString).fileName();
desc.totalSize = 0;
desc.url = pItemString;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
}
}
}
QList<UBLibElement*> UBLibraryController::rootCategoriesList()
{
QList<UBLibElement*> categories;
UBLibElement* element = new UBLibElement(eUBLibElementType_Folder, mAudioStandardDirectoryPath, tr("Audios", "Audio category element"));
element->setThumbnail(QImage(":images/libpalette/AudiosCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mVideoStandardDirectoryPath, tr("Movies", "Movies category element"));
element->setThumbnail(QImage(":images/libpalette/MoviesCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mPicturesStandardDirectoryPath, tr("Pictures", "Pictures category element"));
element->setThumbnail(QImage(":images/libpalette/PicturesCategory.svg"));
element->setMoveable(false);
categories << element;
QString path = UBSettings::settings()->applicationShapeLibraryDirectory();
element = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(path), tr("Shapes", "Shapes category element"));
element->setThumbnail(QImage(":images/libpalette/ShapesCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveUserDirectoryPath, tr("Applications", "Applications category element"));
element->setThumbnail(QImage(":images/libpalette/ApplicationsCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_VirtualFolder, favoriteVirtualPath, tr("Favorite", "Favorite category element"));
element->setThumbnail(QImage(":images/libpalette/FavoritesCategory.svg"));
element->setMoveable(false);
categories << element;
mInteractiveCategoryPath = QUrl::fromLocalFile(UBSettings::settings()->userGipLibraryDirectory());
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveCategoryPath, tr("Interactivities", "Interactives category element"));
element->setThumbnail(QImage(":images/libpalette/InteractivesCategory.svg"));
element->setMoveable(false);
categories << element;
mSearchCategoryPath = QUrl::fromLocalFile(UBSettings::userSearchDirectory());
element = new UBLibElement(eUBLibElementType_Folder, mSearchCategoryPath, tr("Web Search", "Web search category element"));
element->setThumbnail(QImage(":images/libpalette/WebSearchCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mAnimationUserDirectoryPath, tr("Animations", "Animations category element"));
element->setThumbnail(QImage(":images/libpalette/FlashCategory.svg"));
element->setMoveable(false);
categories << element;
categories << UBLibElement::trashElement();
return categories;
}
QImage UBLibraryController::createThumbnail(UBLibElement* pElement)
{
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile());
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(pElement->path().toLocalFile());
if (mimetype.contains("audio"))
thumbnailPath = ":images/libpalette/soundIcon.svg";
else if (mimetype.contains("video"))
thumbnailPath = ":images/libpalette/movieIcon.svg";
else {
if (pElement->extension().startsWith("svg", Qt::CaseInsensitive) || pElement->extension().startsWith("svgz", Qt::CaseInsensitive)) {
thumbnailPath = pElement->path().toLocalFile();
UBThumbnailSvg(pElement->path().toLocalFile());
}
else {
QPixmap pix(pElement->path().toLocalFile());
if (!pix.isNull()) {
pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation);
pix.save(thumbnailPath);
UBThumbnailPixmap pixmap(pix);
UBPlatformUtils::hideFile(thumbnailPath);
UBApplication::showMessage(tr("Creating image thumbnail for %1.").arg(pElement->name()));
}
else{
thumbnailPath = ":images/libpalette/notFound.png";
}
}
}
return QImage(thumbnailPath);
}
QImage UBLibraryController::thumbnailForFile(UBLibElement* pElement)
{
if (pElement->path().toString().contains("uniboardTool://")){
QImage image = QImage(UBToolsManager::manager()->iconFromToolId(pElement->path().toString()));
return image;
}
if (pElement->type() == eUBLibElementType_InteractiveItem){
QImage image = QImage(UBGraphicsWidgetItem::iconFilePath(pElement->path()));
return image;
}
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile());
if (!thumbnailPath.length())
qWarning() << "thumbnailForFile impossible to create thumbnail path for the element " + pElement->path().toLocalFile();
if (QFileInfo(thumbnailPath).exists())
return QImage(thumbnailPath);
else
return createThumbnail(pElement);
}
QList<UBLibElement*> UBLibraryController::addVirtualElementsForItemPath(const QString& pPath)
{
QList<UBLibElement*> content;
if (pPath == mInteractiveUserDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->applicationApplicationsLibraryDirectory());
content << listElementsInPath(UBSettings::settings()->userInteractiveFavoritesDirectory());
foreach(UBLibElement* eachElement, mInternalLibElements)
content << new UBLibElement(eachElement);
}
else if (pPath == mPicturesStandardDirectoryPath.toLocalFile()){
QUrl path = QUrl::fromLocalFile(UBSettings::settings()->applicationImageLibraryDirectory());
content << listElementsInPath(path.toLocalFile());
}
else if (pPath == mInteractiveCategoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->applicationInteractivesDirectory());
}
else if (pPath == mAudioStandardDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->applicationAudiosLibraryDirectory());
}
else if (pPath == mVideoStandardDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->applicationVideosLibraryDirectory());
}
else if (pPath == mAnimationUserDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->applicationAnimationsLibraryDirectory());
}
return content;
}
QList<UBLibElement*> UBLibraryController::listElementsInPath(const QString& pPath)
{
QList<UBLibElement*> content;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(pPath);
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
eUBLibElementType fileType = fileInfo->isDir() ? eUBLibElementType_Folder : eUBLibElementType_Item;
QString itemName = fileInfo->fileName();
QString extension="";
if (UBFileSystemUtils::mimeTypeFromFileName(itemName).contains("application")) {
fileType = eUBLibElementType_InteractiveItem;
itemName = fileInfo->baseName();
extension = fileInfo->completeSuffix();
}
UBLibElement *element = new UBLibElement(fileType, QUrl::fromLocalFile(fileInfo->absoluteFilePath()), itemName);
if(!extension.isEmpty())
element->setExtension(extension);
if (fileType == eUBLibElementType_Folder) {
element->setThumbnail(QImage(":images/libpalette/folder.svg"));
}
else if (fileType == eUBLibElementType_Item) {
if (element->path().toLocalFile().contains(".thumbnail."))
continue;
element->setThumbnail(thumbnailForFile(element));
}
content << element;
}
content << addVirtualElementsForItemPath(pPath);
return content;
}
QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement)
{
Q_UNUSED(pElement);
QList<UBLibElement*> copyOfTheFavoriteList;
foreach(UBLibElement* eachElement, mFavoriteList)
copyOfTheFavoriteList << new UBLibElement(eachElement);
return copyOfTheFavoriteList;
}
void UBLibraryController::moveContent(QList<UBLibElement*> sourceList, UBLibElement *pDestination)
{
if (pDestination->type() != eUBLibElementType_Folder)
qWarning() << "moveContent the destination element isn't a directory";
foreach (UBLibElement* eachSource, sourceList) {
if (!eachSource || pDestination->path().toLocalFile() == eachSource->path().toLocalFile() || eachSource->type() == eUBLibElementType_VirtualFolder)
continue;
if (QFileInfo(eachSource->path().toLocalFile()).isDir())
UBFileSystemUtils::moveDir(eachSource->path().toLocalFile(), pDestination->path().toLocalFile() + "/" + eachSource->name());
else {
QFile(eachSource->path().toLocalFile()).copy(pDestination->path().toLocalFile() + "/" + eachSource->name() + "." + eachSource->extension());
QFile::remove(eachSource->path().toLocalFile());
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(eachSource->path().toLocalFile());
if (thumbnailPath.length() && QFileInfo(thumbnailPath).exists()) {
QString thumbnailFileName = UBFileSystemUtils::lastPathComponent(thumbnailPath);
QFile(thumbnailPath).copy(pDestination->path().toLocalFile() + "/" + thumbnailFileName);
QFile::remove(thumbnailPath);
}
}
}
}
void UBLibraryController::trashElements(QList<UBLibElement*> trashList)
{
moveContent(trashList, UBLibElement::trashElement());
removeFromFavorite(trashList);
}
void UBLibraryController::emptyElementsOnTrash( QList<UBLibElement*> elementsList)
{
foreach(UBLibElement* eachElement, elementsList) {
if (QFileInfo(eachElement->path().toLocalFile()).isDir())
UBFileSystemUtils::deleteDir(eachElement->path().toLocalFile());
else
QFile::remove(eachElement->path().toLocalFile());
}
}
void UBLibraryController::cleanElementsList()
{
qDeleteAll(mElementsList);
mElementsList.clear();
}
QList<UBLibElement*> UBLibraryController::getContent(UBLibElement *element)
{
cleanElementsList();
switch (element->type()) {
case eUBLibElementType_Category: {
mElementsList = rootCategoriesList();
break;
}
case eUBLibElementType_VirtualFolder: {
mElementsList = listElementsInVirtualForlder(element);
break;
}
case eUBLibElementType_Folder: {
mElementsList = listElementsInPath(element->path().toLocalFile());
break;
}
case eUBLibElementType_Item: {
qWarning() << "You are browsing a file";
break;
}
default:
// We should never come here...
Q_ASSERT(false);
break;
}
return mElementsList;
}
UBLibraryController::~UBLibraryController()
{
cleanElementsList();
qDeleteAll(mInternalLibElements);
mInternalLibElements.clear();
}
void UBLibraryController::setItemAsBackground(UBLibElement* image)
{
if (!activeScene()){
qDebug() << "No active scene";
return;
}
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(image->path().toLocalFile());
if(mimeType == "image/svg+xml"){
QUrl url(QUrl::fromLocalFile(image->path().toLocalFile()));
QGraphicsSvgItem* boardItem = activeScene()->addSvg(url, QPointF(0, 0));
activeScene()->setAsBackgroundObject(boardItem, true, true);
}
else{
QPixmap pix(image->path().toLocalFile());
UBGraphicsPixmapItem* boardItem = activeScene()->addPixmap(pix, activeScene()->backgroundObject(), QPointF(0, 0));
activeScene()->setAsBackgroundObject(boardItem, true);
}
}
void UBLibraryController::addItemToPage(UBLibElement* item)
{
QList<QUrl> list;
list << QUrl::fromLocalFile(item->path().toLocalFile());
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(item->path().toLocalFile());
if (mimeType.contains("image")){
addImagesToCurrentPage(list);
}
else if (mimeType.contains("audio")){
addAudiosToCurrentPage(list);
}
else if (mimeType.contains("video")){
addVideosToCurrentPage(list);
}
else if (mimeType.contains("application")){
addInteractivesToCurrentPage(list);
}
else if (mimeType.isEmpty() && item->type() == eUBLibElementType_InteractiveItem){
// Those conditions allow us to detect internal app like
// mask, ruler, compass and protractor
list.clear();
list << item->path().toString().replace("file:","");
addInteractivesToCurrentPage(list);
}
else{
UBApplication::showMessage(tr("Adding to page failed for item %1.").arg(item->name()));
}
}
void UBLibraryController::removeBackground()
{
if (activeScene())
activeScene()->setAsBackgroundObject(0);
}
UBGraphicsScene* UBLibraryController::activeScene()
{
if (mBoardController->selectedDocument())
return mBoardController->activeScene();
return 0;
}
void UBLibraryController::persistFavoriteList()
{
QFile file(UBSettings::userFavoriteListFilePath());
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
//magic number
out << magicNumber;
out << (quint32)mFavoriteList.count();
foreach(UBLibElement* eachElement, mFavoriteList)
{
out << (quint32)eachElement->type();
out << eachElement->path().toString();
out << eachElement->information();
out << eachElement->name();
out << eachElement->extension();
}
file.close();
}
void UBLibraryController::readFavoriteList()
{
QFile file(UBSettings::userFavoriteListFilePath());
file.open(QIODevice::ReadOnly);
QDataStream in(&file); // read the data serialized from the file
quint32 magicNumber;
quint32 numberOfElements;
in >> magicNumber >> numberOfElements;
for(quint32 i = 0; i < numberOfElements; i += 1){
quint32 type;
QString path;
QString info;
QString name;
QString extension;
in >> type >> path >> info >> name >> extension;
UBLibElement* eachElement = new UBLibElement((eUBLibElementType)type, QUrl(path), name);
eachElement->setInformation(info);
eachElement->setExtension(extension);
eachElement->setThumbnail(thumbnailForFile(eachElement));
if(!isOnFavoriteList(eachElement))
mFavoriteList << eachElement;
}
file.close();
persistFavoriteList();
}
UBLibElement* UBLibraryController::isOnFavoriteList(UBLibElement * element)
{
foreach(UBLibElement* eachElement, mFavoriteList)
if(eachElement->path() == element->path())
return eachElement;
return 0;
}
void UBLibraryController::addToFavorite(QList<UBLibElement*> elementList)
{
foreach(UBLibElement* eachElement, elementList)
if(!isOnFavoriteList(eachElement))
mFavoriteList << new UBLibElement(eachElement);
persistFavoriteList();
}
void UBLibraryController::removeFromFavorite(QList<UBLibElement*> elementList)
{
foreach(UBLibElement* eachElement, elementList){
UBLibElement* elementToRemove = isOnFavoriteList(eachElement);
if(elementToRemove)
mFavoriteList.removeOne(elementToRemove);
}
persistFavoriteList();
}
QRectF UBLibraryController::visibleSceneRect()
{
QRectF visibleSceneRect(0, 0, 0, 0);
if (activeScene() && mBoardController && mBoardController->controlView()) {
QPointF topLeftCorner = mBoardController->controlGeometry().topLeft();
QPointF bottomRightCorner =
mBoardController->controlGeometry().bottomRight();
QPointF sceneTopLeft = mBoardController->controlView()->mapToScene(
topLeftCorner.toPoint());
QPointF sceneBottomRight = mBoardController->controlView()->mapToScene(
bottomRightCorner.toPoint());
visibleSceneRect.setTopLeft(sceneTopLeft);
visibleSceneRect.setBottomRight(sceneBottomRight);
}
return visibleSceneRect;
}
void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images)
{
QPointF pos = UBApplication::boardController->activeScene()->normalizedSceneRect().center();
foreach(const QUrl url, images)
{
mLastItemOffsetIndex = qMin(mLastItemOffsetIndex, 5);
QGraphicsItem* itemInScene = 0;
if (activeScene()) {
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(
url.toString());
pos = QPointF(pos.x() + 50 * mLastItemOffsetIndex, pos.y() + 50 * mLastItemOffsetIndex);
mLastItemOffsetIndex++;
//TODO UB 4.x move this logic to the scene ..
if (mimeType == "image/svg+xml") {
itemInScene = activeScene()->addSvg(url, pos);
} else {
itemInScene = activeScene()->addPixmap(QPixmap(
url.toLocalFile()), NULL, pos);
}
}
if (itemInScene) {
itemInScene = activeScene()->scaleToFitDocumentSize(itemInScene, false, UBSettings::objectInControlViewMargin);
}
}
}
void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos)
{
QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, videos)
{
mLastItemOffsetIndex++;
mLastItemOffsetIndex = qMin(mLastItemOffsetIndex, 5);
UBGraphicsMediaItem* itemInScene = UBApplication::boardController->addVideo(url, false, pos);
itemInScene->setPos(QPoint(pos.x() + 50 * mLastItemOffsetIndex, pos.y() + 50 * mLastItemOffsetIndex));
}
}
void UBLibraryController::addAudiosToCurrentPage(const QList<QUrl>& sounds)
{
QPointF centerPos = visibleSceneRect().center();
QPointF pos = centerPos;
//move it a little higher for convenience
centerPos.setX(pos.x() - 200);
centerPos.setY(pos.y() - 100);
foreach(const QUrl url, sounds)
{
mLastItemOffsetIndex++;
mLastItemOffsetIndex = qMin(mLastItemOffsetIndex, 5);
pos = QPointF(centerPos.x() + 50 * mLastItemOffsetIndex,
centerPos.y() + 50 * mLastItemOffsetIndex);
UBApplication::boardController->addAudio(url, false, pos);
}
}
void UBLibraryController::addInteractivesToCurrentPage( const QList<QUrl>& widgets)
{
foreach(const QUrl url, widgets)
mBoardController->downloadURL(url, QPointF(0, 0));
}
QString UBLibraryController::favoritePath()
{
return favoriteVirtualPath;
}
UBLibElement::UBLibElement() {
mType = eUBLibElementType_Category;
mName = QObject::tr("/Home", "Category list label on navigation tool bar");
mbMoveable = false;
mbDeletable = true;
}
UBLibElement::UBLibElement(UBLibElement* element)
{
mType = element->type();
mPath = element->path();
mThumbnail = *element->thumbnail();
mInfo = element->information();
mName = element->name();
mExtension = element->extension();
mbMoveable = element->isMoveable();
mbDeletable = element->isDeletable();
}
UBLibElement::UBLibElement(eUBLibElementType type, const QUrl &path, const QString &name)
{
mType = type;
mPath = path;
mName = name;
mInfo = "";
mbMoveable = true;
mbDeletable = true;
if (type == eUBLibElementType_Folder)
mThumbnail = QImage(":images/libpalette/folder.svg");
if (type == eUBLibElementType_InteractiveItem)
mThumbnail = QImage(UBGraphicsWidgetItem::iconFilePath(path));
if (type == eUBLibElementType_Item)
mExtension = QFileInfo(path.toLocalFile()).completeSuffix();
if(type == eUBLibElementType_VirtualFolder || type == eUBLibElementType_Category)
mbMoveable = false;
}
UBLibElement::~UBLibElement()
{
//NOOP
}
UBChainedLibElement::UBChainedLibElement(UBLibElement *pElem, UBChainedLibElement *pNextElem)
{
mpElem = new UBLibElement(pElem);
mpNextElem = pNextElem;
}
UBChainedLibElement::~UBChainedLibElement()
{
if (NULL != mpNextElem) {
delete mpNextElem;
mpNextElem = NULL;
}
delete mpElem;
}
void UBChainedLibElement::setNextElement(UBChainedLibElement *nextElem)
{
mpNextElem = nextElem;
}
UBChainedLibElement* UBChainedLibElement::lastElement()
{
UBChainedLibElement* pElem = NULL;
if(NULL != mpNextElem)
{
UBChainedLibElement* pLast = mpNextElem->lastElement();
if(NULL != pLast)
{
pElem = pLast;
}
else
{
pElem = mpNextElem;
}
}
return pElem;
}
QUrl UBChainedLibElement::lastItemPath()
{
return lastElement()->element()->path();
}
UBLibElement* UBLibElement::trashElement()
{
UBLibElement *trashElement;
trashElement = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(UBSettings::userTrashDirPath()), QObject::tr("Trash", "Pictures category element"));
trashElement->setThumbnail(QImage(":images/libpalette/TrashCategory.svg"));
trashElement->setMoveable(false);
return trashElement;
}

@ -1,185 +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 2 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 UBLIBRARYCONTROLLER_H_
#define UBLIBRARYCONTROLLER_H_
#include <QtGui>
#include <QtWebKit>
#include "web/UBWebPage.h"
class UBGraphicsScene;
class UBBoardController;
class QGraphicsSvgItem;
class UBLibraryWebView;
class UBWebView;
typedef enum
{
eUBLibElementType_Category = 0,
eUBLibElementType_VirtualFolder,
eUBLibElementType_Folder,
eUBLibElementType_InteractiveItem,
eUBLibElementType_Item
}eUBLibElementType;
class UBLibElement
{
public:
UBLibElement();
UBLibElement(eUBLibElementType type, const QUrl& path, const QString& name);
UBLibElement(UBLibElement* element);
virtual ~UBLibElement();
static UBLibElement* trashElement();
eUBLibElementType type(){return mType;}
void setType(eUBLibElementType type) {mType = type;}
QUrl path(){return mPath;}
void setPath(QUrl path){mPath = path;}
QImage* thumbnail(){return &mThumbnail;}
void setThumbnail(QImage pThumb){mThumbnail = pThumb;}
QString information(){return mInfo;}
void setInformation(QString info){mInfo = info;}
QString name(){return mName;}
void setName(QString name){mName = name;}
QString extension(){return mExtension;}
void setExtension(QString &extension){ mExtension = extension;}
bool isMoveable(){return mbMoveable;}
void setMoveable(bool bState){mbMoveable = bState;}
bool isDeletable() const {return mbDeletable;}
void setDeletable(bool mState) {mbDeletable = mState;}
void setMetadata(QMap<QString, QString> metadatas){mMetadata = metadatas;}
QMap<QString, QString> metadatas(){return mMetadata;}
private:
eUBLibElementType mType;
QUrl mPath;
QImage mThumbnail;
QString mInfo;
QString mName;
QString mExtension;
bool mbMoveable;
bool mbDeletable;
QMap<QString, QString> mMetadata;
};
class UBChainedLibElement
{
public:
UBChainedLibElement(UBLibElement* pElem, UBChainedLibElement* pNextElem=NULL);
virtual ~UBChainedLibElement();
UBChainedLibElement* nextElement(){return mpNextElem;}
UBChainedLibElement* lastElement();
void setNextElement(UBChainedLibElement* nextElem);
UBLibElement* element(){return mpElem;}
QUrl lastItemPath();
private:
UBLibElement* mpElem;
UBChainedLibElement* mpNextElem;
};
class UBLibraryController : public QObject
{
Q_OBJECT;
public:
UBLibraryController(QWidget *parentWidget);
virtual ~UBLibraryController();
QList<UBLibElement*> getContent(UBLibElement* pElement);
void moveContent(QList<UBLibElement*> sourceList, UBLibElement *pDestination);
void trashElements(QList<UBLibElement*> trashList);
void emptyElementsOnTrash(QList<UBLibElement*> elementsList);
void addNativeToolToFavorites(const QUrl& url);
void setItemAsBackground(UBLibElement* image);
void addItemToPage(UBLibElement* item);
void addToFavorite(QList<UBLibElement*> elementList);
void removeFromFavorite(QList<UBLibElement*> elementList);
void importItemOnLibrary(QString& pItemString);
void importImageOnLibrary(QImage &pImage);
QString favoritePath();
void createNewFolder(QString name, UBLibElement* parentElem);
bool canItemsOnElementBeDeleted(UBLibElement *pElement);
void routeItem(QString& pItem, QString pMiddleDirectory = QString());
void routeDataItem(QString& pItem, QByteArray pData);
signals:
void dialogClosed(int state);
void setResource(QString &pathResource,QString &mimetype);
void updateItemsList();
public slots:
void removeBackground();
void addImagesToCurrentPage(const QList<QUrl>& images);
void addVideosToCurrentPage(const QList<QUrl>& videos);
void addAudiosToCurrentPage(const QList<QUrl>& sounds);
void addInteractivesToCurrentPage(const QList<QUrl>& interactiveWidgets);
protected:
UBGraphicsScene* activeScene();
QRectF visibleSceneRect();
QList<UBLibElement*> mFavoriteList;
void persistFavoriteList();
void readFavoriteList();
QList<UBLibElement*> mInternalLibElements;
QList<UBLibElement*> mElementsList;
void cleanElementsList();
private:
QList<UBLibElement*> rootCategoriesList();
QList<UBLibElement*> listElementsInPath(const QString& pPath);
QList<UBLibElement*> listElementsInVirtualForlder(UBLibElement* pElement);
void userPath(QUrl &pPath);
QImage thumbnailForFile(UBLibElement* pPath);
QImage createThumbnail(UBLibElement* pPath);
QList<UBLibElement*> addVirtualElementsForItemPath(const QString& pPath);
void createInternalWidgetItems();
void createDirectory(QUrl& pDirPath);
QUrl mAudioStandardDirectoryPath;
QUrl mVideoStandardDirectoryPath;
QUrl mPicturesStandardDirectoryPath;
QUrl mInteractiveUserDirectoryPath;
QUrl mInteractiveCategoryPath;
QUrl mAnimationUserDirectoryPath;
QUrl mSearchCategoryPath;
QStringList addItemsToCurrentLibrary(const QDir& pSelectedFolder, const QStringList& pExtensions);
UBLibElement* isOnFavoriteList(UBLibElement * element);
QWidget *mParentWidget;
UBBoardController *mBoardController;
int mLastItemOffsetIndex;
QString getBaseDestinationForItem(QString& pItem);
};
#endif /* UBLIBRARYCONTROLLER_H_ */

@ -2,14 +2,12 @@
HEADERS += src/board/UBBoardController.h \ HEADERS += src/board/UBBoardController.h \
src/board/UBBoardPaletteManager.h \ src/board/UBBoardPaletteManager.h \
src/board/UBBoardView.h \ src/board/UBBoardView.h \
src/board/UBLibraryController.h \
src/board/UBDrawingController.h \ src/board/UBDrawingController.h \
src/board/UBFeaturesController.h src/board/UBFeaturesController.h
SOURCES += src/board/UBBoardController.cpp \ SOURCES += src/board/UBBoardController.cpp \
src/board/UBBoardPaletteManager.cpp \ src/board/UBBoardPaletteManager.cpp \
src/board/UBBoardView.cpp \ src/board/UBBoardView.cpp \
src/board/UBLibraryController.cpp \
src/board/UBDrawingController.cpp \ src/board/UBDrawingController.cpp \
src/board/UBFeaturesController.cpp src/board/UBFeaturesController.cpp

@ -365,6 +365,7 @@ void UBApplicationController::showBoard()
emit mainModeChanged(Board); emit mainModeChanged(Board);
UBApplication::boardController->freezeW3CWidgets(false); UBApplication::boardController->freezeW3CWidgets(false);
UBApplication::boardController->activeScene()->updateGroupButtonState();
} }

@ -317,6 +317,11 @@ void UBGraphicsScene::selectionChangedProcessing()
void UBGraphicsScene::updateGroupButtonState() void UBGraphicsScene::updateGroupButtonState()
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
if (UBStylusTool::Selector != currentTool)
return;
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems(); QList<QGraphicsItem*> selItems = selectedItems();
int selCount = selItems.count(); int selCount = selItems.count();

@ -150,11 +150,3 @@ void UBGraphicsWebView::remove()
if (mDelegate) if (mDelegate)
mDelegate->remove(true); mDelegate->remove(true);
} }
bool UBGraphicsWebView::event(QEvent *event)
{
if (event->type() == QEvent::ShortcutOverride)
event->accept();
return QGraphicsWebView::event(event);
}

@ -54,7 +54,6 @@ class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResiza
virtual void wheelEvent(QGraphicsSceneWheelEvent *event); virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool event(QEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
}; };

@ -97,7 +97,6 @@ UBGraphicsWidgetItem::~UBGraphicsWidgetItem()
void UBGraphicsWidgetItem::initialize() void UBGraphicsWidgetItem::initialize()
{ {
installEventFilter(this);
UBGraphicsWebView::setMinimumSize(nominalSize()); UBGraphicsWebView::setMinimumSize(nominalSize());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly
@ -277,9 +276,9 @@ void UBGraphicsWidgetItem::removeScript()
page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}"); page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}");
} }
void UBGraphicsWidgetItem::processDropEvent(QDropEvent *event) void UBGraphicsWidgetItem::processDropEvent(QGraphicsSceneDragDropEvent *event)
{ {
return mUniboardAPI->ProcessDropEvent(event); mUniboardAPI->ProcessDropEvent(event);
} }
bool UBGraphicsWidgetItem::isDropableData(const QMimeData *data) const bool UBGraphicsWidgetItem::isDropableData(const QMimeData *data) const
{ {
@ -486,6 +485,31 @@ void UBGraphicsWidgetItem::unFreeze()
mIsFrozen = false; mIsFrozen = false;
} }
bool UBGraphicsWidgetItem::event(QEvent *event)
{
if (mShouldMoveWidget && event->type() == QEvent::MouseMove) {
QMouseEvent *mouseMoveEvent = static_cast<QMouseEvent*>(event);
if (mouseMoveEvent->buttons() & Qt::LeftButton) {
QPointF scenePos = mapToScene(mouseMoveEvent->pos());
QPointF newPos = pos() + scenePos - mLastMousePos;
setPos(newPos);
mLastMousePos = scenePos;
event->accept();
return true;
}
}
else if (event->type() == QEvent::ShortcutOverride)
event->accept();
return UBGraphicsWebView::event(event);
}
void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
{
processDropEvent(event);
QGraphicsWebView::dropEvent(event);
}
void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
UBGraphicsWebView::mousePressEvent(event); UBGraphicsWebView::mousePressEvent(event);
@ -522,30 +546,6 @@ void UBGraphicsWidgetItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
UBGraphicsWebView::hoverMoveEvent(event); UBGraphicsWebView::hoverMoveEvent(event);
} }
bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event)
{
if (mShouldMoveWidget && obj == this && event->type() == QEvent::MouseMove) {
QMouseEvent *mouseMoveEvent = static_cast<QMouseEvent*>(event);
if (mouseMoveEvent->buttons() & Qt::LeftButton) {
QPointF scenePos = mapToScene(mouseMoveEvent->pos());
QPointF newPos = pos() + scenePos - mLastMousePos;
setPos(newPos);
mLastMousePos = scenePos;
event->accept();
return true;
}
}
/* standard event processing */
return QObject::eventFilter(obj, event);
}
void UBGraphicsWidgetItem::sendJSEnterEvent() void UBGraphicsWidgetItem::sendJSEnterEvent()
{ {
if (page() && page()->mainFrame()) if (page() && page()->mainFrame())

@ -76,7 +76,7 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
virtual void remove(); virtual void remove();
void removeScript(); void removeScript();
void processDropEvent(QDropEvent *event); void processDropEvent(QGraphicsSceneDragDropEvent *event);
bool isDropableData(const QMimeData *data) const; bool isDropableData(const QMimeData *data) const;
virtual QUrl getOwnFolder() const; virtual QUrl getOwnFolder() const;
@ -136,12 +136,13 @@ class UBGraphicsWidgetItem : public UBGraphicsWebView
QMap<QString, QString> mDatastore; QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences; QMap<QString, QString> mPreferences;
virtual bool event(QEvent *event);
virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void sendJSEnterEvent(); virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent(); virtual void sendJSLeaveEvent();
virtual void injectInlineJavaScript(); virtual void injectInlineJavaScript();

@ -271,3 +271,28 @@ void UBFeaturesActionBar::dropEvent(QDropEvent *event)
UBFeaturesActionBar::~UBFeaturesActionBar() UBFeaturesActionBar::~UBFeaturesActionBar()
{ {
} }
/**
* \brief Construtor
* @param parent as the parent widget
* @param action as the related action
* @param name as the related object name
*/
UBActionButton::UBActionButton(QWidget *parent, QAction* action, const char *name):QToolButton(parent)
{
setObjectName(name);
addAction(action);
setDefaultAction(action);
setIconSize(QSize(BUTTON_SIZE, BUTTON_SIZE));
setToolButtonStyle(Qt::ToolButtonIconOnly);
setStyleSheet(QString("QToolButton {color: white; font-weight: bold; font-family: Arial; background-color: transparent; border: none}"));
setFocusPolicy(Qt::NoFocus);
}
/**
* \brief Destructor
*/
UBActionButton::~UBActionButton()
{
}

@ -4,11 +4,27 @@
#include <QWidget> #include <QWidget>
#include <QToolButton> #include <QToolButton>
#include <QDropEvent> #include <QDropEvent>
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h" #include "board/UBFeaturesController.h"
#define BUTTON_SIZE 24
#define ACTIONBAR_HEIGHT 42
class UBFeaturesMimeData; class UBFeaturesMimeData;
typedef enum
{
eButtonSet_Default,
eButtonSet_Properties,
eButtonSet_Favorite
} eButtonSet;
class UBActionButton : public QToolButton
{
public:
UBActionButton(QWidget* parent=0, QAction* action=0, const char* name="UBActionButton");
~UBActionButton();
};
enum UBFeaturesActionBarState enum UBFeaturesActionBarState
{ {
IN_ROOT, IN_ROOT,
@ -26,6 +42,7 @@ public:
~UBFeaturesActionBar(); ~UBFeaturesActionBar();
void setCurrentState( UBFeaturesActionBarState state ); void setCurrentState( UBFeaturesActionBarState state );
void cleanText(){ mSearchBar->clear(); }
signals: signals:
void searchElement(const QString &text); void searchElement(const QString &text);

@ -1,4 +1,6 @@
#include <QDomDocument> #include <QDomDocument>
#include <QWebView>
#include "UBFeaturesWidget.h" #include "UBFeaturesWidget.h"
#include "gui/UBThumbnailWidget.h" #include "gui/UBThumbnailWidget.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
@ -6,7 +8,6 @@
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
const char *UBFeaturesWidget::objNamePathList = "PathList"; const char *UBFeaturesWidget::objNamePathList = "PathList";
const char *UBFeaturesWidget::objNameFeatureList = "FeatureList"; const char *UBFeaturesWidget::objNameFeatureList = "FeatureList";
@ -23,8 +24,6 @@ static const QString mimeSankoreFeatureTypes = "Sankore/featureTypes";
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name) UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
: UBDockPaletteWidget(parent) : UBDockPaletteWidget(parent)
, imageGatherer(NULL) , imageGatherer(NULL)
, mkFolderDlg(NULL)
{ {
setObjectName(name); setObjectName(name);
mName = "FeaturesWidget"; mName = "FeaturesWidget";
@ -143,6 +142,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList); centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
mActionBar->setCurrentState( IN_PROPERTIES ); mActionBar->setCurrentState( IN_PROPERTIES );
} }
mActionBar->cleanText();
} }
void UBFeaturesWidget::createNewFolder() void UBFeaturesWidget::createNewFolder()
@ -151,12 +151,6 @@ void UBFeaturesWidget::createNewFolder()
emit sendFileNameList(controller->getFileNamesInFolders()); emit sendFileNameList(controller->getFileNamesInFolders());
} }
void UBFeaturesWidget::addFolder()
{
if (mkFolderDlg)
controller->addNewFolder(mkFolderDlg->folderName());
}
void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData ) void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
{ {
if (!mimeData->features().count() ) if (!mimeData->features().count() )
@ -335,16 +329,6 @@ void UBFeaturesWidget::removeElementsFromFavorite()
controller->refreshModels(); controller->refreshModels();
} }
void UBFeaturesWidget::resizeEvent(QResizeEvent *event)
{
UBDockPaletteWidget::resizeEvent(event);
if (mkFolderDlg)
{
mkFolderDlg->resize(this->size().width()-20 ,80);
mkFolderDlg->move(5,this->size().height()-200);
}
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
// stackedWidget->setCurrentIndex(ID_LISTVIEW); // stackedWidget->setCurrentIndex(ID_LISTVIEW);

@ -21,7 +21,9 @@
#include "api/UBWidgetUniboardAPI.h" #include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h" #include "UBFeaturesActionBar.h"
#include "UBRubberBand.h" #include "UBRubberBand.h"
#include "gui/UBLibraryWidget.h" #include <QtWebKit>
#include <QWebView>
#include <QWebSettings>
#define THUMBNAIL_WIDTH 400 #define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0 #define ID_LISTVIEW 0
@ -81,7 +83,6 @@ private slots:
void currentSelected( const QModelIndex & ); void currentSelected( const QModelIndex & );
void searchStarted( const QString & ); void searchStarted( const QString & );
void createNewFolder(); void createNewFolder();
void addFolder();
void deleteElements( const UBFeaturesMimeData * ); void deleteElements( const UBFeaturesMimeData * );
void addToFavorite( const UBFeaturesMimeData *); void addToFavorite( const UBFeaturesMimeData *);
void removeFromFavorite( const UBFeaturesMimeData * ); void removeFromFavorite( const UBFeaturesMimeData * );
@ -94,7 +95,6 @@ private slots:
void lockIt(bool pLock); void lockIt(bool pLock);
private: private:
void resizeEvent(QResizeEvent *event);
void switchToListView(); void switchToListView();
void switchToProperties(); void switchToProperties();
void switchToWebView(); void switchToWebView();
@ -105,7 +105,6 @@ private:
QVBoxLayout *layout; QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar; UBFeaturesActionBar *mActionBar;
UBDownloadHttpFile* imageGatherer; UBDownloadHttpFile* imageGatherer;
UBNewFolderDlg *mkFolderDlg;
UBFeaturesCentralWidget *centralWidget; UBFeaturesCentralWidget *centralWidget;
}; };
@ -220,9 +219,6 @@ private slots:
void scanStarted(); void scanStarted();
void scanFinished(); void scanFinished();
private:
}; };
class UBFeaturesNewFolderDialog : public QWidget class UBFeaturesNewFolderDialog : public QWidget

@ -1,534 +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 2 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 <QIcon>
#include <QSize>
#include <QDebug>
#include "UBLibWidget.h"
#include "UBLibActionBar.h"
#include "core/UBApplication.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibActionBar::UBLibActionBar(QWidget *parent, const char *name):QWidget(parent)
, mCrntButtonSet(eButtonSet_Default)
, mPreviousButtonSet(eButtonSet_Default)
, mButtonGroup(NULL)
, mSearchBar(NULL)
, mLayout(NULL)
, mpFavoriteAction(NULL)
, mpSocialAction(NULL)
, mpDeleteAction(NULL)
, mpSearchAction(NULL)
, mpCloseAction(NULL)
, mpRemoveFavorite(NULL)
, mpNewFolderAction(NULL)
, mpFavoriteBtn(NULL)
, mpSocialBtn(NULL)
, mpDeleteBtn(NULL)
, mpSearchBtn(NULL)
, mpCloseBtn(NULL)
, mpRemoveFavoriteBtn(NULL)
, mpNewFolderBtn(NULL)
, bFavorite(false)
, bIsInTrash(false)
{
setObjectName(name);
setStyleSheet(QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;"));
setAcceptDrops(true);
mButtonGroup = new QButtonGroup(this);
mSearchBar = new QLineEdit(this);
mSearchBar->setStyleSheet(QString("background-color:white; border-radius : 10px; padding : 2px;"));
connect(mSearchBar, SIGNAL(returnPressed()), this, SLOT(onActionSearch()));
mLayout = new QHBoxLayout();
setLayout(mLayout);
setMaximumHeight(ACTIONBAR_HEIGHT);
// Create the actions
mpFavoriteAction = new QAction(QIcon(":/images/libpalette/miniFavorite.png"), tr("Add to favorites"), this);
mpSocialAction = new QAction(QIcon(":/images/libpalette/social.png"), tr("Share"), this);
mpSearchAction = new QAction(QIcon(":/images/libpalette/miniSearch.png"), tr("Search"), this);
mpDeleteAction = new QAction(QIcon(":/images/libpalette/miniTrash.png"), tr("Delete"), this);
mpCloseAction = new QAction(QIcon(":/images/close.svg"), tr("Back to folder"), this);
mpRemoveFavorite = new QAction(QIcon(":/images/libpalette/trash_favorite.svg"), tr("Remove from favorites"), this);
mpNewFolderAction = new QAction(QIcon(":/images/libpalette/miniNewFolder.png"), tr("Create new folder"), this);
// Create the buttons
mpFavoriteBtn = new UBActionButton(this, mpFavoriteAction);
mpSocialBtn = new UBActionButton(this, mpSocialAction);
mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction);
mpRemoveFavoriteBtn = new UBActionButton(this, mpRemoveFavorite);
mpNewFolderBtn = new UBActionButton(this, mpNewFolderAction);
// Initialize the buttons
mpSearchBtn->setEnabled(false);
mpNewFolderBtn->setEnabled(false);
// Add the buttons to the button group
mButtonGroup->addButton(mpFavoriteBtn);
mButtonGroup->addButton(mpSocialBtn);
mButtonGroup->addButton(mpSearchBtn);
mButtonGroup->addButton(mpDeleteBtn);
mButtonGroup->addButton(mpCloseBtn);
mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots
connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
// Build the default toolbar
mLayout->addWidget(mpFavoriteBtn);
mLayout->addWidget(mpSocialBtn);
mLayout->addWidget(mpNewFolderBtn);
mLayout->addWidget(mSearchBar);
mLayout->addWidget(mpSearchBtn);
mLayout->addWidget(mpDeleteBtn);
mLayout->addWidget(mpCloseBtn);
mLayout->addWidget(mpRemoveFavoriteBtn);
setButtons(eButtonSet_Default);
}
/**
* \brief Destructor
*/
UBLibActionBar::~UBLibActionBar()
{
if(NULL != mpNewFolderAction)
{
delete mpNewFolderAction;
mpNewFolderAction = NULL;
}
if(NULL != mpNewFolderBtn)
{
delete mpNewFolderBtn;
mpNewFolderBtn = NULL;
}
if(NULL != mpRemoveFavorite)
{
delete mpRemoveFavorite;
mpRemoveFavorite = NULL;
}
if(NULL != mpRemoveFavoriteBtn)
{
delete mpRemoveFavoriteBtn;
mpRemoveFavoriteBtn = NULL;
}
if(NULL != mpCloseAction)
{
delete mpCloseAction;
mpCloseAction = NULL;
}
if(NULL != mpDeleteAction)
{
delete mpDeleteAction;
mpDeleteAction = NULL;
}
if(NULL != mpFavoriteAction)
{
delete mpFavoriteAction;
mpFavoriteAction = NULL;
}
if(NULL != mpSearchAction)
{
delete mpSearchAction;
mpSearchAction = NULL;
}
if(NULL != mpSocialAction)
{
delete mpSocialAction;
mpSocialAction = NULL;
}
if(NULL != mpCloseBtn)
{
delete mpCloseBtn;
mpCloseBtn = NULL;
}
if(NULL != mpDeleteBtn)
{
delete mpDeleteBtn;
mpDeleteBtn = NULL;
}
if(NULL != mpFavoriteBtn)
{
delete mpFavoriteBtn;
mpFavoriteBtn = NULL;
}
if(NULL != mpSearchBtn)
{
delete mpSearchBtn;
mpSearchBtn = NULL;
}
if(NULL != mpSocialBtn)
{
delete mpSocialBtn;
mpSocialBtn = NULL;
}
if(NULL != mButtonGroup)
{
delete mButtonGroup;
mButtonGroup = NULL;
}
if(NULL != mSearchBar)
{
delete mSearchBar;
mSearchBar = NULL;
}
if(NULL != mLayout)
{
delete mLayout;
mLayout = NULL;
}
}
/**
* \brief Set the buttons of the action bar
* @param setID as the button set
*/
void UBLibActionBar::setButtons(eButtonSet setID)
{
mPreviousButtonSet = mCrntButtonSet;
mCrntButtonSet = setID;
switch(setID)
{
case eButtonSet_Default:
mpFavoriteBtn->show();
mpSocialBtn->hide();
mSearchBar->show();
mpSearchBtn->show();
mpDeleteBtn->show();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->show();
break;
case eButtonSet_Properties:
mpFavoriteBtn->show();
mpSocialBtn->hide();
mSearchBar->show();
mpSearchBtn->show();
mpDeleteBtn->hide();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->hide();
break;
case eButtonSet_Favorite:
mpFavoriteBtn->hide();
mpSocialBtn->hide();
mSearchBar->show();
mpSearchBtn->show();
mpDeleteBtn->hide();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
break;
default:
break;
}
}
/**
* \brief (un)set the selected element to favorite
*/
void UBLibActionBar::onActionFavorite()
{
mpFavoriteBtn->setIcon(QIcon(":/images/libpalette/miniFavorite.png"));
libraryController()->addToFavorite(mSelectedElements);
}
/**
* \brief Handle the mouse enter event
* @param event as the event
*/
void UBLibActionBar::enterEvent(QEvent *event)
{
Q_UNUSED(event);
setCursor(Qt::ArrowCursor);
}
/**
* \brief Handle the mouse leave event
* @param event as the event
*/
void UBLibActionBar::leaveEvent(QEvent *event)
{
Q_UNUSED(event);
unsetCursor();
}
/**
* \brief Perform the search
*/
void UBLibActionBar::onActionSearch()
{
emit searchElement(mSearchBar->text());
}
/**
* \brief Trigger the social action
*/
void UBLibActionBar::onActionSocial()
{
// To be implemented
}
/**
* \brief Handles the close action
*/
void UBLibActionBar::onActionClose()
{
emit showFolderContent();
}
/**
* \brief Delete the selected element
*/
void UBLibActionBar::onActionTrash()
{
if(!bIsInTrash)
{
libraryController()->trashElements(mSelectedElements);
}
else
{
libraryController()->emptyElementsOnTrash(mSelectedElements);
}
emit deleteDone();
}
/**
* \brief Remove the selected favorite(s)
*/
void UBLibActionBar::onActionRemoveFavorite()
{
libraryController()->removeFromFavorite(mSelectedElements);
emit deleteDone();
}
/**
* \brief Handles the selection change event
* @param itemList as the list of selected items
* @param isInTrash indicates if the current folder is the trash
*/
void UBLibActionBar::onSelectionChanged(QList<UBLibElement *> itemList, bool isInTrash)
{
bIsInTrash = isInTrash;
mSelectedElements = itemList;
bool bEnable = (itemList.count() != 0) ? true : false;
if(mCrntButtonSet == eButtonSet_Favorite)
{
mpRemoveFavoriteBtn->setEnabled(bEnable);
return;
}
mpFavoriteAction->setEnabled(bEnable);
mpSocialAction->setEnabled(bEnable);
mpDeleteAction->setEnabled(bEnable && libraryController()->canItemsOnElementBeDeleted(itemList.at(0)));
}
/**
* \brief Get the library controller
* @return a pointer on the library controller
*/
UBLibraryController* UBLibActionBar::libraryController()
{
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget());
return libWidget->libNavigator()->libraryWidget()->libraryController();
}
/**
* \brief Show the actions related to the Favorites folder
*/
void UBLibActionBar::onFavoritesEntered(bool bFav)
{
setButtons(bFav ? eButtonSet_Favorite : eButtonSet_Default);
}
/**
* \brief Handles the drag enter event
* @param event as the drag enter event
*/
void UBLibActionBar::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
/**
* \brief Handles the drag move event
* @param event as the drag move event
*/
void UBLibActionBar::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}
/**
* \brief Handles the drop event
* @param event as the given drop event
*/
void UBLibActionBar::dropEvent(QDropEvent *event)
{
const QPoint droppedPoint = event->pos();
QWidget* pTargetW = widgetAtPos(droppedPoint);
if(NULL != pTargetW)
{
if(mpFavoriteBtn == pTargetW)
{
onActionFavorite();
}
else if(mpRemoveFavoriteBtn == pTargetW)
{
onActionRemoveFavorite();
}
else if(mpDeleteBtn == pTargetW)
{
if(mpDeleteBtn->isEnabled())
{
onActionTrash();
}
}
else if(mpSocialBtn == pTargetW)
{
onActionSocial();
}
}
event->acceptProposedAction();
}
/**
* \brief Get the widget at the given position
* @param p as the given position
* @return a pointer on the related QWidget
*/
QWidget* UBLibActionBar::widgetAtPos(const QPoint p)
{
Q_ASSERT(mpDeleteBtn != NULL);
Q_ASSERT(mpFavoriteBtn != NULL);
Q_ASSERT(mpRemoveFavoriteBtn != NULL);
Q_ASSERT(mpSocialBtn != NULL);
QList<UBActionButton*> qlBttns;
qlBttns << mpFavoriteBtn;
qlBttns << mpDeleteBtn;
qlBttns << mpRemoveFavoriteBtn;
qlBttns << mpSocialBtn;
foreach(UBActionButton* bt, qlBttns)
{
if(bt->pos().x() <= p.x() &&
bt->pos().x() + bt->rect().width() >= p.x() &&
bt->pos().y() <= p.y() &&
bt->pos().y() + bt->rect().height() >= p.y())
{
if(bt->isVisible())
{
return bt;
}
}
}
// No interesting button has been found
return NULL;
}
/**
* \brief Handles the text changed event of the search bar
*/
void UBLibActionBar::onSearchTextChanged(QString txt)
{
Q_UNUSED(txt);
onActionSearch();
}
/**
* \brief Add a new folder
*/
void UBLibActionBar::onActionNewFolder()
{
emit newFolderToCreate();
}
/**
* \brief Update the action bar elements
* @param crntElem as the current element
*/
void UBLibActionBar::onNavigbarUpdate(UBLibElement *crntElem)
{
if(NULL != crntElem)
{
if(crntElem->type() == eUBLibElementType_Folder)
{
if(libraryController()->canItemsOnElementBeDeleted(crntElem) && !bIsInTrash)
mpNewFolderBtn->setEnabled(true);
else
mpNewFolderBtn->setEnabled(false);
}
else
{
mpNewFolderBtn->setEnabled(false);
}
}
}
void UBLibActionBar::onItemChanged()
{
mSearchBar->setText("");
mpSearchBtn->setEnabled(false);
}
/**
* \brief Construtor
* @param parent as the parent widget
* @param action as the related action
* @param name as the related object name
*/
UBActionButton::UBActionButton(QWidget *parent, QAction* action, const char *name):QToolButton(parent)
{
setObjectName(name);
addAction(action);
setDefaultAction(action);
setIconSize(QSize(BUTTON_SIZE, BUTTON_SIZE));
setToolButtonStyle(Qt::ToolButtonIconOnly);
setStyleSheet(QString("QToolButton {color: white; font-weight: bold; font-family: Arial; background-color: transparent; border: none}"));
setFocusPolicy(Qt::NoFocus);
}
/**
* \brief Destructor
*/
UBActionButton::~UBActionButton()
{
}

@ -1,120 +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 2 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 UBLIBACTIONBAR_H
#define UBLIBACTIONBAR_H
#include <QWidget>
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QList>
#include <QAction>
#include <QLineEdit>
#include <QToolButton>
#include <QStackedWidget>
#include <QDropEvent>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include "board/UBLibraryController.h"
#define BUTTON_SIZE 24
#define ACTIONBAR_HEIGHT 42
typedef enum
{
eButtonSet_Default,
eButtonSet_Properties,
eButtonSet_Favorite
} eButtonSet;
class UBActionButton : public QToolButton
{
public:
UBActionButton(QWidget* parent=0, QAction* action=0, const char* name="UBActionButton");
~UBActionButton();
};
class UBLibActionBar : public QWidget
{
Q_OBJECT
public:
UBLibActionBar(QWidget* parent=0, const char* name="UBLibActionBar");
~UBLibActionBar();
void setButtons(eButtonSet setID);
eButtonSet previousButtonSet(){return mPreviousButtonSet;}
signals:
void deleteDone();
void showFolderContent();
void searchElement(QString text);
void newFolderToCreate();
public slots:
void onSelectionChanged(QList<UBLibElement*> itemList, bool isInTrash);
void onFavoritesEntered(bool bFav);
void onNavigbarUpdate(UBLibElement* crntElem);
void onItemChanged();
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private slots:
void onActionFavorite();
void onActionSocial();
void onActionSearch();
void onActionTrash();
void onActionClose();
void onActionRemoveFavorite();
void onSearchTextChanged(QString txt);
void onActionNewFolder();
private:
QWidget* widgetAtPos(const QPoint p);
UBLibraryController* libraryController();
eButtonSet mCrntButtonSet;
eButtonSet mPreviousButtonSet;
QButtonGroup* mButtonGroup;
QList<UBLibElement*> mSelectedElements;
QLineEdit* mSearchBar;
QHBoxLayout* mLayout;
QAction* mpFavoriteAction;
QAction* mpSocialAction;
QAction* mpDeleteAction;
QAction* mpSearchAction;
QAction* mpCloseAction;
QAction* mpRemoveFavorite;
QAction* mpNewFolderAction;
UBActionButton* mpFavoriteBtn;
UBActionButton* mpSocialBtn;
UBActionButton* mpDeleteBtn;
UBActionButton* mpSearchBtn;
UBActionButton* mpCloseBtn;
UBActionButton* mpRemoveFavoriteBtn;
UBActionButton* mpNewFolderBtn;
// This flag will be removed after the test, normally we should ask
// the selected item if it is in favorite or not
bool bFavorite;
bool bIsInTrash;
};
#endif // UBLIBACTIONBAR_H

@ -1,321 +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 2 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 "UBLibWidget.h"
#include "UBLibItemProperties.h"
#include "core/UBApplication.h"
#include "core/UBDownloadManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "globals/UBGlobals.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibItemProperties::UBLibItemProperties(QWidget *parent, const char *name):QWidget(parent)
, mpLayout(NULL)
, mpButtonLayout(NULL)
, mpAddPageButton(NULL)
, mpAddToLibButton(NULL)
, mpSetAsBackgroundButton(NULL)
, mpObjInfoLabel(NULL)
, mpObjInfos(NULL)
, mpThumbnail(NULL)
, mpOrigPixmap(NULL)
, mpElement(NULL)
, mpItem(NULL)
{
setObjectName(name);
SET_STYLE_SHEET();
// Create the GUI
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
maxThumbHeight = height() / 4;
mpThumbnail = new QLabel();
QPixmap icon(":images/libpalette/notFound.png");
icon.scaledToWidth(THUMBNAIL_WIDTH);
mpThumbnail->setPixmap(icon);
mpThumbnail->setObjectName("DockPaletteWidgetBox");
mpThumbnail->setStyleSheet("background:white;");
mpThumbnail->setAlignment(Qt::AlignHCenter);
mpLayout->addWidget(mpThumbnail, 0);
mpButtonLayout = new QHBoxLayout();
mpLayout->addLayout(mpButtonLayout, 0);
mpAddPageButton = new UBLibItemButton();
mpAddPageButton->setText(tr("Add to page"));
mpButtonLayout->addWidget(mpAddPageButton);
mpSetAsBackgroundButton = new UBLibItemButton();
mpSetAsBackgroundButton->setText(tr("Set as background"));
mpButtonLayout->addWidget(mpSetAsBackgroundButton);
mpAddToLibButton = new UBLibItemButton();
mpAddToLibButton->setText(tr("Add to library"));
mpButtonLayout->addWidget(mpAddToLibButton);
mpButtonLayout->addStretch(1);
mpObjInfoLabel = new QLabel(tr("Object informations"));
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;"));
mpLayout->addWidget(mpObjInfoLabel, 0);
mpObjInfos = new QTreeWidget(this);
mpObjInfos->setColumnCount(2);
mpObjInfos->header()->hide();
mpObjInfos->setAlternatingRowColors(true);
mpObjInfos->setRootIsDecorated(false);
mpObjInfos->setObjectName("DockPaletteWidgetBox");
mpObjInfos->setStyleSheet("background:white;");
mpLayout->addWidget(mpObjInfos, 1);
connect(mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()));
connect(mpSetAsBackgroundButton, SIGNAL(clicked()), this, SLOT(onSetAsBackground()));
connect(mpAddToLibButton, SIGNAL(clicked()), this, SLOT(onAddToLib()));
}
/**
* \brief Destructor
*/
UBLibItemProperties::~UBLibItemProperties()
{
if(NULL != mpOrigPixmap)
{
delete mpOrigPixmap;
mpOrigPixmap = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
if(NULL != mpSetAsBackgroundButton)
{
delete mpSetAsBackgroundButton;
mpSetAsBackgroundButton = NULL;
}
if(NULL != mpAddPageButton)
{
delete mpAddPageButton;
mpAddPageButton = NULL;
}
if(NULL != mpAddToLibButton)
{
delete mpAddToLibButton;
mpAddToLibButton = NULL;
}
if(NULL != mpObjInfoLabel)
{
delete mpObjInfoLabel;
mpObjInfoLabel = NULL;
}
if(NULL != mpObjInfos)
{
delete mpObjInfos;
mpObjInfos = NULL;
}
if(NULL != mpThumbnail)
{
delete mpThumbnail;
mpThumbnail = NULL;
}
}
/**
* \brief Handle the resize event
* @param event as the resize event
*/
void UBLibItemProperties::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
adaptSize();
}
/**
* \brief Adapt the thumbnail size
*/
void UBLibItemProperties::adaptSize()
{
if(NULL != mpOrigPixmap)
{
if(width() < THUMBNAIL_WIDTH + 40)
{
mpThumbnail->setPixmap(mpOrigPixmap->scaledToWidth(width() - 40));
}
else
{
mpThumbnail->setPixmap(mpOrigPixmap->scaledToWidth(THUMBNAIL_WIDTH));
}
}
}
/**
* \brief Add the element to the page
*/
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());
libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement);
}
}
/**
* \brief Add the item to the library
*/
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);
}
}
/**
* \brief Set the item as background
*/
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());
libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement);
}
}
/**
* \brief Show the given element properties
* @param elem as the given element
*/
void UBLibItemProperties::showElement(UBLibElement *elem)
{
if(NULL != mpOrigPixmap)
{
delete mpOrigPixmap;
mpOrigPixmap = NULL;
}
if(NULL != elem)
{
mpElement = elem;
mpOrigPixmap = new QPixmap(QPixmap::fromImage(*elem->thumbnail()));
mpThumbnail->setPixmap(QPixmap::fromImage(*elem->thumbnail()).scaledToWidth(THUMBNAIL_WIDTH));
populateMetadata();
}
if(UBApplication::isFromWeb(elem->path().toString())){
mpAddToLibButton->show();
if(elem->metadatas()["Type"].toLower().contains("image")){
mpSetAsBackgroundButton->show();
}else{
mpSetAsBackgroundButton->hide();
}
}else{
mpAddToLibButton->hide();
if(UBFileSystemUtils::mimeTypeFromFileName(elem->path().toLocalFile()).contains("image")){
mpSetAsBackgroundButton->show();
}else{
mpSetAsBackgroundButton->hide();
}
}
}
/**
* \brief Navigate backward
*/
void UBLibItemProperties::onBack()
{
emit showFolderContent();
}
/**
* \brief Handle the show event
* @param event as the show event
*/
void UBLibItemProperties::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
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
* @param parent as the parent widget
* @param name as the object name
*/
UBLibItemButton::UBLibItemButton(QWidget *parent, const char *name):QPushButton(parent)
{
setObjectName(name);
setStyleSheet(QString("background-color : #DDDDDD; color : #555555; border-radius : 6px; padding : 5px; font-weight : bold; font-size : 12px;"));
}
/**
* \brief Destructor
*/
UBLibItemButton::~UBLibItemButton()
{
}

@ -1,82 +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 2 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 UBLIBITEMPROPERTIES_H
#define UBLIBITEMPROPERTIES_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QPixmap>
#include <QLabel>
#include <QTextEdit>
#include <QToolButton>
#include <QAction>
#include <QShowEvent>
#include <QTreeWidget>
#include "board/UBLibraryController.h"
#define THUMBNAIL_WIDTH 400
class UBLibItemButton : public QPushButton
{
public:
UBLibItemButton(QWidget* parent=0, const char* name="UBLibItemButton");
~UBLibItemButton();
};
class UBLibItemProperties : public QWidget
{
Q_OBJECT
public:
UBLibItemProperties(QWidget* parent=0, const char* name="UBLibItemProperties");
~UBLibItemProperties();
void showElement(UBLibElement* elem);
signals:
void showFolderContent();
protected:
void resizeEvent(QResizeEvent *event);
void showEvent(QShowEvent *event);
private slots:
void onAddToPage();
void onAddToLib();
void onSetAsBackground();
void onBack();
private:
void adaptSize();
void populateMetadata();
QVBoxLayout* mpLayout;
QHBoxLayout* mpButtonLayout;
UBLibItemButton* mpAddPageButton;
UBLibItemButton* mpAddToLibButton;
UBLibItemButton* mpSetAsBackgroundButton;
QLabel* mpObjInfoLabel;
QTreeWidget* mpObjInfos;
QLabel* mpThumbnail;
QPixmap* mpOrigPixmap;
int maxThumbHeight;
UBLibElement* mpElement;
QTreeWidgetItem* mpItem;
};
#endif // UBLIBITEMPROPERTIES_H

@ -1,189 +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 2 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 "UBLibNavigatorWidget.h"
#include "UBLibWidget.h"
#include "core/UBApplication.h"
#include "globals/UBGlobals.h"
#include "core/memcheck.h"
static int lowBoundForSlider = 40;
static int topBoundForSlider = 120;
static int tickIntervalForSlider = 10;
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QWidget(parent)
, mLayout(NULL)
, mLibWidget(NULL)
, mSlider(NULL)
, mSliderWidthSetting(NULL)
{
setObjectName(name);
SET_STYLE_SHEET();
setAcceptDrops(true);
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget());
mLayout = new QVBoxLayout(this);
setLayout(mLayout);
mLibWidget = new UBLibraryWidget(this);
mLayout->addWidget(mLibWidget, 1);
mSlider = new QSlider(Qt::Horizontal, this);
mSlider->setMinimumHeight(20);
mSlider->setRange(lowBoundForSlider, topBoundForSlider);
//mSliderWidthSetting = new UBSetting(UBSettings::settings(), "Library", "LibWidgetWidth", topBoundForSlider);
//int defaultWidth = mSliderWidthSetting->get().toInt();
int defaultWidth = UBSettings::settings()->libraryIconSize();
qDebug() << defaultWidth;
mSlider->setValue(defaultWidth);
mSlider->setTickInterval(tickIntervalForSlider);
mLayout->addWidget(mSlider, 0);
connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), this, SLOT(onNavigbarUpate(UBLibElement*)));
connect(this, SIGNAL(updateNavigBar(UBChainedLibElement*)), libWidget, SLOT(onUpdateNavigBar(UBChainedLibElement*)));
mLibWidget->updateThumbnailsSize(defaultWidth);
connect(mLibWidget, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(onPropertiesRequested(UBLibElement*)));
connect(mLibWidget, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(onDisplaySearchEngine(UBLibElement*)));
connect(mSlider,SIGNAL(valueChanged(int)),this,SLOT(updateThumbnailsSize(int)));
connect(libWidget->pathViewer(), SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onPathItemClicked(UBChainedLibElement*)));
connect(libWidget->pathViewer(), SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList<QString>,UBLibElement*)));
connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), libWidget->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), libWidget->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, bool)));
connect(libWidget->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder()));
connect(mLibWidget, SIGNAL(favoritesEntered(bool)), libWidget->actionBar(), SLOT(onFavoritesEntered(bool)));
connect(libWidget->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString)));
connect(libWidget->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
connect(mLibWidget, SIGNAL(itemClicked()),libWidget->actionBar(), SLOT(onItemChanged()));
connect(libWidget->pathViewer(), SIGNAL(mouseClick(UBChainedLibElement*)),libWidget->actionBar(), SLOT(onItemChanged()));
mLibWidget->init();
}
/**
* \brief Destructor
*/
UBLibNavigatorWidget::~UBLibNavigatorWidget()
{
if(NULL != mLibWidget)
{
delete mLibWidget;
mLibWidget = NULL;
}
if(NULL != mSlider)
{
delete mSlider;
mSlider = NULL;
}
if(NULL != mSliderWidthSetting)
{
delete mSliderWidthSetting;
mSliderWidthSetting = NULL;
}
if(NULL != mLayout)
{
delete mLayout;
mLayout = NULL;
}
}
void UBLibNavigatorWidget::dropMe(const QMimeData *_data)
{
// Forward the mime data to the library widget
Q_UNUSED(_data);
}
/**
* \brief Update the navigation bar
* @param pElem as the current element
*/
void UBLibNavigatorWidget::onNavigbarUpate(UBLibElement *pElem)
{
Q_UNUSED(pElem);
emit updateNavigBar(mLibWidget->chainedElements);
}
/**
* \brief Handle the click event on an item
* @param elem as the clicked element
*/
void UBLibNavigatorWidget::onPathItemClicked(UBChainedLibElement *elem)
{
if (!this->libraryWidget()->isLoadingLibraryItems())
{
// If this element has some subelement, remove them
removeNextChainedElements(elem);
// The refresh the view
mLibWidget->setCurrentElemsAndRefresh(elem);
}
}
/**
* \brief Remove the next chained elements
* @param fromElem as the current elem
*/
void UBLibNavigatorWidget::removeNextChainedElements(UBChainedLibElement *fromElem)
{
if(NULL != fromElem)
{
if(NULL != fromElem->nextElement())
{
//removeNextChainedElements(fromElem->nextElement());
//delete fromElem->nextElement()->element();
//delete fromElem->nextElement();
delete fromElem->nextElement();
fromElem->setNextElement(NULL);
}
}
}
/**
* \brief Handles the properties requested event
* @param elem as the related element
*/
void UBLibNavigatorWidget::onPropertiesRequested(UBLibElement *elem)
{
emit propertiesRequested(elem);
}
/**
* \brief Handles the display search engine requested event
* @param elem as the related element
*/
void UBLibNavigatorWidget::onDisplaySearchEngine(UBLibElement *elem)
{
emit displaySearchEngine(elem);
}
/**
* \brief Update the thumbnails size
* @param newSize as the given thumbnails size
*/
void UBLibNavigatorWidget::updateThumbnailsSize(int newSize)
{
//mSliderWidthSetting->set(newSize);
UBSettings::settings()->setLibraryIconsize(newSize);
mLibWidget->updateThumbnailsSize(newSize);
}

@ -1,57 +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 2 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 UBLIBNAVIGATORWIDGET_H
#define UBLIBNAVIGATORWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QSlider>
#include <QDropEvent>
#include "UBLibraryWidget.h"
#include "core/UBSetting.h"
class UBLibNavigatorWidget : public QWidget
{
Q_OBJECT
public:
UBLibNavigatorWidget(QWidget* parent=0, const char* name="UBLibNavigatorWidget");
~UBLibNavigatorWidget();
void dropMe(const QMimeData* _data);
UBLibraryWidget* libraryWidget(){return mLibWidget;}
signals:
void propertiesRequested(UBLibElement* elem);
void displaySearchEngine(UBLibElement* elem);
void updateNavigBar(UBChainedLibElement* elem);
private slots:
void onNavigbarUpate(UBLibElement* pElem);
void onPathItemClicked(UBChainedLibElement *elem);
void onPropertiesRequested(UBLibElement* elem);
void updateThumbnailsSize(int newSize);
void onDisplaySearchEngine(UBLibElement* elem);
private:
void removeNextChainedElements(UBChainedLibElement* fromElem);
QVBoxLayout* mLayout;
UBLibraryWidget* mLibWidget;
QSlider* mSlider;
UBSetting* mSliderWidthSetting;
};
#endif // UBLIBNAVIGATORWIDGET_H

@ -1,582 +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 2 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 <QPixmap>
#include <QDrag>
#include <QPainter>
#include "UBLibPathViewer.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "core/UBDownloadManager.h"
#include "board/UBBoardPaletteManager.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibPathViewer::UBLibPathViewer(QWidget *parent, const char *name):QGraphicsView(parent)
, mpElems(NULL)
, mpElemsBackup(NULL)
, mpScene(NULL)
, mpLayout(NULL)
, mpContainer(NULL)
, mpBackElem(NULL)
{
setObjectName(name);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setAcceptDrops(true);
mpBackElem = new UBLibElement();
mpBackElem->setThumbnail(QPixmap(":images/libpalette/back.png").toImage());
mpBackElem->setDeletable(false);
mpScene = new UBPathScene(this);
setScene(mpScene);
mpContainer = new QGraphicsWidget();
mpContainer->setMinimumWidth(width() - 20);
mpScene->addItem(mpContainer);
mpLayout = new QGraphicsLinearLayout();
mpContainer->setLayout(mpLayout);
connect(mpScene, SIGNAL(mouseClick(UBChainedLibElement*)), this, SLOT(onMouseClicked(UBChainedLibElement*)));
connect(mpScene, SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), this, SLOT(onElementsDropped(QList<QString>,UBLibElement*)));
connect(horizontalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(onSliderMoved(int)));
}
/**
* \brief Destructor
*/
UBLibPathViewer::~UBLibPathViewer()
{
if(NULL != mpContainer)
{
delete mpContainer;
mpContainer = NULL;
}
if(NULL != mpBackElem)
{
delete mpBackElem;
mpBackElem = NULL;
}
if(NULL != mpElems)
{
delete mpElems;
mpElems = NULL;
}
//if(NULL != mpElemsBackup)
//{
// delete mpElemsBackup;
// mpElemsBackup = NULL;
//}
//if(NULL != mpLayout)
//{
// delete mpLayout;
// mpLayout = NULL;
//}
if(NULL != mpScene)
{
delete mpScene;
mpScene = NULL;
}
}
/**
* \brief Display the current path
* @param elementsChain as the path to display
*/
void UBLibPathViewer::displayPath(UBChainedLibElement *elementsChain)
{
if(NULL != elementsChain)
{
mpElems = elementsChain;
refreshPath();
}
}
/**
* \brief Refresh the current path
*/
void UBLibPathViewer::refreshPath()
{
if (mpScene && mpContainer)
mpScene->removeItem(mpContainer);
if(mpContainer)
delete mpContainer;
mVItems.clear();
mpScene->mapWidgetToChainedElem()->clear();
mpContainer = new QGraphicsWidget();
mpScene->addItem(mpContainer);
mpLayout = new QGraphicsLinearLayout();
mpContainer->setLayout(mpLayout);
mSceneWidth = 0;
addItem(mpElems);
mpLayout->addStretch();
updateScrolls();
}
/**
* \brief Handle the slider moved event
* @param value as the current slider position
*/
void UBLibPathViewer::onSliderMoved(int value)
{
Q_UNUSED(value);
}
/**
* \brief Update the scroll bar status
*/
void UBLibPathViewer::updateScrolls()
{
int iLimit = mSceneWidth + 40; // 2x 20 pixels margin
int iVp = viewport()->width();
if(iLimit >= iVp)
{
int iDiff = iLimit - iVp;
horizontalScrollBar()->setRange(0, iDiff);
}
else
{
horizontalScrollBar()->setRange(0, 0);
}
}
/**
* \brief Append an item to the path
* @param elem as the element to add to the path
*/
void UBLibPathViewer::addItem(UBChainedLibElement *elem)
{
if(NULL != elem)
{
// Add the icon
QLabel* pIconLabel = new QLabel();
pIconLabel->setStyleSheet(QString("background-color: transparent;"));
pIconLabel->setPixmap((QPixmap::fromImage(*elem->element()->thumbnail())).scaledToWidth(PATHITEMWIDTH));
UBFolderPath* iconWidget = reinterpret_cast<UBFolderPath*>(mpScene->addWidget(pIconLabel));
//iconWidget->setToolTip(elem->element()->name());
iconWidget->setWindowFlags(Qt::BypassGraphicsProxyWidget);
mpLayout->addItem(iconWidget);
mVItems << iconWidget;
mpScene->mapWidgetToChainedElem()->insert(iconWidget,elem);
mSceneWidth += pIconLabel->pixmap()->width() + 4; // 2px border
if(NULL != elem->nextElement())
{
// Add the arrow
QLabel* pArrowLabel = new QLabel();
pArrowLabel->setStyleSheet(QString("background-color: transparent;"));
pArrowLabel->setPixmap(QPixmap(":images/navig_arrow.png"));
QGraphicsWidget* arrowWidget = mpScene->addWidget(pArrowLabel);
mpLayout->addItem(arrowWidget);
mVItems << arrowWidget;
mSceneWidth += pArrowLabel->pixmap()->width() + 4; // 2px border
// Recursively call this method while a next item exists
addItem(elem->nextElement());
}
}
}
/**
* \brief Handles the resize event
* @param event as the resize event
*/
void UBLibPathViewer::resizeEvent(QResizeEvent *event)
{
if(event->oldSize() == event->size())
event->ignore();
else{
if(NULL != mpContainer)
mpContainer->setMinimumWidth(width() - 20);
viewport()->resize(width() - 10, viewport()->height());
updateScrolls();
event->accept();
}
}
void UBLibPathViewer::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
updateScrolls();
}
/**
* \brief Handles the mouse move event
* @param event as the mouse move event
*/
void UBLibPathViewer::mouseMoveEvent(QMouseEvent *event)
{
event->ignore();
}
void UBLibPathViewer::onMouseClicked(UBChainedLibElement *elem)
{
emit mouseClick(elem);
}
int UBLibPathViewer::widgetAt(QPointF p)
{
int position = -1;
for(int i = 0; i < mVItems.size(); i++)
{
QGraphicsWidget* pCrntWidget = mVItems.at(i);
if(NULL != pCrntWidget)
{
QRectF r = pCrntWidget->rect();
QPointF wPos = pCrntWidget->scenePos();
int xMin = wPos.x() + r.x();
int xMax = wPos.x() + r.x() + r.width();
int yMin = wPos.y() + r.y();
int yMax = wPos.y() + r.y() + r.height();
if(p.x() >= xMin &&
p.x() <= xMax &&
p.y() >= yMin &&
p.y() <= yMax)
{
return i;
}
}
}
return position;
}
void UBLibPathViewer::onElementsDropped(QList<QString> elements, UBLibElement *target)
{
emit elementsDropped(elements, target);
}
void UBLibPathViewer::showBack()
{
// Backup the current path so we can go back by clicking on the back button
mpElemsBackup = mpElems;
// Set the correct path to the backElem
UBChainedLibElement* pLastElem = mpElemsBackup->lastElement();
if(NULL != pLastElem)
{
mpBackElem->setPath(pLastElem->element()->path());
mpBackElem->setType(pLastElem->element()->type());
mpBackElem->setName(pLastElem->element()->name());
}
// Display the 'back' element
displayPath(new UBChainedLibElement(mpBackElem));
}
UBFolderPath::UBFolderPath():QGraphicsProxyWidget()
{
}
UBFolderPath::~UBFolderPath()
{
}
/**
* \brief Handles the drag enter event
* @param pEvent as the drag enter event
*/
void UBFolderPath::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
event->acceptProposedAction();
}
/**
* \brief Handles the drop event
* @param pEvent as the drop event
*/
void UBFolderPath::dropEvent(QDropEvent *pEvent)
{
processMimeData(pEvent->mimeData());
pEvent->acceptProposedAction();
}
/**
* \brief Handles the drag move event
* @param pEvent as the drag move event
*/
void UBFolderPath::dragMoveEvent(QDragMoveEvent* pEvent)
{
pEvent->acceptProposedAction();
}
/**
* \brief Process the given MIME data
* @param pData as the MIME data to process
*/
void UBFolderPath::processMimeData(const QMimeData *pData)
{
Q_UNUSED(pData);
}
/**
* \brief Handles the mouse press event
* @param event as the mouse press event
*/
void UBFolderPath::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
}
/**
* \brief Handles the mouse move event
* @param event as the mouse move event
*/
void UBFolderPath::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event);
}
/**
* \brief Handles the mouse release event
* @param event as the mouse release event
*/
void UBFolderPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
}
UBPathScene::UBPathScene(QWidget* parent):QGraphicsScene(parent)
{
connect(UBDownloadManager::downloadManager(), SIGNAL(allDownloadsFinished()), this, SLOT(onAllDownloadsFinished()));
}
UBPathScene::~UBPathScene()
{
}
void UBPathScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
mDragStartPos = event->scenePos();
mClickTime = QTime::currentTime();
}
}
/**
* \brief Handles the mouse release event
* @param event as the mouse release event
*/
void UBPathScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
int elapsedTimeSincePress = mClickTime.elapsed();
if(elapsedTimeSincePress < STARTDRAGTIME)
{
QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(event->pos()));
if(NULL != pGWidget)
{
// We have only one view at a time
UBLibPathViewer* pView = dynamic_cast<UBLibPathViewer*>(this->views().at(0));
if(NULL != pView)
{
int iClickedItem = pView->widgetAt(event->scenePos());
QGraphicsLayout* wgtLayout = pGWidget->layout();
if(iClickedItem != -1 && wgtLayout != NULL)
{
QGraphicsWidget* pFolderW = dynamic_cast<QGraphicsWidget*>(wgtLayout->itemAt(iClickedItem));
if(NULL != pFolderW)
{
UBChainedLibElement* chElem = mMapWidgetToChainedElem[pFolderW];
if(NULL != chElem)
{
emit mouseClick(chElem);
}
}
}
}
}
}
}
/**
* \brief Handles the mouse move event
* @param event as the mouse move event
*/
void UBPathScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
if((event->pos() - mDragStartPos).manhattanLength() < QApplication::startDragDistance())
{
// The user is not doing a drag
return;
}
// The user is performing a drag operation
QDrag* drag = new QDrag(event->widget());
QMimeData* mimeData = new QMimeData();
drag->setMimeData(mimeData);
drag->start();
}
}
void UBPathScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
event->accept();
}
void UBPathScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
{
event->accept();
}
void UBPathScene::dropEvent(QGraphicsSceneDragDropEvent *event)
{
bool bAccept = false;
const QMimeData* pMimeData = event->mimeData();
if(NULL != event->source() && 0 == QString::compare(event->source()->metaObject()->className(), "UBLibraryWidget")){
UBLibElement* pTargetElement = elementFromPos(event->scenePos());
if(NULL != pTargetElement){
if(eUBLibElementType_Folder == pTargetElement->type()){
// The drag comes from this application, we have now to get the list of UBLibElements*
QList<QString> qlDroppedElems;
foreach(QUrl url, pMimeData->urls())
qlDroppedElems << url.toString();
if(!qlDroppedElems.empty()){
// Send a signal with the target dir and the list of ublibelement*
emit elementsDropped(qlDroppedElems, pTargetElement);
}
}
}
bAccept = true;
}else if(NULL != pMimeData && pMimeData->hasUrls()){
QList<QUrl> urls = pMimeData->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
// 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);
bAccept = true;
}
}
}
if(!bAccept && NULL != pMimeData && pMimeData->hasText()){
// The user can only drop an Url in this location so if the text is not an Url,
// we discard it.
QString qsTxt = pMimeData->text().remove(QRegExp("[\\0]"));
if(qsTxt.startsWith("http")){
// 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(qsTxt).fileName();
desc.totalSize = 0;
desc.url = qsTxt;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
bAccept = true;
}
}
if(!bAccept && NULL != pMimeData && pMimeData->hasHtml()){
QString html = pMimeData->html();
QString url = UBApplication::urlFromHtml(html);
if("" != url)
{
// 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(url).fileName();
desc.totalSize = 0;
desc.url = url;
UBDownloadManager::downloadManager()->addFileToDownload(desc);
bAccept = true;
}
}
if(bAccept){
event->accept();
}
else{
event->ignore();
}
}
/**
* \brief Return the element related to the given position
* @param p as the given position
*
*/
UBLibElement* UBPathScene::elementFromPos(QPointF p)
{
UBLibElement* pElem = NULL;
QGraphicsWidget* pGWidget = dynamic_cast<QGraphicsWidget*>(itemAt(p));
if(NULL != pGWidget)
{
UBChainedLibElement* chElem = mMapWidgetToChainedElem[pGWidget];
if(NULL != chElem)
{
return chElem->element();
}
}
return pElem;
}
void UBPathScene::onAllDownloadsFinished()
{
// Hide the download tab
UBApplication::boardController->paletteManager()->stopDownloads();
}

@ -1,148 +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 2 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 UBLIBPATHVIEWER_H
#define UBLIBPATHVIEWER_H
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsWidget>
#include <QGraphicsPixmapItem>
#include <QGraphicsProxyWidget>
#include <QVector>
#include <QPixmap>
#include <QResizeEvent>
#include <QGraphicsLinearLayout>
#include <QMouseEvent>
#include <QTime>
#include <QMap>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
#include <QMimeData>
#include <QPaintEvent>
#include <QShowEvent>
#include "board/UBLibraryController.h"
#define PATHITEMWIDTH 32
#define STARTDRAGTIME 1000000
class UBPathScene : public QGraphicsScene
{
Q_OBJECT
public:
UBPathScene(QWidget* parent=0);
~UBPathScene();
QMap<QGraphicsWidget*, UBChainedLibElement*>* mapWidgetToChainedElem(){return &mMapWidgetToChainedElem;}
signals:
void mouseClick(UBChainedLibElement* elem);
void elementsDropped(QList<QString> elements, UBLibElement* target);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
void dropEvent(QGraphicsSceneDragDropEvent *event);
private slots:
void onAllDownloadsFinished();
private:
UBLibElement* elementFromPos(QPointF p);
/** The drag start position */
QPointF mDragStartPos;
/** A timer used to detect a click or a drag */
QTime mClickTime;
/** A map between a widget and a chained element */
QMap<QGraphicsWidget*, UBChainedLibElement*> mMapWidgetToChainedElem;
};
class UBLibPathViewer : public QGraphicsView
{
Q_OBJECT
public:
UBLibPathViewer(QWidget* parent=0, const char* name="UBLibPathViewer");
~UBLibPathViewer();
void displayPath(UBChainedLibElement* elementsChain);
int widgetAt(QPointF p);
void updateScrolls();
public slots:
void showBack();
signals:
void mouseClick(UBChainedLibElement* elem);
void elementsDropped(QList<QString> elements, UBLibElement* target);
protected:
void resizeEvent(QResizeEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void showEvent(QShowEvent *event);
private slots:
void onMouseClicked(UBChainedLibElement* elem);
void onElementsDropped(QList<QString> elements, UBLibElement* target);
void onSliderMoved(int value);
private:
void refreshPath();
void addItem(UBChainedLibElement* elem);
/** The chained path elements */
UBChainedLibElement* mpElems;
/** The backup chained path elements */
UBChainedLibElement* mpElemsBackup;
/** The scene */
UBPathScene* mpScene;
//QGraphicsScene* mpScene;
/** The layout */
QGraphicsLinearLayout* mpLayout;
/** The container that will display the path properly */
QGraphicsWidget* mpContainer;
/** The list of path items (icons + arrows) */
QVector<QGraphicsWidget*> mVItems;
/** The total width of the element in the scene */
int mSceneWidth;
/** The back element */
UBLibElement* mpBackElem;
};
class UBFolderPath : public QGraphicsProxyWidget
{
public:
UBFolderPath();
~UBFolderPath();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
void dropEvent(QDropEvent *pEvent);
void dragMoveEvent(QDragMoveEvent *pEvent);
private:
void processMimeData(const QMimeData* pData);
};
#endif // UBLIBPATHVIEWER_H

@ -1,89 +0,0 @@
#include <QDomDocument>
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
#include "UBLibWebView.h"
#include "core/memcheck.h"
UBLibWebView::UBLibWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL)
, mpWebSettings(NULL)
, mpLayout(NULL)
, mpSankoreAPI(NULL)
{
setObjectName(name);
SET_STYLE_SHEET();
mpLayout = new QVBoxLayout();
setLayout(mpLayout);
mpView = new QWebView(this);
mpView->setObjectName("SearchEngineView");
mpSankoreAPI = new UBWidgetUniboardAPI(UBApplication::boardController->activeScene());
connect(mpView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
mpLayout->addWidget(mpView);
}
UBLibWebView::~UBLibWebView()
{
if(NULL != mpSankoreAPI){
delete mpSankoreAPI;
mpSankoreAPI = NULL;
}
if(NULL != mpView){
delete mpView;
mpView = NULL;
}
if(NULL != mpLayout){
delete mpLayout;
mpLayout = NULL;
}
}
void UBLibWebView::setElement(UBLibElement *elem)
{
if(NULL != elem)
{
QString qsWidgetName;
QString path = elem->path().toLocalFile();
QString qsConfigPath = QString("%0/config.xml").arg(path);
if(QFile::exists(qsConfigPath))
{
QFile f(qsConfigPath);
if(f.open(QIODevice::ReadOnly))
{
QDomDocument domDoc;
domDoc.setContent(QString(f.readAll()));
QDomElement root = domDoc.documentElement();
QDomNode node = root.firstChild();
while(!node.isNull())
{
if(node.toElement().tagName() == "content")
{
QDomAttr srcAttr = node.toElement().attributeNode("src");
qsWidgetName = srcAttr.value();
break;
}
node = node.nextSibling();
}
f.close();
}
}
mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName)));
}
}
void UBLibWebView::javaScriptWindowObjectCleared()
{
mpView->page()->mainFrame()->addToJavaScriptWindowObject("sankore", mpSankoreAPI);
}

@ -1,32 +0,0 @@
#ifndef UBLIBWEBVIEW_H
#define UBLIBWEBVIEW_H
#include <QWidget>
#include <QWebView>
#include <QWebSettings>
#include <QVBoxLayout>
#include "board/UBLibraryController.h"
#include "api/UBWidgetUniboardAPI.h"
class UBLibWebView : public QWidget
{
Q_OBJECT
public:
UBLibWebView(QWidget* parent = 0, const char* name = "UBLibWebView");
~UBLibWebView();
void setElement(UBLibElement* elem);
protected slots:
virtual void javaScriptWindowObjectCleared();
private:
QWebView* mpView;
QWebSettings* mpWebSettings;
QVBoxLayout* mpLayout;
UBWidgetUniboardAPI* mpSankoreAPI;
};
#endif // UBLIBWEBVIEW_H

@ -1,230 +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 2 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 <QDebug>
#include "UBLibWidget.h"
#include "core/UBApplication.h"
#include "globals/UBGlobals.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mLayout(NULL)
, mStackedWidget(NULL)
, mNavigator(NULL)
, mProperties(NULL)
, mActionBar(NULL)
, mpWebView(NULL)
, mpPathViewer(NULL)
{
setObjectName(name);
mName = "LibWidget";
mVisibleState = true;
SET_STYLE_SHEET();
mIconToLeft = QPixmap(":images/library_open.png");
mIconToRight = QPixmap(":images/library_close.png");
setAcceptDrops(true);
mLayout = new QVBoxLayout(this);
setLayout(mLayout);
// -------------
// Build the GUI
// -------------
// The 'global' widgets
mStackedWidget = new QStackedWidget(this);
mActionBar = new UBLibActionBar(this);
mpPathViewer = new UBLibPathViewer(this);
mpPathViewer->setMaximumHeight(62);
// The internal widgets
mNavigator = new UBLibNavigatorWidget(this);
mProperties = new UBLibItemProperties(this);
mpWebView = new UBLibWebView(this);
mLayout->addWidget(mpPathViewer, 0);
mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mActionBar, 0);
mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mProperties);
mStackedWidget->addWidget(mpWebView);
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
connect(mNavigator, SIGNAL(updateNavigBar(UBChainedLibElement*)), this, SLOT(onUpdateNavigBar(UBChainedLibElement*)));
connect(mNavigator, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(showProperties(UBLibElement*)));
connect(mNavigator, SIGNAL(displaySearchEngine(UBLibElement*)), this, SLOT(showSearchEngine(UBLibElement*)));
connect(mProperties, SIGNAL(showFolderContent()), this, SLOT(showFolder()));
connect(this, SIGNAL(showLibElemProperties()), mpPathViewer, SLOT(showBack()));
connect(this, SIGNAL(showLibSearchEngine()), mpPathViewer, SLOT(showBack()));
}
/**
* \brief Destructor
*/
UBLibWidget::~UBLibWidget()
{
if(NULL != mpPathViewer)
{
delete mpPathViewer;
mpPathViewer = NULL;
}
if(NULL != mNavigator)
{
delete mNavigator;
mNavigator = NULL;
}
if(NULL != mpWebView)
{
delete mpWebView;
mpWebView = NULL;
}
if(NULL != mProperties)
{
delete mProperties;
mProperties = NULL;
}
if(NULL != mStackedWidget)
{
delete mStackedWidget;
mStackedWidget = NULL;
}
if(NULL != mActionBar)
{
delete mActionBar;
mActionBar = NULL;
}
if(NULL != mLayout)
{
delete mLayout;
mLayout = NULL;
}
}
/**
* \brief Handles the drag enter event
* @param pEvent as the drag enter event
*/
void UBLibWidget::dragEnterEvent(QDragEnterEvent *pEvent)
{
setBackgroundRole(QPalette::Highlight);
pEvent->acceptProposedAction();
}
void UBLibWidget::dragLeaveEvent(QDragLeaveEvent *pEvent)
{
pEvent->accept();
}
/**
* \brief Handles the drop event
* @param pEvent as the drop event
*/
void UBLibWidget::dropEvent(QDropEvent *pEvent)
{
processMimeData(pEvent->mimeData());
setBackgroundRole(QPalette::Dark);
mStackedWidget->setCurrentIndex(miCrntStackWidget);
pEvent->acceptProposedAction();
}
/**
* \brief Handles the drag move event
* @param pEvent as the drag move event
*/
void UBLibWidget::dragMoveEvent(QDragMoveEvent *pEvent)
{
pEvent->acceptProposedAction();
}
/**
* \brief Process the dropped MIME data
* @param pData as the mime dropped data
*/
void UBLibWidget::processMimeData(const QMimeData *pData)
{
// Display the different mime types contained in the mime data
QStringList qslFormats = pData->formats();
for(int i = 0; i < qslFormats.size(); i++)
{
qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i);
}
}
void UBLibWidget::showProperties(UBLibElement *elem)
{
if(NULL != elem)
{
emit showLibElemProperties();
mActionBar->setButtons(eButtonSet_Properties);
mProperties->showElement(elem);
mStackedWidget->setCurrentIndex(ID_PROPERTIES);
miCrntStackWidget = ID_PROPERTIES;
}
}
void UBLibWidget::showSearchEngine(UBLibElement *elem)
{
if(NULL != elem)
{
emit showLibSearchEngine();
mActionBar->hide();
mpWebView->setElement(elem);
mStackedWidget->setCurrentIndex(ID_WEBVIEW);
miCrntStackWidget = ID_WEBVIEW;
}
}
void UBLibWidget::showFolder()
{
if(!mActionBar->isVisible()){
mActionBar->setVisible(true);
}
mActionBar->setButtons(mActionBar->previousButtonSet());
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
}
int UBLibWidget::customMargin()
{
return 5;
}
int UBLibWidget::border()
{
return 15;
}
void UBLibWidget::onUpdateNavigBar(UBChainedLibElement *elem)
{
mpPathViewer->displayPath(elem);
mpPathViewer->show();
if(ID_NAVIGATOR != miCrntStackWidget)
{
showFolder();
}
}

@ -1,97 +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 2 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 UBLIBWIDGET_H
#define UBLIBWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QStackedWidget>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
#include <QMimeData>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QLabel>
#include "UBDockPaletteWidget.h"
#include "UBLibNavigatorWidget.h"
#include "UBLibItemProperties.h"
#include "UBLibActionBar.h"
#include "UBLibWebView.h"
#include "UBLibPathViewer.h"
#define ID_NAVIGATOR 0
#define ID_PROPERTIES 1
#define ID_WEBVIEW 2
class UBLibWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBLibWidget(QWidget* parent=0, const char* name="UBLibWidget");
~UBLibWidget();
UBLibActionBar* actionBar(){return mActionBar;}
UBLibNavigatorWidget* libNavigator() {return mNavigator;}
UBLibPathViewer* pathViewer() {return mpPathViewer;}
bool visibleInMode(eUBDockPaletteWidgetMode mode)
{
return mode == eUBDockPaletteWidget_BOARD
|| mode == eUBDockPaletteWidget_DESKTOP;
}
signals:
void resized();
void showLibElemProperties();
void showLibSearchEngine();
protected:
void dragEnterEvent(QDragEnterEvent* pEvent);
void dropEvent(QDropEvent *pEvent);
void dragMoveEvent(QDragMoveEvent* pEvent);
void dragLeaveEvent(QDragLeaveEvent* pEvent);
private slots:
void showProperties(UBLibElement* elem);
void showSearchEngine(UBLibElement* elem);
void showFolder();
void onUpdateNavigBar(UBChainedLibElement* elem);
private:
void processMimeData(const QMimeData* pData);
int customMargin();
int border();
/** The layout */
QVBoxLayout* mLayout;
/** The stacked layout */
QStackedWidget* mStackedWidget;
/** The Navigator widget */
UBLibNavigatorWidget* mNavigator;
/** The Properties widget */
UBLibItemProperties* mProperties;
/** UBLibActionBar */
UBLibActionBar* mActionBar;
/** The current stack widget index*/
int miCrntStackWidget;
/** The webview used to display the search engines */
UBLibWebView* mpWebView;
/** The path navigation widget */
UBLibPathViewer* mpPathViewer;
};
#endif // UBLIBWIDGET_H

@ -1,704 +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 2 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 <QList>
#include <QFileInfo>
#include <QDir>
#include "UBLibraryWidget.h"
#include "core/UBSettings.h"
#include "core/UBSetting.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "board/UBLibraryController.h"
#include "board/UBBoardPaletteManager.h"
#include "core/UBDownloadManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the widget object name
*/
UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailWidget(parent)
, chainedElements(NULL)
, mLibraryController(NULL)
, mpCrntDir(NULL)
, mpCrntElem(NULL)
, mpTmpElem(NULL)
, mLoadingLibraryItems(false)
{
setObjectName(name);
setSpacing(5);
mLibraryController = new UBLibraryController(parentWidget());
}
/**
* \brief Destructor
*/
UBLibraryWidget::~UBLibraryWidget()
{
if(NULL != mLibraryController){
delete mLibraryController;
mLibraryController = NULL;
}
if(NULL != mpCrntDir){
delete mpCrntDir;
mpCrntDir = NULL;
}
if(NULL != mpCrntElem){
delete mpCrntElem;
mpCrntElem = NULL;
}
if(NULL != mpTmpElem){
delete mpTmpElem;
mpTmpElem = NULL;
}
}
/**
* \brief Initialize the widget content
*/
void UBLibraryWidget::init()
{
setAcceptDrops(true);
mpCrntElem = new UBLibElement();
mpCrntElem->setThumbnail(QImage(":images/libpalette/home.png"));
chainedElements = new UBChainedLibElement(mpCrntElem);
QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntElem);
mCurrentElems = qlElems;
setCurrentElemsAndRefresh(chainedElements);
connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int)));
connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
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>)));
connect(mLibraryController,SIGNAL(updateItemsList()),this,SLOT(onRefreshCurrentFolder()));
}
/**
* \brief Refresh the view
*/
void UBLibraryWidget::refreshView()
{
// Clear the view
mItems.clear();
mLabels.clear();
mItemsPaths.clear();
mGraphicItems.clear();
// Generate the graphics items
generateItems();
// Set the new items
setGraphicsItems(mGraphicItems, mItemsPaths, mLabels);
// Refresh the view
refreshScene();
emit navigBarUpdate(mpCrntElem);
bool bFavorite = false;
if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
{
bFavorite = true;
}
emit favoritesEntered(bFavorite);
}
/**
* \brief Generate the graphic items related to the current directory
*/
void UBLibraryWidget::generateItems()
{
for(int i = 0; i < mCurrentElems.size(); i++)
{
UBLibElement* pElem = mCurrentElems.at(i);
mLabels << pElem->name();
mItemsPaths << pElem->path();
QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(QPixmap::fromImage(*pElem->thumbnail()));
mGraphicItems << pixmapItem;
}
}
/**
* \brief Handles the click on an item
* @param item as the clicked item
* @param index as the given index
*/
void UBLibraryWidget::onItemClicked(QGraphicsItem *item, int index)
{
Q_UNUSED(index);
if(NULL != item)
{
mLoadingLibraryItems = true;
int iItem = mGraphicItems.indexOf(item);
if(0 <= iItem)
{
UBLibElement* pElem = mCurrentElems.at(iItem);
if(NULL != pElem)
{
delete mpCrntElem;
mpCrntElem = new UBLibElement(pElem);
if(eUBLibElementType_Folder == pElem->type() || eUBLibElementType_VirtualFolder == pElem->type())
{
// Add the clicked element to the end of the elements list
// (at this level, the user can only go down in the path)
UBChainedLibElement* pNextElem = new UBChainedLibElement(pElem);
appendChainedElement(pNextElem, chainedElements);
delete mpCrntDir;
mpCrntDir = new UBLibElement(pElem);
// Display the content of the folder
QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntDir);
mCurrentElems = qlElems;
refreshView();
}
else
{
if ("application/search" == UBFileSystemUtils::mimeTypeFromFileName(pElem->path().toLocalFile()))
{
emit displaySearchEngine(pElem);
}
else
{
// Display the properties view
emit propertiesRequested(pElem);
}
}
}
emit itemClicked();
}
mLoadingLibraryItems = false;
}
}
/**
* \brief Append the given element to the given chain
* @param element as the element to append
* @param toElem as the given chain
*/
void UBLibraryWidget::appendChainedElement(UBChainedLibElement *element, UBChainedLibElement *toElem)
{
if(NULL != toElem)
{
if(NULL != toElem->nextElement())
{
appendChainedElement(element, toElem->nextElement());
}
else
{
toElem->setNextElement(element);
}
}
}
/**
* \brief Set the current element and refresh the scene
* @param elem as the current element
*/
void UBLibraryWidget::setCurrentElemsAndRefresh(UBChainedLibElement *elem)
{
if(NULL != elem)
{
UBLibElement* pLibElem = elem->element();
if(NULL != pLibElem)
{
if(eUBLibElementType_Item != pLibElem->type())
{
QList<UBLibElement*> qlElements = mLibraryController->getContent(pLibElem);
mCurrentElems = qlElements;
delete mpCrntElem;
mpCrntElem = new UBLibElement(pLibElem);
refreshView();
delete mpCrntDir;
mpCrntDir = new UBLibElement(pLibElem);
bool bFavorite = false;
if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
{
bFavorite = true;
}
emit favoritesEntered(bFavorite);
}
}
}
}
/**
* \brief Handles the selection changed event
*/
void UBLibraryWidget::onSelectionChanged()
{
// Get the selected items
QList<UBLibElement*> qlSelectedItems;
QList<QGraphicsItem*> qlGI = selectedItems();
bCanDrag = true;
foreach(QGraphicsItem* it, qlGI)
{
int itIndex = mGraphicItems.indexOf(it);
if(0 <= itIndex)
{
UBLibElement* pElem = mCurrentElems.at(itIndex);
if(NULL != pElem)
{
if(eUBLibElementType_Category != pElem->type() && eUBLibElementType_VirtualFolder != pElem->type()) {
qlSelectedItems << pElem;
}
if(!pElem->isMoveable())
{
bCanDrag = false;
}
}
}
}
// Check if we are in the trash folder
bool bInTrash = false;
if(NULL != mpCrntDir)
{
if("Trash" == mpCrntDir->name())
{
bInTrash = true;
}
}
// Send the signal with these items
emit itemsSelected(qlSelectedItems, bInTrash);
}
/**
* \brief Handle the delete done event
*/
void UBLibraryWidget::onRefreshCurrentFolder()
{
// Refresh the current view
mCurrentElems = mLibraryController->getContent(mpCrntDir);
refreshView();
}
/**
* \brief Handles the drag enter event
* @param event as the drag enter event
*/
void UBLibraryWidget::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
/**
* \brief Handles the drag move event
* @param event as the drag move event
*/
void UBLibraryWidget::dragMoveEvent(QDragMoveEvent *event)
{
UBLibElement* pElem = elementAt(event->pos());
if(NULL != pElem)
{
// We can only drop an item into a folder
if(eUBLibElementType_Folder == pElem->type() ||
eUBLibElementType_VirtualFolder == pElem->type())
{
event->acceptProposedAction();
}
}
}
void UBLibraryWidget::onDropMe(const QMimeData *_data)
{
Q_UNUSED(_data);
}
/**
* \brief Handles the drop event
* @param event as the drop event
*/
void UBLibraryWidget::dropEvent(QDropEvent *event)
{
const QMimeData* pMimeData = event->mimeData();
if(event->source() == this){
event->accept();
// Get the destination item
UBLibElement* pElem = elementAt(event->pos());
if(NULL != pElem){
if(eUBLibElementType_Folder == pElem->type()){
// The drag comes from this application, we have now to get the list of UBLibElements*
QList<QString> qlDroppedElems;
foreach(QUrl url, pMimeData->urls()){
qlDroppedElems << url.toString();
}
if(!qlDroppedElems.empty())
onElementsDropped(qlDroppedElems, pElem);
}
}
}
else{
bool bDropAccepted = false;
// We must check the URLs first because an image dropped from the web can contains the image datas, as well as the URLs
// and if we want to display the download widget in order to make the user wait for the end of the download, we need
// to check the URLs first!
if (pMimeData->hasUrls()){
QList<QUrl> urlList = pMimeData->urls();
for (int i = 0; i < urlList.size() && i < 32; ++i){
QString crntPath = urlList.at(i).toString();
mLibraryController->importItemOnLibrary(crntPath);
bDropAccepted = true;
}
}
// When an HTML is present, it means that we dropped something from the web. Normally, the HTML contains the element
// of the webpage and has a 'src' attribute containing the URL of the web ressource. Here we are looking for this
// 'src' attribute, get its value and download the ressource from this URL.
if (!bDropAccepted && pMimeData->hasHtml()){
QString html = pMimeData->html();
QString url = UBApplication::urlFromHtml(html);
if("" != url){
mLibraryController->importItemOnLibrary(url);
bDropAccepted = true;
}
}
if (!bDropAccepted && pMimeData->hasText()){
// On linux external dragged element are considered as text;
QString filePath = QUrl(pMimeData->text()).toLocalFile();
if("" != filePath){
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
else{
#ifdef Q_WS_MACX
// With Safari, in 95% of the drops, the mime datas are hidden in Apple Web Archive pasteboard type.
// This is due to the way Safari is working so we have to dig into the pasteboard in order to retrieve
// the data.
QString qsUrl = UBPlatformUtils::urlFromClipboard();
if("" != qsUrl){
// We finally got the url of the dropped ressource! Let's import it!
mLibraryController->importItemOnLibrary(qsUrl);
bDropAccepted = true;
}
#endif
}
}
if (!bDropAccepted && pMimeData->hasImage()){
QImage image = qvariant_cast<QImage>(pMimeData->imageData());
mLibraryController->importImageOnLibrary(image);
bDropAccepted = true;
}
if(bDropAccepted){
onRefreshCurrentFolder();
#ifdef Q_WS_MACX
event->acceptProposedAction();
#else
event->accept();
#endif
}
else{
event->ignore();
}
}
}
/**
* \brief Get the element at the given position
* @param p as the given position
* @return a pointer on the related element
*/
UBLibElement* UBLibraryWidget::elementAt(QPoint p)
{
QGraphicsItem* pItem = itemAt(p);
if(NULL != pItem)
{
int iItem = mGraphicItems.indexOf(pItem);
if(-1 != iItem)
{
return mCurrentElems.at(iItem);
}
}
// If no element is found, return NULL
return NULL;
}
/**
* \brief Get the element from the given name
* @param name as the given element name
* @return the UBLibElement related to the given name
*/
UBLibElement* UBLibraryWidget::elementFromFilePath(const QString &filePath)
{
UBLibElement* pElem = NULL;
foreach(UBLibElement* elem, mCurrentElems)
{
if(elem->path().toLocalFile() == QUrl(filePath).toLocalFile())
{
return elem;
}
}
return pElem;
}
/**
* \brief Update the thumbnails size
* @param newSize as the thumbnail size
*/
void UBLibraryWidget::updateThumbnailsSize(int newSize)
{
setThumbnailWidth(newSize);
refreshView();
}
/**
* \brief Handles the element dropped event
* @param elements as the list of dropped elements
* @param target as the drop target
*/
void UBLibraryWidget::onElementsDropped(QList<QString> elements, UBLibElement *target)
{
if(target != mpCrntDir)
{
QList<UBLibElement*> qlElements;
foreach(QString qsElem, elements)
qlElements << elementFromFilePath(qsElem);
mLibraryController->moveContent(qlElements, target);
mCurrentElems = mLibraryController->getContent(mpCrntDir);
refreshView();
}
}
/**
* \brief Search the element related to the given text
* @param elem as the searched element name
*/
void UBLibraryWidget::onSearchElement(QString elem)
{
// Store the original list of items
mOrigCurrentElems = mLibraryController->getContent(mpCrntDir);
// Build the filtered list
mCurrentElems.clear();
if(elem.isEmpty())
{
mCurrentElems = mOrigCurrentElems;
}
else
{
foreach(UBLibElement* ubLibElem, mOrigCurrentElems)
{
if(ubLibElem->name().toLower().contains(elem.toLower()))
{
mCurrentElems << ubLibElem;
}
}
}
refreshView();
}
/**
* \brief Create a new folder
*/
void UBLibraryWidget::onNewFolderToCreate()
{
// Create here a dialog asking the name of the new folder
UBNewFolderDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
mLibraryController->createNewFolder(dlg.folderName(), mpCrntElem);
onRefreshCurrentFolder();
}
}
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBNewFolderDlg::UBNewFolderDlg(QWidget *parent, const char *name):QDialog(parent)
, mpLabel(NULL)
, mpLineEdit(NULL)
, mpButtons(NULL)
, mpAddButton(NULL)
, mpCancelButton(NULL)
, mpLayout(NULL)
{
setObjectName(name);
setWindowTitle(tr("Add new folder"));
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
mpLabel = new QLabel(tr("New Folder name:"),this);
mpLineEdit = new QLineEdit(this);
mpAddButton = new QPushButton(tr("Add"));
mpAddButton->setDefault(true);
mpCancelButton = new QPushButton(tr("Cancel"));
mpCancelButton->setAutoDefault(false);
mpButtons = new QDialogButtonBox(Qt::Horizontal, this);
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpLayout->addWidget(mpLabel, 1);
mpLayout->addWidget(mpLineEdit);
mpButtons->addButton(mpAddButton,QDialogButtonBox::ActionRole);
mpButtons->addButton(mpCancelButton,QDialogButtonBox::ActionRole);
mpLayout->addWidget(mpButtons, 1,Qt::AlignJustify);
connect(mpAddButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(mpCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(mpLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(text_Changed(const QString &)));
connect(mpLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(text_Edited(const QString &)));
setMaximumHeight(100);
setMinimumHeight(100);
}
/**
* \brief Destructor
*/
UBNewFolderDlg::~UBNewFolderDlg()
{
if(NULL != mpAddButton)
{
delete mpAddButton;
mpAddButton = NULL;
}
if(NULL != mpCancelButton)
{
delete mpCancelButton;
mpCancelButton = NULL;
}
if(NULL != mpButtons)
{
delete mpButtons;
mpButtons = NULL;
}
if(NULL != mpLineEdit)
{
delete mpLineEdit;
mpLineEdit = NULL;
}
if(NULL != mpLabel)
{
delete mpLabel;
mpLabel = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
}
/**
* \brief Get the folder name
* @return the entered folder name
*/
QString UBNewFolderDlg::folderName()
{
return mpLineEdit->text();
}
void UBNewFolderDlg::text_Changed(const QString &newText)
{
Q_UNUSED(newText);
}
/*
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash) // Note: The C++ compiler transforms backslashes in strings. To include a \ in a regexp, enter it twice, i.e. \\. To match the backslash character itself, enter it four times, i.e. \\\\.
| (vertical bar or pipe)
? (question mark)
* (asterisk)
*/
void UBNewFolderDlg::text_Edited(const QString &newText)
{
QString new_text = newText;
#ifdef Q_WS_WIN // Defined on Windows.
QString illegalCharList(" < > : \" / \\ | ? * ");
QRegExp regExp("[<>:\"/\\\\|?*]");
#endif
#ifdef Q_WS_QWS // Defined on Qt for Embedded Linux.
QString illegalCharList(" < > : \" / \\ | ? * ");
QRegExp regExp("[<>:\"/\\\\|?*]");
#endif
#ifdef Q_WS_MAC // Defined on Mac OS X.
QString illegalCharList(" < > : \" / \\ | ? * ");
QRegExp regExp("[<>:\"/\\\\|?*]");
#endif
#ifdef Q_WS_X11 // Defined on X11.
QString illegalCharList(" < > : \" / \\ | ? * ");
QRegExp regExp("[<>:\"/\\\\|?*]");
#endif
if(new_text.indexOf(regExp) > -1)
{
new_text.remove(regExp);
mpLineEdit->setText(new_text);
QToolTip::showText(mpLineEdit->mapToGlobal(QPoint()), "A file name can`t contain any of the following characters:\r\n"+illegalCharList);
}
}
void UBLibraryWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
{
Q_UNUSED(pContentHeader);
if(pSuccess)
{
QString urlString = sourceUrl.toString();
mLibraryController->routeDataItem(urlString, pData);
}
}
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);
}

@ -1,124 +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 2 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 UBLIBRARYWIDGET_H
#define UBLIBRARYWIDGET_H
#include <QList>
#include <QVector>
#include <QGraphicsItem>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "UBThumbnailWidget.h"
#include "board/UBLibraryController.h"
class UBLibraryController;
class UBChainedLibElement;
class UBLibElement;
class UBLibraryWidget : public UBThumbnailWidget
{
Q_OBJECT
public:
UBLibraryWidget(QWidget* parent=0, const char* name="UBLibraryWidget");
~UBLibraryWidget();
UBChainedLibElement* chainedElements;
void setCurrentElemsAndRefresh(UBChainedLibElement* elem);
void updateThumbnailsSize(int newSize);
void init();
UBLibraryController* libraryController() {return mLibraryController;}
bool isLoadingLibraryItems() const { return mLoadingLibraryItems; }
public slots:
void onRefreshCurrentFolder();
void onElementsDropped(QList<QString> elements, UBLibElement* target);
void onSearchElement(QString elem);
void onNewFolderToCreate();
void onDropMe(const QMimeData* _data);
void onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData);
signals:
void navigBarUpdate(UBLibElement* pElem);
void itemsSelected(QList<UBLibElement*> elemList, bool inTrash);
void propertiesRequested(UBLibElement* pElem);
void displaySearchEngine(UBLibElement* pElem);
void favoritesEntered(bool bFav);
void itemClicked();
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private slots:
void onItemClicked(QGraphicsItem* pItem, int index);
void onSelectionChanged();
void onDisplayMetadata(QMap<QString,QString> metadatas);
private:
void refreshView();
void generateItems();
void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem);
UBLibElement* elementAt(QPoint p);
UBLibElement* elementFromFilePath(const QString& filePath);
UBLibraryController* mLibraryController;
UBLibElement* mpCrntDir;
UBLibElement* mpCrntElem;
UBLibElement* mpTmpElem;
QList<UBLibElement*> mCurrentElems;
QList<UBLibElement*> mOrigCurrentElems;
QList<QGraphicsItem*> mItems;
bool mLoadingLibraryItems;
};
class UBNewFolderDlg : public QDialog
{
Q_OBJECT
public:
UBNewFolderDlg(QWidget* parent=0, const char* name="NewFolderDlg");
~UBNewFolderDlg();
QString folderName();
public slots:
void text_Changed(const QString &);
void text_Edited(const QString &);
private:
QLabel* mpLabel;
QLineEdit* mpLineEdit;
QDialogButtonBox* mpButtons;
QPushButton* mpAddButton;
QPushButton* mpCancelButton;
QVBoxLayout* mpLayout;
};
#endif // UBLIBRARYWIDGET_H

@ -30,11 +30,6 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBDocumentNavigator.h \ src/gui/UBDocumentNavigator.h \
src/gui/UBDockPalette.h \ src/gui/UBDockPalette.h \
src/gui/UBPropertyPalette.h \ src/gui/UBPropertyPalette.h \
src/gui/UBLibNavigatorWidget.h \
src/gui/UBLibItemProperties.h \
src/gui/UBLibActionBar.h \
src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \
src/gui/UBUpdateDlg.h \ src/gui/UBUpdateDlg.h \
src/gui/UBDockPaletteWidget.h \ src/gui/UBDockPaletteWidget.h \
src/gui/UBLeftPalette.h \ src/gui/UBLeftPalette.h \
@ -84,20 +79,13 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBDocumentNavigator.cpp \ src/gui/UBDocumentNavigator.cpp \
src/gui/UBDockPalette.cpp \ src/gui/UBDockPalette.cpp \
src/gui/UBPropertyPalette.cpp \ src/gui/UBPropertyPalette.cpp \
src/gui/UBLibNavigatorWidget.cpp \
src/gui/UBLibItemProperties.cpp \
src/gui/UBLibActionBar.cpp \
src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \
src/gui/UBUpdateDlg.cpp \ src/gui/UBUpdateDlg.cpp \
src/gui/UBDockPaletteWidget.cpp \ src/gui/UBDockPaletteWidget.cpp \
src/gui/UBLeftPalette.cpp \ src/gui/UBLeftPalette.cpp \
src/gui/UBRightPalette.cpp \ src/gui/UBRightPalette.cpp \
src/gui/UBPageNavigationWidget.cpp \ src/gui/UBPageNavigationWidget.cpp \
src/gui/UBLibWidget.cpp \
src/gui/UBMagnifer.cpp \ src/gui/UBMagnifer.cpp \
src/gui/UBCachePropertiesWidget.cpp \ src/gui/UBCachePropertiesWidget.cpp \
src/gui/UBLibWebView.cpp \
src/gui/UBDownloadWidget.cpp \ src/gui/UBDownloadWidget.cpp \
src/gui/UBDockDownloadWidget.cpp \ src/gui/UBDockDownloadWidget.cpp \
src/gui/UBFeaturesWidget.cpp \ src/gui/UBFeaturesWidget.cpp \

Loading…
Cancel
Save