UBFeaturesComputingThread UBFeaturesNewFolderDialog

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent f6585ab884
commit fd289bc6d9
  1. 17
      resources/style.qss
  2. 384
      src/board/UBFeaturesController.cpp
  3. 81
      src/board/UBFeaturesController.h
  4. 11
      src/gui/UBFeaturesActionBar.cpp
  5. 375
      src/gui/UBFeaturesWidget.cpp
  6. 110
      src/gui/UBFeaturesWidget.h

@ -5,15 +5,21 @@ QWidget#UBLibNavigatorWidget,
QWidget#UBLibItemProperties, QWidget#UBLibItemProperties,
QWidget#UBDownloadWidget, QWidget#UBDownloadWidget,
QWidget#UBTeacherGuideWidget, QWidget#UBTeacherGuideWidget,
QWidget#UBFeatureProperties,
QWidget#UBFeaturesNavigatorWidget, QWidget#UBFeaturesNavigatorWidget,
QWidget#PathList QWidget#PathList,
QWidget#UBFeaturesCentralWidget
{ {
background: #EEEEEE; background: #EEEEEE;
border-radius: 10px; border-radius: 10px;
border: 2px solid #999999; border: 2px solid #999999;
} }
QWidget#mAdditionalDataContainer
{
border-radius: 10px;
border: 2px solid #999999;
}
QWidget#UBMediaVideoContainer QWidget#UBMediaVideoContainer
{ {
background: #000000; background: #000000;
@ -33,12 +39,9 @@ QListView
border: 0px; border: 0px;
} }
QWidget#UBFeatureProperties
QWidget#UBFeaturesWebView
{ {
background: #EEEEEE; border: 2px;
border-radius : 10px;
border: 2px solid #999999;
} }
QWebView#SearchEngineView QWebView#SearchEngineView

@ -1,5 +1,6 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QPointF> #include <QPointF>
#include <QtGui>
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
@ -9,7 +10,6 @@
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h" #include "frameworks/UBPlatformUtils.h"
#include "core/UBDownloadManager.h" #include "core/UBDownloadManager.h"
#include "domain/UBAbstractWidget.h" #include "domain/UBAbstractWidget.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
@ -22,22 +22,172 @@
const QString UBFeaturesController::virtualRootName = "root"; const QString UBFeaturesController::virtualRootName = "root";
UBFeature::UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath)
{ {
Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (abort) {
return;
}
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
QString fileName = fileInfo->fileName();
QImage icon = UBFeaturesController::getIcon(fullFileName, featureType);
if ( fullFileName.contains(".thumbnail."))
continue;
UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
emit sendFeature(testFeature);
emit featureSent();
// featuresList->append(testFeature);
// if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) {
// featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) );
// }
if (featureType == FEATURE_FOLDER) {
scanFS(QUrl::fromLocalFile(fullFileName), currVirtualPath + "/" + fileName);
}
}
} }
UBFeature::~UBFeature() void UBFeaturesComputingThread::scanAll(QList<QPair<QUrl, QString> > pScanningData)
{ {
for (int i = 0; i < mChildren.count(); i++) { for (int i = 0; i < pScanningData.count(); i++) {
delete mChildren[i]; if (abort) {
return;
} }
QPair<QUrl, QString> curPair = pScanningData.at(i);
scanFS(curPair.first, curPair.second);
}
}
for (int i = 0; i < mParents.count(); i++) { int UBFeaturesComputingThread::featuresCount(const QUrl &pPath)
mParents[i]->mChildren.removeAll(this); {
int noItems = 0;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(pPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = UBFeaturesController::fileTypeFromUrl(fullFileName);
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++;
} else {
continue;
}
if (featureType == FEATURE_FOLDER) {
noItems += featuresCount(QUrl::fromLocalFile(fullFileName));
}
}
return noItems;
}
int UBFeaturesComputingThread::featuresCountAll(QList<QPair<QUrl, QString> > pScanningData)
{
int noItems = 0;
for (int i = 0; i < pScanningData.count(); i++) {
QPair<QUrl, QString> curPair = pScanningData.at(i);
noItems += featuresCount(curPair.first);
}
return noItems;
}
UBFeaturesComputingThread::UBFeaturesComputingThread(QObject *parent) :
QThread(parent)
{
restart = false;
abort = false;
}
void UBFeaturesComputingThread::compute(const QList<QPair<QUrl, QString> > &pScanningData)
{
QMutexLocker curLocker(&mMutex);
mScanningData = pScanningData;
if (!isRunning()) {
start(LowPriority);
} else {
restart = true;
mWaitCondition.wakeOne();
} }
} }
void UBFeaturesComputingThread::run()
{
forever {
qDebug() << "Custom thread started execution";
mMutex.lock();
QList<QPair<QUrl, QString> > searchData = mScanningData;
mMutex.unlock();
if (abort) {
return;
}
if (restart) {
break;
}
QTime curTime = QTime::currentTime();
int fsCnt = featuresCountAll(searchData);
int msecsto = curTime.msecsTo(QTime::currentTime());
qDebug() << "time on evaluation" << msecsto;
emit maxFilesCountEvaluated(fsCnt);
emit scanStarted();
scanAll(searchData);
emit scanFinished();
mMutex.lock();
if (!restart) {
mWaitCondition.wait(&mMutex);
}
restart = false;
mMutex.unlock();
}
}
UBFeaturesComputingThread::~UBFeaturesComputingThread()
{
qDebug() << "thread destructor catched";
mMutex.lock();
abort = true;
mWaitCondition.wakeOne();
mMutex.unlock();
quit();
}
UBFeature::UBFeature(const QString &url, const QImage &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
{
}
UBFeature::~UBFeature()
{
}
QString UBFeature::getUrl() const QString UBFeature::getUrl() const
{ {
if ( elementType == FEATURE_INTERNAL ) if ( elementType == FEATURE_INTERNAL )
@ -108,18 +258,18 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
mLibSearchDirectoryPath =QUrl::fromLocalFile(UBSettings::settings()->userSearchDirectory()); mLibSearchDirectoryPath =QUrl::fromLocalFile(UBSettings::settings()->userSearchDirectory());
trashDirectoryPath = QUrl::fromLocalFile(UBSettings::userTrashDirPath()); trashDirectoryPath = QUrl::fromLocalFile(UBSettings::userTrashDirPath());
rootElement = UBFeature(QString(), QPixmap( ":images/libpalette/home.png" ), "root", QUrl()); rootElement = UBFeature(QString(), QImage( ":images/libpalette/home.png" ), "root", QUrl());
audiosElement = UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath, FEATURE_CATEGORY); audiosElement = UBFeature( rootPath, QImage(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath, FEATURE_CATEGORY);
moviesElement = UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath, FEATURE_CATEGORY); moviesElement = UBFeature( rootPath, QImage(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath, FEATURE_CATEGORY);
picturesElement = UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath, FEATURE_CATEGORY); picturesElement = UBFeature( rootPath, QImage(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
flashElement = UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath, FEATURE_CATEGORY); flashElement = UBFeature( rootPath, QImage(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
interactElement = UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath, FEATURE_CATEGORY); interactElement = UBFeature( rootPath, QImage(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
applicationsElement = UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY); applicationsElement = UBFeature( rootPath, QImage(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
shapesElement = UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY ); shapesElement = UBFeature( rootPath, QImage(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY );
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE ); favoriteElement = UBFeature( rootPath, QImage(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY); webSearchElement = UBFeature( rootPath, QImage(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY);
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH ); trashElement = UBFeature( rootPath, QImage(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
featuresList = new QList <UBFeature>(); featuresList = new QList <UBFeature>();
@ -142,7 +292,40 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
featuresPathModel->setSourceModel(featuresModel); featuresPathModel->setSourceModel(featuresModel);
connect(featuresModel, SIGNAL(dataRestructured()), featuresProxyModel, SLOT(invalidate())); connect(featuresModel, SIGNAL(dataRestructured()), featuresProxyModel, SLOT(invalidate()));
connect(&mCThread, SIGNAL(sendFeature(UBFeature)), featuresModel, SLOT(addItem(UBFeature)));
connect(&mCThread, SIGNAL(featureSent()), this, SIGNAL(featureAddedFromThread()));
connect(&mCThread, SIGNAL(scanStarted()), this, SIGNAL(scanStarted()));
connect(&mCThread, SIGNAL(scanFinished()), this, SIGNAL(scanFinished()));
connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int)));
//Very unsafe function. Considering using deleteLater() instead
// connect(qApp, SIGNAL(aboutToQuit()), &mCThread, SLOT(terminate()));
QTimer::singleShot(0, this, SLOT(startThread()));
// startThread();
}
void UBFeaturesController::startThread()
{
QList<QPair<QUrl, QString> > computingData;
computingData << QPair<QUrl, QString>(mLibAudiosDirectoryPath, audiosPath)
<< QPair<QUrl, QString>(mLibVideosDirectoryPath, moviesPath)
<< QPair<QUrl, QString>(mLibAnimationsDirectoryPath, flashPath)
<< QPair<QUrl, QString>(mLibPicturesDirectoryPath, picturesPath)
<< QPair<QUrl, QString>(mUserInteractiveDirectoryPath, appPath)
<< QPair<QUrl, QString>(mUserAudioDirectoryPath, audiosPath)
<< QPair<QUrl, QString>(mUserPicturesDirectoryPath, picturesPath)
<< QPair<QUrl, QString>(mUserVideoDirectoryPath, moviesPath)
<< QPair<QUrl, QString>(mUserAnimationDirectoryPath, flashPath)
<< QPair<QUrl, QString>(mLibApplicationsDirectoryPath, appPath)
<< QPair<QUrl, QString>(mLibShapesDirectoryPath, shapesPath)
<< QPair<QUrl, QString>(mLibInteractiveDirectoryPath, interactPath)
<< QPair<QUrl, QString>(trashDirectoryPath, trashPath)
<< QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
mCThread.compute(computingData);
} }
void UBFeaturesController::scanFS() void UBFeaturesController::scanFS()
@ -166,29 +349,55 @@ void UBFeaturesController::scanFS()
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools(); QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
foreach (UBToolsManager::UBToolDescriptor tool, tools) { foreach (UBToolsManager::UBToolDescriptor tool, tools) {
featuresList->append(UBFeature(appPath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); featuresList->append(UBFeature(appPath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
if (favoriteSet->find(QUrl(tool.id)) != favoriteSet->end()) { if (favoriteSet->find(QUrl(tool.id)) != favoriteSet->end()) {
featuresList->append(UBFeature(favoritePath, tool.icon, tool.label, QUrl(tool.id), FEATURE_INTERNAL)); featuresList->append(UBFeature(favoritePath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
} }
} }
QTime time = QTime::currentTime();
//Claudio: //Claudio:
// don't change the order of the scans // don't change the order of the scans
fileSystemScan( mLibAudiosDirectoryPath, audiosPath); // fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
fileSystemScan( mLibVideosDirectoryPath, moviesPath); // fileSystemScan( mLibVideosDirectoryPath, moviesPath);
fileSystemScan( mLibAnimationsDirectoryPath, flashPath); // fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath ); // fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserInteractiveDirectoryPath, appPath ); // fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath ); // fileSystemScan( mUserAudioDirectoryPath, audiosPath );
fileSystemScan( mUserPicturesDirectoryPath, picturesPath ); // fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserVideoDirectoryPath, moviesPath ); // fileSystemScan( mUserVideoDirectoryPath, moviesPath );
fileSystemScan( mUserAnimationDirectoryPath, flashPath ); // fileSystemScan( mUserAnimationDirectoryPath, flashPath );
fileSystemScan( mLibApplicationsDirectoryPath, appPath ); // fileSystemScan( mLibApplicationsDirectoryPath, appPath );
fileSystemScan( mLibShapesDirectoryPath, shapesPath ); // fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath ); // fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath ); // fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); // fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
int i =0;
i += featuresCount(mLibAudiosDirectoryPath);
i += featuresCount(mLibVideosDirectoryPath);
i += featuresCount(mLibAnimationsDirectoryPath);
i += featuresCount(mLibPicturesDirectoryPath);
i += featuresCount(mUserInteractiveDirectoryPath);
i += featuresCount(mUserAudioDirectoryPath);
i += featuresCount(mUserPicturesDirectoryPath);
i += featuresCount(mUserVideoDirectoryPath);
i += featuresCount(mUserAnimationDirectoryPath);
i += featuresCount(mLibApplicationsDirectoryPath);
i += featuresCount(mLibShapesDirectoryPath);
i += featuresCount(mLibInteractiveDirectoryPath);
i += featuresCount(trashDirectoryPath);
i += featuresCount(mLibSearchDirectoryPath);
int msecs = QTime(time).msecsTo(QTime::currentTime());
qDebug() << "Loading library" << msecs << "msecs\nNumber of elements" << i;
// emit TopIndexingLimitSet(i);
// emit indexingProgressValueChanged(i / 4);
} }
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath) void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath)
@ -201,7 +410,7 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
UBFeatureElementType featureType = fileTypeFromUrl(fullFileName); UBFeatureElementType featureType = fileTypeFromUrl(fullFileName);
QString fileName = fileInfo->fileName(); QString fileName = fileInfo->fileName();
QPixmap icon(getIcon(fullFileName, featureType)); QImage icon = getIcon(fullFileName, featureType);
if ( fullFileName.contains(".thumbnail.")) if ( fullFileName.contains(".thumbnail."))
continue; continue;
@ -220,6 +429,31 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
} }
} }
int UBFeaturesController::featuresCount(const QUrl &currPath)
{
int noItems = 0;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currPath.toLocalFile());
QFileInfoList::iterator fileInfo;
for ( fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
QString fullFileName = fileInfo->absoluteFilePath();
UBFeatureElementType featureType = fileTypeFromUrl(fullFileName);
if (featureType != FEATURE_INVALID && !fullFileName.contains(".thumbnail.")) {
noItems++;
} else {
continue;
}
if (featureType == FEATURE_FOLDER) {
noItems += featuresCount(QUrl::fromLocalFile(fullFileName));
}
}
return noItems;
}
void UBFeaturesController::loadFavoriteList() void UBFeaturesController::loadFavoriteList()
{ {
favoriteSet = new QSet<QUrl>(); favoriteSet = new QSet<QUrl>();
@ -260,7 +494,7 @@ void UBFeaturesController::addToFavorite( const QUrl &path )
{ {
QFileInfo fileInfo( filePath ); QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName(); QString fileName = fileInfo.fileName();
UBFeature elem( favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) ); UBFeature elem(favoritePath, getIcon( filePath, FEATURE_CATEGORY ), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( path ); favoriteSet->insert( path );
saveFavoriteList(); saveFavoriteList();
@ -318,33 +552,30 @@ UBFeatureElementType UBFeaturesController::fileTypeFromUrl( const QString &path
return fileType; return fileType;
} }
QPixmap UBFeaturesController::getIcon(const QString &path, UBFeatureElementType pFType = FEATURE_INVALID) QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType pFType = FEATURE_INVALID)
{ {
if ( pFType == FEATURE_FOLDER ) if (pFType == FEATURE_FOLDER) {
{ return QImage(":images/libpalette/folder.svg");
return QPixmap(":images/libpalette/folder.svg");
} } else if (pFType == FEATURE_INTERACTIVE) {
else if ( pFType == FEATURE_INTERACTIVE ) return QImage(UBAbstractWidget::iconFilePath(QUrl::fromLocalFile(path)));
{
return QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
} }
if ( path.contains("uniboardTool://") ) if ( path.contains("uniboardTool://") ) {
{ return QImage( UBToolsManager::manager()->iconFromToolId(path) );
return QPixmap( UBToolsManager::manager()->iconFromToolId(path) );
} } if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application")) {
if ( UBFileSystemUtils::mimeTypeFromFileName(path).contains("application") ) return QImage( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
{
return QPixmap( UBAbstractWidget::iconFilePath( QUrl::fromLocalFile(path) ) );
} }
QPixmap thumb; QImage thumb;
QString thumbnailPath = UBFileSystemUtils::thumbnailPath( path ); QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
if ( QFileInfo( thumbnailPath ).exists() ) if ( QFileInfo( thumbnailPath ).exists() )
thumb = QPixmap( thumbnailPath ); thumb = QImage( thumbnailPath );
else thumb = createThumbnail( path ); else thumb = createThumbnail( path );
return thumb; return thumb;
} }
@ -354,12 +585,11 @@ bool UBFeaturesController::isDeletable( const QUrl &url )
return type == FEATURE_ITEM; return type == FEATURE_ITEM;
} }
QPixmap UBFeaturesController::createThumbnail(const QString &path) QImage UBFeaturesController::createThumbnail(const QString &path)
{ {
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path); QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(path); QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(path);
QString extension = QFileInfo(path).completeSuffix(); QString extension = QFileInfo(path).completeSuffix();
//UBApplication::showMessage(tr("Creating image thumbnail for %1.").arg(pElement->name()));
if ( mimetype.contains("audio" )) if ( mimetype.contains("audio" ))
thumbnailPath = ":images/libpalette/soundIcon.svg"; thumbnailPath = ":images/libpalette/soundIcon.svg";
@ -373,7 +603,7 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
} }
else else
{ {
QPixmap pix(path); QImage pix(path);
if (!pix.isNull()) if (!pix.isNull())
{ {
pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation); pix = pix.scaledToWidth(qMin(UBSettings::maxThumbnailWidth, pix.width()), Qt::SmoothTransformation);
@ -386,7 +616,7 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
} }
} }
return QPixmap(thumbnailPath); return QImage(thumbnailPath);
} }
void UBFeaturesController::importImage(const QImage &image, const QString &fileName) void UBFeaturesController::importImage(const QImage &image, const QString &fileName)
@ -412,7 +642,7 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName; QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
image.save(filePath); image.save(filePath);
QPixmap thumb = createThumbnail( filePath ); QImage thumb = createThumbnail( filePath );
UBFeature resultItem = UBFeature( dest.getFullVirtualPath(), thumb, mFileName, UBFeature resultItem = UBFeature( dest.getFullVirtualPath(), thumb, mFileName,
QUrl::fromLocalFile( filePath ), FEATURE_ITEM ); QUrl::fromLocalFile( filePath ), FEATURE_ITEM );
@ -420,7 +650,7 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
} }
void UBFeaturesController::addNewFolder(const QString &name) void UBFeaturesController::addNewFolder(QString name)
{ {
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
@ -432,7 +662,7 @@ void UBFeaturesController::addNewFolder(const QString &name)
if(!QFileInfo(path).exists()) { if(!QFileInfo(path).exists()) {
QDir().mkpath(path); QDir().mkpath(path);
} }
UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QPixmap(":images/libpalette/folder.svg"), UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QImage(":images/libpalette/folder.svg"),
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER ); name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
featuresModel->addItem( newFeatureFolder ); featuresModel->addItem( newFeatureFolder );
@ -523,7 +753,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
deleteItem( url ); deleteItem( url );
} }
QPixmap thumb = getIcon( newFullPath ); QImage thumb = getIcon( newFullPath );
UBFeatureElementType type = FEATURE_ITEM; UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") ) if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
@ -550,9 +780,24 @@ void UBFeaturesController::siftElements(const QString &pSiftValue)
featuresPathModel->invalidate(); featuresPathModel->invalidate();
} }
UBFeature UBFeaturesController::getFeature(const QModelIndex &index, QListView *pOnView) UBFeature UBFeaturesController::getFeature(const QModelIndex &index, const QString &listName)
{ {
return qobject_cast<QSortFilterProxyModel *>(pOnView->model())->data(index, Qt::UserRole + 1).value<UBFeature>(); // QSortFilterProxyModel *model = qobject_cast<QSortFilterProxyModel *>(pOnView->model());
QAbstractItemModel *model = 0;
if (listName == UBFeaturesWidget::objNamePathList) {
model = featuresPathModel;
} else if (listName == UBFeaturesWidget::objNameFeatureList) {
model = curListModel;
}
if (model) {
return model->data(index, Qt::UserRole + 1).value<UBFeature>();
}
return UBFeature();
// return pOnView->model()->data(index, Qt::UserRole + 1).value<UBFeature>(); /*featuresSearchModel->data(index, Qt::UserRole + 1).value<UBFeature>()*/;
} }
void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnView) void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnView)
@ -561,11 +806,13 @@ void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnV
pOnView->setModel(featuresProxyModel); pOnView->setModel(featuresProxyModel);
featuresProxyModel->invalidate(); featuresProxyModel->invalidate();
} else if ( pattern.size() > 2 ) { curListModel = featuresProxyModel;
} else if ( pattern.size() > 1 ) {
featuresSearchModel->setFilterWildcard( "*" + pattern + "*" ); featuresSearchModel->setFilterWildcard( "*" + pattern + "*" );
pOnView->setModel(featuresSearchModel ); pOnView->setModel(featuresSearchModel );
featuresSearchModel->invalidate(); featuresSearchModel->invalidate();
curListModel = featuresSearchModel;
} }
} }
@ -599,7 +846,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive)) if (!sourcePath.compare(newFullPath, Qt::CaseInsensitive))
QFile(sourcePath).copy(newFullPath); QFile(sourcePath).copy(newFullPath);
QPixmap thumb = getIcon(newFullPath); QImage thumb = getIcon(newFullPath);
UBFeatureElementType type = FEATURE_ITEM; UBFeatureElementType type = FEATURE_ITEM;
if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application")) if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application"))
@ -641,7 +888,7 @@ void UBFeaturesController::moveExternalData(const QUrl &url, const UBFeature &de
Q_ASSERT(QFileInfo(newFullPath).exists()); Q_ASSERT(QFileInfo(newFullPath).exists());
QPixmap thumb = getIcon(newFullPath, type); QImage thumb = getIcon(newFullPath, type);
UBFeature newElement(destVirtualPath, thumb, name, QUrl::fromLocalFile(newFullPath), type); UBFeature newElement(destVirtualPath, thumb, name, QUrl::fromLocalFile(newFullPath), type);
featuresModel->addItem(newElement); featuresModel->addItem(newElement);
@ -710,6 +957,7 @@ void UBFeaturesController::assignFeaturesListVeiw(UBFeaturesListView *pList)
pList->setItemDelegate(itemDelegate); pList->setItemDelegate(itemDelegate);
pList->setModel(featuresProxyModel); pList->setModel(featuresProxyModel);
curListModel = featuresProxyModel;
} }
void UBFeaturesController::assignPathListView(UBFeaturesListView *pList) void UBFeaturesController::assignPathListView(UBFeaturesListView *pList)

@ -12,6 +12,10 @@
#include <QUrl> #include <QUrl>
#include <QByteArray> #include <QByteArray>
#include <QtGui> #include <QtGui>
#include <QImage>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
class UBFeaturesModel; class UBFeaturesModel;
class UBFeaturesItemDelegate; class UBFeaturesItemDelegate;
@ -20,8 +24,45 @@ class UBFeaturesProxyModel;
class UBFeaturesSearchProxyModel; class UBFeaturesSearchProxyModel;
class UBFeaturesPathProxyModel; class UBFeaturesPathProxyModel;
class UBFeaturesListView; class UBFeaturesListView;
class UBFeature;
class UBFeaturesComputingThread : public QThread
{
Q_OBJECT
public:
explicit UBFeaturesComputingThread(QObject *parent = 0);
virtual ~UBFeaturesComputingThread();
void compute(const QList<QPair<QUrl, QString> > &pScanningData);
protected:
void run();
signals:
void sendFeature(UBFeature pFeature);
void featureSent();
void scanStarted();
void scanFinished();
void maxFilesCountEvaluated(int max);
public slots:
private:
void scanFS(const QUrl & currentPath, const QString & currVirtualPath);
void scanAll(QList<QPair<QUrl, QString> > pScanningData);
int featuresCount(const QUrl &pPath);
int featuresCountAll(QList<QPair<QUrl, QString> > pScanningData);
private:
QMutex mMutex;
QWaitCondition mWaitCondition;
QUrl mScanningPath;
QString mScanningVirtualPath;
QList<QPair<QUrl, QString> > mScanningData;
bool restart;
bool abort;
};
//#include "UBDockPaletteWidget.h"
enum UBFeatureElementType enum UBFeatureElementType
{ {
@ -41,12 +82,12 @@ class UBFeature
{ {
public: public:
UBFeature() {;} UBFeature() {;}
//UBFeature(const UBFeature &f); // UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY); UBFeature(const QString &url, const QImage &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
// UBFeature(); // UBFeature();
virtual ~UBFeature(); virtual ~UBFeature();
QString getName() const { return mName; } QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;} QImage getThumbnail() const {return mThumbnail;}
QString getVirtualPath() const { return virtualDir; } QString getVirtualPath() const { return virtualDir; }
//QString getPath() const { return mPath; }; //QString getPath() const { return mPath; };
QUrl getFullPath() const { return mPath; } QUrl getFullPath() const { return mPath; }
@ -64,20 +105,13 @@ public:
const QMap<QString,QString> & getMetadata() const { return metadata; } const QMap<QString,QString> & getMetadata() const { return metadata; }
void setMetadata( const QMap<QString,QString> &data ) { metadata = data; } void setMetadata( const QMap<QString,QString> &data ) { metadata = data; }
bool hasChildren() const {return mChildren.count();}
bool hasParents() const {return mParents.count();}
bool hasRelationships() const {return mChildren.count() && mParents.count();}
private: private:
QString virtualDir; QString virtualDir;
QPixmap mThumbnail; QImage mThumbnail;
QString mName; QString mName;
QUrl mPath; QUrl mPath;
UBFeatureElementType elementType; UBFeatureElementType elementType;
QMap<QString,QString> metadata; QMap<QString,QString> metadata;
QList<UBFeature*> mChildren;
QList<UBFeature*> mParents;
}; };
Q_DECLARE_METATYPE( UBFeature ) Q_DECLARE_METATYPE( UBFeature )
@ -111,7 +145,7 @@ public:
void rescanModel(); void rescanModel();
void siftElements(const QString &pSiftValue); void siftElements(const QString &pSiftValue);
//TODO make less complicated for betteer maintainence //TODO make less complicated for betteer maintainence
UBFeature getFeature(const QModelIndex &index, QListView *pOnView); UBFeature getFeature(const QModelIndex &index, const QString &listName);
void searchStarted(const QString &pattern, QListView *pOnView); void searchStarted(const QString &pattern, QListView *pOnView);
void refreshModels(); void refreshModels();
@ -119,18 +153,17 @@ public:
void deleteItem(const UBFeature &pFeature); void deleteItem(const UBFeature &pFeature);
bool isTrash( const QUrl &url ); bool isTrash( const QUrl &url );
void moveToTrash(UBFeature feature, bool deleteManualy = false); void moveToTrash(UBFeature feature, bool deleteManualy = false);
void addNewFolder(const QString &name);
void addToFavorite( const QUrl &path ); void addToFavorite( const QUrl &path );
void removeFromFavorite(const QUrl &path, bool deleteManualy = false); void removeFromFavorite(const QUrl &path, bool deleteManualy = false);
void importImage(const QImage &image, const QString &fileName = QString()); void importImage(const QImage &image, const QString &fileName = QString());
void importImage( const QImage &image, const UBFeature &destination, const QString &fileName = QString() ); void importImage( const QImage &image, const UBFeature &destination, const QString &fileName = QString() );
void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath); void fileSystemScan(const QUrl &currPath, const QString & currVirtualPath);
int featuresCount(const QUrl &currPath);
static UBFeatureElementType fileTypeFromUrl( const QString &path ); static UBFeatureElementType fileTypeFromUrl( const QString &path );
static QString fileNameFromUrl( const QUrl &url ); static QString fileNameFromUrl( const QUrl &url );
static QPixmap getIcon( const QString &path, UBFeatureElementType pFType ); static QImage getIcon( const QString &path, UBFeatureElementType pFType );
static bool isDeletable( const QUrl &url ); static bool isDeletable( const QUrl &url );
static char featureTypeSplitter() {return ':';} static char featureTypeSplitter() {return ':';}
@ -139,6 +172,16 @@ public:
void assignFeaturesListVeiw(UBFeaturesListView *pList); void assignFeaturesListVeiw(UBFeaturesListView *pList);
void assignPathListView(UBFeaturesListView *pList); void assignPathListView(UBFeaturesListView *pList);
signals:
void maxFilesCountEvaluated(int pLimit);
void scanStarted();
void scanFinished();
void featureAddedFromThread();
private slots:
void addNewFolder(QString name);
void startThread();
private: private:
UBFeaturesItemDelegate *itemDelegate; UBFeaturesItemDelegate *itemDelegate;
@ -149,16 +192,16 @@ private:
UBFeaturesSearchProxyModel *featuresSearchModel; UBFeaturesSearchProxyModel *featuresSearchModel;
UBFeaturesPathProxyModel *featuresPathModel; UBFeaturesPathProxyModel *featuresPathModel;
QAbstractItemModel *curListModel;
UBFeaturesComputingThread mCThread;
private: private:
static QPixmap createThumbnail(const QString &path); static QImage createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path ); //void addImageToCurrentPage( const QString &path );
void loadFavoriteList(); void loadFavoriteList();
void saveFavoriteList(); void saveFavoriteList();
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
QUrl mUserAudioDirectoryPath; QUrl mUserAudioDirectoryPath;

@ -53,6 +53,7 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
//mpSearchBtn = new UBActionButton(this, mpSearchAction); //mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpRescanModelBtn = new UBActionButton(this, mpRescanModelAction); mpRescanModelBtn = new UBActionButton(this, mpRescanModelAction);
mpRescanModelBtn->hide();
mpDeleteBtn = new UBActionButton(this, mpDeleteAction); mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction); mpCloseBtn = new UBActionButton(this, mpCloseAction);
@ -124,7 +125,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show(); mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(true); mpNewFolderBtn->setEnabled(true);
mpDeleteBtn->setEnabled(true); mpDeleteBtn->setEnabled(true);
mpRescanModelBtn->show(); // mpRescanModelBtn->show();
break; break;
case IN_ROOT: case IN_ROOT:
mpFavoriteBtn->show(); mpFavoriteBtn->show();
@ -136,7 +137,7 @@ void UBFeaturesActionBar::setButtons()
mpNewFolderBtn->show(); mpNewFolderBtn->show();
mpNewFolderBtn->setEnabled(false); mpNewFolderBtn->setEnabled(false);
mpDeleteBtn->setEnabled(false); mpDeleteBtn->setEnabled(false);
mpRescanModelBtn->show(); // mpRescanModelBtn->show();
break; break;
case IN_PROPERTIES: case IN_PROPERTIES:
mpFavoriteBtn->show(); mpFavoriteBtn->show();
@ -147,7 +148,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide(); mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide(); mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->hide(); mpNewFolderBtn->hide();
mpRescanModelBtn->hide(); // mpRescanModelBtn->hide();
break; break;
case IN_FAVORITE: case IN_FAVORITE:
mpFavoriteBtn->hide(); mpFavoriteBtn->hide();
@ -158,7 +159,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide(); mpCloseBtn->hide();
mpRemoveFavoriteBtn->show(); mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide(); mpNewFolderBtn->hide();
mpRescanModelBtn->hide(); // mpRescanModelBtn->hide();
break; break;
case IN_TRASH: case IN_TRASH:
mpFavoriteBtn->hide(); mpFavoriteBtn->hide();
@ -171,7 +172,7 @@ void UBFeaturesActionBar::setButtons()
mpCloseBtn->hide(); mpCloseBtn->hide();
//mpRemoveFavoriteBtn->show(); //mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide(); mpNewFolderBtn->hide();
mpRescanModelBtn->hide(); // mpRescanModelBtn->hide();
break; break;
default: default:
break; break;

@ -8,9 +8,14 @@
#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::objNameFeatureList = "FeatureList";
const char *objNamePathList = "PathList"; const QString UBFeaturesNewFolderDialog::acceptText = tr("Accept");
const char *objNameFeatureList = "FeatureList"; const QString UBFeaturesNewFolderDialog::cancelText = tr("Cancel");
const QString UBFeaturesNewFolderDialog::labelText = tr("Enter a new folder name");
const QMargins FeatureListMargins(0, 0, 0, 30); const QMargins FeatureListMargins(0, 0, 0, 30);
const int FeatureListBorderOffset = 10; const int FeatureListBorderOffset = 10;
@ -43,39 +48,19 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
pathListView = new UBFeaturesListView(this, objNamePathList); pathListView = new UBFeaturesListView(this, objNamePathList);
controller->assignPathListView(pathListView); controller->assignPathListView(pathListView);
//Maintains the view of the main part of the palette. Consists of centralWidget = new UBFeaturesCentralWidget(this);
//mNavigator controller->assignFeaturesListVeiw(centralWidget->listView());
//featureProperties centralWidget->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt());
//webVeiw
stackedWidget = new QStackedWidget(this);
//Main features icon view with QSlider on the bottom
mNavigator = new UBFeaturesNavigatorWidget(this);
controller->assignFeaturesListVeiw(mNavigator->listView());
mNavigator->setSliderPosition(UBSettings::settings()->featureSliderPosition->get().toInt());
//Specifies the properties of a standalone element
featureProperties = new UBFeatureProperties(this);
//Used to show search bar on the search widget
webView = new UBFeaturesWebView(this);
//filling stackwidget
stackedWidget->addWidget(mNavigator);
stackedWidget->addWidget(featureProperties);
stackedWidget->addWidget(webView);
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
//Bottom actionbar for DnD, quick search etc //Bottom actionbar for DnD, quick search etc
mActionBar = new UBFeaturesActionBar(controller, this); mActionBar = new UBFeaturesActionBar(controller, this);
//Filling main layout //Filling main layout
layout->addWidget(pathListView); layout->addWidget(pathListView);
layout->addWidget(stackedWidget); layout->addWidget(centralWidget);
layout->addWidget(mActionBar); layout->addWidget(mActionBar);
connect(mNavigator->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &))); connect(centralWidget->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &))); connect(mActionBar, SIGNAL(searchElement(const QString &)), this, SLOT( searchStarted(const QString &)));
connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder())); connect(mActionBar, SIGNAL(newFolderToCreate()), this, SLOT(createNewFolder()));
connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *))); connect(mActionBar, SIGNAL(deleteElements(const UBFeaturesMimeData *)), this, SLOT(deleteElements(const UBFeaturesMimeData *)));
@ -90,6 +75,12 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name)
connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>))); connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>)));
connect(UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray)) connect(UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray))
, this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray))); , this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray)));
connect(centralWidget, SIGNAL(lockMainWidget(bool)), this, SLOT(lockIt(bool)));
connect(centralWidget, SIGNAL(createNewFolderSignal(QString)), controller, SLOT(addNewFolder(QString)));
connect(controller, SIGNAL(scanStarted()), centralWidget, SLOT(scanStarted()));
connect(controller, SIGNAL(scanFinished()), centralWidget, SLOT(scanFinished()));
connect(controller, SIGNAL(maxFilesCountEvaluated(int)), centralWidget, SIGNAL(maxFilesCountEvaluated(int)));
connect(controller, SIGNAL(featureAddedFromThread()), centralWidget, SLOT(increaseStatusBarValue()));
} }
UBFeaturesWidget::~UBFeaturesWidget() UBFeaturesWidget::~UBFeaturesWidget()
@ -100,7 +91,7 @@ UBFeaturesWidget::~UBFeaturesWidget()
void UBFeaturesWidget::searchStarted(const QString &pattern) void UBFeaturesWidget::searchStarted(const QString &pattern)
{ {
controller->searchStarted(pattern, mNavigator->listView()); controller->searchStarted(pattern, centralWidget->listView());
} }
void UBFeaturesWidget::currentSelected(const QModelIndex &current) void UBFeaturesWidget::currentSelected(const QModelIndex &current)
@ -110,25 +101,16 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
return; return;
} }
//Calling to reset the model for listView. Maybe separate function needed
controller->searchStarted("", mNavigator->listView());
QString objName = sender()->objectName(); QString objName = sender()->objectName();
if (objName.isEmpty()) { if (objName.isEmpty()) {
qWarning() << "incorrrect sender"; qWarning() << "incorrrect sender";
} else if (objName == objNamePathList) {
//Calling to reset the model for listView. Maybe separate function needed
controller->searchStarted("", centralWidget->listView());
} }
QListView *calledList = 0; UBFeature feature = controller->getFeature(current, objName);
if (objName == objNamePathList) {
calledList = pathListView;
} else if (objName == objNameFeatureList) {
calledList = mNavigator->listView();
}
UBFeature feature = controller->getFeature(current, calledList);
// QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( mNavigator->listView()->model() );
// UBFeature feature = model->data(current, Qt::UserRole + 1).value<UBFeature>();
if ( feature.isFolder() ) { if ( feature.isFolder() ) {
QString newPath = feature.getFullVirtualPath(); QString newPath = feature.getFullVirtualPath();
@ -136,7 +118,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
controller->setCurrentElement(feature); controller->setCurrentElement(feature);
controller->siftElements(newPath); controller->siftElements(newPath);
switchToListView(); centralWidget->switchTo(UBFeaturesCentralWidget::MainList);
if ( feature.getType() == FEATURE_FAVORITE ) { if ( feature.getType() == FEATURE_FAVORITE ) {
mActionBar->setCurrentState( IN_FAVORITE ); mActionBar->setCurrentState( IN_FAVORITE );
@ -145,35 +127,24 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
mActionBar->setCurrentState( IN_ROOT ); mActionBar->setCurrentState( IN_ROOT );
} else if (feature.getType() == FEATURE_TRASH) { } else if (feature.getType() == FEATURE_TRASH) {
mActionBar->setCurrentState( IN_TRASH ); mActionBar->setCurrentState(IN_TRASH);
} else { } else {
mActionBar->setCurrentState( IN_FOLDER ); mActionBar->setCurrentState(IN_FOLDER);
} }
} else if ( feature.getType() == FEATURE_SEARCH ) { } else if (feature.getType() == FEATURE_SEARCH) {
webView->showElement( feature ); centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturesWebView);
switchToWebView();
} else { } else {
featureProperties->showElement( feature ); centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES ); mActionBar->setCurrentState( IN_PROPERTIES );
} }
} }
void UBFeaturesWidget::createNewFolder() void UBFeaturesWidget::createNewFolder()
{ {
if (!mkFolderDlg) centralWidget->showAdditionalData(UBFeaturesCentralWidget::NewFolderDialog, UBFeaturesCentralWidget::Modal);
{
mkFolderDlg = new UBNewFolderDlg(this);
connect (mkFolderDlg, SIGNAL(accepted()), this, SLOT(addFolder()));
}
mkFolderDlg->setWindowFlags(Qt::WindowStaysOnTopHint);
mkFolderDlg->resize(this->size().width()-20 ,80);
mkFolderDlg->move(5,this->size().height()-200);
mkFolderDlg->show();
} }
void UBFeaturesWidget::addFolder() void UBFeaturesWidget::addFolder()
@ -203,7 +174,7 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
void UBFeaturesWidget::deleteSelectedElements() void UBFeaturesWidget::deleteSelectedElements()
{ {
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes(); QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
foreach ( QModelIndex sel, selected ) foreach ( QModelIndex sel, selected )
{ {
@ -224,6 +195,14 @@ void UBFeaturesWidget::rescanModel()
controller->rescanModel(); controller->rescanModel();
} }
void UBFeaturesWidget::lockIt(bool pLock)
{
mActionBar->setEnabled(!pLock);
pathListView->setEnabled(!pLock);
centralWidget->setLockedExcludingAdditional(pLock);
// pathListView->setLocked(true);
}
void UBFeaturesWidget::addToFavorite( const UBFeaturesMimeData * mimeData ) void UBFeaturesWidget::addToFavorite( const UBFeaturesMimeData * mimeData )
{ {
if ( !mimeData->hasUrls() ) if ( !mimeData->hasUrls() )
@ -253,7 +232,7 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
{ {
QString previewImageUrl; QString previewImageUrl;
switch (UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"]))) switch (static_cast<int>(UBFileSystemUtils::mimeTypeFromUrl(QUrl(metadata["Url"]))))
{ {
case UBMimeType::RasterImage: case UBMimeType::RasterImage:
case UBMimeType::VectorImage: case UBMimeType::VectorImage:
@ -282,11 +261,10 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
}break; }break;
} }
UBFeature feature( QString(), QPixmap(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM ); UBFeature feature( QString(), QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata ); feature.setMetadata( metadata );
featureProperties->showElement( feature ); centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES ); mActionBar->setCurrentState( IN_PROPERTIES );
} }
@ -298,12 +276,14 @@ void UBFeaturesWidget::onPreviewLoaded(int id, bool pSuccess, QUrl sourceUrl, QS
Q_UNUSED(isBackground); Q_UNUSED(isBackground);
Q_UNUSED(pSize); Q_UNUSED(pSize);
Q_UNUSED(pPos); Q_UNUSED(pPos);
Q_UNUSED(sourceUrl);
Q_UNUSED(pContentTypeHeader)
QImage img; QImage img;
img.loadFromData(pData); img.loadFromData(pData);
QPixmap pix = QPixmap::fromImage(img); QPixmap pix = QPixmap::fromImage(img);
featureProperties->setOrigPixmap(pix); centralWidget->setPropertiesPixmap(pix);
featureProperties->setThumbnail(pix); centralWidget->setPropertiesThumbnail(pix);
} }
void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData) void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUrl, QString pContentHeader, QByteArray pData)
@ -318,14 +298,14 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
void UBFeaturesWidget::addElementsToFavorite() void UBFeaturesWidget::addElementsToFavorite()
{ {
if ( currentStackedWidget == ID_PROPERTIES ) { if ( centralWidget->currentView() == UBFeaturesCentralWidget::FeaturePropertiesList ) {
UBFeature feature = featureProperties->getCurrentElement(); UBFeature feature = centralWidget->getCurElementFromProperties();
if ( feature != UBFeature() && !UBApplication::isFromWeb(feature.getFullPath().toString())) { if ( feature != UBFeature() && !UBApplication::isFromWeb(feature.getFullPath().toString())) {
controller->addToFavorite( feature.getFullPath() ); controller->addToFavorite( feature.getFullPath() );
} }
} else if ( currentStackedWidget == ID_LISTVIEW ) { } else if ( centralWidget->currentView() == UBFeaturesCentralWidget::MainList ) {
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes(); QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i ) { for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>(); UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
controller->addToFavorite(feature.getFullPath()); controller->addToFavorite(feature.getFullPath());
@ -337,7 +317,7 @@ void UBFeaturesWidget::addElementsToFavorite()
void UBFeaturesWidget::removeElementsFromFavorite() void UBFeaturesWidget::removeElementsFromFavorite()
{ {
QModelIndexList selected = mNavigator->listView()->selectionModel()->selectedIndexes(); QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
QList <QUrl> items; QList <QUrl> items;
for ( int i = 0; i < selected.size(); ++i ) { for ( int i = 0; i < selected.size(); ++i ) {
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>(); UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
@ -363,20 +343,20 @@ void UBFeaturesWidget::resizeEvent(QResizeEvent *event)
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); // stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW; // currentStackedWidget = ID_LISTVIEW;
} }
void UBFeaturesWidget::switchToProperties() void UBFeaturesWidget::switchToProperties()
{ {
stackedWidget->setCurrentIndex(ID_PROPERTIES); // stackedWidget->setCurrentIndex(ID_PROPERTIES);
currentStackedWidget = ID_PROPERTIES; // currentStackedWidget = ID_PROPERTIES;
} }
void UBFeaturesWidget::switchToWebView() void UBFeaturesWidget::switchToWebView()
{ {
stackedWidget->setCurrentIndex(ID_WEBVIEW); // stackedWidget->setCurrentIndex(ID_WEBVIEW);
currentStackedWidget = ID_WEBVIEW; // currentStackedWidget = ID_WEBVIEW;
} }
QStringList UBFeaturesMimeData::formats() const QStringList UBFeaturesMimeData::formats() const
@ -390,7 +370,7 @@ void UBFeaturesWidget::importImage(const QImage &image, const QString &fileName)
} }
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
: QListView(parent) : QListView(parent)
{ {
setObjectName(name); setObjectName(name);
} }
@ -423,7 +403,7 @@ void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
void UBFeaturesListView::dropEvent( QDropEvent *event ) void UBFeaturesListView::dropEvent( QDropEvent *event )
{ {
QWidget *eventSource = event->source(); QWidget *eventSource = event->source();
if (eventSource && eventSource->objectName() == objNameFeatureList) { if (eventSource && eventSource->objectName() == UBFeaturesWidget::objNameFeatureList) {
event->setDropAction( Qt::MoveAction ); event->setDropAction( Qt::MoveAction );
} }
@ -445,9 +425,9 @@ UBFeaturesNavigatorWidget::UBFeaturesNavigatorWidget(QWidget *parent, const char
name = "UBFeaturesNavigatorWidget"; name = "UBFeaturesNavigatorWidget";
setObjectName(name); setObjectName(name);
SET_STYLE_SHEET() // SET_STYLE_SHEET()
mListView = new UBFeaturesListView(this, objNameFeatureList); mListView = new UBFeaturesListView(this, UBFeaturesWidget::objNameFeatureList);
mListSlder = new QSlider(Qt::Horizontal, this); mListSlder = new QSlider(Qt::Horizontal, this);
@ -461,7 +441,7 @@ UBFeaturesNavigatorWidget::UBFeaturesNavigatorWidget(QWidget *parent, const char
mainLayer->addWidget(mListView, 1); mainLayer->addWidget(mListView, 1);
mainLayer->addWidget(mListSlder, 0); mainLayer->addWidget(mListSlder, 0);
mainLayer->setMargin(0);
connect(mListSlder, SIGNAL(valueChanged(int)), mListView, SLOT(thumbnailSizeChanged(int))); connect(mListSlder, SIGNAL(valueChanged(int)), mListView, SLOT(thumbnailSizeChanged(int)));
} }
@ -471,6 +451,207 @@ void UBFeaturesNavigatorWidget::setSliderPosition(int pValue)
mListSlder->setValue(pValue); mListSlder->setValue(pValue);
} }
UBFeaturesCentralWidget::UBFeaturesCentralWidget(QWidget *parent) : QWidget(parent)
{
setObjectName("UBFeaturesCentralWidget");
SET_STYLE_SHEET();
QVBoxLayout *mLayout = new QVBoxLayout(this);
setLayout(mLayout);
//Maintains the view of the main part of the palette. Consists of
//mNavigator
//featureProperties
//webVeiw
mStackedWidget = new QStackedWidget(this);
//Main features icon view with QSlider on the bottom
mNavigator = new UBFeaturesNavigatorWidget(this);
//Specifies the properties of a standalone element
mFeatureProperties = new UBFeatureProperties(this);
//Used to show search bar on the search widget
webView = new UBFeaturesWebView(this);
//filling stackwidget
mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mFeatureProperties);
mStackedWidget->addWidget(webView);
mStackedWidget->setCurrentIndex(MainList);
mStackedWidget->setContentsMargins(0, 0, 0, 0);
mAdditionalDataContainer = new QStackedWidget(this);
mAdditionalDataContainer->setObjectName("mAdditionalDataContainer");
//New folder dialog
UBFeaturesNewFolderDialog *dlg = new UBFeaturesNewFolderDialog(mAdditionalDataContainer);
mAdditionalDataContainer->addWidget(dlg);
mAdditionalDataContainer->setCurrentIndex(NewFolderDialog);
connect(dlg, SIGNAL(createNewFolder(QString)), this, SLOT(createNewFolderSlot(QString)));
connect(dlg, SIGNAL(closeDialog()), this, SLOT(hideAdditionalData()));
//Progress bar to show scanning progress
QProgressBar *progressBar = new QProgressBar();
mAdditionalDataContainer->addWidget(progressBar);
mAdditionalDataContainer->setCurrentIndex(ProgressBarWidget);
progressBar->setMinimum(0);
progressBar->setValue(0);
progressBar->setMaximum(10000);
connect(this, SIGNAL(maxFilesCountEvaluated(int)), progressBar, SLOT(setMaximum(int)));
mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mAdditionalDataContainer, 0);
mAdditionalDataContainer->hide();
}
void UBFeaturesCentralWidget::showElement(const UBFeature &feature, StackElement pView)
{
if (pView == FeaturesWebView) {
webView->showElement(feature);
mStackedWidget->setCurrentIndex(FeaturesWebView);
} else if (pView == FeaturePropertiesList) {
mFeatureProperties->showElement(feature);
mStackedWidget->setCurrentIndex(FeaturePropertiesList);
}
}
void UBFeaturesCentralWidget::switchTo(StackElement pView)
{
mStackedWidget->setCurrentIndex(pView);
}
void UBFeaturesCentralWidget::setPropertiesPixmap(const QPixmap &pix)
{
mFeatureProperties->setOrigPixmap(pix);
}
void UBFeaturesCentralWidget::setPropertiesThumbnail(const QPixmap &pix)
{
mFeatureProperties->setThumbnail(pix);
}
UBFeature UBFeaturesCentralWidget::getCurElementFromProperties()
{
return mFeatureProperties->getCurrentElement();
}
void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState)
{
mAdditionalDataContainer->setMaximumHeight(mAdditionalDataContainer->widget(pWidgetType)->sizeHint().height());
mAdditionalDataContainer->setCurrentIndex(pWidgetType);
mAdditionalDataContainer->show();
emit lockMainWidget(pState == Modal ? true : false);
}
void UBFeaturesCentralWidget::setLockedExcludingAdditional(bool pLock)
{
// Lock all the members excluding mAdditionalDataContainer
mStackedWidget->setEnabled(!pLock);
}
void UBFeaturesCentralWidget::createNewFolderSlot(QString pStr)
{
emit createNewFolderSignal(pStr);
hideAdditionalData();
}
void UBFeaturesCentralWidget::hideAdditionalData()
{
emit lockMainWidget(false);
mAdditionalDataContainer->hide();
}
void UBFeaturesCentralWidget::scanStarted()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && !progressBar->isVisible()) {
showAdditionalData((AddWidget)1);
}
}
void UBFeaturesCentralWidget::scanFinished()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar && progressBar->isVisible()) {
hideAdditionalData();
qDebug() << "progressBar max value is " << progressBar->maximum();
}
}
void UBFeaturesCentralWidget::increaseStatusBarValue()
{
if (!mAdditionalDataContainer->widget(ProgressBarWidget)) {
return;
}
QProgressBar *progressBar = qobject_cast<QProgressBar*>(mAdditionalDataContainer->widget(ProgressBarWidget));
if (progressBar) {
progressBar->setValue(progressBar->value() + 1);
}
}
UBFeaturesNewFolderDialog::UBFeaturesNewFolderDialog(QWidget *parent) : QWidget(parent)
{
// SET_STYLE_SHEET()
this->setStyleSheet("background:white;");
QVBoxLayout *mainLayout = new QVBoxLayout();
setLayout(mainLayout);
QVBoxLayout *labelLayout = new QVBoxLayout(this);
QLabel *mLabel = new QLabel(labelText, this);
mLineEdit = new QLineEdit(this);
mValidator = new QRegExpValidator(QRegExp("[\^\/\:\?\*\|\<\>\"]{2,}"));
mLineEdit->setValidator(mValidator);
labelLayout->addWidget(mLabel);
labelLayout->addWidget(mLineEdit);
QHBoxLayout *buttonLayout = new QHBoxLayout(this);
QPushButton *acceptButton = new QPushButton(acceptText, this);
QPushButton *cancelButton = new QPushButton(cancelText, this);
buttonLayout->addWidget(acceptButton);
buttonLayout->addWidget(cancelButton);
mainLayout->addLayout(labelLayout);
mainLayout->addLayout(buttonLayout);
connect(acceptButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void UBFeaturesNewFolderDialog::setRegexp(const QRegExp pRegExp)
{
mValidator->setRegExp(pRegExp);
}
void UBFeaturesNewFolderDialog::accept()
{
// Setting all the constraints we need
emit createNewFolder(mLineEdit->text());
mLineEdit->clear();
}
void UBFeaturesNewFolderDialog::reject()
{
mLineEdit->clear();
emit closeDialog();
}
UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent) UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(parent)
, mpView(NULL) , mpView(NULL)
, mpWebSettings(NULL) , mpWebSettings(NULL)
@ -499,6 +680,7 @@ UBFeaturesWebView::UBFeaturesWebView(QWidget* parent, const char* name):QWidget(
mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true); mpWebSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
mpLayout->addWidget(mpView); mpLayout->addWidget(mpView);
mpLayout->setMargin(0);
connect(mpView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); connect(mpView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
} }
@ -578,8 +760,6 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
{ {
setObjectName(name); setObjectName(name);
SET_STYLE_SHEET();
// Create the GUI // Create the GUI
mpLayout = new QVBoxLayout(this); mpLayout = new QVBoxLayout(this);
setLayout(mpLayout); setLayout(mpLayout);
@ -625,6 +805,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) :
mpObjInfos->setObjectName("DockPaletteWidgetBox"); mpObjInfos->setObjectName("DockPaletteWidgetBox");
mpObjInfos->setStyleSheet("background:white;"); mpObjInfos->setStyleSheet("background:white;");
mpLayout->addWidget(mpObjInfos, 1); mpLayout->addWidget(mpObjInfos, 1);
mpLayout->setMargin(0);
connect( mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()) ); connect( mpAddPageButton, SIGNAL(clicked()), this, SLOT(onAddToPage()) );
connect( mpSetAsBackgroundButton, SIGNAL( clicked() ), this, SLOT( onSetAsBackground() ) ); connect( mpSetAsBackgroundButton, SIGNAL( clicked() ), this, SLOT( onSetAsBackground() ) );
@ -700,7 +881,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const
return UBFeature(); return UBFeature();
} }
void UBFeatureProperties::setOrigPixmap(QPixmap &pix) void UBFeatureProperties::setOrigPixmap(const QPixmap &pix)
{ {
if (mpOrigPixmap) if (mpOrigPixmap)
@ -709,7 +890,7 @@ void UBFeatureProperties::setOrigPixmap(QPixmap &pix)
mpOrigPixmap = new QPixmap(pix); mpOrigPixmap = new QPixmap(pix);
} }
void UBFeatureProperties::setThumbnail(QPixmap &pix) void UBFeatureProperties::setThumbnail(const QPixmap &pix)
{ {
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH));
adaptSize(); adaptSize();
@ -730,7 +911,7 @@ void UBFeatureProperties::adaptSize()
} }
} }
void UBFeatureProperties::showElement( const UBFeature &elem ) void UBFeatureProperties::showElement(const UBFeature &elem)
{ {
if ( mpOrigPixmap ) if ( mpOrigPixmap )
{ {
@ -742,9 +923,9 @@ void UBFeatureProperties::showElement( const UBFeature &elem )
delete mpElement; delete mpElement;
mpElement = NULL; mpElement = NULL;
} }
mpElement = new UBFeature( elem ); mpElement = new UBFeature(elem);
mpOrigPixmap = new QPixmap( elem.getThumbnail() ); mpOrigPixmap = new QPixmap(QPixmap::fromImage(elem.getThumbnail()));
mpThumbnail->setPixmap(elem.getThumbnail().scaledToWidth(THUMBNAIL_WIDTH)); mpThumbnail->setPixmap(QPixmap::fromImage(elem.getThumbnail()).scaledToWidth(THUMBNAIL_WIDTH));
populateMetadata(); populateMetadata();
if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) ) if ( UBApplication::isFromWeb( elem.getFullPath().toString() ) )
@ -794,8 +975,8 @@ void UBFeatureProperties::populateMetadata()
void UBFeatureProperties::onAddToPage() void UBFeatureProperties::onAddToPage()
{ {
QWidget *w = parentWidget()->parentWidget(); QWidget *w = parentWidget()->parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w ); UBFeaturesWidget* featuresWidget = qobject_cast<UBFeaturesWidget*>( w );
if (featuresWidget) if (featuresWidget)
featuresWidget->getFeaturesController()->addItemToPage( *mpElement ); featuresWidget->getFeaturesController()->addItemToPage( *mpElement );
} }
@ -818,8 +999,8 @@ void UBFeatureProperties::onAddToLib()
void UBFeatureProperties::onSetAsBackground() void UBFeatureProperties::onSetAsBackground()
{ {
QWidget *w = parentWidget()->parentWidget(); QWidget *w = parentWidget()->parentWidget()->parentWidget();
UBFeaturesWidget* featuresWidget = dynamic_cast<UBFeaturesWidget*>( w ); UBFeaturesWidget* featuresWidget = qobject_cast<UBFeaturesWidget*>( w );
featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement ); featuresWidget->getFeaturesController()->addItemAsBackground( *mpElement );
} }
@ -845,7 +1026,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
} }
else if (role == Qt::DecorationRole) { else if (role == Qt::DecorationRole) {
return QIcon( featuresList->at(index.row()).getThumbnail() ); return QIcon( QPixmap::fromImage(featuresList->at(index.row()).getThumbnail()));
} else if (role == Qt::UserRole) { } else if (role == Qt::UserRole) {
return featuresList->at(index.row()).getVirtualPath(); return featuresList->at(index.row()).getVirtualPath();
@ -1017,7 +1198,7 @@ void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destina
QString sourceVirtualPath = source.getVirtualPath(); QString sourceVirtualPath = source.getVirtualPath();
UBFeatureElementType sourceType = source.getType(); UBFeatureElementType sourceType = source.getType();
QPixmap sourceIcon = source.getThumbnail(); QImage sourceIcon = source.getThumbnail();
Q_ASSERT( QFileInfo( sourcePath ).exists() ); Q_ASSERT( QFileInfo( sourcePath ).exists() );
@ -1183,7 +1364,7 @@ void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionVie
{ {
painter->drawPixmap( rect.left() - 10, rect.center().y() - 5, *arrowPixmap ); painter->drawPixmap( rect.left() - 10, rect.center().y() - 5, *arrowPixmap );
} }
painter->drawPixmap( rect.left() + 5, rect.center().y() - 5, feature.getThumbnail().scaledToHeight( 30, Qt::SmoothTransformation ) ); painter->drawImage( rect.left() + 5, rect.center().y() - 5, feature.getThumbnail().scaledToHeight( 30, Qt::SmoothTransformation ) );
} }
UBFeaturesPathItemDelegate::~UBFeaturesPathItemDelegate() UBFeaturesPathItemDelegate::~UBFeaturesPathItemDelegate()

@ -43,6 +43,8 @@ class UBFeaturesListView;
class UBFeaturesWebView; class UBFeaturesWebView;
class UBFeaturesNavigatorWidget; class UBFeaturesNavigatorWidget;
class UBFeaturesMimeData; class UBFeaturesMimeData;
class UBFeaturesCentralWidget;
class UBFeaturesNewFolderDialog;
class UBFeaturesWidget : public UBDockPaletteWidget class UBFeaturesWidget : public UBDockPaletteWidget
{ {
@ -63,6 +65,9 @@ public:
static const int maxThumbnailSize = 100; static const int maxThumbnailSize = 100;
static const int defaultThumbnailSize = 40; static const int defaultThumbnailSize = 40;
static const char *objNamePathList;
static const char *objNameFeatureList;
public: public:
int scrollbarHorisontalPadding() const { return 10;} int scrollbarHorisontalPadding() const { return 10;}
int scrollbarVerticalIndent() const { return 0;} int scrollbarVerticalIndent() const { return 0;}
@ -82,6 +87,7 @@ private slots:
void removeElementsFromFavorite(); void removeElementsFromFavorite();
void deleteSelectedElements(); void deleteSelectedElements();
void rescanModel(); void rescanModel();
void lockIt(bool pLock);
private: private:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
@ -91,17 +97,12 @@ private:
private: private:
UBFeaturesController *controller; UBFeaturesController *controller;
UBFeaturesNavigatorWidget *mNavigator;
UBFeaturesListView *pathListView; UBFeaturesListView *pathListView;
QVBoxLayout *layout; QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar; UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget;
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer; UBDownloadHttpFile* imageGatherer;
UBNewFolderDlg *mkFolderDlg; UBNewFolderDlg *mkFolderDlg;
UBFeaturesCentralWidget *centralWidget;
}; };
@ -134,6 +135,7 @@ protected:
private slots: private slots:
void thumbnailSizeChanged(int); void thumbnailSizeChanged(int);
}; };
@ -153,6 +155,93 @@ private:
}; };
class UBFeaturesCentralWidget : public QWidget
{
Q_OBJECT
public:
enum StackElement{
MainList = 0,
FeaturePropertiesList,
FeaturesWebView
};
enum AddWidget {
NewFolderDialog = 0,
ProgressBarWidget
};
enum AddWidgetState {
NonModal = 0,
Modal
};
UBFeaturesCentralWidget(QWidget *parent = 0);
void setSliderPosition(int pValue) {mNavigator->setSliderPosition(pValue);}
UBFeaturesListView *listView() {return mNavigator->listView();}
void showElement(const UBFeature &feature, StackElement pView);
void switchTo(StackElement pView);
void setPropertiesPixmap(const QPixmap &pix);
void setPropertiesThumbnail(const QPixmap &pix);
StackElement currentView() const {return static_cast<StackElement>(mStackedWidget->currentIndex());}
UBFeature getCurElementFromProperties();
void showAdditionalData(AddWidget pWidgetType, AddWidgetState pState = NonModal);
void setLockedExcludingAdditional(bool pLock);
QStackedWidget *mStackedWidget;
UBFeaturesNavigatorWidget *mNavigator;
UBFeatureProperties *mFeatureProperties;
UBFeaturesWebView *webView;
QStackedWidget *mAdditionalDataContainer;
signals:
void lockMainWidget(bool pLock);
void createNewFolderSignal(QString pStr);
// progressbar widget related signals
void maxFilesCountEvaluated(int pValue);
private slots:
void createNewFolderSlot(QString pStr);
void hideAdditionalData();
void scanStarted();
void scanFinished();
void increaseStatusBarValue();
private:
};
class UBFeaturesNewFolderDialog : public QWidget
{
Q_OBJECT
public:
static const QString acceptText;
static const QString cancelText;
static const QString labelText;
UBFeaturesNewFolderDialog(QWidget *parent = 0);
void setRegexp(const QRegExp pRegExp);
signals:
void createNewFolder(QString str);
void closeDialog();
private slots:
void accept();
void reject();
private:
QLineEdit *mLineEdit;
QRegExpValidator *mValidator;
};
class UBFeaturesWebView : public QWidget class UBFeaturesWebView : public QWidget
{ {
@ -182,8 +271,8 @@ public:
void showElement(const UBFeature &elem); void showElement(const UBFeature &elem);
UBFeature getCurrentElement() const; UBFeature getCurrentElement() const;
void setOrigPixmap(QPixmap &pix); void setOrigPixmap(const QPixmap &pix);
void setThumbnail(QPixmap &pix); void setThumbnail(const QPixmap &pix);
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
@ -231,7 +320,6 @@ public:
UBFeaturesModel(QList<UBFeature> *pFeaturesList, QObject *parent = 0) : QAbstractListModel(parent), featuresList(pFeaturesList) {;} UBFeaturesModel(QList<UBFeature> *pFeaturesList, QObject *parent = 0) : QAbstractListModel(parent), featuresList(pFeaturesList) {;}
virtual ~UBFeaturesModel(){;} virtual ~UBFeaturesModel(){;}
void addItem( const UBFeature &item );
void deleteFavoriteItem( const QString &path ); void deleteFavoriteItem( const QString &path );
void deleteItem( const QString &path ); void deleteItem( const QString &path );
void deleteItem(const UBFeature &feature); void deleteItem(const UBFeature &feature);
@ -251,6 +339,9 @@ public:
Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; } Qt::DropActions supportedDropActions() const { return Qt::MoveAction | Qt::CopyAction; }
// void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; } // void setFeaturesList(QList <UBFeature> *flist ) { featuresList = flist; }
public slots:
void addItem( const UBFeature &item );
private: private:
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
}; };
@ -314,4 +405,5 @@ private:
QPixmap *arrowPixmap; QPixmap *arrowPixmap;
}; };
#endif // UBFEATURESWIDGET_H #endif // UBFEATURESWIDGET_H

Loading…
Cancel
Save