Sankore 942 Trap flash content

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 38d759fd4a
commit 021617ee3e
  1. 26
      src/board/UBBoardController.cpp
  2. 7
      src/board/UBBoardController.h
  3. 19
      src/board/UBFeaturesController.cpp
  4. 2
      src/board/UBFeaturesController.h
  5. 5
      src/gui/UBFeaturesWidget.cpp
  6. 5
      src/gui/UBFeaturesWidget.h

@ -53,6 +53,8 @@
#include "domain/UBPageSizeUndoCommand.h" #include "domain/UBPageSizeUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "board/UBFeaturesController.h"
#include "gui/UBFeaturesWidget.h"
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
@ -897,7 +899,7 @@ void UBBoardController::groupButtonClicked()
} }
} }
void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const QSize& pSize, bool isBackground) void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const QSize& pSize, bool isBackground, bool internalData)
{ {
qDebug() << "something has been dropped on the board! Url is: " << url.toString(); qDebug() << "something has been dropped on the board! Url is: " << url.toString();
QString sUrl = url.toString(); QString sUrl = url.toString();
@ -922,7 +924,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
if (shouldLoadFileData) if (shouldLoadFileData)
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
downloadFinished(true, url, contentType, file.readAll(), pPos, pSize, isBackground); downloadFinished(true, url, contentType, file.readAll(), pPos, pSize, isBackground, internalData);
if (shouldLoadFileData) if (shouldLoadFileData)
file.close(); file.close();
@ -945,7 +947,9 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
} }
UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader,
QByteArray pData, QPointF pPos, QSize pSize,
bool isBackground, bool internalData)
{ {
QString mimeType = pContentTypeHeader; QString mimeType = pContentTypeHeader;
@ -1155,7 +1159,10 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QStri
else else
size = mActiveScene->nominalSize() * .8; size = mActiveScene->nominalSize() * .8;
Q_UNUSED(internalData)
QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size); QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size);
emit npapiWidgetCreated(widgetUrl);
if (widgetUrl.length() > 0) if (widgetUrl.length() > 0)
{ {
@ -1339,7 +1346,6 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mActiveSceneIndex = index; mActiveSceneIndex = index;
setDocument(pDocumentProxy, forceReload); setDocument(pDocumentProxy, forceReload);
updateSystemScaleFactor(); updateSystemScaleFactor();
mControlView->setScene(mActiveScene); mControlView->setScene(mActiveScene);
@ -1668,13 +1674,11 @@ void UBBoardController::hide()
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
} }
void UBBoardController::show() void UBBoardController::show()
{ {
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
} }
void UBBoardController::persistCurrentScene() void UBBoardController::persistCurrentScene()
{ {
if(UBPersistenceManager::persistenceManager() if(UBPersistenceManager::persistenceManager()
@ -1689,7 +1693,6 @@ void UBBoardController::persistCurrentScene()
} }
} }
void UBBoardController::updateSystemScaleFactor() void UBBoardController::updateSystemScaleFactor()
{ {
qreal newScaleFactor = 1.0; qreal newScaleFactor = 1.0;
@ -2100,9 +2103,16 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
int index = 0; int index = 0;
const UBFeaturesMimeData *internalMimeData = qobject_cast<const UBFeaturesMimeData*>(pMimeData);
bool internalData = false;
if (internalMimeData) {
internalData = true;
}
foreach(const QUrl url, urls){ foreach(const QUrl url, urls){
QPointF pos(pPos + QPointF(index * 15, index * 15)); QPointF pos(pPos + QPointF(index * 15, index * 15));
downloadURL(url, pos);
downloadURL(url, pos, QSize(), false, internalData);
index++; index++;
} }

@ -189,8 +189,10 @@ class UBBoardController : public UBDocumentContainer
void firstScene(); void firstScene();
void lastScene(); void lastScene();
void groupButtonClicked(); void groupButtonClicked();
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false); void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false, bool internalData = false);
UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false); UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader,
QByteArray pData, QPointF pPos, QSize pSize,
bool isBackground = false, bool internalData = false);
void changeBackground(bool isDark, bool isCrossed); void changeBackground(bool isDark, bool isCrossed);
void setToolCursor(int tool); void setToolCursor(int tool);
void showMessage(const QString& message, bool showSpinningWheel = false); void showMessage(const QString& message, bool showSpinningWheel = false);
@ -236,6 +238,7 @@ class UBBoardController : public UBDocumentContainer
void documentReorganized(int index); void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata); void displayMetadata(QMap<QString, QString> metadata);
void pageSelectionChanged(int index); void pageSelectionChanged(int index);
void npapiWidgetCreated(const QString &Url);
protected: protected:
void setupViews(); void setupViews();

