Exemple #1
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);
    }
    
    
}
Exemple #2
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);
}
Exemple #3
0
void MainWindow::initialize()
{
    createActions();
    createTrayIcon();
    setIcon();

    statusLedLabel = new QLabel;
    if(statusLedLabel)
    {
        statusBar()->addWidget(statusLedLabel);
        statusLedLabel->setPixmap(QPixmap("://images/led-red.png"));
    }

    statusLabel = new QLabel;
    if(statusLabel)
    {
        statusBar()->addWidget(statusLabel);
        statusLabel->setText(tr("Minecraft Server: Stopped"));
    }

    ui->actionStart->setEnabled(true);
    ui->actionStop->setEnabled(false);
    ui->actionSettings->setEnabled(true);
    ui->serverPropertiesTextEdit->setEnabled(true);
    ui->sendCommandButton->setEnabled(false);
    ui->actionSaveServerProperties->setEnabled(false);

    if(trayIcon)
    {
        trayIcon->show();
    }

    m_pServerProcess = new QProcess(this);

    connect( m_pServerProcess, SIGNAL(started()), SLOT(onStart()) );
    connect( m_pServerProcess, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(onFinish(int,QProcess::ExitStatus)) );
    connect( m_pServerProcess, SIGNAL(readyReadStandardOutput()), SLOT(onStandardOutput()) );
    connect( m_pServerProcess, SIGNAL(readyReadStandardError()), SLOT(onStandardError()) );

    m_pFileSystemWatcher = new QFileSystemWatcher(this);
    connect( m_pFileSystemWatcher, SIGNAL(fileChanged(QString)), SLOT(onWatchedFileChanged(QString)) );

    m_pDirSystemWatcher = new QFileSystemWatcher(this);
    connect( m_pDirSystemWatcher, SIGNAL(directoryChanged(QString)), SLOT(onWatchedDirChanged(QString)) );

    m_pSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "Qt Minecraft Server", "qtmcserver", this);

    loadSettings();

    if(m_mcServerPath.isEmpty())
    {
        on_actionSettings_triggered();
    }

    loadServerProperties();

    if(!m_mcServerPath.isEmpty())
    {
        updateWatchedFileSystemPath("", getMinecraftServerPropertiesPath(m_mcServerPath));
        updateWatchedDirSystemPath("", getMinecraftServerWorkingDirectoryPath(m_mcServerPath));
    }
}