Commit 034503dd authored by Ilia Ryabokon's avatar Ilia Ryabokon

Deprecated lib widget cleaned

parent 43829e44
......@@ -82,12 +82,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mPendingPanButtonPressed(false)
, mPendingEraseButtonPressed(false)
, mpPageNavigWidget(NULL)
//#ifdef USE_WEB_WIDGET
, mpLibWidget(NULL)
//#endif
, mpCachePropWidget(NULL)
, mpDownloadWidget(NULL)
, mpDesktopLibWidget(NULL)
, mpTeacherGuideWidget(NULL)
, mDownloadInProgress(false)
{
......@@ -100,18 +96,11 @@ UBBoardPaletteManager::~UBBoardPaletteManager()
{
delete mAddItemPalette;
if(NULL != mStylusPalette)
{
delete mStylusPalette;
mStylusPalette = NULL;
}
if(NULL != mpDesktopLibWidget)
{
delete mpDesktopLibWidget;
mpDesktopLibWidget = NULL;
}
}
void UBBoardPaletteManager::initPalettesPosAtStartup()
......@@ -135,10 +124,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget();
#endif
mpCachePropWidget = new UBCachePropertiesWidget();
mpDownloadWidget = new UBDockDownloadWidget();
......
......@@ -22,7 +22,6 @@
#include "gui/UBLeftPalette.h"
#include "gui/UBRightPalette.h"
#include "gui/UBPageNavigationWidget.h"
#include "gui/UBLibWidget.h"
#include "gui/UBCachePropertiesWidget.h"
#include "gui/UBDockDownloadWidget.h"
#include "core/UBApplicationController.h"
......@@ -136,11 +135,6 @@ class UBBoardPaletteManager : public QObject
/** The page navigator widget */
UBPageNavigationWidget* mpPageNavigWidget;
//#ifdef USE_WEB_WIDGET
/** The library widget */
UBLibWidget* mpLibWidget;
//#endif
/** The cache properties widget */
UBCachePropertiesWidget* mpCachePropWidget;
......@@ -148,11 +142,6 @@ class UBBoardPaletteManager : public QObject
/** The download widget */
UBDockDownloadWidget* mpDownloadWidget;
// HACK: here we duplicate the lib widget for the desktop mode
// we MUST refactor the architecture in order to use only one
// lib widget!
UBLibWidget* mpDesktopLibWidget;
UBDockTeacherGuideWidget* mpTeacherGuideWidget;
bool mDownloadInProgress;
......
This diff is collapsed.
/*
* 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 \
src/board/UBBoardPaletteManager.h \
src/board/UBBoardView.h \
src/board/UBLibraryController.h \
src/board/UBDrawingController.h \
src/board/UBFeaturesController.h
SOURCES += src/board/UBBoardController.cpp \
src/board/UBBoardPaletteManager.cpp \
src/board/UBBoardView.cpp \
src/board/UBLibraryController.cpp \
src/board/UBDrawingController.cpp \
src/board/UBFeaturesController.cpp
......
......@@ -271,3 +271,28 @@ void UBFeaturesActionBar::dropEvent(QDropEvent *event)
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 <QToolButton>
#include <QDropEvent>
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
#define BUTTON_SIZE 24
#define ACTIONBAR_HEIGHT 42
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
{
IN_ROOT,
......
#include <QDomDocument>
#include <QWebView>
#include "UBFeaturesWidget.h"
#include "gui/UBThumbnailWidget.h"
#include "frameworks/UBFileSystemUtils.h"
......@@ -6,7 +8,6 @@
#include "core/UBDownloadManager.h"
#include "globals/UBGlobals.h"
#include "board/UBBoardController.h"
#include "globals/UBGlobals.h"
const char *UBFeaturesWidget::objNamePathList = "PathList";
const char *UBFeaturesWidget::objNameFeatureList = "FeatureList";
......@@ -23,8 +24,6 @@ static const QString mimeSankoreFeatureTypes = "Sankore/featureTypes";
UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
: UBDockPaletteWidget(parent)
, imageGatherer(NULL)
, mkFolderDlg(NULL)
{
setObjectName(name);
mName = "FeaturesWidget";
......@@ -151,12 +150,6 @@ void UBFeaturesWidget::createNewFolder()
emit sendFileNameList(controller->getFileNamesInFolders());
}
void UBFeaturesWidget::addFolder()
{
if (mkFolderDlg)
controller->addNewFolder(mkFolderDlg->folderName());
}
void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
{
if (!mimeData->features().count() )
......@@ -335,16 +328,6 @@ void UBFeaturesWidget::removeElementsFromFavorite()
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()
{
// stackedWidget->setCurrentIndex(ID_LISTVIEW);
......
......@@ -21,7 +21,9 @@
#include "api/UBWidgetUniboardAPI.h"
#include "UBFeaturesActionBar.h"
#include "UBRubberBand.h"
#include "gui/UBLibraryWidget.h"
#include <QtWebKit>
#include <QWebView>
#include <QWebSettings>
#define THUMBNAIL_WIDTH 400
#define ID_LISTVIEW 0
......@@ -81,7 +83,6 @@ private slots:
void currentSelected( const QModelIndex & );
void searchStarted( const QString & );
void createNewFolder();
void addFolder();
void deleteElements( const UBFeaturesMimeData * );
void addToFavorite( const UBFeaturesMimeData *);
void removeFromFavorite( const UBFeaturesMimeData * );
......@@ -94,7 +95,6 @@ private slots:
void lockIt(bool pLock);
private:
void resizeEvent(QResizeEvent *event);
void switchToListView();
void switchToProperties();
void switchToWebView();
......@@ -105,7 +105,6 @@ private:
QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar;
UBDownloadHttpFile* imageGatherer;
UBNewFolderDlg *mkFolderDlg;
UBFeaturesCentralWidget *centralWidget;
};
......@@ -220,9 +219,6 @@ private slots:
void scanStarted();
void scanFinished();
private:
};
class UBFeaturesNewFolderDialog : public QWidget
......
This diff is collapsed.
/*
* 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
/*
* 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()
{
}
/*
* 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
/*
* 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);
}
/*
* 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
This diff is collapsed.
/*
* 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
#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);
}
#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
/*
* 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();
}
}
/*
* 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
This diff is collapsed.
/*
* 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/UBDockPalette.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/UBDockPaletteWidget.h \
src/gui/UBLeftPalette.h \
......@@ -84,20 +79,13 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBDocumentNavigator.cpp \
src/gui/UBDockPalette.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/UBDockPaletteWidget.cpp \
src/gui/UBLeftPalette.cpp \
src/gui/UBRightPalette.cpp \
src/gui/UBPageNavigationWidget.cpp \
src/gui/UBLibWidget.cpp \
src/gui/UBMagnifer.cpp \
src/gui/UBCachePropertiesWidget.cpp \
src/gui/UBLibWebView.cpp \
src/gui/UBDownloadWidget.cpp \
src/gui/UBDockDownloadWidget.cpp \
src/gui/UBFeaturesWidget.cpp \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment