Model::PlacedProject Model::getNeighbor( PlacedProject const & inProject ) { switch ( inProject.area ) { case Area::kTopLeft: case Area::kTop: case Area::kTopRight: { return PlacedProject ( inProject.row - 1, inProject.col, oppositeSide( inProject.area ) ); } case Area::kRightTop: case Area::kRight: case Area::kRightBottom: { return PlacedProject ( inProject.row, inProject.col + 1, oppositeSide( inProject.area ) ); } case Area::kBottomRight: case Area::kBottom: case Area::kBottomLeft: { return PlacedProject ( inProject.row + 1, inProject.col, oppositeSide( inProject.area ) ); } case Area::kLeftBottom: case Area::kLeft: case Area::kLeftTop: { return PlacedProject ( inProject.row, inProject.col - 1, oppositeSide( inProject.area ) ); } case Area::kCentral: { return inProject; } } assert( !"Invalid Area to get neighbor of" ); return inProject; }
void MainWindow::slotFileChanged(const QString &path) { QFileInfo info(path); QString dstDir; if (info.isFile()) { dstDir = oppositeSide(info.absolutePath()); } else if (info.isDir()) { dstDir = oppositeSide(path); } else { return; } Common::asyncCopy(path, dstDir); }
void MainWindow::slotDirectoryChanged(const QString &dir) { QStringList files, subdirs; Common::foreachDir(dir, files, subdirs); foreach (const QString &file, files) { if (!watcher_->files().contains(file)) { slotFileChanged(file); } } foreach (const QString &subdir, subdirs) { if (!watcher_->directories().contains(subdir)) { slotFileChanged(subdir); } } QStringList dstFiles, dstSubdis; Common::foreachDir(oppositeSide(dir), dstFiles, dstSubdis); foreach (const QString &file, dstFiles) { if (!isOppositeSideExist(file, false)) { Common::deleteFile(file); } } foreach (const QString &subdir, dstSubdis) { if (!isOppositeSideExist(subdir, false)) { Common::deleteDir(subdir); } } }
bool Transfer::assignSessions(Session *source, Session *destination) { bool result = true; // We need a source session if (!m_sourceUrl.isLocalFile() && !m_srcConnection) { if (!source) m_srcSession = KFTPSession::Manager::self()->spawnRemoteSession(IgnoreSide, m_sourceUrl, 0); else m_srcSession = source; if (!(m_srcConnection = initializeSession(m_srcSession))) result = false; } // We need a destination session if (!m_destUrl.isLocalFile() && !m_dstConnection) { if (!destination) m_dstSession = KFTPSession::Manager::self()->spawnRemoteSession(m_srcSession ? oppositeSide(m_srcSession->getSide()) : IgnoreSide, m_destUrl, 0); else m_dstSession = destination; if (!(m_dstConnection = initializeSession(m_dstSession))) result = false; } return result; }
bool MainWindow::isOppositeSideExist(QString path, bool isFrom) { QFileInfo info(oppositeSide(path, isFrom)); return info.exists(); }