[Qt] Obtenir une arborecense d'un serveur ftp

jyz93 Messages postés 3 Date d'inscription samedi 21 mars 2009 Statut Membre Dernière intervention 27 janvier 2010 - 11 juin 2009 à 12:56
jyz93 Messages postés 3 Date d'inscription samedi 21 mars 2009 Statut Membre Dernière intervention 27 janvier 2010 - 18 juin 2009 à 00:16
Bonjour a tous,

Voila Je suis en train de programmé un client
ftp et j'ai besoin d'obtenir l'arborescence du serveur sur lequel je
suis connecté afin de pouvoir modifié mon site ect...
Je travail en
C++ avec Qt. J'ai vu la méthode QFtp::list(); le problème c'est que je
ne vois pas comment l'utilisé etant donné qu'elle retourne un int :s
J'aimerais par la suite placé mon arborecense dans une architecture mvc avec une vue de type QTreeView.

Merci d'avance pour votre aide,

2 réponses

SebLinck Messages postés 212 Date d'inscription mardi 17 mai 2005 Statut Membre Dernière intervention 23 juin 2011
16 juin 2009 à 16:34
int QFtp::list ( const QString & dir = QString() )

Lists the contents of directory dir on the FTP server. If dir is empty, it lists the contents of the current directory.


The listInfo() signal is emitted for each directory entry found.


The function does not block and returns immediately. The command is
scheduled, and its execution is performed asynchronously. The function
returns a unique identifier which is passed by commandStarted() and commandFinished().


When the command is started the commandStarted() signal is emitted. When it is finished the commandFinished() signal is emitted.


See also listInfo(), commandStarted(), and commandFinished().





Cordialement,
Sébastien.
0
jyz93 Messages postés 3 Date d'inscription samedi 21 mars 2009 Statut Membre Dernière intervention 27 janvier 2010
18 juin 2009 à 00:16
Donc voici mon code (reduite) :
fileList = new QTreeWidget;  //Je fais mon QTreeWidget
fileList->setEnabled(false);
fileList->setRootIsDecorated(false);
fileList->setHeaderLabels(QStringList() << tr("Name") << tr("Size") << tr("Owner") << tr("Group") << tr("Time"));
fileList->header()->setStretchLastSection(false);

QWidget *widget = new QWidget;
QGridLayout layout_1 = new QGridLayout;
layout_1->addWidget(fileList, 3, 0);      //Je place mon QTreeWidget dans ma fenêtre via un layout
widget->setLayout(layout_1);

connect(ftp, SIGNAL(commandFinished(int, bool)), this, SLOT(commandefini(int, bool)));
connect(ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(arbo(QUrlInfo)));  //connexion des signaux avec les slots...
connect(connexion,SIGNAL(clicked()),qApp,SLOT(connect1()));

void fenetre::connect1()
{

ftp->connectToHost(ftptext->text(), portnum->value());
ftp->login(utilisateurtext->text(), mdptext->text());

}

void fenetre::commandefini(int i, bool i2)
{

        if (ftp->currentCommand() == 3)  //Une fois que connectToHost se termine, je lance ftp->list();
        {
            if (i2)
            {
                ftp->close();
            }
            else
            {
            int id = ftp->list();
            qDebug()<< id << ftp->state();
            }
        }

        if (ftp->currentCommand() == 4)
        {
        }
}

void fenetre::arbo(const QUrlInfo &arbo1)
{
    qDebug()<<"arbo : "<< arbo1.name();

     QTreeWidgetItem *item = new QTreeWidgetItem;
     item->setText(0, arbo1.name());
     item->setText(1, QString::number(arbo1.size()));
     item->setText(2, arbo1.owner());
     item->setText(3, arbo1.group());
     item->setText(4, arbo1.lastModified().toString("MMM dd yyyy"));

     isDirectory[arbo1.name()] = arbo1.isDir();
     fileList->addTopLevelItem(item);
     if (!fileList->currentItem())
     {
         fileList->setCurrentItem(fileList->topLevelItem(0));
         fileList->setEnabled(true);
     }

}

Mais j'obtient ceci apres comme valeur a la ligne : qDebug()<< id << ftp->state();

Starting C:/jéjé/jeje/projet/Net Developpe/release/Net Developpe.exe...
3 3 

id vaut 3 or il devrait valoir 6, valeur de ftp->list(); et non 3 la valeur de  ftp->connectToHost();
Cela a donc pour effet de ne pas lancé mon slot arbo...
0
Rejoignez-nous