Use tuple instead of pair of pairs
This commit is contained in:
parent
267f1df204
commit
1d52ff388f
@ -148,15 +148,13 @@ void MainWindow::getNames() {
|
||||
* orig - original filenames
|
||||
* renamed - renamed filenames (sorted in the same order as `orig`)
|
||||
*/
|
||||
void renameFiles(
|
||||
const std::vector< std::pair< std::pair< int, std::string >,
|
||||
std::pair< std::string, std::string > > >
|
||||
&renamed ) {
|
||||
for ( auto renamed_it = renamed.begin(); renamed_it != renamed.end();
|
||||
++renamed_it ) {
|
||||
void renameFiles( const std::vector<
|
||||
std::tuple< int, std::string, std::string, std::string > >
|
||||
&renamed_files ) {
|
||||
for ( const auto &renamed : renamed_files ) {
|
||||
FSLib::rename(
|
||||
renamed_it->first.second + "/" + renamed_it->second.first,
|
||||
renamed_it->first.second + "/" + renamed_it->second.second );
|
||||
std::get< 1 >( renamed ) + "/" + std::get< 2 >( renamed ),
|
||||
std::get< 1 >( renamed ) + "/" + std::get< 3 >( renamed ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -222,15 +220,15 @@ void MainWindow::finishedSelection() {
|
||||
|
||||
auto buff = tx->get_buffer();
|
||||
buff->place_cursor( buff->begin() );
|
||||
buff->insert_at_cursor( renamed_files[0].second.first.c_str() );
|
||||
buff->insert_at_cursor( std::get< 2 >( renamed_files[0] ).c_str() );
|
||||
buff->insert_at_cursor( " --> " );
|
||||
buff->insert_at_cursor( renamed_files[0].second.second.c_str() );
|
||||
buff->insert_at_cursor( std::get< 3 >( renamed_files[0] ).c_str() );
|
||||
|
||||
for ( size_t i = 1; i < renamed_files.size(); i++ ) {
|
||||
buff->insert_at_cursor( "\n" );
|
||||
buff->insert_at_cursor( renamed_files[i].second.first.c_str() );
|
||||
buff->insert_at_cursor( std::get< 2 >( renamed_files[i] ).c_str() );
|
||||
buff->insert_at_cursor( " --> " );
|
||||
buff->insert_at_cursor( renamed_files[i].second.second.c_str() );
|
||||
buff->insert_at_cursor( std::get< 3 >( renamed_files[i] ).c_str() );
|
||||
}
|
||||
|
||||
auto response = dialog->run();
|
||||
|
@ -177,8 +177,7 @@ std::vector< string > getEpisodeNames( const string &id, const string &season,
|
||||
return episodes;
|
||||
}
|
||||
|
||||
std::vector<
|
||||
std::pair< std::pair< int, string >, std::pair< string, string > > >
|
||||
std::vector< std::tuple< int, string, string, string > >
|
||||
getRenamedFiles( const string &show, int season, const string id,
|
||||
const string &language, const string &pattern,
|
||||
const bool &linux, const std::map< int, string > &files,
|
||||
@ -193,9 +192,7 @@ getRenamedFiles( const string &show, int season, const string id,
|
||||
return {};
|
||||
|
||||
// vector of pairs <ep_num,dir>,<original_name,new_name>
|
||||
std::vector<
|
||||
std::pair< std::pair< int, string >, std::pair< string, string > > >
|
||||
renamed_files;
|
||||
std::vector< std::tuple< int, string, string, string > > renamed_files;
|
||||
|
||||
for ( const auto &x : files ) {
|
||||
auto last = x.second.find_last_of( _tv_rename_dir_divider );
|
||||
@ -257,9 +254,7 @@ getRenamedFiles( const string &show, int season, const string id,
|
||||
}
|
||||
}
|
||||
}
|
||||
renamed_files.emplace_back(
|
||||
std::pair< int, string >( x.first, dir ),
|
||||
std::pair< string, string >( og_name, name ) );
|
||||
renamed_files.emplace_back( x.first, dir, og_name, name );
|
||||
}
|
||||
}
|
||||
return renamed_files;
|
||||
@ -335,10 +330,9 @@ void singleSeason( const string &path, const string &show, int season,
|
||||
goto end;
|
||||
|
||||
if ( print || !trust ) {
|
||||
for ( auto renamed = renamed_files.begin();
|
||||
renamed != renamed_files.end(); ++renamed ) {
|
||||
cout << renamed->second.first << " --> " << renamed->second.second
|
||||
<< std::endl;
|
||||
for ( const auto renamed : renamed_files ) {
|
||||
cout << std::get< 2 >( renamed ) << " --> "
|
||||
<< std::get< 3 >( renamed ) << std::endl;
|
||||
}
|
||||
|
||||
if ( !trust ) {
|
||||
@ -352,16 +346,15 @@ void singleSeason( const string &path, const string &show, int season,
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto renamed = renamed_files.begin(); renamed != renamed_files.end();
|
||||
++renamed ) {
|
||||
FSLib::rename( renamed->first.second + _tv_rename_dir_divider +
|
||||
renamed->second.first,
|
||||
renamed->first.second + _tv_rename_dir_divider +
|
||||
renamed->second.second );
|
||||
for ( const auto renamed : renamed_files ) {
|
||||
FSLib::rename( std::get< 1 >( renamed ) + _tv_rename_dir_divider +
|
||||
std::get< 2 >( renamed ),
|
||||
std::get< 1 >( renamed ) + _tv_rename_dir_divider +
|
||||
std::get< 3 >( renamed ) );
|
||||
if ( found_files == nullptr ) {
|
||||
files_ptr[0][renamed->first.first] = renamed->first.second +
|
||||
_tv_rename_dir_divider +
|
||||
renamed->second.second;
|
||||
files_ptr[0][std::get< 0 >( renamed )] = std::get< 1 >( renamed ) +
|
||||
_tv_rename_dir_divider +
|
||||
std::get< 3 >( renamed );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "network.hpp"
|
||||
@ -39,8 +40,7 @@ void singleSeason( const string &path, const string &show, int season,
|
||||
|
||||
#ifdef GUI
|
||||
|
||||
std::vector<
|
||||
std::pair< std::pair< int, string >, std::pair< string, string > > >
|
||||
std::vector< std::tuple< int, string, string, string > >
|
||||
getRenamedFiles( const string &show, int season, const string id,
|
||||
const string &language, const string &pattern,
|
||||
const bool &linux, const std::map< int, string > &files,
|
||||
|
Loading…
Reference in New Issue
Block a user