Implemented new folder creating

preferencesAboutTextFull
Anna Udovichenko 13 years ago
parent b7ceb4d3d5
commit addc1fe130
  1. 31
      src/board/UBFeaturesController.cpp
  2. 5
      src/board/UBFeaturesController.h
  3. 143
      src/gui/UBFeaturesActionBar.cpp
  4. 45
      src/gui/UBFeaturesActionBar.h
  5. 51
      src/gui/UBFeaturesWidget.cpp
  6. 18
      src/gui/UBFeaturesWidget.h

@ -60,7 +60,8 @@ void UBFeaturesController::initDirectoryTree()
QList <UBToolsManager::UBToolDescriptor> tools = UBToolsManager::manager()->allTools();
featuresList->push_back( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) );
featuresList->append( UBFeature( QString(), QPixmap( ":images/libpalette/home.png" ), "root", QString() ) );
currentElement = featuresList->at(0);
appPath = rootPath + "/Applications";
audiosPath = rootPath + "/Audios";
@ -70,17 +71,17 @@ void UBFeaturesController::initDirectoryTree()
interactPath = rootPath + "/Interactivities";
shapesPath = rootPath + "/Shapes";
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ) );
featuresList->push_back( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/AudiosCategory.svg"), "Audios" , mUserAudioDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/MoviesCategory.svg"), "Movies" , mUserVideoDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/PicturesCategory.svg"), "Pictures" , mUserPicturesDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ApplicationsCategory.svg"), "Applications" , mUserInteractiveDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/FlashCategory.svg"), "Animations" , mUserAnimationDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/InteractivesCategory.svg"), "Interactivities" , mLibInteractiveDirectoryPath ) );
featuresList->append( UBFeature( rootPath, QPixmap(":images/libpalette/ShapesCategory.svg"), "Shapes" , mLibShapesDirectoryPath ) );
foreach (UBToolsManager::UBToolDescriptor tool, tools)
{
featuresList->push_back( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) );
featuresList->append( UBFeature( appPath, tool.icon, tool.label, tool.id, FEATURE_INTERNAL ) );
}
fileSystemScan( mUserInteractiveDirectoryPath, appPath );
fileSystemScan( mUserAudioDirectoryPath, audiosPath );
@ -131,7 +132,7 @@ void UBFeaturesController::fileSystemScan(const QString & currentPath, const QSt
icon = QPixmap( thumbnailPath );
else icon = createThumbnail( fullFileName );*/
}
featuresList->push_back( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) );
featuresList->append( UBFeature( currVirtualPath, icon, fileName, fullFileName, fileType ) );
if ( fileType == FEATURE_FOLDER )
{
@ -187,6 +188,16 @@ QPixmap UBFeaturesController::createThumbnail(const QString &path)
return QPixmap(thumbnailPath);
}
UBFeature UBFeaturesController::newFolder( const QString &name )
{
QString path = currentElement.getFullPath() + "/" + name;
if(!QFileInfo(path).exists())
{
QDir().mkpath(path);
}
return UBFeature( currentElement.getUrl() + "/" + currentElement.getName(), QPixmap(":images/libpalette/folder.svg"), name, path, FEATURE_FOLDER );
}
void UBFeaturesController::addItemToPage(const UBFeature &item)
{
UBApplication::boardController->downloadURL( QUrl::fromLocalFile( item.getFullPath() ) );

@ -55,9 +55,13 @@ public:
QString getRootPath()const { return rootPath; }
void addItemToPage(const UBFeature &item);
UBFeature getCurrentElement()const { return currentElement; }
void setCurrentElement( const UBFeature &elem ) { currentElement = elem; }
static QPixmap thumbnailForFile( const QString &path );
static UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination );
static UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination );
UBFeature newFolder( const QString &name );
private:
void initDirectoryTree();
void fileSystemScan(const QString &currPath, const QString & currVirtualPath);
@ -92,6 +96,7 @@ private:
QString interactPath;
int mLastItemOffsetIndex;
UBFeature currentElement;
};

@ -1,9 +1,150 @@
#include "UBFeaturesActionBar.h"
UBFeaturesActionBar::UBFeaturesActionBar( QWidget* parent, const char* name ) : QWidget (parent)
UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWidget* parent, const char* name ) : QWidget (parent)
, featuresController(controller)
, mButtonGroup(NULL)
, mSearchBar(NULL)
, mLayout(NULL)
, mpFavoriteAction(NULL)
, mpSocialAction(NULL)
, mpDeleteAction(NULL)
, mpSearchAction(NULL)
, mpCloseAction(NULL)
, mpRemoveFavorite(NULL)
, mpNewFolderAction(NULL)
, mpFavoriteBtn(NULL)
, mpSocialBtn(NULL)
, mpDeleteBtn(NULL)
, mpCloseBtn(NULL)
, mpRemoveFavoriteBtn(NULL)
, mpNewFolderBtn(NULL)
{
setObjectName(name);
setStyleSheet(QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;"));
setAcceptDrops(true);
mButtonGroup = new QButtonGroup(this);
mSearchBar = new QLineEdit(this);
mSearchBar->setStyleSheet(QString("background-color:white; border-radius : 10px; padding : 2px;"));
//connect(mSearchBar, SIGNAL(returnPressed()), this, SLOT(onActionSearch()));
mLayout = new QHBoxLayout();
setLayout(mLayout);
setMaximumHeight(ACTIONBAR_HEIGHT);
// Create the actions
mpFavoriteAction = new QAction(QIcon(":/images/libpalette/miniFavorite.png"), tr("Add to favorites"), this);
mpSocialAction = new QAction(QIcon(":/images/libpalette/social.png"), tr("Share"), this);
mpSearchAction = new QAction(QIcon(":/images/libpalette/miniSearch.png"), tr("Search"), this);
mpDeleteAction = new QAction(QIcon(":/images/libpalette/miniTrash.png"), tr("Delete"), this);
mpCloseAction = new QAction(QIcon(":/images/close.svg"), tr("Back to folder"), this);
mpRemoveFavorite = new QAction(QIcon(":/images/libpalette/trash_favorite.svg"), tr("Remove from favorites"), this);
mpNewFolderAction = new QAction(QIcon(":/images/libpalette/miniNewFolder.png"), tr("Create new folder"), this);
// Create the buttons
mpFavoriteBtn = new UBActionButton(this, mpFavoriteAction);
mpSocialBtn = new UBActionButton(this, mpSocialAction);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction);
mpRemoveFavoriteBtn = new UBActionButton(this, mpRemoveFavorite);
mpNewFolderBtn = new UBActionButton(this, mpNewFolderAction);
// Initialize the buttons
//mpSearchBtn->setEnabled(false);
mpNewFolderBtn->setEnabled(false);
// Add the buttons to the button group
mButtonGroup->addButton(mpFavoriteBtn);
mButtonGroup->addButton(mpSocialBtn);
//mButtonGroup->addButton(mpSearchBtn);
mButtonGroup->addButton(mpDeleteBtn);
mButtonGroup->addButton(mpCloseBtn);
mButtonGroup->addButton(mpRemoveFavoriteBtn);
mButtonGroup->addButton(mpNewFolderBtn);
// Connect signals & slots
/*connect(mpFavoriteAction,SIGNAL(triggered()), this, SLOT(onActionFavorite()));
connect(mpSocialAction,SIGNAL(triggered()), this, SLOT(onActionSocial()));
connect(mpSearchAction,SIGNAL(triggered()), this, SLOT(onActionSearch()));
connect(mpDeleteAction,SIGNAL(triggered()), this, SLOT(onActionTrash()));
connect(mpCloseAction, SIGNAL(triggered()), this, SLOT(onActionClose()));
connect(mpRemoveFavorite, SIGNAL(triggered()), this, SLOT(onActionRemoveFavorite()));
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));*/
connect(mSearchBar, SIGNAL(textChanged(QString)), this, SLOT(onSearchTextChanged(QString)));
connect(mpNewFolderAction, SIGNAL(triggered()), this, SLOT(onActionNewFolder()));
// Build the default toolbar
mLayout->addWidget(mpFavoriteBtn);
mLayout->addWidget(mpSocialBtn);
mLayout->addWidget(mpNewFolderBtn);
mLayout->addWidget(mSearchBar);
//mLayout->addWidget(mpSearchBtn);
mLayout->addWidget(mpDeleteBtn);
mLayout->addWidget(mpCloseBtn);
mLayout->addWidget(mpRemoveFavoriteBtn);
setCurrentState( IN_ROOT );
}
void UBFeaturesActionBar::setCurrentState( UBFeaturesActionBarState state )
{
currentState = state;
setButtons();
}
void UBFeaturesActionBar::setButtons()
{
switch( currentState )
{
case IN_FOLDER:
mpNewFolderBtn->setEnabled(true);
case IN_ROOT:
mpFavoriteBtn->show();
mpSocialBtn->hide();
mSearchBar->show();
mpDeleteBtn->show();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->show();
break;
case IN_PROPERTIES:
mpFavoriteBtn->show();
mpSocialBtn->hide();
mSearchBar->show();
//mpSearchBtn->show();
mpDeleteBtn->hide();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->hide();
mpNewFolderBtn->hide();
break;
case IN_FAVORITE:
mpFavoriteBtn->hide();
mpSocialBtn->hide();
mSearchBar->show();
//mpSearchBtn->show();
mpDeleteBtn->hide();
mpCloseBtn->hide();
mpRemoveFavoriteBtn->show();
mpNewFolderBtn->hide();
break;
default:
break;
}
}
void UBFeaturesActionBar::onSearchTextChanged(QString txt)
{
emit searchElement(mSearchBar->text());
}
void UBFeaturesActionBar::onActionNewFolder()
{
emit newFolderToCreate();
}
UBFeaturesActionBar::~UBFeaturesActionBar()
{
}

@ -4,13 +4,56 @@
#include <QWidget>
#include <QToolButton>
#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
enum UBFeaturesActionBarState
{
IN_ROOT,
IN_FOLDER,
IN_PROPERTIES,
IN_FAVORITE
};
class UBFeaturesActionBar : public QWidget
{
Q_OBJECT
public:
UBFeaturesActionBar(QWidget* parent=0, const char* name="UBFeaturesActionBar");
UBFeaturesActionBar(UBFeaturesController *controller, QWidget* parent=0, const char* name="UBFeaturesActionBar");
~UBFeaturesActionBar();
void setCurrentState( UBFeaturesActionBarState state );
signals:
void searchElement(QString text);
void newFolderToCreate();
private slots:
void onSearchTextChanged(QString txt);
void onActionNewFolder();
private:
void setButtons();
UBFeaturesController *featuresController;
UBFeaturesActionBarState currentState;
eButtonSet mCrntButtonSet;
eButtonSet mPreviousButtonSet;
QButtonGroup* mButtonGroup;
QLineEdit* mSearchBar;
QHBoxLayout* mLayout;
QAction* mpFavoriteAction;
QAction* mpSocialAction;
QAction* mpDeleteAction;
QAction* mpSearchAction;
QAction* mpCloseAction;
QAction* mpRemoveFavorite;
QAction* mpNewFolderAction;
UBActionButton* mpFavoriteBtn;
UBActionButton* mpSocialBtn;
UBActionButton* mpDeleteBtn;
//UBActionButton* mpSearchBtn;
UBActionButton* mpCloseBtn;
UBActionButton* mpRemoveFavoriteBtn;
UBActionButton* mpNewFolderBtn;
};

