1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-12 07:48:04 +00:00

Add lookup function to get PathType display names

This commit is contained in:
Chocobo1 2016-05-17 03:02:27 +08:00
parent 83b58468d9
commit 6ead0ae9ee
3 changed files with 21 additions and 6 deletions

View File

@ -128,10 +128,8 @@ QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const
else if (role == Qt::DisplayRole) { else if (role == Qt::DisplayRole) {
switch (pathData->downloadType) { switch (pathData->downloadType) {
case DOWNLOAD_IN_WATCH_FOLDER: case DOWNLOAD_IN_WATCH_FOLDER:
value = tr("Watch Folder");
break;
case DEFAULT_LOCATION: case DEFAULT_LOCATION:
value = tr("Default Folder"); value = pathTypeDisplayName(pathData->downloadType);
break; break;
case CUSTOM_LOCATION: case CUSTOM_LOCATION:
value = pathData->downloadPath; value = pathData->downloadPath;
@ -392,3 +390,18 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
} }
} }
} }
QString ScanFoldersModel::pathTypeDisplayName(const PathType type)
{
switch(type) {
case DOWNLOAD_IN_WATCH_FOLDER:
return tr("Monitored folder");
case DEFAULT_LOCATION:
return tr("Default save location");
case CUSTOM_LOCATION:
return tr("Browse...");
default:
qDebug("Invalid PathType: %d", type);
};
return QString();
}

View File

@ -73,6 +73,8 @@ public:
static void freeInstance(); static void freeInstance();
static ScanFoldersModel *instance(); static ScanFoldersModel *instance();
static QString pathTypeDisplayName(const PathType type);
int rowCount(const QModelIndex &parent = QModelIndex()) const; int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;

View File

@ -63,9 +63,9 @@ QWidget *ScanFoldersDelegate::createEditor(QWidget *parent, const QStyleOptionVi
QComboBox* editor = new QComboBox(parent); QComboBox* editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus); editor->setFocusPolicy(Qt::StrongFocus);
editor->addItem(tr("Same as monitored folder")); editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::DOWNLOAD_IN_WATCH_FOLDER));
editor->addItem(tr("Default save location")); editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::DEFAULT_LOCATION));
editor->addItem(tr("Browse...")); editor->addItem(ScanFoldersModel::pathTypeDisplayName(ScanFoldersModel::CUSTOM_LOCATION));
if (index.data(Qt::UserRole).toInt() == ScanFoldersModel::CUSTOM_LOCATION) { if (index.data(Qt::UserRole).toInt() == ScanFoldersModel::CUSTOM_LOCATION) {
editor->insertSeparator(3); editor->insertSeparator(3);
editor->addItem(index.data().toString()); editor->addItem(index.data().toString());