Search widget in right palette resolved

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 58bc81c05b
commit d4072aae09
  1. 51
      src/board/UBFeaturesController.cpp
  2. 2
      src/board/UBFeaturesController.h
  3. 167
      src/gui/UBFeaturesWidget.cpp
  4. 76
      src/gui/UBFeaturesWidget.h

@ -114,7 +114,7 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
applicationsElement = UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
shapesElement = UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath, FEATURE_CATEGORY );
favoriteElement = UBFeature( rootPath, QPixmap(":images/libpalette/FavoritesCategory.svg"), "Favorites", QUrl("favorites"), FEATURE_FAVORITE );
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_SEARCH);
webSearchElement = UBFeature( rootPath, QPixmap(":images/libpalette/WebSearchCategory.svg"), "Web search", mLibSearchDirectoryPath, FEATURE_CATEGORY);
trashElement = UBFeature( rootPath, QPixmap(":images/libpalette/TrashCategory.svg"), "Trash", trashDirectoryPath, FEATURE_TRASH );
@ -171,18 +171,25 @@ void UBFeaturesController::scanFS()
}
}
fileSystemScan(mUserInteractiveDirectoryPath, appPath);
fileSystemScan(mUserAudioDirectoryPath, audiosPath);
fileSystemScan(mUserPicturesDirectoryPath, picturesPath);
fileSystemScan(mUserVideoDirectoryPath, moviesPath);
fileSystemScan(mUserAnimationDirectoryPath, flashPath);
//Claudio:
// don't change the order of the scans
fileSystemScan( mLibAudiosDirectoryPath, audiosPath);
fileSystemScan( mLibVideosDirectoryPath, moviesPath);
fileSystemScan( mLibAnimationsDirectoryPath, flashPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath );
fileSystemScan( mUserPicturesDirectoryPath, picturesPath );
fileSystemScan( mUserVideoDirectoryPath, moviesPath );
fileSystemScan( mUserAnimationDirectoryPath, flashPath );
fileSystemScan( mLibApplicationsDirectoryPath, appPath );
fileSystemScan( mLibShapesDirectoryPath, shapesPath );
fileSystemScan( mLibInteractiveDirectoryPath, interactPath );
fileSystemScan( trashDirectoryPath, trashPath );
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search" );
fileSystemScan(mLibApplicationsDirectoryPath, appPath);
fileSystemScan( mLibPicturesDirectoryPath, picturesPath);
fileSystemScan( mLibShapesDirectoryPath, shapesPath);
fileSystemScan( mLibInteractiveDirectoryPath, interactPath);
fileSystemScan( trashDirectoryPath, trashPath);
fileSystemScan( mLibSearchDirectoryPath, rootPath + "/" + "Web search");
}
void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QString & currVirtualPath)
@ -464,23 +471,29 @@ UBFeature UBFeaturesController::getParentFeatureForUrl( const QUrl &url )
return UBFeature();
}
UBFeature UBFeaturesController::addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData )
void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteArray &pData)
{
UBFeature dest = getParentFeatureForUrl( sourceUrl );
if ( dest == UBFeature() )
return UBFeature();
return;
QString fileName = QFileInfo( sourceUrl.toString() ).fileName();
QString filePath = dest.getFullPath().toLocalFile() + "/" + fileName;
QFile file( filePath );
if( file.open(QIODevice::WriteOnly ))
if ( file.open(QIODevice::WriteOnly ))
{
file.write(pData);
file.close();
return UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM );
UBFeature downloadedFeature = UBFeature( dest.getFullVirtualPath(), thumbnailForFile( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM);
if (downloadedFeature != UBFeature()) {
featuresModel->addItem(downloadedFeature);
}
}
return UBFeature();
}
UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeature &destination )
@ -523,7 +536,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
void UBFeaturesController::rescanModel()
{
featuresModel->removeRows(0, featuresList->count() - 1);
featuresModel->removeRows(0, featuresList->count());
//Could implement infolder scanning for better perfomance
scanFS();

@ -101,7 +101,7 @@ public:
void setCurrentElement( const UBFeature &elem ) {currentElement = elem;}
const UBFeature & getTrashElement () const { return trashElement; }
UBFeature addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData );
void addDownloadedFile( const QUrl &sourceUrl, const QByteArray &pData );
UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination );
UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination );

