RioCopy Class Reference
#include <RioCopy.h>
Detailed Description
Definition at line 34 of file RioCopy.h.
Constructor & Destructor Documentation
If the you use this constructor this class will show a progress dialog and the destination fileWindow will be refreshed after termination.
This option can be used when a user drag an object for copy
Definition at line 40 of file RioCopy.cpp.
00049 : QDialog( rioQt, NULL, true )
00050 #else
00051 : QDialog( rioQt )
00052 #endif
00053 {
00054 setCaption( tr( "Copy in progress..." ) );
00055
00056 #ifndef USE_QT_GRID
00057
00058 setModal( true );
00059 #endif
00060
00061 QVBoxLayout *main_layout = new QVBoxLayout( this, 5 );
00062 QHBoxLayout *current_file_layout = new QHBoxLayout( main_layout, 5 );
00063 QVBoxLayout *middle_layout = new QVBoxLayout( main_layout, 5 );
00064 QGridLayout *button_layout = new QGridLayout( main_layout, 1, 3, 5 );
00065
00066 lbl_copying_file = new QLabel( tr( "Copying file: " ), this );
00067 lbl_current_file = new QLabel( this );
00068 lbl_current_file->setAlignment( Qt::AlignLeft );
00069 lbl_overall = new QLabel( tr( "Overall progress:" ), this );
00070
00071 pb_current_file = new QProgressBar( 100, this );
00072 pb_overall = new QProgressBar( 100, this );
00073
00074 QPushButton *bt_cancel = new QPushButton( this );
00075 bt_cancel->setText( tr( "Cancel" ) );
00076 bt_cancel->setFixedWidth( 100 );
00077
00078 current_file_layout->addWidget( lbl_copying_file );
00079 current_file_layout->addWidget( lbl_current_file );
00080 middle_layout->addWidget( pb_current_file );
00081 middle_layout->addWidget( lbl_overall );
00082 middle_layout->addWidget( pb_overall );
00083 button_layout->addWidget( bt_cancel, 0, 1 );
00084
00085
00086 lbl_current_file->setFixedWidth( 200 );
00087
00088
00089 connect( bt_cancel, SIGNAL( clicked() ), this, SLOT( userCancel() ) );
00090
00091
00092 show();
00093
00094
00095 this->rioQt = rioQt;
00096 this->rioExplorer = rioExplorer;
00097 this->src_session = src_session;
00098 this->dest_session = dest_session;
00099 this->source_list = source_list;
00100 this->dest_file = strdup( dest_file.ascii() );
00101 this->destFileWindow = destFileWindow;
00102 copy_allowed = true;
00103 }
Member Function Documentation
void RioCopy::closeEvent |
( |
QCloseEvent * |
|
) |
[private] |
Reimplements the closeEvent.
Definition at line 195 of file RioCopy.cpp.
bool RioCopy::doCopy |
( |
void |
|
) |
|
Call RioExplorer::cp function Returns true if the copy was performed with success, and false otherwise.
Definition at line 109 of file RioCopy.cpp.
00110 {
00111 bool copy_status;
00112 #ifdef RIO_DEBUG2
00113 struct timeval start, end;
00114 #endif
00115
00116
00117 total_completed = 0;
00118 total_size = 0;
00119 copy_running = true;
00120 copy_status = true;
00121
00122
00123
00124 for( QStringList::Iterator it = source_list->begin();
00125 it != source_list->end();
00126 ++it )
00127 {
00128 vector<ObjectInfo> src_files;
00129 ObjectInfo fileInfo;
00130
00131 rioExplorer->getObjectInfo( (char *)(*it).ascii(), src_session, &fileInfo );
00132 copy_status = rioExplorer->ls( &fileInfo, &src_files,
00133 src_session, true, true );
00134
00135 for( unsigned int i = 0;
00136 copy_status && ( i < (unsigned int)src_files.size() );
00137 i++ )
00138 {
00139
00140 if( !src_files[i].isDir() )
00141 total_size += src_files[i].getSize();
00142 }
00143 }
00144
00145
00146 vector<ObjectInfo> fileInfo_list;
00147 ObjectInfo *fileInfo;
00148
00149 for( QStringList::Iterator it = source_list->begin();
00150 it != source_list->end();
00151 ++it )
00152 {
00153 fileInfo = new ObjectInfo;
00154 rioExplorer->getObjectInfo( (char *)(*it).ascii(), src_session, fileInfo );
00155
00156 fileInfo_list.push_back( *fileInfo );
00157 }
00158
00159
00160 copy_running = true;
00161 for( unsigned int i = 0 ; copy_allowed && ( i < fileInfo_list.size() ) ; i++ )
00162 {
00163 #ifdef RIO_DEBUG2
00164 gettimeofday( &start, NULL );
00165 #endif
00166 copy_status = rioExplorer->cp( src_session, dest_session,
00167 &fileInfo_list[i],
00168 (char *)dest_file.c_str(),
00169 true, true,
00170 ©_allowed,
00171 ¤t_file,
00172 ¤t_file_completed,
00173 ¤t_file_size,
00174 &total_completed );
00175 #ifdef RIO_DEBUG2
00176 gettimeofday( &end, NULL );
00177 RioErr << "RioCopy::doCopy Tempo para copiar o arquivo "
00178 << fileInfo_list[i].getFullName() << ": "
00179 << ( ( (double) ( end.tv_sec - start.tv_sec ) ) * 1000000.0 +
00180 ( (double) ( end.tv_usec - start.tv_usec ) ) ) / 1000000.0
00181 << " segundos " << endl;
00182 #endif
00183 }
00184
00185 copy_running = false;
00186 close();
00187
00188 return copy_status;
00189 }
QString RioCopy::truncateFileName |
( |
string |
file_name |
) |
[private] |
This function truncates the current file name if it is greater than CURRENT_FILE_MAX_LENGTH.
Definition at line 242 of file RioCopy.cpp.
00243 {
00244 QString new_file_name = QString( file_name );
00245
00246 if( new_file_name.length() > CURRENT_FILE_MAX_LENGTH )
00247 {
00248 new_file_name = new_file_name.right( CURRENT_FILE_MAX_LENGTH - 3 );
00249 new_file_name = "..." + new_file_name;
00250 }
00251
00252 return new_file_name;
00253 }
void RioCopy::updateProgress |
( |
void |
|
) |
|
bool RioCopy::userCancel |
( |
void |
|
) |
[private, virtual, slot] |
Ask user to confirm if really want to cancel the current copy If he confirms, cancel the thread execution.
Definition at line 212 of file RioCopy.cpp.
00213 {
00214 bool status;
00215 ShowMessageEvent *event;
00216
00217 status = true;
00218 event = new ShowMessageEvent( ShowMessageEvent::QUESTION,
00219 tr( "Do you really want to cancel this copy?" ),
00220 tr( "Cancel copy in progress" ) );
00221 QApplication::sendEvent( rioQt, event );
00222
00223 int result = event->getResult();
00224 delete event;
00225
00226 if( result == QMessageBox::Yes )
00227 {
00228 copy_allowed = false;
00229 }
00230 else
00231 {
00232 status = false;
00233 }
00234
00235 return status;
00236 }
Field Documentation
The documentation for this class was generated from the following files: