fixed issue with xwiki widgets

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent d4cb4b2b01
commit 3146be4c29
  1. 6
      resources/library/search/Image Planete.wgs/index.html
  2. 319
      src/gui/UBFeaturesWidget.cpp

@ -69,7 +69,7 @@
var iHeight = $("<input type='hidden'/>"); var iHeight = $("<input type='hidden'/>");
var iWidth = $("<input type='hidden'/>"); var iWidth = $("<input type='hidden'/>");
var iTitle = $("<input type='hidden'/>"); var iTitle = $("<input type='hidden'/>");
var iThumbnailUrl = $("<input type='hidden'/>");
// We use titleNoFormatting so that no HTML tags are left in the // We use titleNoFormatting so that no HTML tags are left in the
// title // title
//title.innerHTML = result.title; //title.innerHTML = result.title;
@ -96,12 +96,14 @@
iHeight.attr("value", result.height); iHeight.attr("value", result.height);
iWidth.attr("value", result.width); iWidth.attr("value", result.width);
iTitle.attr("value",result.title); iTitle.attr("value",result.title);
iThumbnailUrl.attr("value",newImg.src);
//imgContainer.append($(title)); //imgContainer.append($(title));
imgContainer.append(iUrl); imgContainer.append(iUrl);
imgContainer.append(iContent); imgContainer.append(iContent);
imgContainer.append(iHeight); imgContainer.append(iHeight);
imgContainer.append(iWidth); imgContainer.append(iWidth);
imgContainer.append(iTitle); imgContainer.append(iTitle);
imgContainer.append(iThumbnailUrl);
// Put our title + image in the content // Put our title + image in the content
imgContainer.appendTo(contentDiv); imgContainer.appendTo(contentDiv);
@ -252,6 +254,8 @@
parent.find("input:hidden").eq(3).val() + parent.find("input:hidden").eq(3).val() +
"</value></data><data><key>Title</key><value>" + "</value></data><data><key>Title</key><value>" +
parent.find("input:hidden").eq(4).val() + parent.find("input:hidden").eq(4).val() +
"</value></data><data><key>thumbnailUrl</key><value>" +
parent.find("input:hidden").eq(5).val() +
"</value></data></metadata>"; "</value></data></metadata>";
return meta; return meta;
} }

@ -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;
} case UBMimeType::RasterImage:
case UBMimeType::VectorImage:
previewImageUrl = widgetsUrl;
break;
}
} else if (!widgetsThumbsUrl.isNull()) { 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);
@ -270,10 +270,9 @@ void UBFeaturesWidget::onDisplayMetadata( QMap<QString,QString> metadata )
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(); QString tmp = QUrl::fromEncoded(metadata["Url"].toAscii()).toString();
qDebug() << tmp;
UBFeature feature( "/root", QImage(previewImageUrl), QString(), tmp/*metadata["Url"]*/, FEATURE_ITEM ); 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();
} }
@ -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;
@ -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;
} }
} }

Loading…
Cancel
Save