Exemplo n.º 1
0
FileManager::FileManager(QListView *listView, QWidget *parent)
	: m_view(listView),
	  m_parent(parent)
{
    m_model = new QFileSystemModel(this);

	m_currentIndex = m_model->setRootPath(QDir::current().absolutePath());

	m_model->setFilter(QDir::Files | QDir::System | QDir::NoDot | QDir::Dirs);
	m_model->setReadOnly(true);

	m_view->setLayoutMode(QListView::Batched);

	m_view->setModel(m_model);
	m_view->setRootIndex(m_currentIndex);
	m_view->setSelectionMode(QAbstractItemView::ExtendedSelection);

	m_selectionModel = m_view->selectionModel();

    connect(m_selectionModel, &QItemSelectionModel::currentChanged, this, &FileManager::fileSelect);
    connect(m_view, &QListView::activated, this, &FileManager::handleItemActivation);

/*
	connect(m_selectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
		this, SLOT(fileSelect(const QModelIndex &, const QModelIndex &)));

	connect(m_view, SIGNAL(activated(QModelIndex)),
		this, SLOT(handleItemActivation(QModelIndex)));
*/
#if 0
    connect(m_model, SIGNAL(directoryLoaded(QString)), this, SLOT(onDirectoryLoaded(QString)));
#endif
}
Exemplo n.º 2
0
/*!
    Sets the model which provides completions to \a model. The \a model can
    be list model or a tree model. If a model has been already previously set
    and it has the QCompleter as its parent, it is deleted.

    For convenience, if \a model is a QFileSystemModel, QCompleter switches its
    caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive
    on other platforms.

    \sa completionModel(), modelSorting, {Handling Tree Models}
*/
void QCompleter::setModel(QAbstractItemModel *model)
{
    Q_D(QCompleter);
    QAbstractItemModel *oldModel = d->proxy->sourceModel();
    d->proxy->setSourceModel(model);
    if (d->popup)
        setPopup(d->popup); // set the model and make new connections
    if (oldModel && oldModel->QObject::parent() == this)
        delete oldModel;
#ifndef QT_NO_DIRMODEL
    if (qobject_cast<QDirModel *>(model)) {
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
        setCaseSensitivity(Qt::CaseInsensitive);
#else
        setCaseSensitivity(Qt::CaseSensitive);
#endif
    }
#endif // QT_NO_DIRMODEL
#ifndef QT_NO_FILESYSTEMMODEL
    QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
    if (fsModel) {
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
        setCaseSensitivity(Qt::CaseInsensitive);
#else
        setCaseSensitivity(Qt::CaseSensitive);
#endif
        setCompletionRole(QFileSystemModel::FileNameRole);
        connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
    }
#endif // QT_NO_FILESYSTEMMODEL
}
Exemplo n.º 3
0
FolderProvider::FolderProvider(const QRectF &rect, QGraphicsObject *parent)
    : cherry_kit::TableModel(parent), d(new FolderProviderPrivate) {

  d->mIconProvider = new QFileIconProvider();
  d->mFileSystemModel = new QFileSystemModel(this);
  d->mFileSystemModel->setIconProvider(d->mIconProvider);
  connect(d->mFileSystemModel, SIGNAL(directoryLoaded(QString)), this,
          SLOT(onDirectoryReady(QString)));
}
Exemplo n.º 4
0
TextureDirWidget::TextureDirWidget(QWidget *parent) :
    QWidget(parent),
    m_toolBar(new Manhattan::StyledBar),
    m_view(new QTreeView),
    m_model(new QFileSystemModel)
{
//    QAction *small = m_toolBar->addAction(tr("Small icon size"));
//    small->setCheckable(true);
//    connect(small, SIGNAL(triggered()), this, SLOT(setSmallIconSize()));

//    QAction *medium = m_toolBar->addAction(tr("Medium icon size"));
//    medium->setCheckable(true);
//    connect(medium, SIGNAL(triggered()), this, SLOT(setMediumIconSize()));

//    QAction *big = m_toolBar->addAction(tr("Big icon size"));
//    big->setCheckable(true);
//    connect(big, SIGNAL(triggered()), this, SLOT(setBigIconSize()));

//    QActionGroup *group = new QActionGroup(m_toolBar);
//    group->addAction(small);
//    group->addAction(medium);
//    group->addAction(big);

//    m_toolBar->setSingleRow(false);
    {
        QHBoxLayout *layout = new QHBoxLayout(m_toolBar);
        layout->setMargin(0);
        layout->setSpacing(4);
        layout->setContentsMargins(5, 0, 0, 0);
        layout->addWidget(new QLabel(tr(LabelText)));
    }

    connect(m_model, SIGNAL(directoryLoaded(QString)), m_view, SLOT(expandAll()));
    m_model->setRootPath(QDir::currentPath());
    m_model->setNameFilterDisables(false);
    m_model->setNameFilters(nameFilters());
    m_model->setIconProvider(new TextureIconProvider);

    m_view->setDragEnabled(true);
    m_view->setDragDropMode(QAbstractItemView::DragOnly);
    m_view->setHeaderHidden(true);
    m_view->setIconSize(IconSize);
    m_view->setModel(m_model);
    m_view->setRootIndex(m_model->index(QDir::currentPath()));
    for(int i = 1; i < m_model->columnCount(); ++i) {
        m_view->setColumnHidden(i, true);
    }
    m_view->setStyleSheet("QTreeView { border: 0; }");

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(m_toolBar);
    layout->addWidget(m_view);
}
Exemplo n.º 5
0
/*
    Get specific file info's, batch the files so update when we have 100
    items and every 200ms after that
 */
