added infrastructure to add a ignore list in shared files

This commit is contained in:
csoler 2017-09-10 19:58:57 +02:00
parent 160ab7b4f3
commit 884b3a6220
11 changed files with 216 additions and 11 deletions

View file

@ -54,6 +54,30 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags)
QObject::connect(ui.autoCheckDirectoriesDelay_SB,SIGNAL(valueChanged(int)),this,SLOT(updateAutoScanDirectoriesPeriod())) ;
QObject::connect(ui.shareDownloadDirectoryCB, SIGNAL(toggled(bool)), this,SLOT(updateShareDownloadDirectory())) ;
QObject::connect(ui.followSymLinks_CB, SIGNAL(toggled(bool)), this,SLOT(updateFollowSymLinks())) ;
QObject::connect(ui.prefixesIgnoreList_LE, SIGNAL(textChanged(QString)), this,SLOT(updateIgnoreLists())) ;
QObject::connect(ui.prefixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
QObject::connect(ui.suffixesIgnoreList_LE, SIGNAL(textChanged(QString)), this,SLOT(updateIgnoreLists())) ;
QObject::connect(ui.suffixesIgnoreList_CB, SIGNAL(toggled(bool)), this,SLOT(updateIgnoreLists())) ;
}
void TransferPage::updateIgnoreLists()
{
uint32_t flags = 0 ;
if(ui.prefixesIgnoreList_CB->isChecked()) flags |= RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES ;
if(ui.suffixesIgnoreList_CB->isChecked()) flags |= RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES ;
std::list<std::string> lp,ls ;
{ QStringList L = ui.prefixesIgnoreList_LE->text().split(';') ; for(QStringList::const_iterator it(L.begin());it!=L.end();++it) lp.push_back((*it).toStdString()) ; }
{ QStringList L = ui.suffixesIgnoreList_LE->text().split(';') ; for(QStringList::const_iterator it(L.begin());it!=L.end();++it) ls.push_back((*it).toStdString()) ; }
rsFiles->setIgnoreLists(lp,ls,flags) ;
std::cerr << "Setting ignore lists: " << std::endl;
std::cerr << " flags: " << flags << std::endl;
std::cerr << " prefixes: " ; for(auto it(lp.begin());it!=lp.end();++it) std::cerr << "\"" << *it << "\" " ; std::cerr << std::endl;
std::cerr << " suffixes: " ; for(auto it(ls.begin());it!=ls.end();++it) std::cerr << "\"" << *it << "\" " ; std::cerr << std::endl;
}
void TransferPage::updateMaxTRUpRate(int b)
@ -125,6 +149,32 @@ void TransferPage::load()
case RS_FILE_PERM_DIRECT_DL_NO: whileBlocking(ui._filePermDirectDL_CB)->setCurrentIndex(1) ; break ;
default: whileBlocking(ui._filePermDirectDL_CB)->setCurrentIndex(2) ; break ;
}
std::list<std::string> suffixes, prefixes;
uint32_t ignore_flags ;
rsFiles->getIgnoreLists(prefixes,suffixes,ignore_flags) ;
QString ignore_prefixes_string,ignore_suffixes_string ;
for(auto it(prefixes.begin());it!=prefixes.end();)
{
ignore_prefixes_string += QString::fromStdString(*it) ;
if(++it != prefixes.end())
ignore_prefixes_string += ";" ;
}
for(auto it(suffixes.begin());it!=suffixes.end();)
{
ignore_suffixes_string += QString::fromStdString(*it) ;
if(++it != suffixes.end())
ignore_suffixes_string += ";" ;
}
whileBlocking(ui.prefixesIgnoreList_CB)->setChecked( ignore_flags & RS_FILE_SHARE_FLAGS_IGNORE_PREFIXES ) ;
whileBlocking(ui.suffixesIgnoreList_CB)->setChecked( ignore_flags & RS_FILE_SHARE_FLAGS_IGNORE_SUFFIXES ) ;
whileBlocking(ui.prefixesIgnoreList_LE)->setText( ignore_prefixes_string );
whileBlocking(ui.suffixesIgnoreList_LE)->setText( ignore_suffixes_string );
}
void TransferPage::updateDefaultStrategy(int i)

View file

@ -50,6 +50,7 @@ class TransferPage: public ConfigPage
void updateEncryptionPolicy(int);
void updateMaxUploadSlots(int);
void updateFilePermDirectDL(int);
void updateIgnoreLists();
void editDirectories() ;
void setIncomingDirectory();

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1126</width>
<height>1099</height>
<height>1103</height>
</rect>
</property>
<layout class="QVBoxLayout" name="TransferPageVLayout">
@ -16,7 +16,7 @@
<property name="title">
<string>Shared Directories</string>
</property>
<layout class="QVBoxLayout" name="sharedGBoxVLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="shareDownloadHLayout">
<item>
@ -88,6 +88,34 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="suffixesIgnoreList_CB">
<property name="text">
<string>ignore files with these suffixes:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="suffixesIgnoreList_LE"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="prefixesIgnoreList_CB">
<property name="text">
<string>ignore files with these prefixes:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="prefixesIgnoreList_LE"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>