FtpWindow::FtpWindow(QWidget *parent) : QDialog(parent), ftp(0), networkSession(0) { ftpServerLabel = new QLabel(tr("Ftp &server:")); ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); fileList = new QTreeWidget; fileList->setEnabled(false); fileList->setRootIsDecorated(false); fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); fileList->header()->setStretchLastSection(false); connectButton = new QPushButton(tr("Connect")); connectButton->setDefault(true); cdToParentButton = new QPushButton; cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); downloadButton = new QPushButton(tr("Download")); downloadButton->setEnabled(false); quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); progressDialog = new QProgressDialog(this); connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(processItem(QTreeWidgetItem*,int))); connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton())); connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect())); connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowTitle(tr("FTP")); }
CFtpSelection::CFtpSelection(QWidget *parent): QDialog(parent) { _ui.setupUi(this); connect(_ui.connectButton, SIGNAL(clicked()), this, SLOT(ConnectButtonClicked())); connect(_ui.doneButton, SIGNAL(clicked()), this, SLOT(DoneButtonClicked())); connect(_ui.cdToParrent, SIGNAL(clicked()), this, SLOT(cdToParent())); connect(_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); // file list connect(_ui.fileList, SIGNAL(itemActivated(QTreeWidgetItem *,int)),this, SLOT(processItem(QTreeWidgetItem *,int))); _ui.fileList->setEnabled(false); _ui.fileList->setRootIsDecorated(false); _ui.fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); _ui.fileList->header()->setStretchLastSection(false); // buttons _ui.cdToParrent->setEnabled(false); _ui.doneButton->setEnabled(false); status = false; }
int FtpWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: connectOrDisconnect(); break; case 1: downloadFile(); break; case 2: cancelDownload(); break; case 3: ftpCommandFinished((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 4: addToList((*reinterpret_cast< const QUrlInfo(*)>(_a[1]))); break; case 5: processItem((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 6: cdToParent(); break; case 7: updateDataTransferProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; case 8: enableDownloadButton(); break; default: ; } _id -= 9; } return _id; }
FtpWindow::FtpWindow(QWidget *parent) : QDialog(parent), ftp(0), networkSession(0) { ftpServerLabel = new QLabel(tr("Ftp &server:")); ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com"); ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server.")); #ifdef Q_OS_SYMBIAN // Use word wrapping to fit the text on screen statusLabel->setWordWrap( true ); #endif fileList = new QTreeWidget; fileList->setEnabled(false); fileList->setRootIsDecorated(false); fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); fileList->header()->setStretchLastSection(false); connectButton = new QPushButton(tr("Connect")); connectButton->setDefault(true); cdToParentButton = new QPushButton; cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); downloadButton = new QPushButton(tr("Download")); downloadButton->setEnabled(false); quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(downloadButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); progressDialog = new QProgressDialog(this); connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(processItem(QTreeWidgetItem*,int))); connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton())); connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); connect(connectButton, SIGNAL(clicked()), this, SLOT(connectOrDisconnect())); connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); #ifndef Q_OS_SYMBIAN topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); #else // Make app better lookin on small screen QHBoxLayout *topLayout2 = new QHBoxLayout; topLayout2->addWidget(cdToParentButton); topLayout2->addWidget(connectButton); #endif QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); #ifdef Q_OS_SYMBIAN // Make app better lookin on small screen mainLayout->addLayout(topLayout2); #endif mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); mainLayout->addWidget(buttonBox); setLayout(mainLayout); QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton())); connectButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); qDebug() << "Opening session..."; networkSession->open(); } setWindowTitle(tr("FTP")); }
FtpDialog::FtpDialog(QWidget *parent, QString pathToVideoFile, QString videoFileName) : QDialog(parent) { m_pathToVideoFile = pathToVideoFile; m_videoFileName = videoFileName; ftp = NULL; ftpServerLabel = new QLabel(tr("Ftp &server:"), this); //ftpServerLineEdit = new QLineEdit("ftp.qt.nokia.com", this); ftpServerLineEdit = new QLineEdit("127.0.0.1", this); ftpServerLabel->setBuddy(ftpServerLineEdit); statusLabel = new QLabel(tr("Please enter the name of an FTP server."), this); statusLabel->setWordWrap(true); fileList = new QTreeWidget(this); fileList->setEnabled(false); fileList->setRootIsDecorated(false); fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time")); fileList->header()->setStretchLastSection(false); connectButton = new QPushButton(tr("Connect"), this); connectButton->setDefault(true); cdToParentButton = new QPushButton(this); cdToParentButton->setIcon(QPixmap(":/images/cdtoparent.png")); cdToParentButton->setEnabled(false); uploadButton = new QPushButton(tr("Upload"), this); uploadButton->setEnabled(false); quitButton = new QPushButton(tr("Quit"), this); QHBoxLayout * buttonBoxLayout = new QHBoxLayout; buttonBoxLayout->addWidget(uploadButton); buttonBoxLayout->addWidget(quitButton); /*buttonBox = new QDialogButtonBox(this); buttonBox->addButton(uploadButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);*/ progressDialog = new QProgressDialog(this); connect(quitButton, SIGNAL(clicked()), this, SLOT(reject())); connect(connectButton, SIGNAL(clicked()), this, SLOT(onConnectOrDisconnect())); connect(fileList, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(processItem(QTreeWidgetItem*,int))); //connect(fileList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(enableDownloadButton())); connect(uploadButton, SIGNAL(clicked()), this, SLOT(uploadFile())); connect(cdToParentButton, SIGNAL(clicked()), this, SLOT(cdToParent())); /* connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));*/ QHBoxLayout * topLayout = new QHBoxLayout; topLayout->addWidget(ftpServerLabel); topLayout->addWidget(ftpServerLineEdit); topLayout->addWidget(cdToParentButton); topLayout->addWidget(connectButton); QVBoxLayout * mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); mainLayout->addWidget(fileList); mainLayout->addWidget(statusLabel); //mainLayout->addWidget(buttonBox); mainLayout->addLayout(buttonBoxLayout); setLayout(mainLayout); QNetworkConfigurationManager manager; //qDebug() << manager.capabilities() << "end"; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { // Get saved network configuration QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); // If the saved network configuration is not currently discovered use the system default QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(enableConnectButton())); connectButton->setEnabled(false); quitButton->setEnabled(false); statusLabel->setText(tr("Opening network session.")); networkSession->open(); } setWindowTitle(tr("FTP")); }