void RemoteFileInfoGatherer::getFileInfos(const QString &path, const QStringList &files)
{
    // List drives
    if (path.isEmpty()) {
#ifdef QT_BUILD_INTERNAL
        fetchedRoot.store(true);
#endif
        QFileInfoList infoList;
        if (files.isEmpty()) {
            infoList = QDir::drives();
        } else {
            infoList.reserve(files.count());
            for (const auto &file : files)
                infoList << QFileInfo(file);
        }
        for (int i = infoList.count() - 1; i >= 0; --i) {
            QString driveName = translateDriveName(infoList.at(i));
            QVector<QPair<QString,FileInfo> > updatedFiles;
            updatedFiles.append(QPair<QString,FileInfo>(driveName, toFileInfo(infoList.at(i))));
            emit updates(path, updatedFiles);
        }
        return;
    }

    QElapsedTimer base;
    base.start();
    QFileInfo fileInfo;
    bool firstTime = true;
    QVector<QPair<QString, FileInfo> > updatedFiles;
    QStringList filesToCheck = files;

    QStringList allFiles;
    if (files.isEmpty()) {
        QDirIterator dirIt(path, QDir::AllEntries | QDir::System | QDir::Hidden);
        while (!abort.load() && dirIt.hasNext()) {
            dirIt.next();
            fileInfo = dirIt.fileInfo();
            allFiles.append(fileInfo.fileName());
            fetch(fileInfo, base, firstTime, updatedFiles, path);
        }
    }
    if (!allFiles.isEmpty())
        emit newListOfFiles(path, allFiles);

    QStringList::const_iterator filesIt = filesToCheck.constBegin();
    while (!abort.load() && filesIt != filesToCheck.constEnd()) {
        fileInfo.setFile(path + QDir::separator() + *filesIt);
        ++filesIt;
        fetch(fileInfo, base, firstTime, updatedFiles, path);
    }
    if (!updatedFiles.isEmpty())
        emit updates(path, updatedFiles);
    emit directoryLoaded(path);
}
Exemplo n.º 6
0
void directoryReader::readDirectory(QString path){
    QDir dir(path);
    QFileInfoList lst=dir.entryInfoList();
    QSet<QString> files;
    foreach(QFileInfo elem,lst){
        if(elem.isDir()){
            files.insert(elem.fileName()+QDir::separator());
        }else{
            files.insert(elem.fileName());
        }
    }

    emit directoryLoaded(path,files);
}
Exemplo n.º 7
0
void
FileSystemModel::onDirectoryLoadedByGatherer(const QString& directory)
{
    
    ///Get the item corresponding to the directory
    boost::shared_ptr<FileSystemItem> item = _imp->getItemFromPath(directory);
    if (!item) {
        qDebug() << "FileSystemModel failed to load the following requested directory: " << directory;
        return;
    }
    
    if (directory != _imp->currentRootPath) {
        return;
    }
    
    if (!_imp->rootPathWatched) {
        assert(_imp->watcher);
        
        ///Watch all files in the directory and track changes
        for (int i = 0; i < item->childCount(); ++i) {
            boost::shared_ptr<FileSystemItem> child = item->childAt(i);
            boost::shared_ptr<SequenceParsing::SequenceFromFiles> sequence = child->getSequence();
            
            if (sequence) {
                ///Add all items in the sequence
                if (sequence->isSingleFile()) {
                    _imp->watcher->addPath(sequence->generateValidSequencePattern().c_str());
                } else {
                    const std::map<int,SequenceParsing::FileNameContent>& indexes = sequence->getFrameIndexes();
                    for (std::map<int,SequenceParsing::FileNameContent>::const_iterator it = indexes.begin();
                         it != indexes.end(); ++it) {
                        _imp->watcher->addPath(it->second.absoluteFileName().c_str());
                    }
                }
    
            } else {
                const QString& absolutePath = child->absoluteFilePath();
                _imp->watcher->addPath(absolutePath);
            }
            
        }
        
        ///Set it to true to prevent it from being re-watched
        _imp->rootPathWatched = true;
    }
    
    ///Finally notify the client that the directory is ready for use
    emit directoryLoaded(directory);
}
Exemplo n.º 8
0
// Constructor
FileSelectorWidget::FileSelectorWidget(QWidget* parent) : QWidget(parent)
{
	ui.setupUi(this);

	// Setup file system model and attach to view
	fileSystemModel_.setRootPath("");
	fileSystemModel_.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::AllEntries);
	fileSystemModel_.setNameFilterDisables(false);
	ui.FileView->setModel(&fileSystemModel_);
	ui.FileView->hideColumn(2);

	// Connect signals
	connect(&fileSystemModel_, SIGNAL(directoryLoaded(QString)), this, SLOT(resizeFileView(QString)));
	connect(ui.FavouritesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(favouritesContextMenuRequested(QPoint)));

	refreshing_ = false;
	updatePluginFromFilename_ = false;
}
Exemplo n.º 9
0
FileSystemModel::FileSystemModel(SortableViewI* view)
: QAbstractItemModel()
, _imp(new FileSystemModelPrivate(this,view))
{
    QObject::connect(&_imp->gatherer, SIGNAL(directoryLoaded(QString)), this, SLOT(onDirectoryLoadedByGatherer(QString)));
    
    
    _imp->headers << tr("Name") << tr("Size") << tr("Type") << tr("Date Modified");
    
    _imp->rootItem.reset(new FileSystemItem(true,QString(),boost::shared_ptr<SequenceParsing::SequenceFromFiles>(),QDateTime(),0));
    
    _imp->watcher = new QFileSystemWatcher;
    QObject::connect(_imp->watcher, SIGNAL(directoryChanged(QString)), this, SLOT(onWatchedDirectoryChanged(QString)));
    QObject::connect(_imp->watcher, SIGNAL(fileChanged(QString)), this, SLOT(onWatchedFileChanged(QString)));
    _imp->watcher->addPath(QDir::rootPath());
    
    QFileInfoList drives = QDir::drives();
    
    ///Fetch all drives by default
    for (int i = 0; i < drives.size(); ++i) {
      
        QString driveName;
#ifdef __NATRON_WIN32__
        // for drives, there is no filename
        driveName = drives[i].canonicalPath();
#else
        driveName = generateChildAbsoluteName(_imp->rootItem.get(),drives[i].fileName());
#endif
        
        boost::shared_ptr<FileSystemItem> child(new FileSystemItem(true, //isDir
                                                                   driveName, //drives have canonical path
                                                                   boost::shared_ptr<SequenceParsing::SequenceFromFiles>(),
                                                                   drives[i].lastModified(),
                                                                   drives[i].size(),
                                                                   _imp->rootItem.get()));
        _imp->rootItem->addChild(child);
    }
    
    
}
Exemplo n.º 10
0
void
FileSystemModel::setRootPath(const QString& path)
{
    assert(QThread::currentThread() == qApp->thread());
    
    ///Check if the path exists
    {
        QDir dir(path);
        if ( !dir.exists() ) {
            return;
        }
    }
    
    _imp->currentRootPath = path;
    
    ///Set it to false so that onDirectoryLoadedByGatherer will watch the content of the directory
    _imp->rootPathWatched = false;
    
    ///Make sure the path exist
    boost::shared_ptr<FileSystemItem> item = _imp->mkPath(path);
    
    if (item && item != _imp->rootItem) {
        
        delete _imp->watcher;
        _imp->watcher = new QFileSystemWatcher;
        QObject::connect(_imp->watcher, SIGNAL(directoryChanged(QString)), this, SLOT(onWatchedDirectoryChanged(QString)));
        QObject::connect(_imp->watcher, SIGNAL(fileChanged(QString)), this, SLOT(onWatchedFileChanged(QString)));
        _imp->watcher->removePath(_imp->currentRootPath);
        _imp->watcher->addPath(item->absoluteFilePath());
        
        _imp->populateItem(item);
    } else {
        emit directoryLoaded(path);
    }
    
    emit rootPathChanged(path);
}
Exemplo n.º 11
0
void MainWindow::setModels()
{
    m_FSmodel = new FileSystemCustomModel;
    m_FSmodel->setRootPath("");
    connect(m_FSmodel, SIGNAL(directoryLoaded(QString)), this, SLOT(slotDirectoryWasLoaded(QString)));

    m_dirsModel = new LeftViewProxyModel;
    m_dirsModel->setSourceModel(m_FSmodel);
    m_dirsModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    m_dirsModel->sort(0, Qt::AscendingOrder);

    m_dirsContentsModel = new RightViewProxyModel;
    m_dirsContentsModel->setSourceModel(m_FSmodel);
    m_dirsContentsModel->sort(0, Qt::AscendingOrder);

    // files info list model
    m_infoModel = new FileInfoListModel;
    connect(this, SIGNAL(sigUpdateFileInfo(long,long)), m_infoModel, SLOT(slotChangeFileInfo(long,long)));
    connect(this, SIGNAL(sigRightViewResetted()), m_infoModel, SLOT(slotClearFileInfo()));

#ifdef TEST_MODEL
    ModelTest *modelTest = new ModelTest(m_dirsContentsModel, this);
#endif
}
Exemplo n.º 12
0
void
FileGathererThread::gatheringKernel(const boost::shared_ptr<FileSystemItem>& item)
{

    QDir dir( item->absoluteFilePath() );
    
    Qt::SortOrder viewOrder = _imp->model->sortIndicatorOrder();
    FileSystemModel::Sections sortSection = (FileSystemModel::Sections)_imp->model->sortIndicatorSection();
    switch (sortSection) {
        case FileSystemModel::Name:
            dir.setSorting(QDir::Name);
            break;
        case FileSystemModel::Size:
            dir.setSorting(QDir::Size);
            break;
        case FileSystemModel::Type:
            dir.setSorting(QDir::Type);
            break;
        case FileSystemModel::DateModified:
            dir.setSorting(QDir::Time);
            break;
        default:
            break;
    }
    
    ///All entries in the directory
    QFileInfoList all = dir.entryInfoList(_imp->model->filter());
    
    ///List of all possible file sequences in the directory or directories
    FileSequences sequences;
    
    int start;
    int end;
    switch (viewOrder) {
        case Qt::AscendingOrder:
            start = 0;
            end = all.size();
            break;
        case Qt::DescendingOrder:
            start = all.size() - 1;
            end = -1;
            break;
    }
    
    int i = start;
    while (i != end) {
        
        ///If we must abort we do it now
        if ( _imp->checkForAbort() ) {
            return;
        }
        
        if ( all[i].isDir() ) {
            ///This is a directory
            sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i]));
        } else {
            

            QString filename = all[i].fileName();

            /// If the item does not match the filter regexp set by the user, discard it
            if ( !_imp->model->isAcceptedByRegexps(filename) ) {
                KERNEL_INCR();
                continue;
            }
            
            /// If file sequence fetching is disabled, accept it
            if ( !_imp->model->isSequenceModeEnabled() ) {
                sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i]));
                KERNEL_INCR();
                continue;
            }

            std::string absoluteFilePath = generateChildAbsoluteName(item.get(), filename).toStdString();
            
            
            bool foundMatchingSequence = false;
            
            /// If we reach here, this is a valid file and we need to determine if it belongs to another sequence or we need
            /// to create a new one
            SequenceParsing::FileNameContent fileContent(absoluteFilePath);
            
            ///Note that we use a reverse iterator because we have more chance to find a match in the last recently added entries
            for (FileSequences::reverse_iterator it = sequences.rbegin(); it != sequences.rend(); ++it) {
                
                if ( it->first && it->first->tryInsertFile(fileContent,false) ) {
                    
                    foundMatchingSequence = true;
                    break;
                }
                
            }
            
            if (!foundMatchingSequence) {
                
                boost::shared_ptr<SequenceParsing::SequenceFromFiles> newSequence( new SequenceParsing::SequenceFromFiles(fileContent,true) );
                sequences.push_back(std::make_pair(newSequence, all[i]));

            }
            
        }
        KERNEL_INCR();
    }
    
    ///Now iterate through the sequences and create the children as necessary
    for (FileSequences::iterator it = sequences.begin(); it != sequences.end(); ++it) {
        item->addChild(it->first, it->second);
    }
    
    emit directoryLoaded( item->absoluteFilePath() );
}
Exemplo n.º 13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    scene(new QGraphicsScene),
    dir_model_(new QFileSystemModel()),
    files_(new QFileSystemModel()),
    files_watcher_(new QFileSystemWatcher),
    file_model_(new QStandardItemModel()),
    img_queue_model_(new QStandardItemModel()),
    result(NULL),
    img_spacing_(0),
    img_margin_(0),
    status_text_("Select")
{
    ui->setupUi(this);
    statusBar()->addWidget(&status_text_);

    //QGraphicsView 관련변수 초기화
    //scene = new QGraphicsScene;
    ui->graphicsView->setScene(scene);



    //dir_model_ 초기화
    QString path = "./";
    //dir_model_ = new QFileSystemModel();
    dir_model_->setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
    dir_model_->setRootPath(path);
    ui->treeView->setModel(dir_model_);
    ui->treeView->hideColumn(1);
    ui->treeView->hideColumn(2);
    ui->treeView->hideColumn(3);

    //
    //files_watcher_ = new QFileSystemWatcher;

    //file_model_ 초기화
    for(unsigned int i=0; i<kExtName::CNT; i++) {
        ext_lists_ << kExtName::STRING[i];
    }
    //files_ = new QFileSystemModel();
    //file_model_ = new QStandardItemModel();
    files_->setFilter(QDir::NoDotAndDotDot | QDir::Files);
    files_->setNameFilters(ext_lists_);
    files_->setNameFilterDisables(false);
    ui->fileView->setModel(file_model_);
    ui->fileView->setViewMode(QListView::IconMode);
    ui->fileView->setFlow(QListView::LeftToRight);
    ui->fileView->setGridSize(QSize(96,60));
    ui->fileView->setUniformItemSizes(true);
    ui->fileView->setEditTriggers(QAbstractItemView::NoEditTriggers);


    //qImageListWidget 초기화
    //img_queue_model_ = new QStandardItemModel();
    ui->qImgListWidget->setViewMode(QListView::IconMode);
    ui->qImgListWidget->setGridSize(QSize(170,115));
    ui->qImgListWidget->setFlow(QListView::LeftToRight);
    ui->qImgListWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->qImgListWidget->setWrapping(false);

    ui->qImgListWidget->setIconSize(QSize(161,100));
    ui->qImgListWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->qImgListWidget->setResizeMode(QListView::Adjust);
    ui->splitter->setStretchFactor(1,2);


    //result = new QImage;

    QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->qImgListWidget);
    connect(shortcut, SIGNAL(activated()), this, SLOT(SelectedItemDelete()));    
    connect(files_, SIGNAL(directoryLoaded(QString)), this, SLOT(DirFilesFilter(QString)));
    connect(ui->fileView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(EnqueueImgModel(QModelIndex)));
    connect(file_model_, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(FileViewUpdate(QModelIndex)));
    connect(ui->qImgListWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(MakeImage()));
    connect(files_watcher_, SIGNAL(directoryChanged(QString)), this ,SLOT(chnageDir(QString)));
    ui->actionSave->setDisabled(true);


}
Exemplo n.º 14
0
void NBFolderView::createAndSetupActions() {

	connect( IconView, SIGNAL( peek( QModelIndex ) ), this, SLOT( doPeek( QModelIndex ) ) );

	connect( IconView, SIGNAL( open( QModelIndex ) ), this, SLOT( doOpen( QModelIndex ) ) );
	connect( IconView, SIGNAL( open( QString ) ), this, SLOT( doOpen( QString ) ) );

	connect( IconView, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) );
	connect( IconView, SIGNAL( actionsMenuRequested( QPoint ) ), this, SLOT( showActionsMenu( QPoint ) ) );

	connect(
		IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
		this, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) )
	);

	connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) );

	connect( IconView, SIGNAL( link( QStringList, QString ) ), this, SLOT( link( QStringList, QString ) ) );

	// DragDrop copy
	connect( IconView, SIGNAL( copy( QStringList, QString ) ), this, SLOT( copy( QStringList, QString ) ) );

	// DragDrop move
	connect( IconView, SIGNAL( move( QStringList, QString ) ), this, SLOT( move( QStringList, QString ) ) );

	// Update actions once the directory is loaded
	connect( fsModel, SIGNAL( directoryLoaded( QString ) ), this, SLOT( updateActions() ) );

	// Peek
	peekAct = new QAction( QIcon( ":/icons/peek.png" ), "Pee&k", this );
	peekAct->setShortcuts( Settings->shortcuts( "Peek" ) );

	connect( peekAct, SIGNAL( triggered() ), this, SLOT( doPeek() ) );
	addAction( peekAct );

	// Home Dir
	actHomeDir = new QAction( QIcon( ":/icons/home.png" ), "&Home", this );
	actHomeDir->setShortcuts( Settings->shortcuts( "GoHome" ) );

	connect( actHomeDir, SIGNAL( triggered() ), this, SLOT( loadHomeDir() ) );
	addAction( actHomeDir );

	// Home
	actGoHome = new QAction( QIcon( ":/icons/home.png" ), "&Home", this );
	actGoHome->setShortcut( tr( "Alt+Shift+Home" ) );

	connect( actGoHome, SIGNAL( triggered() ), this, SLOT( doOpenHome() ) );
	addAction( actGoHome );

	// Up
	actParDir = new QAction( QIcon( ":/icons/up.png" ), "&Up", this );
	actParDir->setShortcuts( Settings->shortcuts( "GoUp" ) );

	connect( actParDir, SIGNAL( triggered() ), fsModel, SLOT( goUp() ) );
	addAction( actParDir );

	// Back
	actPrevDir = new QAction( QIcon( ":/icons/prev.png" ), "&Back", this );
	actPrevDir->setShortcuts( Settings->shortcuts( "GoLeft" ) );

	connect( actPrevDir, SIGNAL( triggered() ), fsModel, SLOT( goBack() ) );
	addAction( actPrevDir );

	// Forward
	actNextDir = new QAction( QIcon( ":/icons/next.png" ), "&Forward", this );
	actNextDir->setShortcuts( Settings->shortcuts( "GoRight" ) );

	connect( actNextDir, SIGNAL( triggered() ), fsModel, SLOT( goForward() ) );
	addAction( actNextDir );

	// New Folder
	actNewDir = new QAction( QIcon::fromTheme( "folder-new" ), "New folder", this );
	actNewDir->setShortcuts( Settings->shortcuts( "NewFolder" ) );

	connect( actNewDir, SIGNAL( triggered() ), this, SLOT( newFolder() ) );
	addAction( actNewDir );

	// New file
	actNewFile = new QAction( QIcon::fromTheme( "document-new" ), "New File", this );
	actNewFile->setShortcuts( Settings->shortcuts( "NewFile" ) );

	connect( actNewFile, SIGNAL( triggered() ), this, SLOT( newFile() ) );
	addAction( actNewFile );

	// New file
	actNewEncFS = new QAction( QIcon::fromTheme( "document-new" ), "New Encrypted Directory", this );
	actNewEncFS->setShortcuts( Settings->shortcuts( "NewEncFS" ) );

	connect( actNewEncFS, SIGNAL( triggered() ), this, SLOT( createEncFS() ) );
	addAction( actNewEncFS );

	// Copy
	copyAct = new QAction( QIcon( ":/icons/copy.png" ), "&Copy", this );
	copyAct->setShortcuts( Settings->shortcuts( "Copy" ) );

	connect( copyAct, SIGNAL( triggered() ), this, SLOT( prepareCopy() ) );
	addAction( copyAct );

	// Move
	moveAct = new QAction( QIcon( ":/icons/cut.png" ), "Cu&t", this );
	moveAct->setShortcuts( Settings->shortcuts( "Cut" ) );

	connect( moveAct, SIGNAL( triggered() ), this, SLOT( prepareMove() ) );
	addAction( moveAct );

	// Paste
	pasteAct = new QAction( QIcon( ":/icons/paste.png" ), "&Paste", this );
	pasteAct->setShortcuts( Settings->shortcuts( "Paste" ) );

	connect( pasteAct, SIGNAL( triggered() ), this, SLOT( prepareIO() ) );
	addAction( pasteAct );

	// Rename
	renameAct = new QAction( QIcon( ":/icons/rename.png" ), "&Rename", this );
	renameAct->setShortcuts( Settings->shortcuts( "Rename" ) );

	connect( renameAct, SIGNAL( triggered() ), this, SLOT( doRename() ) );
	addAction( renameAct );

	// Reload
	reloadAct = new QAction( QIcon( ":/icons/reload.png" ), "Re&fresh", this );
	reloadAct->setShortcuts( Settings->shortcuts( "Reload" ) );

	connect( reloadAct, SIGNAL( triggered() ), this, SLOT( doReload() ) );
	addAction( reloadAct );

	// showDotFiles
	showHideDotFiles = new QAction( QIcon( ":/icons/showDotFiles.png" ), "Show &Hidden", this );
	showHideDotFiles->setShortcuts( Settings->shortcuts( "ToggleHidden" ) );

	connect( showHideDotFiles, SIGNAL( triggered() ), this, SLOT( doToggleHidden() ) );
	addAction( showHideDotFiles );

	// Trash
	trashAct = new QAction( QIcon( ":/icons/trash.png" ), "Move to trash", this );
	trashAct->setShortcuts( Settings->shortcuts( "Trash" ) );

	connect( trashAct, SIGNAL( triggered() ), this, SLOT( doSendToTrash() ) );
	addAction( trashAct );

	// Delete
	delAct = new QAction( QIcon( ":/icons/delete.png" ), "Delete", this );
	delAct->setShortcuts( Settings->shortcuts( "Delete" ) );

	connect( delAct, SIGNAL( triggered() ), this, SLOT( doDelete() ) );
	addAction( delAct );

	// Properties
	propertiesAct = new QAction( QIcon( ":/icons/props.png" ), "&Properties", this );
	propertiesAct->setShortcuts( Settings->shortcuts( "Properties" ) );

	connect( propertiesAct, SIGNAL( triggered() ), this, SIGNAL( showProperties() ) );
	addAction( propertiesAct );

	// Permissions
	permissionsAct = new QAction( QIcon::fromTheme( "system-users" ), "P&ermissions", this );
	permissionsAct->setShortcuts( Settings->shortcuts( "Permissions" ) );

	connect( permissionsAct, SIGNAL( triggered() ), this, SIGNAL( showPermissions() ) );
	addAction( permissionsAct );

	// Open a virtual terminal emulator
	openVTE = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE", this );
	openVTE->setShortcuts( Settings->shortcuts( "Terminal" ) );

	connect( openVTE, SIGNAL( triggered() ), this, SLOT( openTerminal() ) );
	addAction( openVTE );

	// Open a virtual terminal emulator
	openVTEin = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE Here", this );
	// openVTEin->setShortcuts( Settings->shortcuts( "Terminal" ) );
	connect( openVTEin, SIGNAL( triggered() ), this, SLOT( openTerminalIn() ) );

	// Select All
	QAction *selectAllAct = new QAction( "&Select All", this );
	selectAllAct->setShortcuts( Settings->shortcuts( "SelectAll" ) );

	connect( selectAllAct, SIGNAL( triggered() ), this, SLOT( selectAll() ) );
	addAction( selectAllAct );

	// Sorting
	sortByNameAct = new QAction( QIcon::fromTheme( "format-text-underline" ), "&Name", this );
	sortByNameAct->setCheckable( true );
	connect( sortByNameAct, SIGNAL( triggered() ), this, SLOT( sortByName() ) );

	sortByTypeAct = new QAction( QIcon::fromTheme( "preferences-other" ), "&Type", this );
	sortByTypeAct->setCheckable( true );
	connect( sortByTypeAct, SIGNAL( triggered() ), this, SLOT( sortByType() ) );

	sortBySizeAct = new QAction( QIcon( ":/icons/size.png" ), "&Size", this );
	sortBySizeAct->setCheckable( true );
	connect( sortBySizeAct, SIGNAL( triggered() ), this, SLOT( sortBySize() ) );

	sortByDateAct = new QAction( QIcon::fromTheme( "office-calendar" ), "&Date", this );
	sortByDateAct->setCheckable( true );
	connect( sortByDateAct, SIGNAL( triggered() ), this, SLOT( sortByDate() ) );

	QActionGroup *sortGroup = new QActionGroup( this );
	sortGroup->addAction( sortByNameAct );
	sortGroup->addAction( sortByTypeAct );
	sortGroup->addAction( sortBySizeAct );
	sortGroup->addAction( sortByDateAct );

	switch( ( int )Settings->value( "SortColumn" ) ) {
		case 0: {
			sortByNameAct->setChecked( true );
			break;
		}
		case 1: {
			sortBySizeAct->setChecked( true );
			break;
		}
		case 2: {
			sortByTypeAct->setChecked( true );
			break;
		}
		case 4: {
			sortByDateAct->setChecked( true );
			break;
		}
	}

	groupsAct = new QAction( QIcon::fromTheme( "view-group", QIcon( ":/icons/groups.png" ) ), "Show in &Groups", this );
	groupsAct->setCheckable( true );
	groupsAct->setChecked( Settings->value( "Grouping" ) );
	connect( groupsAct, SIGNAL( triggered() ), this, SIGNAL( toggleGroups() ) );

	// Add bookmark
	addBookMarkAct = new QAction( QIcon( ":/icons/bookmark.png" ), "Add &Bookmark", this );
	addBookMarkAct->setShortcuts( Settings->shortcuts( "AddBookmark" ) );

	connect( addBookMarkAct, SIGNAL( triggered() ), this, SLOT( addBookMark() ) );
	addAction( addBookMarkAct );

	/* Add to SuperStart */
	addToSuperStartAct = new QAction( QIcon( ":/icons/superstart.png" ), "Add to S&uperStart", this );
	addToSuperStartAct->setShortcut( tr( "Ctrl+U" ) );

	connect( addToSuperStartAct, SIGNAL( triggered() ), this, SLOT( addToSuperStart() ) );
	addAction( addToSuperStartAct );

	updateActions();
};
Exemplo n.º 15
0
/**
 * @brief RsCollectionDialog::RsCollectionDialog
 * @param collectionFileName: Filename of RSCollection saved
 * @param colFileInfos: Vector of ColFileInfo to be add in intialization
 * @param creation: Open dialog as RsColl Creation or RsColl DownLoad
 * @param readOnly: Open dialog for RsColl as ReadOnly
 */
RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName
                                       , const std::vector<ColFileInfo>& colFileInfos
                                       , const bool& creation /* = false*/
                                       , const bool& readOnly)
  : _fileName(collectionFileName), _creationMode(creation) ,_readOnly(readOnly)
{
	ui.setupUi(this) ;

	uint32_t size = colFileInfos.size();
	for(uint32_t i=0;i<size;++i)
	{
		const ColFileInfo &colFileInfo = colFileInfos[i];
		_newColFileInfos.push_back(colFileInfo);
	}

	setWindowFlags(Qt::Window); // for maximize button
	setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint);

	setWindowTitle(QString("%1 - %2").arg(windowTitle()).arg(QFileInfo(_fileName).completeBaseName()));
	
	
	ui.headerFrame->setHeaderImage(QPixmap(":/images/library64.png"));
	ui.headerFrame->setHeaderText(tr("Collection Editor"));

	// 1 - add all elements to the list.

	ui._fileEntriesTW->setColumnCount(COLUMN_COUNT) ;

	QTreeWidgetItem *headerItem = ui._fileEntriesTW->headerItem();
	headerItem->setText(COLUMN_FILE, tr("File"));
	headerItem->setText(COLUMN_SIZE, tr("Size"));
	headerItem->setText(COLUMN_HASH, tr("Hash"));
	headerItem->setText(COLUMN_FILEC, tr("File Count"));

	bool wrong_chars = !updateList();

	// 2 - connect necessary signals/slots

	connect(ui._changeFile, SIGNAL(clicked()), this, SLOT(changeFileName()));
	connect(ui._add_PB, SIGNAL(clicked()), this, SLOT(add()));
	connect(ui._addRecur_PB, SIGNAL(clicked()), this, SLOT(addRecursive()));
	connect(ui._remove_PB, SIGNAL(clicked()), this, SLOT(remove()));
	connect(ui._makeDir_PB, SIGNAL(clicked()), this, SLOT(makeDir()));
	connect(ui._cancel_PB, SIGNAL(clicked()), this, SLOT(cancel()));
	connect(ui._save_PB, SIGNAL(clicked()), this, SLOT(save()));
	connect(ui._download_PB, SIGNAL(clicked()), this, SLOT(download()));
	connect(ui._hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
	connect(ui._fileEntriesTW, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));

	// 3 Initialize List
	_dirModel = new QFileSystemModel(this);
	_dirModel->setRootPath("/");
	_dirModel->setFilter(QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot);
	_dirLoaded = false;
	connect(_dirModel, SIGNAL(directoryLoaded(QString)), this, SLOT(directoryLoaded(QString)));

	_tree_proxyModel = new FSMSortFilterProxyModel(this);
	_tree_proxyModel->setDynamicSortFilter(true);
	_tree_proxyModel->setSourceModel(_dirModel);
	_tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
	_tree_proxyModel->setSortRole(Qt::DisplayRole);

	ui._systemFileTW->setModel(_tree_proxyModel);
	//Selection Setup
	_selectionProxy = ui._systemFileTW->selectionModel();

	// 4 Restore Configuration
	// load settings
	processSettings(true);

	// 5 Activate button follow creationMode
	ui._changeFile->setVisible(_creationMode && !_readOnly);
	ui._makeDir_PB->setVisible(_creationMode && !_readOnly);
	ui._save_PB->setVisible(_creationMode && !_readOnly);
	ui._treeViewFrame->setVisible(_creationMode && !_readOnly);
	ui._download_PB->setVisible(!_creationMode && !_readOnly);

	ui._fileEntriesTW->installEventFilter(this);
	ui._systemFileTW->installEventFilter(this);

	// 6 Add HashBox
	setAcceptDrops(true);
	ui._hashBox->setDropWidget(this);
	ui._hashBox->setAutoHide(true);
	ui._hashBox->setDefaultTransferRequestFlags(RS_FILE_REQ_ANONYMOUS_ROUTING) ;

	if(wrong_chars)
		QMessageBox::warning(NULL,tr("Bad filenames have been cleaned"),tr("Some filenames or directory names contained forbidden characters.\nCharacters <b>\",|,/,\\,&lt;,&gt;,*,?</b> will be replaced by '_'.\n Concerned files are listed in red.")) ;
}