예제 #1
0
//////////////////////////////////////////////////////////////////////////
/// A FileSystemWatcher notification when a file is renamed
//////////////////////////////////////////////////////////////////////////
void SyncSystem::slotFileRenamed(QString oldName, QString newName)
{
  if(m_LostSyncTimer->isActive())
  {
    //Force the timer to run for 5 more seconds
    m_LostSyncTimer->setInterval(s_ResyncTimeout);
  }

  QSharedPointer<SyncRules> oldPathRules = GetSyncRulesForPath(oldName);
  QSharedPointer<SyncRules> newPathRules = GetSyncRulesForPath(newName);

  SyncRuleFlags_e eOldFlags;
  SyncRuleFlags_e eFlags;
  if(oldPathRules->CheckFileAndPath(oldName.toLower(), eOldFlags) )
  {
    if(checkForRescan(newName))
    {
      return;
    }

    bool oldBinary = ((eOldFlags & e_Binary) == e_Binary);
    bool oldExecutable = ((eOldFlags & e_Executable) == e_Executable);

    //old name should be synced
    if(newPathRules->CheckFileAndPath(newName.toLower(), eFlags))
    {
      bool binary = ((eFlags & e_Binary) == e_Binary);
      bool executable = ((eFlags & e_Executable) == e_Executable);
      //new file should also be synced, delete the old sync the new (to avoid the need for new server protocol)
      addTodo(oldName, oldBinary, oldExecutable, true);
      addTodo(newName, binary, executable, false);
    }
    else
    {
      //old name was in sync, new is not. delete 
      addTodo(oldName, oldBinary, oldExecutable, true);
    }
  }
  else if(newPathRules->CheckFileAndPath(newName.toLower(), eFlags))
  {
    if(checkForRescan(newName))
    {
      return;
    }

    bool binary = ((eFlags & e_Binary) == e_Binary);
    bool executable = ((eFlags & e_Executable) == e_Executable);

    //Old file was not in sync, but the new is
    addTodo(newName, binary, executable, false);
  }
}
예제 #2
0
void SyncSystem::recvSendFileResult(const QString &filename, const QDateTime &mtime, int result)
{
  //sync has been stopped, ignore what the server is sending
  if(m_SyncState == e_Idle)
    return;

  if( !result )
  {
    m_FileErrors++;
    qWarning() << "[SyncSystem.sendFile] copy of file failed: " << filename;
    SyncRuleFlags_e flags = e_NoFlags;
    if(GetSyncRulesForPath(filename)->CheckFile(filename.toLower(), flags))
    {
      bool binary = flags == e_Binary || flags == e_BinaryExecutable;
      addTodo(filename, binary, false, false, true);
      emit signalFileStatus(filename, mtime, false);
    }
  }
  else
  {
    m_FilesCopied++;
    QMap<QString, FileTodo>::iterator erase = m_NameToInfo.find(filename);
    Q_ASSERT(erase != m_NameToInfo.end());
    if(erase != m_NameToInfo.end())
    {
      m_BytesInTransit -= erase.value().m_Size;
      m_NameToInfo.erase(erase);
      emit signalFileStatus(filename, mtime, true);
    }
  }
  emit signalFilesCopied(m_FilesCopied, m_FilesPendingCopy, m_FileErrors);
  updateSyncState();
}
예제 #3
0
void QTodoList::contextMenuActivated(int id)
{
	switch(id)
	{
	case CMID_ADDTODO:
		QTUM::get()->startRecording();
		addTodo();
		QTUM::get()->stopRecording();
		break;
	case CMID_ADDTODOATTOP:
		QTUM::get()->startRecording();
		addTodoAtTop();
		QTUM::get()->stopRecording();
		break;
	case CMID_ADDTODOATBOTTOM:
		QTUM::get()->startRecording();
		addTodo();
		QTUM::get()->stopRecording();
		break;
	case CMID_ADDSECTION:
		QTUM::get()->startRecording();
		addSection();
		QTUM::get()->stopRecording();
		break;
	case CMID_SORT:
		sort();
		break;
	case CMID_COPY:
		copy();
		break;
	case CMID_CUT:
		cut();
		break;
	case CMID_PASTE:
		paste();
		break;
	case CMID_SELECT_ALL:
		selectAll();
		break;
	case CMID_DESELECT_ALL:
		deselectAll();
		break;
	}
}
//**************************************************************************
// AServerWindow :: moreTodo()
//**************************************************************************
bool AServerWindow::moreTodo()       //Add more items to the todo list
{
  addTodo( MI_BUY_GIFTS );              //Add item to todo list
  addTodo( MI_PAY_PHONE );              //
  addTodo( MI_PAY_TAXES );              //
  addTodo( MI_PAPERS );                 //
  addTodo( MI_TRASH );                  //
  addTodo( MI_WASH_CAR );               //
  addTodo( MI_WASH_DISH );              //
  todoList.select(0);                   //Set the first item selected
  return true;                          //
} /* end AServerWindow :: moreTodo() */
예제 #5
0
//////////////////////////////////////////////////////////////////////////
/// A FileSystemWatcher notification when a file is changed
//////////////////////////////////////////////////////////////////////////
void SyncSystem::slotFileChanged(QString file)
{
  if(m_LostSyncTimer->isActive())
  {
    //Force the timer to run for 5 more seconds
    m_LostSyncTimer->setInterval(s_ResyncTimeout);
  }

  QSharedPointer<SyncRules> rules = GetSyncRulesForPath(file);

  SyncRuleFlags_e eFlags;
  if(rules->CheckFileAndPath(file.toLower(), eFlags))
  {
    bool binary = ((eFlags & e_Binary) == e_Binary);
    bool executable = ((eFlags & e_Executable) == e_Executable);
    addTodo(file, binary, executable, false);
  }
}
예제 #6
0
//////////////////////////////////////////////////////////////////////////
/// Send a file to the server, replacing \r\n with \n for text files.
/// 
/// Creates the timers and connects the signals.
/// Does the initial connection to the server before entering the event 
/// loop.
//////////////////////////////////////////////////////////////////////////
void SyncSystem::sendFile( const QString &filename, bool binary, bool executable )
{
  //Get the source and destination directory from the branch information
  if(m_CurrentSourcePath.isEmpty())
  {
//     QString infoString("Missing source path for branch");
//     QMessageBox::information(this, "Information", infoString, "Ok", "", "");
    return;
  }

  QString path = joinPath(m_CurrentSourcePath,filename);
  QFile file( path );

  if( file.open(QIODevice::ReadOnly) )
  {
    QFileInfo fileinfo( file );

    QByteArray data = file.readAll();
    if( !binary )
    {
      // 0d 0a -> 0a
      char *src = data.data();
      char *dst = data.data();
      char *srcend = src + data.size();
      //int state = 0;
      while( src != srcend )
      {
        if( *src != 0x0d )
        {
          *dst++ = *src;
        }
        src++;
      }
      data.resize( static_cast<int>(dst-data.data()) );
    }
    m_Connection->sendSendFile( filename, fileinfo.lastModified(), data, executable );
  }
  else
  {
    qWarning() << "[SyncSystem.sendFile] Could not open file " << filename;
    addTodo(filename, binary, executable, false, true);
  }
}
예제 #7
0
void SyncSystem::recvStatFileReply(const QString &filename, const QDateTime &mtime)
{
  //sync has been stopped, ignore what the server is sending
  if(m_SyncState == e_Idle)
    return;
  //find the unresolved file in the map
  QMap<QString,ScannerBase::FileInfo>::iterator iUnresolved = m_UnresolvedFiles.find( filename );
  if( iUnresolved == m_UnresolvedFiles.end() )
  {
    qCritical() << "[SyncSystem.Error]  *** Internal error: " << filename << " missing from unresolved list";
    return;
  }

  //check if the mtimes are similar (cant do exact comparison due to different OSes having somewhat different resolutions)
  if(!mtime.isValid() ||  abs(iUnresolved.value().mtime.secsTo(mtime)) > 1 ) 
  {
    addTodo(filename, iUnresolved.value().binary, iUnresolved.value().executable, false);
  }

  m_UnresolvedFiles.erase( iUnresolved );
  m_FilesResolved++;
  emit signalFileStats(m_FilesResolved, m_FilesPendingStat);
  updateSyncState();
}
예제 #8
0
void QTodoList::addTodoBelow(QTodoItem* sister)
{
	addTodo(findPosBelowTodoItem(sister),sister->getDepth());
}
예제 #9
0
void QTodoList::addTodoAtTop()
{
	addTodo(0,0);
}
예제 #10
0
void QTodoList::addTodoAbove(QTodoItem* sister)
{
	addTodo(findWidget(sister),sister->getDepth());
}
예제 #11
0
void QTodoList::addSubTodo(QTodoItem* parent)
{
	addTodo(findWidget(parent)+1,parent->getDepth()+1);
}