fixed deleting default widget

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent e130379b3e
commit 62a82e1daa
  1. 10
      src/board/UBFeaturesController.cpp
  2. 2
      src/board/UBFeaturesController.h
  3. 8
      src/gui/UBFeaturesActionBar.cpp

@ -40,6 +40,10 @@ bool UBFeature::isFolder() const
|| elementType == FEATURE_FOLDER; || elementType == FEATURE_FOLDER;
} }
bool UBFeature::isDeletable()const
{
return elementType == FEATURE_ITEM;
}
UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) : UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
QObject(pParentWidget), QObject(pParentWidget),
@ -281,6 +285,12 @@ QPixmap UBFeaturesController::thumbnailForFile(const QString &path)
return thumb; return thumb;
} }
bool UBFeaturesController::isDeletable( const QUrl &url )
{
UBFeatureElementType type = fileTypeFromUrl( fileNameFromUrl(url) );
return type == FEATURE_ITEM;
}
QPixmap UBFeaturesController::createThumbnail(const QString &path) QPixmap UBFeaturesController::createThumbnail(const QString &path)
{ {
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path); QString thumbnailPath = UBFileSystemUtils::thumbnailPath(path);

@ -37,6 +37,7 @@ public:
QString getVirtualPath() const { return virtualPath + "/" + mName; } QString getVirtualPath() const { return virtualPath + "/" + mName; }
UBFeatureElementType getType() const { return elementType; } UBFeatureElementType getType() const { return elementType; }
bool isFolder() const; bool isFolder() const;
bool isDeletable() const;
bool operator ==( const UBFeature &f )const; bool operator ==( const UBFeature &f )const;
bool operator !=( const UBFeature &f )const; bool operator !=( const UBFeature &f )const;
private: private:
@ -74,6 +75,7 @@ public:
static QString fileNameFromUrl( const QUrl &url ); static QString fileNameFromUrl( const QUrl &url );
static QPixmap thumbnailForFile( const QString &path ); static QPixmap thumbnailForFile( const QString &path );
static bool isDeletable( const QUrl &url );
private: private:
void initDirectoryTree(); void initDirectoryTree();
void fileSystemScan(const QString &currPath, const QString & currVirtualPath); void fileSystemScan(const QString &currPath, const QString & currVirtualPath);

@ -179,14 +179,22 @@ void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event ) void UBFeaturesActionBar::dragEnterEvent( QDragEnterEvent *event )
{ {
if (event->mimeData()->hasFormat("text/uri-list")) if (event->mimeData()->hasFormat("text/uri-list"))
{
event->acceptProposedAction(); event->acceptProposedAction();
} }
}
void UBFeaturesActionBar::dropEvent( QDropEvent *event ) void UBFeaturesActionBar::dropEvent( QDropEvent *event )
{ {
QWidget *dest = childAt( event->pos() ); QWidget *dest = childAt( event->pos() );
if ( dest == mpDeleteBtn ) if ( dest == mpDeleteBtn )
{ {
QList <QUrl> urls = event->mimeData()->urls();
foreach ( QUrl url, urls )
{
if ( !UBFeaturesController::isDeletable( url ) )
return;
}
event->setDropAction( Qt::MoveAction ); event->setDropAction( Qt::MoveAction );
event->accept(); event->accept();
emit deleteElements( *event->mimeData() ); emit deleteElements( *event->mimeData() );

Loading…
Cancel
Save