@ -154,7 +154,9 @@ void UBFeaturesComputingThread::run()
emit maxFilesCountEvaluated(fsCnt); emit maxFilesCountEvaluated(fsCnt);
emit scanStarted(); emit scanStarted();
curTime = QTime::currentTime();
scanAll(searchData, favoriteSet); scanAll(searchData, favoriteSet);
qDebug() << "Time on finishing" << curTime.msecsTo(QTime::currentTime());
emit scanFinished(); emit scanFinished();
mMutex.lock(); mMutex.lock();
@ -303,6 +305,7 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int))); connect(&mCThread, SIGNAL(maxFilesCountEvaluated(int)), this, SIGNAL(maxFilesCountEvaluated(int)));
connect(&mCThread, SIGNAL(scanCategory(QString)), this, SIGNAL(scanCategory(QString))); connect(&mCThread, SIGNAL(scanCategory(QString)), this, SIGNAL(scanCategory(QString)));
connect(&mCThread, SIGNAL(scanPath(QString)), this, SIGNAL(scanPath(QString))); connect(&mCThread, SIGNAL(scanPath(QString)), this, SIGNAL(scanPath(QString)));
connect(UBApplication::boardController, SIGNAL(npapiWidgetCreated(QString)), this, SLOT(createNpApiFeature(QString)));
QTimer::singleShot(0, this, SLOT(startThread())); QTimer::singleShot(0, this, SLOT(startThread()));
} }
@ -326,11 +329,20 @@ void UBFeaturesController::startThread()
<< QPair<QUrl, QString>(mLibShapesDirectoryPath, shapesPath) << QPair<QUrl, QString>(mLibShapesDirectoryPath, shapesPath)
<< QPair<QUrl, QString>(mLibInteractiveDirectoryPath, interactPath) << QPair<QUrl, QString>(mLibInteractiveDirectoryPath, interactPath)
<< QPair<QUrl, QString>(trashDirectoryPath, trashPath) << QPair<QUrl, QString>(trashDirectoryPath, trashPath)
<< QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search" ); << QPair<QUrl, QString>(mLibSearchDirectoryPath, rootPath + "/" + "Web search");
mCThread.compute(computingData, favoriteSet); mCThread.compute(computingData, favoriteSet);
} }
void UBFeaturesController::createNpApiFeature(const QString &str)
{
Q_ASSERT(QFileInfo(str).exists() && QFileInfo(str).isDir());
QString widgetName = QFileInfo(str).fileName();
featuresModel->addItem(UBFeature(QString(appPath+"/Web"), QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(str))), widgetName, QUrl::fromLocalFile(str), FEATURE_INTERACTIVE));
}
void UBFeaturesController::scanFS() void UBFeaturesController::scanFS()
{ {
featuresList->clear(); featuresList->clear();
@ -502,6 +514,8 @@ UBFeatureElementType UBFeaturesController::fileTypeFromUrl(const QString &path)
if ( mimeString.contains("application")) { if ( mimeString.contains("application")) {
if (mimeString.contains("application/search")) { if (mimeString.contains("application/search")) {
fileType = FEATURE_SEARCH; fileType = FEATURE_SEARCH;
} else if (mimeString.contains("application/x-shockwave-flash")) {
fileType = FEATURE_FLASH;
} else { } else {
fileType = FEATURE_INTERACTIVE; fileType = FEATURE_INTERACTIVE;
} }
@ -530,6 +544,8 @@ QImage UBFeaturesController::getIcon(const QString &path, UBFeatureElementType p
return QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(path))); return QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(path)));
} else if (pFType == FEATURE_INTERNAL) { } else if (pFType == FEATURE_INTERNAL) {
return QImage(UBToolsManager::manager()->iconFromToolId(path)); return QImage(UBToolsManager::manager()->iconFromToolId(path));
} else if (pFType == FEATURE_FLASH) {
return QImage(":images/libpalette/FlashIcon.svg");
} else if (pFType == FEATURE_AUDIO) { } else if (pFType == FEATURE_AUDIO) {
return QImage(":images/libpalette/soundIcon.svg"); return QImage(":images/libpalette/soundIcon.svg");
} else if (pFType == FEATURE_VIDEO) { } else if (pFType == FEATURE_VIDEO) {
@ -802,6 +818,7 @@ void UBFeaturesController::searchStarted(const QString &pattern, QListView *pOnV
curListModel = featuresProxyModel; curListModel = featuresProxyModel;
} else if ( pattern.size() > 1 ) { } else if ( pattern.size() > 1 ) {
// featuresSearchModel->setFilterPrefix(currentElement.getFullVirtualPath());
featuresSearchModel->setFilterWildcard( "*" + pattern + "*" ); featuresSearchModel->setFilterWildcard( "*" + pattern + "*" );
pOnView->setModel(featuresSearchModel ); pOnView->setModel(featuresSearchModel );
featuresSearchModel->invalidate(); featuresSearchModel->invalidate();

@ -78,6 +78,7 @@ enum UBFeatureElementType
FEATURE_AUDIO, FEATURE_AUDIO,
FEATURE_VIDEO, FEATURE_VIDEO,
FEATURE_IMAGE, FEATURE_IMAGE,
FEATURE_FLASH,
FEATURE_TRASH, FEATURE_TRASH,
FEATURE_FAVORITE, FEATURE_FAVORITE,
FEATURE_SEARCH, FEATURE_SEARCH,
@ -192,6 +193,7 @@ signals:
private slots: private slots:
void addNewFolder(QString name); void addNewFolder(QString name);
void startThread(); void startThread();
void createNpApiFeature(const QString &str);
private: private:

@ -1337,6 +1337,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const
|| item.getType() == FEATURE_AUDIO || item.getType() == FEATURE_AUDIO
|| item.getType() == FEATURE_VIDEO || item.getType() == FEATURE_VIDEO
|| item.getType() == FEATURE_IMAGE || item.getType() == FEATURE_IMAGE
|| item.getType() == FEATURE_FLASH
|| item.getType() == FEATURE_INTERNAL || item.getType() == FEATURE_INTERNAL
|| item.getType() == FEATURE_FOLDER) || item.getType() == FEATURE_FOLDER)
@ -1387,7 +1388,9 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
|| feature.getType() == FEATURE_VIDEO || feature.getType() == FEATURE_VIDEO
|| feature.getType() == FEATURE_IMAGE; || feature.getType() == FEATURE_IMAGE;
return isFile && filterRegExp().exactMatch( feature.getName() ); return isFile
&& feature.getFullVirtualPath().contains(mFilterPrefix)
&& filterRegExp().exactMatch( feature.getName() );
} }
bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const

@ -394,10 +394,13 @@ class UBFeaturesSearchProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
public: public:
UBFeaturesSearchProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent) {;} UBFeaturesSearchProxyModel(QObject *parent = 0) : QSortFilterProxyModel(parent), mFilterPrefix() {;}
virtual ~UBFeaturesSearchProxyModel() {} virtual ~UBFeaturesSearchProxyModel() {}
void setFilterPrefix(const QString &newPrefix) {mFilterPrefix = newPrefix;}
protected: protected:
virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex & sourceParent ) const; virtual bool filterAcceptsRow ( int sourceRow, const QModelIndex & sourceParent ) const;
private:
QString mFilterPrefix;
}; };
class UBFeaturesPathProxyModel : public QSortFilterProxyModel class UBFeaturesPathProxyModel : public QSortFilterProxyModel

Loading…
Cancel
Save