qBittorrent
TrackerEntriesDialog Class Reference

#include <trackerentriesdialog.h>

Inheritance diagram for TrackerEntriesDialog:
Collaboration diagram for TrackerEntriesDialog:

Public Member Functions

 TrackerEntriesDialog (QWidget *parent)
 
 ~TrackerEntriesDialog () override
 
void setTrackers (const QVector< BitTorrent::TrackerEntry > &trackers)
 
QVector< BitTorrent::TrackerEntrytrackers () const
 

Private Member Functions

void saveSettings ()
 
void loadSettings ()
 

Private Attributes

Ui::TrackerEntriesDialog * m_ui
 
SettingValue< QSize > m_storeDialogSize
 

Detailed Description

Definition at line 46 of file trackerentriesdialog.h.

Constructor & Destructor Documentation

◆ TrackerEntriesDialog()

TrackerEntriesDialog::TrackerEntriesDialog ( QWidget *  parent)
explicit

Definition at line 42 of file trackerentriesdialog.cpp.

43  : QDialog(parent)
44  , m_ui(new Ui::TrackerEntriesDialog)
46 {
47  m_ui->setupUi(this);
48 
49  connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
50  connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
51 
52  loadSettings();
53 }
Ui::TrackerEntriesDialog * m_ui
SettingValue< QSize > m_storeDialogSize
#define SETTINGS_KEY(name)

References loadSettings(), and m_ui.

Here is the call graph for this function:

◆ ~TrackerEntriesDialog()

TrackerEntriesDialog::~TrackerEntriesDialog ( )
override

Definition at line 55 of file trackerentriesdialog.cpp.

56 {
57  saveSettings();
58 
59  delete m_ui;
60 }

References m_ui, and saveSettings().

Here is the call graph for this function:

Member Function Documentation

◆ loadSettings()

void TrackerEntriesDialog::loadSettings ( )
private

Definition at line 111 of file trackerentriesdialog.cpp.

112 {
114 }
void resize(QWidget *widget, const QSize &newSize={})
Definition: utils.cpp:54

References m_storeDialogSize, and Utils::Gui::resize().

Referenced by TrackerEntriesDialog().

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

◆ saveSettings()

void TrackerEntriesDialog::saveSettings ( )
private

Definition at line 106 of file trackerentriesdialog.cpp.

107 {
108  m_storeDialogSize = size();
109 }

References m_storeDialogSize.

Referenced by ~TrackerEntriesDialog().

Here is the caller graph for this function:

◆ setTrackers()

void TrackerEntriesDialog::setTrackers ( const QVector< BitTorrent::TrackerEntry > &  trackers)

Definition at line 62 of file trackerentriesdialog.cpp.

63 {
64  int maxTier = -1;
65  QHash<int, QString> tiers; // <tier, tracker URLs>
66 
67  for (const BitTorrent::TrackerEntry &entry : trackers)
68  {
69  tiers[entry.tier] += (entry.url + '\n');
70  maxTier = std::max(maxTier, entry.tier);
71  }
72 
73  QString text = tiers.value(0);
74 
75  for (int i = 1; i <= maxTier; ++i)
76  text += ('\n' + tiers.value(i));
77 
78  m_ui->plainTextEdit->setPlainText(text);
79 }
QVector< BitTorrent::TrackerEntry > trackers() const
Definition: trackerentry.h:38

References m_ui, and trackers().

Here is the call graph for this function:

◆ trackers()

QVector< BitTorrent::TrackerEntry > TrackerEntriesDialog::trackers ( ) const

Definition at line 81 of file trackerentriesdialog.cpp.

82 {
83  const QString plainText = m_ui->plainTextEdit->toPlainText();
84  const QList<QStringView> lines = QStringView(plainText).split(u'\n');
85 
86  QVector<BitTorrent::TrackerEntry> entries;
87  entries.reserve(lines.size());
88 
89  int tier = 0;
90  for (QStringView line : lines)
91  {
92  line = line.trimmed();
93 
94  if (line.isEmpty())
95  {
96  ++tier;
97  continue;
98  }
99 
100  entries.append({line.toString(), tier});
101  }
102 
103  return entries;
104 }

References m_ui.

Referenced by setTrackers().

Here is the caller graph for this function:

Member Data Documentation

◆ m_storeDialogSize

SettingValue<QSize> TrackerEntriesDialog::m_storeDialogSize
private

Definition at line 63 of file trackerentriesdialog.h.

Referenced by loadSettings(), and saveSettings().

◆ m_ui

Ui::TrackerEntriesDialog* TrackerEntriesDialog::m_ui
private

The documentation for this class was generated from the following files: