|
|
@ -47,7 +47,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name) |
|
|
|
|
|
|
|
|
|
|
|
//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(centralWidget); |
|
|
|
layout->addWidget(centralWidget); |
|
|
@ -153,7 +153,7 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
QList<UBFeature> featuresList = mimeData->features(); |
|
|
|
QList<UBFeature> featuresList = mimeData->features(); |
|
|
|
|
|
|
|
|
|
|
|
foreach ( UBFeature curFeature, featuresList ) { |
|
|
|
foreach ( UBFeature curFeature, featuresList ) { |
|
|
|
if ( curFeature.inTrash()) { |
|
|
|
if ( curFeature.inTrash()) { |
|
|
|
controller->deleteItem(curFeature.getFullPath()); |
|
|
|
controller->deleteItem(curFeature.getFullPath()); |
|
|
@ -175,7 +175,7 @@ void UBFeaturesWidget::deleteSelectedElements() |
|
|
|
{ |
|
|
|
{ |
|
|
|
featureasToMove.append(controller->getFeature(selected.at(i), objNameFeatureList)); |
|
|
|
featureasToMove.append(controller->getFeature(selected.at(i), objNameFeatureList)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (UBFeature feature, featureasToMove) |
|
|
|
foreach (UBFeature feature, featureasToMove) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (feature.isDeletable()) { |
|
|
|
if (feature.isDeletable()) { |
|
|
@ -232,34 +232,34 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata ) |
|
|
|
QString previewImageUrl = ":images/libpalette/notFound.png"; |
|
|
|
QString previewImageUrl = ":images/libpalette/notFound.png"; |
|
|
|
|
|
|
|
|
|
|
|
QString widgetsUrl = QUrl::fromEncoded(metadata["Url"].toAscii()).toString()/*metadata.value("Url", QString())*/; |
|
|
|
QString widgetsUrl = QUrl::fromEncoded(metadata["Url"].toAscii()).toString()/*metadata.value("Url", QString())*/; |
|
|
|
QString widgetsThumbsUrl = QUrl::fromEncoded(metadata["thumbnailUrl"].toAscii()).toString(); |
|
|
|
QString widgetsThumbsUrl = QUrl::fromEncoded(metadata["thumbnailUrl"].toAscii()).toString(); |
|
|
|
|
|
|
|
|
|
|
|
bool isLocal = QFileInfo(widgetsUrl).exists(); |
|
|
|
bool isLocal = QFileInfo(widgetsUrl).exists(); |
|
|
|
|
|
|
|
|
|
|
|
if (isLocal) { |
|
|
|
|
|
|
|
QString strType = UBFileSystemUtils::mimeTypeFromFileName(widgetsUrl); |
|
|
|
|
|
|
|
UBMimeType::Enum thumbType = UBFileSystemUtils::mimeTypeFromString(strType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (static_cast<int>(thumbType)) { |
|
|
|
QString strType = UBFileSystemUtils::mimeTypeFromFileName(widgetsUrl); |
|
|
|
case UBMimeType::Audio: |
|
|
|
UBMimeType::Enum thumbType = UBFileSystemUtils::mimeTypeFromString(strType); |
|
|
|
previewImageUrl = ":images/libpalette/soundIcon.svg"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case UBMimeType::Video: |
|
|
|
switch (static_cast<int>(thumbType)) { |
|
|
|
previewImageUrl = ":images/libpalette/movieIcon.svg"; |
|
|
|
case UBMimeType::Audio: |
|
|
|
break; |
|
|
|
previewImageUrl = ":images/libpalette/soundIcon.svg"; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case UBMimeType::Flash: |
|
|
|
case UBMimeType::Video: |
|
|
|
previewImageUrl = ":images/libpalette/FlashIcon.svg"; |
|
|
|
previewImageUrl = ":images/libpalette/movieIcon.svg"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case UBMimeType::RasterImage: |
|
|
|
case UBMimeType::Flash: |
|
|
|
case UBMimeType::VectorImage: |
|
|
|
previewImageUrl = ":images/libpalette/FlashIcon.svg"; |
|
|
|
previewImageUrl = widgetsUrl; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (!widgetsThumbsUrl.isNull()) { |
|
|
|
case UBMimeType::RasterImage: |
|
|
|
|
|
|
|
case UBMimeType::VectorImage: |
|
|
|
|
|
|
|
previewImageUrl = widgetsUrl; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!widgetsThumbsUrl.isNull()) { |
|
|
|
previewImageUrl = ":/images/libpalette/loading.png"; |
|
|
|
previewImageUrl = ":/images/libpalette/loading.png"; |
|
|
|
if (!imageGatherer) |
|
|
|
if (!imageGatherer) |
|
|
|
imageGatherer = new UBDownloadHttpFile(0, this); |
|
|
|
imageGatherer = new UBDownloadHttpFile(0, this); |
|
|
@ -269,11 +269,10 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata ) |
|
|
|
// We send here the request and store its reply in order to be able to cancel it if needed
|
|
|
|
// We send here the request and store its reply in order to be able to cancel it if needed
|
|
|
|
imageGatherer->get(QUrl(widgetsThumbsUrl), QPoint(0,0), QSize(), false); |
|
|
|
imageGatherer->get(QUrl(widgetsThumbsUrl), QPoint(0,0), QSize(), false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString tmp = QUrl::fromEncoded(metadata["Url"].toAscii()).toString(); |
|
|
|
|
|
|
|
qDebug() << tmp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature feature( "/root", QImage(previewImageUrl), QString(), tmp/*metadata["Url"]*/, FEATURE_ITEM ); |
|
|
|
QString tmp = QUrl::fromEncoded(metadata["Url"].toAscii()).toString(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature feature( "/root", QImage(previewImageUrl), QString(), widgetsThumbsUrl, FEATURE_ITEM ); |
|
|
|
feature.setMetadata( metadata ); |
|
|
|
feature.setMetadata( metadata ); |
|
|
|
|
|
|
|
|
|
|
|
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList); |
|
|
|
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList); |
|
|
@ -303,7 +302,7 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(pContentHeader) |
|
|
|
Q_UNUSED(pContentHeader) |
|
|
|
if (pSuccess) { |
|
|
|
if (pSuccess) { |
|
|
|
qDebug() << pData.length(); |
|
|
|
qDebug() << pData.length(); |
|
|
|
controller->addDownloadedFile(sourceUrl, pData); |
|
|
|
controller->addDownloadedFile(sourceUrl, pData); |
|
|
|
controller->refreshModels(); |
|
|
|
controller->refreshModels(); |
|
|
|
} |
|
|
|
} |
|
|
@ -372,7 +371,7 @@ void UBFeaturesWidget::importImage(const QImage &image, const QString &fileName) |
|
|
|
controller->importImage(image, fileName); |
|
|
|
controller->importImage(image, fileName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
|
|
|
|
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) |
|
|
|
: QListView(parent) |
|
|
|
: QListView(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
@ -381,7 +380,7 @@ UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) |
|
|
|
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() ) |
|
|
|
event->acceptProposedAction(); |
|
|
|
event->acceptProposedAction(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event ) |
|
|
|
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event ) |
|
|
@ -547,7 +546,7 @@ void UBFeaturesCentralWidget::setPropertiesThumbnail(const QPixmap &pix) |
|
|
|
|
|
|
|
|
|
|
|
UBFeature UBFeaturesCentralWidget::getCurElementFromProperties() |
|
|
|
UBFeature UBFeaturesCentralWidget::getCurElementFromProperties() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return mFeatureProperties->getCurrentElement(); |
|
|
|
return mFeatureProperties->getCurrentElement(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState) |
|
|
|
void UBFeaturesCentralWidget::showAdditionalData(AddWidget pWidgetType, AddWidgetState pState) |
|
|
@ -782,36 +781,36 @@ void UBFeaturesWebView::javaScriptWindowObjectCleared() |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesWebView::showElement(const UBFeature &elem) |
|
|
|
void UBFeaturesWebView::showElement(const UBFeature &elem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString qsWidgetName; |
|
|
|
QString qsWidgetName; |
|
|
|
QString path = elem.getFullPath().toLocalFile(); |
|
|
|
QString path = elem.getFullPath().toLocalFile(); |
|
|
|
|
|
|
|
|
|
|
|
QString qsConfigPath = QString("%0/config.xml").arg(path); |
|
|
|
QString qsConfigPath = QString("%0/config.xml").arg(path); |
|
|
|
|
|
|
|
|
|
|
|
if(QFile::exists(qsConfigPath)) |
|
|
|
if(QFile::exists(qsConfigPath)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QFile f(qsConfigPath); |
|
|
|
QFile f(qsConfigPath); |
|
|
|
if(f.open(QIODevice::ReadOnly)) |
|
|
|
if(f.open(QIODevice::ReadOnly)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QDomDocument domDoc; |
|
|
|
QDomDocument domDoc; |
|
|
|
domDoc.setContent(QString(f.readAll())); |
|
|
|
domDoc.setContent(QString(f.readAll())); |
|
|
|
QDomElement root = domDoc.documentElement(); |
|
|
|
QDomElement root = domDoc.documentElement(); |
|
|
|
|
|
|
|
|
|
|
|
QDomNode node = root.firstChild(); |
|
|
|
QDomNode node = root.firstChild(); |
|
|
|
while(!node.isNull()) |
|
|
|
while(!node.isNull()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(node.toElement().tagName() == "content") |
|
|
|
if(node.toElement().tagName() == "content") |
|
|
|
{ |
|
|
|
{ |
|
|
|
QDomAttr srcAttr = node.toElement().attributeNode("src"); |
|
|
|
QDomAttr srcAttr = node.toElement().attributeNode("src"); |
|
|
|
qsWidgetName = srcAttr.value(); |
|
|
|
qsWidgetName = srcAttr.value(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
node = node.nextSibling(); |
|
|
|
node = node.nextSibling(); |
|
|
|
} |
|
|
|
} |
|
|
|
f.close(); |
|
|
|
f.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName)));
|
|
|
|
mpView->load(QUrl::fromLocalFile(QString("%0/%1").arg(path).arg(qsWidgetName))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesWebView::onLoadFinished(bool ok) |
|
|
|
void UBFeaturesWebView::onLoadFinished(bool ok) |
|
|
@ -834,7 +833,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : |
|
|
|
, mpOrigPixmap(NULL) |
|
|
|
, mpOrigPixmap(NULL) |
|
|
|
, mpElement(NULL) |
|
|
|
, mpElement(NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
|
|
|
|
|
|
|
|
// Create the GUI
|
|
|
|
// Create the GUI
|
|
|
|
mpLayout = new QVBoxLayout(this); |
|
|
|
mpLayout = new QVBoxLayout(this); |
|
|
@ -869,7 +868,7 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : |
|
|
|
|
|
|
|
|
|
|
|
mpButtonLayout->addStretch(1); |
|
|
|
mpButtonLayout->addStretch(1); |
|
|
|
|
|
|
|
|
|
|
|
mpObjInfoLabel = new QLabel(tr("Object informations")); |
|
|
|
mpObjInfoLabel = new QLabel(tr("Object informations")); |
|
|
|
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); |
|
|
|
mpObjInfoLabel->setStyleSheet(QString("color: #888888; font-size : 18px; font-weight:bold;")); |
|
|
|
mpLayout->addWidget(mpObjInfoLabel, 0); |
|
|
|
mpLayout->addWidget(mpObjInfoLabel, 0); |
|
|
|
|
|
|
|
|
|
|
@ -883,23 +882,23 @@ UBFeatureProperties::UBFeatureProperties( QWidget *parent, const char *name ) : |
|
|
|
mpLayout->addWidget(mpObjInfos, 1); |
|
|
|
mpLayout->addWidget(mpObjInfos, 1); |
|
|
|
mpLayout->setMargin(0); |
|
|
|
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() ) ); |
|
|
|
connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) ); |
|
|
|
connect( mpAddToLibButton, SIGNAL( clicked() ), this, SLOT(onAddToLib() ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeatureProperties::~UBFeatureProperties() |
|
|
|
UBFeatureProperties::~UBFeatureProperties() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( mpOrigPixmap ) |
|
|
|
if ( mpOrigPixmap ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpOrigPixmap; |
|
|
|
delete mpOrigPixmap; |
|
|
|
mpOrigPixmap = NULL; |
|
|
|
mpOrigPixmap = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
if ( mpElement ) |
|
|
|
if ( mpElement ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpElement; |
|
|
|
delete mpElement; |
|
|
|
mpElement = NULL; |
|
|
|
mpElement = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
if ( mpThumbnail ) |
|
|
|
if ( mpThumbnail ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpThumbnail; |
|
|
|
delete mpThumbnail; |
|
|
@ -959,7 +958,7 @@ UBFeature UBFeatureProperties::getCurrentElement() const |
|
|
|
|
|
|
|
|
|
|
|
void UBFeatureProperties::setOrigPixmap(const QPixmap &pix) |
|
|
|
void UBFeatureProperties::setOrigPixmap(const QPixmap &pix) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (mpOrigPixmap) |
|
|
|
if (mpOrigPixmap) |
|
|
|
delete mpOrigPixmap; |
|
|
|
delete mpOrigPixmap; |
|
|
|
|
|
|
|
|
|
|
@ -967,7 +966,7 @@ void UBFeatureProperties::setOrigPixmap(const QPixmap &pix) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeatureProperties::setThumbnail(const QPixmap &pix) |
|
|
|
void UBFeatureProperties::setThumbnail(const QPixmap &pix) |
|
|
|
{
|
|
|
|
{ |
|
|
|
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH)); |
|
|
|
mpThumbnail->setPixmap(pix.scaledToWidth(THUMBNAIL_WIDTH)); |
|
|
|
adaptSize(); |
|
|
|
adaptSize(); |
|
|
|
} |
|
|
|
} |
|
|
@ -989,42 +988,42 @@ void UBFeatureProperties::adaptSize() |
|
|
|
|
|
|
|
|
|
|
|
void UBFeatureProperties::showElement(const UBFeature &elem) |
|
|
|
void UBFeatureProperties::showElement(const UBFeature &elem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( mpOrigPixmap ) |
|
|
|
if ( mpOrigPixmap ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpOrigPixmap; |
|
|
|
delete mpOrigPixmap; |
|
|
|
mpOrigPixmap = NULL; |
|
|
|
mpOrigPixmap = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
if ( mpElement ) |
|
|
|
if ( mpElement ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mpElement; |
|
|
|
delete mpElement; |
|
|
|
mpElement = NULL; |
|
|
|
mpElement = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
mpElement = new UBFeature(elem); |
|
|
|
mpElement = new UBFeature(elem); |
|
|
|
mpOrigPixmap = new QPixmap(QPixmap::fromImage(elem.getThumbnail())); |
|
|
|
mpOrigPixmap = new QPixmap(QPixmap::fromImage(elem.getThumbnail())); |
|
|
|
mpThumbnail->setPixmap(QPixmap::fromImage(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() ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpAddToLibButton->show(); |
|
|
|
mpAddToLibButton->show(); |
|
|
|
if( elem.getMetadata()["Type"].toLower().contains("image") ) |
|
|
|
if( elem.getMetadata()["Type"].toLower().contains("image") ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpAddToLibButton->hide(); |
|
|
|
mpAddToLibButton->hide(); |
|
|
|
if (UBFileSystemUtils::mimeTypeFromFileName( elem.getFullPath().toLocalFile() ).contains("image")) |
|
|
|
if (UBFileSystemUtils::mimeTypeFromFileName( elem.getFullPath().toLocalFile() ).contains("image")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
mpSetAsBackgroundButton->show(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
mpSetAsBackgroundButton->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1034,7 +1033,7 @@ void UBFeatureProperties::populateMetadata() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(NULL != mpObjInfos){ |
|
|
|
if(NULL != mpObjInfos){ |
|
|
|
mpObjInfos->clear(); |
|
|
|
mpObjInfos->clear(); |
|
|
|
QMap<QString, QString> metas = mpElement->getMetadata(); |
|
|
|
QMap<QString, QString> metas = mpElement->getMetadata(); |
|
|
|
QList<QString> lKeys = metas.keys(); |
|
|
|
QList<QString> lKeys = metas.keys(); |
|
|
|
QList<QString> lValues = metas.values(); |
|
|
|
QList<QString> lValues = metas.values(); |
|
|
|
|
|
|
|
|
|
|
@ -1095,7 +1094,7 @@ UBFeatureItemButton::~UBFeatureItemButton() |
|
|
|
|
|
|
|
|
|
|
|
QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const |
|
|
|
QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!index.isValid()) |
|
|
|
if (!index.isValid()) |
|
|
|
return QVariant(); |
|
|
|
return QVariant(); |
|
|
|
|
|
|
|
|
|
|
|
if (role == Qt::DisplayRole) { |
|
|
|
if (role == Qt::DisplayRole) { |
|
|
@ -1106,21 +1105,21 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const |
|
|
|
return QIcon( QPixmap::fromImage(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(); |
|
|
|
|
|
|
|
|
|
|
|
} else if (role == Qt::UserRole + 1) { |
|
|
|
} else if (role == Qt::UserRole + 1) { |
|
|
|
//return featuresList->at(index.row()).getType();
|
|
|
|
//return featuresList->at(index.row()).getType();
|
|
|
|
UBFeature f = featuresList->at(index.row()); |
|
|
|
UBFeature f = featuresList->at(index.row()); |
|
|
|
return QVariant::fromValue( f ); |
|
|
|
return QVariant::fromValue( f ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return QVariant(); |
|
|
|
return QVariant(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const |
|
|
|
QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFeaturesMimeData *mimeData = new UBFeaturesMimeData(); |
|
|
|
UBFeaturesMimeData *mimeData = new UBFeaturesMimeData(); |
|
|
|
QList <QUrl> urlList; |
|
|
|
QList <QUrl> urlList; |
|
|
|
QList <UBFeature> featuresList; |
|
|
|
QList <UBFeature> featuresList; |
|
|
|
QByteArray typeData; |
|
|
|
QByteArray typeData; |
|
|
|
|
|
|
|
|
|
|
@ -1136,8 +1135,8 @@ QMimeData* UBFeaturesModel::mimeData(const QModelIndexList &indexes) const |
|
|
|
typeData += UBFeaturesController::featureTypeSplitter(); |
|
|
|
typeData += UBFeaturesController::featureTypeSplitter(); |
|
|
|
} |
|
|
|
} |
|
|
|
typeData += QString::number(element.getType()).toAscii(); |
|
|
|
typeData += QString::number(element.getType()).toAscii(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mimeData->setUrls(urlList); |
|
|
|
mimeData->setUrls(urlList); |
|
|
|
mimeData->setFeatures(featuresList); |
|
|
|
mimeData->setFeatures(featuresList); |
|
|
@ -1159,11 +1158,11 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
dataFromSameModel = true; |
|
|
|
dataFromSameModel = true; |
|
|
|
|
|
|
|
|
|
|
|
if ((!mimeData->hasUrls() && !mimeData->hasImage()) ) |
|
|
|
if ((!mimeData->hasUrls() && !mimeData->hasImage()) ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if ( action == Qt::IgnoreAction ) |
|
|
|
if ( action == Qt::IgnoreAction ) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
if ( column > 0 ) |
|
|
|
if ( column > 0 ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
UBFeature parentFeature; |
|
|
|
UBFeature parentFeature; |
|
|
|
if (!parent.isValid()) { |
|
|
|
if (!parent.isValid()) { |
|
|
@ -1193,39 +1192,39 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::addItem( const UBFeature &item ) |
|
|
|
void UBFeaturesModel::addItem( const UBFeature &item ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() ); |
|
|
|
beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() ); |
|
|
|
featuresList->append( item ); |
|
|
|
featuresList->append( item ); |
|
|
|
endInsertRows(); |
|
|
|
endInsertRows(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::deleteFavoriteItem( const QString &path ) |
|
|
|
void UBFeaturesModel::deleteFavoriteItem( const QString &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) && |
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) && |
|
|
|
!QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) |
|
|
|
!QString::compare( featuresList->at(i).getVirtualPath(), "/root/favorites", Qt::CaseInsensitive ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::deleteItem( const QString &path ) |
|
|
|
void UBFeaturesModel::deleteItem( const QString &path ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
for ( int i = 0; i < featuresList->size(); ++i ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) ) |
|
|
|
if ( !QString::compare( featuresList->at(i).getFullPath().toString(), path, Qt::CaseInsensitive ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
removeRow( i, QModelIndex() ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::deleteItem(const UBFeature &feature) |
|
|
|
void UBFeaturesModel::deleteItem(const UBFeature &feature) |
|
|
@ -1240,28 +1239,28 @@ void UBFeaturesModel::deleteItem(const UBFeature &feature) |
|
|
|
|
|
|
|
|
|
|
|
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) |
|
|
|
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( row < 0 ) |
|
|
|
if ( row < 0 ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if ( row + count > featuresList->size() ) |
|
|
|
if ( row + count > featuresList->size() ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
beginRemoveRows( parent, row, row + count - 1 ); |
|
|
|
beginRemoveRows( parent, row, row + count - 1 ); |
|
|
|
//featuresList->remove( row, count );
|
|
|
|
//featuresList->remove( row, count );
|
|
|
|
featuresList->erase( featuresList->begin() + row, featuresList->begin() + row + count ); |
|
|
|
featuresList->erase( featuresList->begin() + row, featuresList->begin() + row + count ); |
|
|
|
endRemoveRows(); |
|
|
|
endRemoveRows(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) |
|
|
|
bool UBFeaturesModel::removeRow( int row, const QModelIndex & parent ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( row < 0 ) |
|
|
|
if ( row < 0 ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if ( row >= featuresList->size() ) |
|
|
|
if ( row >= featuresList->size() ) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
beginRemoveRows( parent, row, row ); |
|
|
|
beginRemoveRows( parent, row, row ); |
|
|
|
//featuresList->remove( row );
|
|
|
|
//featuresList->remove( row );
|
|
|
|
featuresList->erase( featuresList->begin() + row ); |
|
|
|
featuresList->erase( featuresList->begin() + row ); |
|
|
|
endRemoveRows(); |
|
|
|
endRemoveRows(); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destination |
|
|
|
void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destination |
|
|
@ -1343,9 +1342,9 @@ void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destina |
|
|
|
Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Qt::ItemFlags resultFlags = QAbstractItemModel::flags(index); |
|
|
|
Qt::ItemFlags resultFlags = QAbstractItemModel::flags(index); |
|
|
|
if ( index.isValid() ) |
|
|
|
if ( index.isValid() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
UBFeature item = index.data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
if ( item.getType() == FEATURE_INTERACTIVE |
|
|
|
if ( item.getType() == FEATURE_INTERACTIVE |
|
|
|
|| item.getType() == FEATURE_ITEM |
|
|
|
|| item.getType() == FEATURE_ITEM |
|
|
|
|| item.getType() == FEATURE_AUDIO |
|
|
|
|| item.getType() == FEATURE_AUDIO |
|
|
@ -1367,7 +1366,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
|
|
|
|
|
|
|
|
QStringList UBFeaturesModel::mimeTypes() const |
|
|
|
QStringList UBFeaturesModel::mimeTypes() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QStringList types; |
|
|
|
QStringList types; |
|
|
|
types << "text/uri-list" << "image/png" << "image/tiff" << "image/gif" << "image/jpeg"; |
|
|
|
types << "text/uri-list" << "image/png" << "image/tiff" << "image/gif" << "image/jpeg"; |
|
|
|
return types; |
|
|
|
return types; |
|
|
|
} |
|
|
|
} |
|
|
@ -1382,17 +1381,17 @@ int UBFeaturesModel::rowCount(const QModelIndex &parent) const |
|
|
|
|
|
|
|
|
|
|
|
bool UBFeaturesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
bool UBFeaturesProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
QString path = index.data( Qt::UserRole ).toString(); |
|
|
|
QString path = index.data( Qt::UserRole ).toString(); |
|
|
|
|
|
|
|
|
|
|
|
return filterRegExp().exactMatch(path); |
|
|
|
return filterRegExp().exactMatch(path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
/*QString name = sourceModel()->data(index, Qt::DisplayRole).toString();
|
|
|
|
/*QString name = sourceModel()->data(index, Qt::DisplayRole).toString();
|
|
|
|
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/ |
|
|
|
eUBLibElementType type = (eUBLibElementType)sourceModel()->data(index, Qt::UserRole + 1).toInt();*/ |
|
|
|
|
|
|
|
|
|
|
|
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
bool isFile = feature.getType() == FEATURE_INTERACTIVE |
|
|
|
bool isFile = feature.getType() == FEATURE_INTERACTIVE |
|
|
@ -1409,10 +1408,10 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn |
|
|
|
|
|
|
|
|
|
|
|
bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const |
|
|
|
{ |
|
|
|
{ |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); |
|
|
|
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
UBFeature feature = sourceModel()->data(index, Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
|
|
|
|
|
|
|
|
return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() ); |
|
|
|
return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const |
|
|
|
QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const |
|
|
@ -1421,18 +1420,18 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc |
|
|
|
|
|
|
|
|
|
|
|
QString text = value.toString(); |
|
|
|
QString text = value.toString(); |
|
|
|
text = text.replace(".wgt", ""); |
|
|
|
text = text.replace(".wgt", ""); |
|
|
|
if (listView) |
|
|
|
if (listView) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QFontMetrics fm = listView->fontMetrics(); |
|
|
|
const QFontMetrics fm = listView->fontMetrics(); |
|
|
|
const QSize iSize = listView->gridSize(); |
|
|
|
const QSize iSize = listView->gridSize(); |
|
|
|
return elidedText( fm, iSize.width(), Qt::ElideRight, text ); |
|
|
|
return elidedText( fm, iSize.width(), Qt::ElideRight, text ); |
|
|
|
} |
|
|
|
} |
|
|
|
return text; |
|
|
|
return text; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeaturesPathItemDelegate::UBFeaturesPathItemDelegate(QObject *parent) : QStyledItemDelegate(parent) |
|
|
|
UBFeaturesPathItemDelegate::UBFeaturesPathItemDelegate(QObject *parent) : QStyledItemDelegate(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
arrowPixmap = new QPixmap(":images/navig_arrow.png"); |
|
|
|
arrowPixmap = new QPixmap(":images/navig_arrow.png"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString UBFeaturesPathItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const |
|
|
|
QString UBFeaturesPathItemDelegate::displayText ( const QVariant & value, const QLocale & locale ) const |
|
|
@ -1445,20 +1444,20 @@ QString UBFeaturesPathItemDelegate::displayText ( const QVariant & value, const |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
|
|
void UBFeaturesPathItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
UBFeature feature = index.data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
UBFeature feature = index.data( Qt::UserRole + 1 ).value<UBFeature>(); |
|
|
|
QRect rect = option.rect; |
|
|
|
QRect rect = option.rect; |
|
|
|
if ( !feature.getFullPath().isEmpty() ) |
|
|
|
if ( !feature.getFullPath().isEmpty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
painter->drawPixmap( rect.left() - 10, rect.center().y() - 5, *arrowPixmap ); |
|
|
|
painter->drawPixmap( rect.left() - 10, rect.center().y() - 5, *arrowPixmap ); |
|
|
|
} |
|
|
|
} |
|
|
|
painter->drawImage( 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() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( arrowPixmap ) |
|
|
|
if ( arrowPixmap ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete arrowPixmap; |
|
|
|
delete arrowPixmap; |
|
|
|
arrowPixmap = NULL; |
|
|
|
arrowPixmap = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|