@ -1,6 +1,7 @@
#include "UBFeaturesWidget.h"
#include "domain/UBAbstractWidget.h"
#include "gui/UBThumbnailWidget.h"
#include "gui/UBLibraryWidget.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h"
#include "core/UBDownloadManager.h"
@ -87,7 +88,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
stackedWidget->setCurrentIndex(ID_LISTVIEW);
currentStackedWidget = ID_LISTVIEW;
mActionBar = new UBLibActionBar(this);
mActionBar = new UBFeaturesActionBar(controller, this);
layout->addWidget(mActionBar);
/*connect(featuresListView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex &, const QModelIndex & )),
@ -95,6 +96,7 @@ UBFeaturesWidget::UBFeaturesWidget(QWidget *parent, const char *name):UBDockPale
connect( featuresListView, SIGNAL(clicked ( const QModelIndex & ) ),
this, SLOT( currentSelected(const QModelIndex &) ) );
connect( mActionBar, SIGNAL( searchElement(QString) ), this, SLOT( searchStarted(QString) ) );
connect( mActionBar, SIGNAL( newFolderToCreate() ), this, SLOT( createNewFolder() ) );
connect( pathListView, SIGNAL(clicked( const QModelIndex & ) ),
this, SLOT( currentPathChanged( const QModelIndex & ) ) );
}
@ -127,6 +129,7 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
{
QString newPath = feature.getUrl() + "/" + feature.getName();
//pathViewer->addPathElement( feature.getThumbnail(), newPath );
controller->setCurrentElement( feature );
model->setFilterFixedString( newPath );
model->invalidate();
@ -134,11 +137,13 @@ void UBFeaturesWidget::currentSelected(const QModelIndex &current)
featuresPathModel->setPath( newPath );
featuresPathModel->invalidate();
mActionBar->setCurrentState( IN_FOLDER );
}
else
{
featureProperties->showElement( feature );
switchToProperties();
mActionBar->setCurrentState( IN_PROPERTIES );
}
}
@ -158,9 +163,29 @@ void UBFeaturesWidget::currentPathChanged(const QModelIndex &index)
featuresProxyModel->setFilterFixedString(newPath);
featuresProxyModel->invalidate();
switchToListView();
controller->setCurrentElement( feature );
if ( feature.getType() == FEATURE_CATEGORY && feature.getName() == "root" )
{
mActionBar->setCurrentState( IN_ROOT );
}
else
{
mActionBar->setCurrentState( IN_FOLDER );
}
}
}
void UBFeaturesWidget::createNewFolder()
{
UBNewFolderDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
UBFeature newFolder = controller->newFolder( dlg.folderName() );
featuresModel->addItem( newFolder );
featuresProxyModel->invalidate();
}
}
void UBFeaturesWidget::switchToListView()
{
@ -175,6 +200,7 @@ void UBFeaturesWidget::switchToProperties()
}
/*
void UBFeaturesWidget::currentPathChanged(const QString &path)
{
@ -185,7 +211,7 @@ void UBFeaturesWidget::currentPathChanged(const QString &path)
featuresProxyModel->invalidate();
switchToListView();
}
*/
UBFeaturesWidget::~UBFeaturesWidget()
@ -330,14 +356,14 @@ void UBFeatureProperties::onAddToPage()
UBFeatureProperties::~UBFeatureProperties()
{
}
/*
UBFeaturesPathViewer::UBFeaturesPathViewer(const QPixmap &root, const QString &rootPath, QGraphicsScene *sc, QWidget* parent, const char* name) : QGraphicsView(sc, parent)
{
setObjectName(name);
/*setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
*/
//setAttribute(Qt::WA_StyledBackground, true);
//setStyleSheet(UBApplication::globalStyleSheet());
layout = new QGraphicsLinearLayout();
container = new QGraphicsWidget();
@ -396,7 +422,7 @@ void UBFeaturesPathViewer::truncatePath(int number)
}
scene()->invalidate();
}
*/
UBFeatureItemButton::UBFeatureItemButton(QWidget *parent, const char *name):QPushButton(parent)
{
setObjectName(name);
@ -498,13 +524,18 @@ bool UBFeaturesModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction act
{
element = UBFeaturesController::copyItemToFolder( url, parentFeature );
}
beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() );
featuresList->push_back( element );
endInsertRows();
addItem( element );
}
return true;
}
void UBFeaturesModel::addItem( const UBFeature &item )
{
beginInsertRows( QModelIndex(), featuresList->size(), featuresList->size() );
featuresList->push_back( item );
endInsertRows();
}
bool UBFeaturesModel::removeRows( int row, int count, const QModelIndex & parent )
{
if ( row < 0 )

@ -16,8 +16,9 @@
#include <QDropEvent>
#include "UBDockPaletteWidget.h"
#include "UBLibActionBar.h"
//#include "UBLibActionBar.h"
#include "board/UBFeaturesController.h"
#include "UBFeaturesActionBar.h"
#define THUMBNAIL_WIDTH 400
@ -67,18 +68,19 @@ private:
UBFeaturesListView *featuresListView;
UBFeaturesListView *pathListView;
QVBoxLayout *layout;
UBFeaturesPathViewer *pathViewer;
//UBFeaturesPathViewer *pathViewer;
QGraphicsScene *pathScene;
UBLibActionBar *mActionBar;
UBFeaturesActionBar *mActionBar;
UBFeatureProperties *featureProperties;
QStackedWidget *stackedWidget;
int currentStackedWidget;
private slots:
void currentSelected(const QModelIndex &);
void currentPathChanged(const QString &);
void currentSelected( const QModelIndex & );
//void currentPathChanged(const QString &);
void currentPathChanged( const QModelIndex & );
void searchStarted(QString);
void searchStarted( QString );
void createNewFolder();
};
class UBFeaturesListView : public QListView
@ -91,6 +93,7 @@ protected:
virtual void dropEvent( QDropEvent *event );
};
/*
class UBFeaturesPathViewer : public QGraphicsView
{
Q_OBJECT
@ -129,7 +132,7 @@ protected:
private:
QString path;
};
*/
class UBFeatureProperties : public QWidget
{
@ -183,6 +186,7 @@ public:
UBFeaturesModel( QObject *parent = 0 ) : QAbstractListModel(parent) {;}
virtual ~UBFeaturesModel(){;}
void addItem( const UBFeature &item );
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
QMimeData *mimeData( const QModelIndexList &indexes ) const;
QStringList mimeTypes() const;

Loading…
Cancel
Save