qBittorrent
anonymous_namespace{addnewtorrentdialog.cpp} Namespace Reference

Classes

class  FileStorageAdaptor
 

Functions

SettingsStoragesettings ()
 
int indexOfPath (const FileSystemPathComboEdit *fsPathEdit, const QString &savePath)
 
void setPath (FileSystemPathComboEdit *fsPathEdit, const QString &newPath)
 
void updatePathHistory (const QString &settingsKey, const QString &path, const int maxLength)
 

Variables

const QString KEY_ENABLED = QStringLiteral(SETTINGS_KEY("Enabled"))
 
const QString KEY_TOPLEVEL = QStringLiteral(SETTINGS_KEY("TopLevel"))
 
const QString KEY_SAVEPATHHISTORY = QStringLiteral(SETTINGS_KEY("SavePathHistory"))
 
const QString KEY_DOWNLOADPATHHISTORY = QStringLiteral(SETTINGS_KEY("DownloadPathHistory"))
 
const QString KEY_SAVEPATHHISTORYLENGTH = QStringLiteral(SETTINGS_KEY("SavePathHistoryLength"))
 

Function Documentation

◆ indexOfPath()

int anonymous_namespace{addnewtorrentdialog.cpp}::indexOfPath ( const FileSystemPathComboEdit fsPathEdit,
const QString &  savePath 
)

Definition at line 126 of file addnewtorrentdialog.cpp.

127  {
128  const QDir saveDir {savePath};
129  for (int i = 0; i < fsPathEdit->count(); ++i)
130  {
131  if (QDir(fsPathEdit->item(i)) == saveDir)
132  return i;
133  }
134  return -1;
135  }
QString item(int index) const
Definition: fspathedit.cpp:364

References FileSystemPathComboEdit::count(), and FileSystemPathComboEdit::item().

Referenced by setPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPath()

void anonymous_namespace{addnewtorrentdialog.cpp}::setPath ( FileSystemPathComboEdit fsPathEdit,
const QString &  newPath 
)

Definition at line 137 of file addnewtorrentdialog.cpp.

138  {
139  int existingIndex = indexOfPath(fsPathEdit, newPath);
140  if (existingIndex < 0)
141  {
142  // New path, prepend to combo box
143  fsPathEdit->insertItem(0, newPath);
144  existingIndex = 0;
145  }
146 
147  fsPathEdit->setCurrentIndex(existingIndex);
148  }
void insertItem(int index, const QString &text)
Definition: fspathedit.cpp:374
void setCurrentIndex(int index)
Definition: fspathedit.cpp:384
int indexOfPath(const FileSystemPathComboEdit *fsPathEdit, const QString &savePath)

References indexOfPath(), FileSystemPathComboEdit::insertItem(), and FileSystemPathComboEdit::setCurrentIndex().

Referenced by AddNewTorrentDialog::populateSavePaths().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ settings()

◆ updatePathHistory()

void anonymous_namespace{addnewtorrentdialog.cpp}::updatePathHistory ( const QString &  settingsKey,
const QString &  path,
const int  maxLength 
)

Definition at line 150 of file addnewtorrentdialog.cpp.

151  {
152  // Add last used save path to the front of history
153 
154  auto pathList = settings()->loadValue<QStringList>(settingsKey);
155  const int selectedSavePathIndex = pathList.indexOf(path);
156  if (selectedSavePathIndex > -1)
157  pathList.move(selectedSavePathIndex, 0);
158  else
159  pathList.prepend(path);
160  settings()->storeValue(settingsKey, QStringList(pathList.mid(0, maxLength)));
161  }
void storeValue(const QString &key, const T &value)
T loadValue(const QString &key, const T &defaultValue={}) const

References SettingsStorage::loadValue(), settings(), and SettingsStorage::storeValue().

Referenced by AddNewTorrentDialog::accept().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ KEY_DOWNLOADPATHHISTORY

const QString anonymous_namespace{addnewtorrentdialog.cpp}::KEY_DOWNLOADPATHHISTORY = QStringLiteral(SETTINGS_KEY("DownloadPathHistory"))

◆ KEY_ENABLED

const QString anonymous_namespace{addnewtorrentdialog.cpp}::KEY_ENABLED = QStringLiteral(SETTINGS_KEY("Enabled"))

◆ KEY_SAVEPATHHISTORY

const QString anonymous_namespace{addnewtorrentdialog.cpp}::KEY_SAVEPATHHISTORY = QStringLiteral(SETTINGS_KEY("SavePathHistory"))

◆ KEY_SAVEPATHHISTORYLENGTH

const QString anonymous_namespace{addnewtorrentdialog.cpp}::KEY_SAVEPATHHISTORYLENGTH = QStringLiteral(SETTINGS_KEY("SavePathHistoryLength"))

◆ KEY_TOPLEVEL

const QString anonymous_namespace{addnewtorrentdialog.cpp}::KEY_TOPLEVEL = QStringLiteral(SETTINGS_KEY("TopLevel"))