Advertisement
Guest User

Untitled

a guest
Jun 15th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. void MainWindow::onDirectoryChanged( const QString& path )
  2. {
  3.     foreach( const QFileInfo& fileInfo, QDir( path ).entryInfoList( QDir::NoDotAndDotDot | QDir::Files ) )
  4.     {
  5.         bool is_success_copy = false;
  6.  
  7.         for( int row = 0; row != ui->copyPathList->count(); ++row )
  8.         {
  9.             QString dest_dir_path = ui->copyPathList->item( row )->text();
  10.  
  11.             if( !QFileInfo( dest_dir_path ).exists() )
  12.             {
  13.                 ui->copyPathList->item( row )->setBackgroundColor( Qt::red );
  14.                 continue;
  15.             }
  16.             else
  17.             {
  18.                 is_success_copy = true;
  19.                 ui->copyPathList->item( row )->setBackgroundColor( Qt::color0 );
  20.             }
  21.  
  22.             QString from_path = fileInfo.filePath();
  23.             QString to_path = QString( "%1/%2" ).arg( dest_dir_path, fileInfo.fileName() );
  24.  
  25.             QFile::copy( from_path, to_path );
  26.         }
  27.  
  28.         if( is_success_copy )
  29.             QFile::remove( fileInfo.absoluteFilePath() );
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement