Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Aleksei Kanash 13 years ago
commit 81a2a555c9
  1. 55
      src/board/UBFeaturesController.cpp
  2. 1
      src/board/UBFeaturesController.h
  3. 9
      src/gui/UBFeaturesActionBar.cpp
  4. 2
      src/gui/UBFeaturesActionBar.h
  5. 40
      src/gui/UBFeaturesWidget.cpp
  6. 2
      src/gui/UBFeaturesWidget.h

@ -345,6 +345,27 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
return QPixmap(thumbnailPath); return QPixmap(thumbnailPath);
} }
UBFeature UBFeaturesController::importImage( const QImage &image, const UBFeature &destination )
{
QDateTime now = QDateTime::currentDateTime();
QString fileName = tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss") + ".png";
UBFeature dest = destination;
if ( !destination.getFullVirtualPath().startsWith( picturesElement.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = picturesElement;
}
QString filePath = dest.getFullPath().toLocalFile() + "/" + fileName;
image.save(filePath);
QPixmap thumb = createThumbnail( filePath );
return UBFeature( dest.getFullVirtualPath(), thumb, fileName,
QUrl::fromLocalFile( filePath ), FEATURE_ITEM );
}
UBFeature UBFeaturesController::newFolder( const QString &name ) UBFeature UBFeaturesController::newFolder( const QString &name )
{ {
QString path = currentElement.getFullPath().toLocalFile() + "/" + name; QString path = currentElement.getFullPath().toLocalFile() + "/" + name;
@ -408,8 +429,39 @@ UBFeature UBFeaturesController::addDownloadedFile( const QUrl &sourceUrl, const
UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination ) UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination )
{ {
UBFeature newElement = copyItemToFolder( url, destination ); /*UBFeature newElement = copyItemToFolder( url, destination );
deleteItem( url ); deleteItem( url );
return newElement;*/
QString sourcePath = url.toLocalFile();
Q_ASSERT( QFileInfo( sourcePath ).exists() );
UBFeature possibleDest = getDestinationForItem( url );
UBFeature dest = destination;
if ( destination != trashElement &&
!destination.getFullVirtualPath().startsWith( possibleDest.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = possibleDest;
}
QString name = QFileInfo( sourcePath ).fileName();
QString destPath = dest.getFullPath().toLocalFile();
QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name;
if ( sourcePath.compare( newFullPath, Qt::CaseInsensitive ) )
{
QFile( sourcePath ).copy( newFullPath );
deleteItem( url );
}
QPixmap thumb = thumbnailForFile( newFullPath );
UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE;
UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement; return newElement;
} }
@ -433,6 +485,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
QString destPath = dest.getFullPath().toLocalFile(); QString destPath = dest.getFullPath().toLocalFile();
QString destVirtualPath = dest.getFullVirtualPath(); QString destVirtualPath = dest.getFullVirtualPath();
QString newFullPath = destPath + "/" + name; QString newFullPath = destPath + "/" + name;
if ( !sourcePath.compare( newFullPath, Qt::CaseInsensitive ) )
QFile( sourcePath ).copy( newFullPath ); QFile( sourcePath ).copy( newFullPath );
QPixmap thumb = thumbnailForFile( newFullPath ); QPixmap thumb = thumbnailForFile( newFullPath );

@ -86,6 +86,7 @@ public:
UBFeature newFolder( const QString &name ); UBFeature newFolder( const QString &name );
UBFeature addToFavorite( const QUrl &path ); UBFeature addToFavorite( const QUrl &path );
void removeFromFavorite( const QUrl &path ); void removeFromFavorite( const QUrl &path );
UBFeature importImage( const QImage &image, const UBFeature &destination );
static QString fileNameFromUrl( const QUrl &url ); static QString fileNameFromUrl( const QUrl &url );
static QPixmap thumbnailForFile( const QString &path ); static QPixmap thumbnailForFile( const QString &path );

@ -66,8 +66,8 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mButtonGroup->addButton(mpRemoveFavoriteBtn); mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn); mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots // Connect signals & slots
/*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite())); connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial())); /*connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch())); connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash())); connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose())); connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
@ -170,6 +170,11 @@ void UBFeaturesActionBar::onActionNewFolder()
emit newFolderToCreate(); emit newFolderToCreate();
} }
void UBFeaturesActionBar::onActionFavorite()
{
emit addElementsToFavorite();
}
/* /*
void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event) void UBFeaturesActionBar::dragMoveEvent(QDragMoveEvent *event)
{ {

@ -30,9 +30,11 @@ signals:
void deleteElements( const QMimeData &data ); void deleteElements( const QMimeData &data );
void addToFavorite( const QMimeData &data ); void addToFavorite( const QMimeData &data );
void removeFromFavorite( const QMimeData &data ); void removeFromFavorite( const QMimeData &data );
void addElementsToFavorite();
private slots: private slots:
void onSearchTextChanged(QString txt); void onSearchTextChanged(QString txt);
void onActionNewFolder(); void onActionNewFolder();
void onActionFavorite();
protected: protected:
//void dragMoveEvent(QDragMoveEvent *event); //void dragMoveEvent(QDragMoveEvent *event);
void dragEnterEvent( QDragEnterEvent *event ); void dragEnterEvent( QDragEnterEvent *event );

@ -121,6 +121,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) ); connect( mActionBar, SIGNAL( deleteElements(const QMimeData &) ), this, SLOT( deleteElements(const QMimeData &) ) );
connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( addToFavorite(const QMimeData &) ), this, SLOT( addToFavorite(const QMimeData &) ) );
connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) ); connect( mActionBar, SIGNAL( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
connect ( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ), connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) ); this, SLOT( currentPathChanged( const QModelIndex & ) ) );
connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) ); connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
@ -333,6 +334,20 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
} }
} }
void UBFeaturesWidget::addElementsToFavorite()
{
QModelIndexList selected = featuresListView->selectionModel()->selectedIndexes();
for ( int i = 0; i < selected.size(); ++i )
{
UBFeature feature = selected.at(i).data( Qt::UserRole + 1 ).value<UBFeature>();
UBFeature elem = controller->addToFavorite( feature.getFullPath() );
if ( !elem.getVirtualPath().isEmpty() && !elem.getVirtualPath().isNull() )
featuresModel->addItem( elem );
}
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() );
model->invalidate();
}
void UBFeaturesWidget::switchToListView() void UBFeaturesWidget::switchToListView()
{ {
stackedWidget->setCurrentIndex(ID_LISTVIEW); stackedWidget->setCurrentIndex(ID_LISTVIEW);
@ -404,13 +419,19 @@ void UBFeaturesListView::mouseReleaseEvent( QMouseEvent *event )
*/ */
void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event ) void UBFeaturesListView::dragEnterEvent( QDragEnterEvent *event )
{ {
if ( event->mimeData()->hasUrls() ) if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() )
event->acceptProposedAction();
}
void UBFeaturesListView::dragMoveEvent( QDragMoveEvent *event )
{
if ( event->mimeData()->hasUrls() || event->mimeData()->hasImage() )
event->acceptProposedAction(); event->acceptProposedAction();
} }
void UBFeaturesListView::dropEvent( QDropEvent *event ) void UBFeaturesListView::dropEvent( QDropEvent *event )
{ {
if( event->source() || dynamic_cast<UBFeaturesListView *>( event->source() ) ) if( event->source() && dynamic_cast<UBFeaturesListView *>( event->source() ) )
{ {
event->setDropAction( Qt::MoveAction ); event->setDropAction( Qt::MoveAction );
} }
@ -775,7 +796,7 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
{ {
Q_UNUSED(row) Q_UNUSED(row)
if ( !mimeData->hasUrls() ) if ( !mimeData->hasUrls() && !mimeData->hasImage() )
return false; return false;
if ( action == Qt::IgnoreAction ) if ( action == Qt::IgnoreAction )
return true; return true;
@ -794,6 +815,8 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>(); parentFeature = parent.data( Qt::UserRole + 1).value<UBFeature>();
} }
if ( mimeData->hasUrls() )
{
QList<QUrl> urls = mimeData->urls(); QList<QUrl> urls = mimeData->urls();
foreach ( QUrl url, urls ) foreach ( QUrl url, urls )
@ -810,13 +833,20 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
} }
addItem( element ); addItem( element );
} }
}
else if ( mimeData->hasImage() )
{
QImage image = qvariant_cast<QImage>( mimeData->imageData() );
UBFeature element = dynamic_cast<UBFeaturesWidget *>(QObject::parent())->getFeaturesController()->importImage( image, parentFeature );
addItem( element );
}
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->push_back( item ); featuresList->append( item );
endInsertRows(); endInsertRows();
} }
@ -897,7 +927,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"; types << "text/uri-list" << "image/png" << "image/tiff" << "image/gif" << "image/jpeg";
return types; return types;
} }

@ -101,6 +101,7 @@ private slots:
void thumbnailSizeChanged( int ); void thumbnailSizeChanged( int );
void onDisplayMetadata( QMap<QString,QString> ); void onDisplayMetadata( QMap<QString,QString> );
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray); void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite();
protected: protected:
bool eventFilter(QObject *target, QEvent *event); bool eventFilter(QObject *target, QEvent *event);
}; };
@ -114,6 +115,7 @@ public:
protected: protected:
virtual void dragEnterEvent( QDragEnterEvent *event ); virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event ); virtual void dropEvent( QDropEvent *event );
virtual void dragMoveEvent( QDragMoveEvent *event );
/*virtual void mousePressEvent( QMouseEvent *event ); /*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event ); virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/ virtual void mouseReleaseEvent( QMouseEvent *event );*/

Loading…
Cancel
Save