@ -69,8 +69,8 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
mActionBar = new UBFeaturesActionBar(controller, this);
//Filling main layout
layout->addWidget( pathListView );
layout->addWidget( stackedWidget );
layout->addWidget(pathListView);
layout->addWidget(stackedWidget);
layout->addWidget(mActionBar);
connect(mNavigator->listView(), SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
@ -83,120 +83,11 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect(mActionBar, SIGNAL(addElementsToFavorite() ), this, SLOT ( addElementsToFavorite()) );
connect(mActionBar, SIGNAL(removeElementsFromFavorite()), this, SLOT (removeElementsFromFavorite()));
connect( mActionBar, SIGNAL(rescanModel()), this, SLOT(rescanModel()));
connect(mActionBar, SIGNAL(rescanModel()), this, SLOT(rescanModel()));
connect(pathListView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(currentSelected(const QModelIndex &)));
connect( UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>)));
connect( UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray)), this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray)));
//=======
// stackedWidget = new QStackedWidget(this);
// layout = new QVBoxLayout(this);
// controller = new UBFeaturesController(this);
// featuresModel = new UBFeaturesModel(this);
// featuresModel->setFeaturesList( controller->getFeatures() );
// featuresModel->setSupportedDragActions( Qt::CopyAction | Qt::MoveAction );
// featuresListView = new UBFeaturesListView(this);
// pathListView = new UBFeaturesListView(this);
// featuresProxyModel = new UBFeaturesProxyModel(this);
// featuresProxyModel->setFilterFixedString( controller->getRootPath() );
// featuresProxyModel->setSourceModel( featuresModel );
// featuresProxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
// featuresSearchModel = new UBFeaturesSearchProxyModel(this);
// featuresSearchModel->setSourceModel( featuresModel );
// featuresSearchModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
// featuresPathModel = new UBFeaturesPathProxyModel(this);
// featuresPathModel->setPath( controller->getRootPath() );
// featuresPathModel->setSourceModel( featuresModel );
// //featuresListView->setStyleSheet( QString("background: #EEEEEE;border-radius: 10px;border: 2px solid #999999;") );
// featuresListView->setDragDropMode( QAbstractItemView::DragDrop );
// featuresListView->setSelectionMode( QAbstractItemView::ContiguousSelection );
// featuresListView->setModel( featuresProxyModel );
// featuresListView->setResizeMode( QListView::Adjust );
// featuresListView->setViewMode( QListView::IconMode );
// itemDelegate = new UBFeaturesItemDelegate( this, featuresListView );
// featuresListView->setItemDelegate( itemDelegate );
// //featuresListView->setSelectionRectVisible(false);
// featuresListView->setIconSize( QSize(currentIconSize, currentIconSize) );
// featuresListView->setGridSize( QSize(currentIconSize * 1.75, currentIconSize * 1.75) );
// //pathListView->setStyleSheet( QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;") );
// pathListView->setModel( featuresPathModel );
// pathListView->setViewMode( QListView::IconMode );
// pathListView->setIconSize( QSize(defaultThumbnailSize - 10, defaultThumbnailSize - 10) );
// pathListView->setGridSize( QSize(defaultThumbnailSize + 10, defaultThumbnailSize - 10) );
// pathListView->setFixedHeight( 60 );
// pathItemDelegate = new UBFeaturesPathItemDelegate( this );
// pathListView->setItemDelegate( pathItemDelegate );
// pathListView->setSelectionMode( QAbstractItemView::NoSelection );
// pathListView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
// pathListView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
// pathListView->setFlow( QListView::LeftToRight );
// pathListView->setWrapping(false);
// //pathListView->setResizeMode( QListView::Adjust );
// //pathListView->setMovement( QListView::Static );
// pathListView->setDragDropMode( QAbstractItemView::DropOnly );
// //pathViewer = new UBFeaturesPathViewer( QPixmap(":images/libpalette/home.png"), controller->getRootPath(), pathScene, this );
// featureProperties = new UBFeatureProperties(this);
// webView = new UBFeaturesWebView(this);
// //layout->addWidget( pathViewer );
// //pathViewer->show();
// //layout->addWidget( featuresListView );
// layout->addWidget( pathListView );
// layout->addWidget( stackedWidget );
// stackedWidget->addWidget( featuresListView );
// stackedWidget->addWidget( featureProperties );
// stackedWidget->addWidget( webView );
// stackedWidget->setCurrentIndex(ID_LISTVIEW);
// currentStackedWidget = ID_LISTVIEW;
// mActionBar = new UBFeaturesActionBar(controller, this);
// thumbSlider = new QSlider( Qt::Horizontal, featuresListView );
// thumbSlider->setMinimum( minThumbnailSize );
// thumbSlider->setMaximum( maxThumbnailSize );
// thumbSlider->setValue(currentIconSize);
// //qDebug() << "init" << featuresListView->height();
// thumbSlider->move( 0, featuresListView->height() );
// thumbSlider->resize( thumbSlider->width(), thumbSlider->height() + 4 );
// thumbSlider->show();
// featuresListView->installEventFilter(this);
// //layout->addWidget( thumbSlider );
// layout->addWidget( mActionBar );
// /*connect(featuresListView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex &, const QModelIndex & )),
// this, SLOT(currentSelected(const QModelIndex &)));*/
// connect( featuresListView, SIGNAL(clicked ( const QModelIndex & ) ),
// this, SLOT( currentSelected(const QModelIndex &) ) );
// connect( mActionBar, SIGNAL( searchElement(const QString &) ), this, SLOT( searchStarted(const QString &) ) );
// connect( mActionBar, SIGNAL( newFolderToCreate() ), this, SLOT( createNewFolder() ) );
// 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( removeFromFavorite(const QMimeData &) ), this, SLOT( removeFromFavorite(const QMimeData &) ) );
// connect( mActionBar, SIGNAL( addElementsToFavorite() ), this, SLOT ( addElementsToFavorite() ) );
// connect( mActionBar, SIGNAL( removeElementsFromFavorite() ), this, SLOT ( removeElementsFromFavorite() ) );
// connect( mActionBar, SIGNAL( deleteSelectedElements() ), this, SLOT( deleteSelectedElements() ) );
// connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
// this, SLOT( currentPathChanged( const QModelIndex & ) ) );
// //connect( thumbSlider, SIGNAL( sliderMoved(int) ), this, SLOT(thumbnailSizeChanged( int ) ) );
// connect(thumbSlider, SIGNAL(valueChanged(int)), this, SLOT(thumbnailSizeChanged(int)));
// connect( UBApplication::boardController, SIGNAL( displayMetadata( QMap<QString,QString> ) ),
// this, SLOT( onDisplayMetadata( QMap<QString,QString> ) ) );
// connect( UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray ) ),
// this, SLOT( onAddDownloadedFileToLibrary( bool, QUrl, QString,QByteArray ) ) );
//>>>>>>> e38b24544e8b8b1d5bd41dabdeaf588df7d45185
connect(UBApplication::boardController, SIGNAL(displayMetadata(QMap<QString,QString>)), this, SLOT(onDisplayMetadata( QMap<QString,QString>)));
connect(UBDownloadManager::downloadManager(), SIGNAL( addDownloadedFileToLibrary( bool, QUrl, QString, QByteArray))
, this, SLOT(onAddDownloadedFileToLibrary(bool, QUrl, QString,QByteArray)));
}
UBFeaturesWidget::~UBFeaturesWidget()
@ -402,15 +293,9 @@ void UBFeaturesWidget::onAddDownloadedFileToLibrary(bool pSuccess, QUrl sourceUr
{
Q_UNUSED(pContentHeader)
if ( pSuccess )
{
UBFeature newFeature = controller->addDownloadedFile( sourceUrl, pData );
if ( newFeature != UBFeature() )
{
featuresModel->addItem( newFeature );
QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( mNavigator->listView()->model() );
model->invalidate();
}
if (pSuccess) {
controller->addDownloadedFile(sourceUrl, pData);
controller->refreshModels();
}
}
@ -467,34 +352,6 @@ void UBFeaturesWidget::switchToWebView()
currentStackedWidget = ID_WEBVIEW;
}
void UBFeaturesWidget::updateSliderPosition()
{
// //Calculating the topleft position of the slider
// int scrollBarVOffset = featuresListView->horizontalScrollBar()->isVisible() ? featuresListView->horizontalScrollBar()->height() : 0;
// int xSlider = scrollbarHorisontalPadding();
// int ySlider = featuresListView->height() - (thumbSlider->height() + scrollbarVerticalIndent() + scrollBarVOffset);
// thumbSlider->move( xSlider, ySlider);
// //Calculating new slider's size
// int scrollBarHOffset = featuresListView->verticalScrollBar()->isVisible() ? featuresListView->verticalScrollBar()->width() : 0;
// int wSlider = featuresListView->width() - 2 * scrollbarHorisontalPadding() - scrollBarHOffset;
// int hSlider = thumbSlider->height();
// thumbSlider->resize(wSlider, hSlider);
}
/*
void UBFeaturesWidget::currentPathChanged(const QString &path)
{
int newDepth = path.count("/");
pathViewer->truncatePath(newDepth);
featuresListView->setModel( featuresProxyModel );
featuresProxyModel->setFilterFixedString(path);
featuresProxyModel->invalidate();
switchToListView();
}
*/
QStringList UBFeaturesMimeData::formats() const
{
return QMimeData::formats();
@ -945,7 +802,6 @@ UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPus
UBFeatureItemButton::~UBFeatureItemButton()
{
}
QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
@ -1248,10 +1104,7 @@ bool UBFeaturesSearchProxyModel::filterAcceptsRow( int sourceRow, const QModelIn
bool UBFeaturesPathProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent )const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
/*QString name = sourceModel()->data(index, Qt::DisplayRole).toString();
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>();
return feature.isFolder() && path.startsWith( feature.getFullVirtualPath() );
}

@ -60,7 +60,6 @@ public:
static const int minThumbnailSize = 20;
static const int maxThumbnailSize = 100;
static const int defaultThumbnailSize = 40;
//<<<<<<< HEAD
public:
int scrollbarHorisontalPadding() const { return 10;}
@ -75,90 +74,27 @@ private slots:
void addToFavorite( const UBFeaturesMimeData *);
void removeFromFavorite( const UBFeaturesMimeData * );
void onDisplayMetadata( QMap<QString,QString> );
//=======
//private:
// void switchToListView();
// void switchToProperties();
// void switchToWebView();
// UBFeaturesController *controller;
// UBFeaturesItemDelegate *itemDelegate;
// UBFeaturesPathItemDelegate *pathItemDelegate;
// UBFeaturesModel *featuresModel;
// UBFeaturesProxyModel *featuresProxyModel;
// UBFeaturesSearchProxyModel *featuresSearchModel;
// UBFeaturesPathProxyModel *featuresPathModel;
// UBFeaturesListView *featuresListView;
// UBFeaturesListView *pathListView;
// QSlider *thumbSlider;
// QVBoxLayout *layout;
// //UBFeaturesPathViewer *pathViewer;
// //QGraphicsScene *pathScene;
// UBFeaturesActionBar *mActionBar;
// UBFeatureProperties *featureProperties;
// UBFeaturesWebView *webView;
// QStackedWidget *stackedWidget;
// int currentStackedWidget;
// UBDownloadHttpFile* imageGatherer;
//private slots:
//
// void currentSelected( const QModelIndex & );
// //void currentPathChanged(const QString &);
// void currentPathChanged( const QModelIndex & );
// void searchStarted( const QString & );
// void createNewFolder();
// void deleteElements( const QMimeData & );
// void addToFavorite( const QMimeData & );
// void removeFromFavorite( const QMimeData & );
// void thumbnailSizeChanged( int );
// void onDisplayMetadata( QMap<QString,QString> );
//>>>>>>> e38b24544e8b8b1d5bd41dabdeaf588df7d45185
void onAddDownloadedFileToLibrary(bool, QUrl, QString, QByteArray);
void addElementsToFavorite();
void removeElementsFromFavorite();
void deleteSelectedElements();
//<<<<<<< HEAD
void rescanModel();
private:
void switchToListView();
void switchToProperties();
void switchToWebView();
void updateSliderPosition();
private:
UBFeaturesController *controller;
UBFeaturesItemDelegate *itemDelegate;
UBFeaturesPathItemDelegate *pathItemDelegate;
UBFeaturesModel *featuresModel;
UBFeaturesProxyModel *featuresProxyModel;
UBFeaturesSearchProxyModel *featuresSearchModel;
UBFeaturesPathProxyModel *featuresPathModel;
UBFeaturesNavigatorWidget *mNavigator;
UBFeaturesListView *pathListView;
QVBoxLayout *layout;
UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
UBFeaturesWebView *webView;
QStackedWidget *stackedWidget;
int currentStackedWidget;
UBDownloadHttpFile* imageGatherer;
};
@ -175,11 +111,6 @@ public:
private:
QList<UBFeature> mFeatures;
//=======
//protected:
// bool eventFilter(QObject *target, QEvent *event);
//>>>>>>> e38b24544e8b8b1d5bd41dabdeaf588df7d45185
};
@ -195,16 +126,9 @@ protected:
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event );
virtual void dragMoveEvent( QDragMoveEvent *event );
/*virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseMoveEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );*/
private slots:
void thumbnailSizeChanged(int);
private:
//UBRubberBand *rubberBand;
//QPoint rubberOrigin;
};

Loading…
Cancel
Save