#include <addtorrentdialog.h>
Inheritance diagram for AddTorrentDialog:


Definition at line 31 of file addtorrentdialog.h.
Public Slots | |
| void | setTorrent (const QString &torrentFile) |
Public Member Functions | |
| AddTorrentDialog (QWidget *parent=0) | |
| QString | torrentFileName () const |
| QString | destinationFolder () const |
Private Slots | |
| void | selectTorrent () |
| void | selectDestination () |
| void | enableOkButton () |
Private Attributes | |
| Ui_AddTorrentFile | ui |
| QString | destinationDirectory |
| QString | lastDirectory |
| QString | lastDestinationDirectory |
| AddTorrentDialog::AddTorrentDialog | ( | QWidget * | parent = 0 |
) |
Definition at line 46 of file addtorrentdialog.cpp.
References QObject::connect(), QDir::current(), destinationDirectory, path, selectDestination(), selectTorrent(), setTorrent(), SIGNAL, SLOT, and ui.
00047 : QDialog(parent, Qt::Sheet) 00048 { 00049 ui.setupUi(this); 00050 00051 connect(ui.browseTorrents, SIGNAL(clicked()), 00052 this, SLOT(selectTorrent())); 00053 connect(ui.browseDestination, SIGNAL(clicked()), 00054 this, SLOT(selectDestination())); 00055 connect(ui.torrentFile, SIGNAL(textChanged(const QString &)), 00056 this, SLOT(setTorrent(const QString &))); 00057 00058 ui.destinationFolder->setText(destinationDirectory = QDir::current().path()); 00059 ui.torrentFile->setFocus(); 00060 }
Here is the call graph for this function:

| QString AddTorrentDialog::torrentFileName | ( | ) | const |
Definition at line 144 of file addtorrentdialog.cpp.
References ui.
00145 { 00146 return ui.torrentFile->text(); 00147 }
| QString AddTorrentDialog::destinationFolder | ( | ) | const |
Definition at line 149 of file addtorrentdialog.cpp.
References ui.
Referenced by MainWindow::acceptFileDrop(), and MainWindow::addTorrent().
00150 { 00151 return ui.destinationFolder->text(); 00152 }
| void AddTorrentDialog::setTorrent | ( | const QString & | torrentFile | ) | [slot] |
Definition at line 90 of file addtorrentdialog.cpp.
References MetaInfo::announceUrl(), MetaInfo::comment(), MetaInfo::createdBy(), enableOkButton(), MetaInfo::fileForm(), info, QString::isEmpty(), lastDestinationDirectory, lastDirectory, MetaInfo::multiFiles(), name, MetaInfoSingleFile::name, MetaInfo::name(), QFile::open(), MetaInfo::parse(), MetaInfoMultiFile::path, QIODevice::readAll(), QIODevice::ReadOnly, MetaInfo::singleFile(), MetaInfo::SingleFileForm, stringNumber(), MetaInfo::totalSize(), and ui.
Referenced by MainWindow::acceptFileDrop(), MainWindow::addTorrent(), AddTorrentDialog(), and selectTorrent().
00091 { 00092 if (torrentFile.isEmpty()) { 00093 enableOkButton(); 00094 return; 00095 } 00096 00097 ui.torrentFile->setText(torrentFile); 00098 if (!torrentFile.isEmpty()) 00099 lastDirectory = QFileInfo(torrentFile).absolutePath(); 00100 00101 if (lastDestinationDirectory.isEmpty()) 00102 lastDestinationDirectory = lastDirectory; 00103 00104 MetaInfo metaInfo; 00105 QFile torrent(torrentFile); 00106 if (!torrent.open(QFile::ReadOnly) || !metaInfo.parse(torrent.readAll())) { 00107 enableOkButton(); 00108 return; 00109 } 00110 00111 ui.torrentFile->setText(torrentFile); 00112 ui.announceUrl->setText(metaInfo.announceUrl()); 00113 if (metaInfo.comment().isEmpty()) 00114 ui.commentLabel->setText("<unknown>"); 00115 else 00116 ui.commentLabel->setText(metaInfo.comment()); 00117 if (metaInfo.createdBy().isEmpty()) 00118 ui.creatorLabel->setText("<unknown>"); 00119 else 00120 ui.creatorLabel->setText(metaInfo.createdBy()); 00121 ui.sizeLabel->setText(stringNumber(metaInfo.totalSize())); 00122 if (metaInfo.fileForm() == MetaInfo::SingleFileForm) { 00123 ui.torrentContents->setHtml(metaInfo.singleFile().name); 00124 } else { 00125 QString html; 00126 foreach (MetaInfoMultiFile file, metaInfo.multiFiles()) { 00127 QString name = metaInfo.name(); 00128 if (!name.isEmpty()) { 00129 html += name; 00130 if (!name.endsWith('/')) 00131 html += '/'; 00132 } 00133 html += file.path + "<br>"; 00134 } 00135 ui.torrentContents->setHtml(html); 00136 } 00137 00138 QFileInfo info(torrentFile); 00139 ui.destinationFolder->setText(info.absolutePath()); 00140 00141 enableOkButton(); 00142 }
| void AddTorrentDialog::selectTorrent | ( | ) | [private, slot] |
Definition at line 62 of file addtorrentdialog.cpp.
References QFileDialog::getOpenFileName(), QString::isEmpty(), lastDirectory, and setTorrent().
Referenced by AddTorrentDialog().
00063 { 00064 QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a torrent file"), 00065 lastDirectory, 00066 tr("Torrents (*.torrent);; All files (*.*)")); 00067 if (fileName.isEmpty()) 00068 return; 00069 lastDirectory = QFileInfo(fileName).absolutePath(); 00070 setTorrent(fileName); 00071 }
| void AddTorrentDialog::selectDestination | ( | ) | [private, slot] |
Definition at line 73 of file addtorrentdialog.cpp.
References destinationDirectory, enableOkButton(), QFileDialog::getExistingDirectory(), QString::isEmpty(), lastDestinationDirectory, and ui.
Referenced by AddTorrentDialog().
00074 { 00075 QString dir = QFileDialog::getExistingDirectory(this, tr("Choose a destination directory"), 00076 lastDestinationDirectory); 00077 if (dir.isEmpty()) 00078 return; 00079 lastDestinationDirectory = destinationDirectory = dir; 00080 ui.destinationFolder->setText(destinationDirectory); 00081 enableOkButton(); 00082 }
| void AddTorrentDialog::enableOkButton | ( | ) | [private, slot] |
Definition at line 84 of file addtorrentdialog.cpp.
References ui.
Referenced by selectDestination(), and setTorrent().
00085 { 00086 ui.okButton->setEnabled(!ui.destinationFolder->text().isEmpty() 00087 && !ui.torrentFile->text().isEmpty()); 00088 }
Ui_AddTorrentFile AddTorrentDialog::ui [private] |
Definition at line 50 of file addtorrentdialog.h.
Referenced by AddTorrentDialog(), destinationFolder(), enableOkButton(), selectDestination(), setTorrent(), and torrentFileName().
Definition at line 51 of file addtorrentdialog.h.
Referenced by AddTorrentDialog(), and selectDestination().
QString AddTorrentDialog::lastDirectory [private] |
Definition at line 53 of file addtorrentdialog.h.
Referenced by selectDestination(), and setTorrent().
1.5.1