//******************************************************************* // md5_create PRIVATE //******************************************************************* void QBtWorkspace::md5_create() { QBtView* src = 0; QBtView* dst = 0; if( !src_and_dst_view( src, dst ) ) return; SelectionsSet data = SelectionsSet(); get_selections( src, data ); if( data.size() != 1 ) return; const QString src_fpath = *data.begin(); const QString src_dir = src->current_path(); const QString dst_fpath = src_fpath + ".md5sum"; if( QFileInfo( dst_fpath ).exists() ) QFile::remove( dst_fpath ); if( QFileInfo( src_fpath ).isDir() ) { return; } if( !QFileInfo( src_dir ).isWritable() ) { QMessageBox::critical( this, tr( Md5 ), tr( NoWritableDir ).arg( src_dir ) ); return; } QBtShared::set_cursor( Qt::BusyCursor ); const QString cmd = Md5Create.arg( QBtShared::quoted_fpath( src_fpath ), QBtShared::quoted_fpath( dst_fpath ) ); system( cmd.toLocal8Bit() ); QBtShared::restore_cursor(); src->refresh( QFileInfo( dst_fpath).fileName() ); if( src->current_path() == dst->current_path() ) dst->refresh(); }
void QBtWorkspace::drop_files(const QMap<QString, QVariant> &userInfo) { QStringList files = userInfo["files"].toStringList(); QString dropPath = userInfo["drop_target"].toString(); SelectionsSet dropedFiles; foreach (QString file, files) { dropedFiles.insert(file); }
//******************************************************************* // set_files PUBLIC //******************************************************************* void QBtDeleteQuest::set_files( const SelectionsSet& in_data ) { SelectionsSet::const_iterator it = in_data.begin(); const SelectionsSet::const_iterator end = in_data.end(); while( it != end ) { QTreeWidgetItem* const itm = new QTreeWidgetItem( view_ ); itm->setText( 0, QFileInfo( *it ).fileName() ); ++it; } view_->resizeColumnToContents( 0 ); }
//******************************************************************* // join_files PRIVATE //******************************************************************* void QBtWorkspace::join_files() { QBtView* src = 0; QBtView* dst = 0; if( !src_and_dst_view( src, dst ) ) return; // aby moc cos laczyc musza byc zaznaczone co najmniej 1 plik. SelectionsSet data = SelectionsSet(); get_selections( src, data ); if( data.empty() ) return; // uzytkownik musi miec uprawnienia do zapisu w docelowym katalogu QString dst_dir = dst->current_path(); const QFileInfo dst_dir_fi( dst_dir ); if( !dst_dir_fi.isWritable() ) { QMessageBox::critical( this, tr( FilesJoining ), tr( NoWritableDir ).arg( dst_dir ) ); return; } // uzytkownik musi podac nazwe pliku wynikowego bool ok; const QString fname = QInputDialog::getText( this, tr( FilesJoining ), tr( EnterFileName ), QLineEdit::Normal, QString(), &ok ); if( !ok || fname.trimmed().isEmpty() ) return; // Absolutna sciezka do pliku wynikowego. if( !dst_dir.endsWith( '/' ) ) dst_dir += '/'; const QString dst_fpath = dst_dir + fname; // jesli plik juz istnieje uzytkownik musi podjac decyzje co z tym fantem zrobic const QFileInfo dst_fi( dst_fpath ); if( dst_fi.exists() ) { const int answer = QMessageBox::question( this, tr( FilesJoining ), tr( CanOverwrite ).arg( dst_fpath ), QMessageBox::Yes, QMessageBox::No ); if( QMessageBox::No == answer ) return; } // wykonaj laczenie plikow QBtFileJoiner dialog( this, data, dst_fpath ); if( QDialog::Accepted == dialog.exec() ) { // odswiez pokazywana zawartosc i ustaw sie na tym pliku. dst->refresh( QFileInfo( dst_fpath ).fileName() ); if( src->current_path() == dst->current_path() ) src->refresh(); } }
//******************************************************************* // access_permissions PRIVATE //******************************************************************* void QBtView::access_permissions() { SelectionsSet data = get_selected_items(); if( data.empty() ) { if( QBtShared::is_regular_file( selected_file_full_name() ) ) { const QFileInfo fi( selected_file_path() ); data.insert( fi.absoluteFilePath() ); } } if( data.empty() ) return; QBtAttrDialog dialog( this, data ); if( QDialog::Accepted == dialog.exec() ) refresh(); }
//******************************************************************* // md5_check PRIVATE //******************************************************************* void QBtWorkspace::md5_check() { QBtView* src = 0; QBtView* dst = 0; if( !src_and_dst_view( src, dst ) ) return; SelectionsSet data = SelectionsSet(); get_selections( src, data ); if( data.size() != 1 ) return; const QString src_fpath = *data.begin(); QBtSystemCall sc; sc.run( Md5Check.arg( QBtShared::quoted_fpath( src_fpath ) ) ); const QString msg = sc.result(); QMessageBox::information( this, tr( Md5 ), msg ); }
//******************************************************************* // remove_selected PRIVATE //------------------------------------------------------------------- // Funkcja wywolywana po nacisnieciu klawiszy Delete lub F8. // Usuwa z dysku zaznaczone /lub aktualny plik. //******************************************************************* void QBtView::remove_selected() { SelectionsSet data = get_selected_items(); if( data.empty() ) { if( QBtShared::is_regular_file( selected_file_full_name() ) ) { const QFileInfo fi( selected_file_path() ); data.insert( fi.absoluteFilePath() ); } } if( data.empty() ) return; QBtDeleteQuest quest( this ); quest.set_files( data ); if( quest.exec() != QDialog::Accepted ) return; const bool wipe = quest.to_wipe(); QBtDeleter deleter( this ); deleter.set_data( data, wipe ); if( QDialog::Accepted == deleter.exec() ) refresh(); }
//******************************************************************* // get_selections PRIVATE //******************************************************************* bool QBtWorkspace::get_selections( QBtView* const in_view, SelectionsSet& out_data ) const { out_data = in_view->get_selected_items(); return !out_data.empty(); }