|
|
@ -56,6 +56,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale |
|
|
|
featuresListView->setViewMode( QListView::IconMode ); |
|
|
|
featuresListView->setViewMode( QListView::IconMode ); |
|
|
|
itemDelegate = new UBFeaturesItemDelegate( this, featuresListView ); |
|
|
|
itemDelegate = new UBFeaturesItemDelegate( this, featuresListView ); |
|
|
|
featuresListView->setItemDelegate( itemDelegate ); |
|
|
|
featuresListView->setItemDelegate( itemDelegate ); |
|
|
|
|
|
|
|
//featuresListView->setSelectionRectVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
featuresListView->setIconSize( QSize(defaultThumbnailSize, defaultThumbnailSize) ); |
|
|
|
featuresListView->setIconSize( QSize(defaultThumbnailSize, defaultThumbnailSize) ); |
|
|
|
featuresListView->setGridSize( QSize(defaultThumbnailSize * 1.75, defaultThumbnailSize * 1.75) ); |
|
|
|
featuresListView->setGridSize( QSize(defaultThumbnailSize * 1.75, defaultThumbnailSize * 1.75) ); |
|
|
@ -71,6 +72,9 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale |
|
|
|
pathListView->setSelectionMode( QAbstractItemView::NoSelection ); |
|
|
|
pathListView->setSelectionMode( QAbstractItemView::NoSelection ); |
|
|
|
pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|
|
|
pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); |
|
|
|
pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); |
|
|
|
pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); |
|
|
|
|
|
|
|
pathListView->setFlow( QListView::LeftToRight ); |
|
|
|
|
|
|
|
pathListView->setWrapping(false); |
|
|
|
|
|
|
|
|
|
|
|
//pathListView->setResizeMode( QListView::Adjust );
|
|
|
|
//pathListView->setResizeMode( QListView::Adjust );
|
|
|
|
//pathListView->setMovement( QListView::Static );
|
|
|
|
//pathListView->setMovement( QListView::Static );
|
|
|
|
pathListView->setDragDropMode( QAbstractItemView::DropOnly ); |
|
|
|
pathListView->setDragDropMode( QAbstractItemView::DropOnly ); |
|
|
@ -170,6 +174,10 @@ void UBFeaturesWidget::currentSelected(const QModelIndex ¤t) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mActionBar->setCurrentState( IN_FAVORITE ); |
|
|
|
mActionBar->setCurrentState( IN_FAVORITE ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (feature.getType() == FEATURE_TRASH) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mActionBar->setCurrentState( IN_TRASH ); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mActionBar->setCurrentState( IN_FOLDER ); |
|
|
|
mActionBar->setCurrentState( IN_FOLDER ); |
|
|
@ -208,6 +216,10 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
mActionBar->setCurrentState( IN_FAVORITE ); |
|
|
|
mActionBar->setCurrentState( IN_FAVORITE ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (feature.getType() == FEATURE_TRASH) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
mActionBar->setCurrentState( IN_TRASH ); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
mActionBar->setCurrentState( IN_FOLDER ); |
|
|
|
mActionBar->setCurrentState( IN_FOLDER ); |
|
|
@ -224,7 +236,6 @@ void UBFeaturesWidget::createNewFolder() |
|
|
|
featuresModel->addItem( newFolder ); |
|
|
|
featuresModel->addItem( newFolder ); |
|
|
|
featuresProxyModel->invalidate(); |
|
|
|
featuresProxyModel->invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) |
|
|
|
void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) |
|
|
@ -315,11 +326,39 @@ UBFeaturesWidget::~UBFeaturesWidget() |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name ) : QListView(parent) |
|
|
|
UBFeaturesListView::UBFeaturesListView( QWidget* parent, const char* name )
|
|
|
|
|
|
|
|
: QListView(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
setObjectName(name); |
|
|
|
setObjectName(name); |
|
|
|
|
|
|
|
//rubberBand = new UBRubberBand( QRubberBand::Rectangle, this );
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
void UBFeaturesListView::mousePressEvent( QMouseEvent *event ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rubberOrigin = event->pos(); |
|
|
|
|
|
|
|
rubberBand->setGeometry( QRect( rubberOrigin, QSize() ) ); |
|
|
|
|
|
|
|
//qDebug() << rubberOrigin.x() << rubberOrigin.y();
|
|
|
|
|
|
|
|
rubberBand->show(); |
|
|
|
|
|
|
|
QListView::mousePressEvent(event); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesListView::mouseMoveEvent( QMouseEvent *event ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QPoint current = event->pos(); |
|
|
|
|
|
|
|
rubberBand->setGeometry( QRect( rubberOrigin, current ).normalized() ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//setSelection( rubberBand->rect(), QItemSelectionModel::Select );
|
|
|
|
|
|
|
|
QListView::mouseMoveEvent(event); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
rubberBand->hide(); |
|
|
|
|
|
|
|
QListView::mouseReleaseEvent(event); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ( event->mimeData()->hasUrls() ) |
|
|
|
if ( event->mimeData()->hasUrls() ) |
|
|
@ -537,19 +576,15 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act |
|
|
|
|
|
|
|
|
|
|
|
int endRow = 0; |
|
|
|
int endRow = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBFeature parentFeature; |
|
|
|
if ( !parent.isValid() ) |
|
|
|
if ( !parent.isValid() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return false; |
|
|
|
parentFeature = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->getCurrentElement(); |
|
|
|
/*if (row < 0)
|
|
|
|
|
|
|
|
endRow = featuresList->size(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
endRow = qMin( row, featuresList->size() );*/ |
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else |
|
|
|
else |
|
|
|
endRow = parent.row(); |
|
|
|
{ |
|
|
|
Q_UNUSED(endRow) //why do we need this variable?
|
|
|
|
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
|
|
|
|
} |
|
|
|
UBFeature parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QUrl> urls = mimeData->urls(); |
|
|
|
QList<QUrl> urls = mimeData->urls(); |
|
|
|
|
|
|
|
|
|
|
@ -628,7 +663,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
return Qt::ItemIsDragEnabled | defaultFlags; |
|
|
|
return Qt::ItemIsDragEnabled | defaultFlags; |
|
|
|
if ( item.isFolder() && !item.getFullPath().isNull() ) |
|
|
|
if ( item.isFolder() && !item.getFullPath().isNull() ) |
|
|
|
return defaultFlags | Qt::ItemIsDropEnabled; |
|
|
|
return defaultFlags | Qt::ItemIsDropEnabled; |
|
|
|
else return defaultFlags; |
|
|
|
else return defaultFlags | Qt::ItemIsDropEnabled; |
|
|
|
} |
|
|
|
} |
|
|
|
/*if ( index.isValid() )
|
|
|
|
/*if ( index.isValid() )
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -647,7 +682,7 @@ Qt::ItemFlags UBFeaturesModel::flags( const QModelIndex &index ) const |
|
|
|
default:; |
|
|
|
default:; |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
}*/ |
|
|
|
return defaultFlags; |
|
|
|
return defaultFlags | Qt::ItemIsDropEnabled; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -710,13 +745,7 @@ QString UBFeaturesItemDelegate::displayText ( const QVariant & value, const QLoc |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QFontMetrics fm = listView->fontMetrics(); |
|
|
|
const QFontMetrics fm = listView->fontMetrics(); |
|
|
|
const QSize iSize = listView->iconSize(); |
|
|
|
const QSize iSize = listView->iconSize(); |
|
|
|
|
|
|
|
return elidedText( fm, iSize.width(), Qt::ElideRight, text ); |
|
|
|
if ( iSize.width() > 0 && fm.width(text) > iSize.width() ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
while (fm.width(text) > iSize.width()) |
|
|
|
|
|
|
|
text.resize(text.size()-1); |
|
|
|
|
|
|
|
text += "..."; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return text; |
|
|
|
return text; |
|
|
|
} |
|
|
|
} |
|
|
|