Projet

Général

Profil

Révision bbebc37b

Voir les différences:

original.cpp
522 522

  
523 523
void original::on_btnFTPPublish_clicked()
524 524
{
525
    m_currentFTPFileUpload = -1;
526

  
525 527
    m_ftp = new QFtp(this);
526 528
    connect(m_ftp, SIGNAL(commandFinished(int,bool)),
527 529
            this, SLOT(ftpCommandFinished(int,bool)));
......
548 550
    //On uploade l'album en cours
549 551
    //m_ftp->put()
550 552

  
551
    m_currentFTPFileUpload = 0;
552 553

  
553 554
}
554 555

  
555 556
void original::ftpCommandFinished(int commandId, bool error)
556 557
{
558
    qDebug() << "ftpCommandFinished : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand();
557 559
#ifndef QT_NO_CURSOR
558 560
    setCursor(Qt::ArrowCursor);
559 561
#endif
......
569 571

  
570 572
    if (m_ftp->currentCommand() == QFtp::Put) {
571 573
        qDebug() << "Put ...";
572
        //on passe au suivant
573
        on_btnPHP_clicked();
574 574
    }
575 575

  
576 576
    if (m_ftp->currentCommand() == QFtp::Get) {
......
581 581
    } else if (m_ftp->currentCommand() == QFtp::List) {
582 582
        qDebug() << "List ...";
583 583
    }
584

  
585
    //on passe au suivant
586
    if(m_currentFTPFileUpload >= 0 && m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
587
        uploadRecursif();
588
    }
584 589
}
585 590

  
586 591
void original::addToList(const QUrlInfo &urlInfo)
......
595 600

  
596 601
void original::on_btnPHP_clicked()
597 602
{
603
    qDebug() << "on_btnPHP_clicked";
598 604
    //On uploade le code php
599 605
    m_ftp->cd(ui->leFTPDirectory->text());
600 606
    QDir dir(m_baseDir.absolutePath() + "/www");
601
    dir.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
602
    QFileInfoList list = dir.entryInfoList();
603
    if(m_currentFTPFileUpload < list.count()) {
604
        qDebug() << "Upload ... " << list.at(m_currentFTPFileUpload).fileName();
605
        QFile *fic = new QFile(list.at(m_currentFTPFileUpload).absoluteFilePath());
606
        fic->open(QIODevice::ReadOnly);
607
        m_ftp->put(fic,list.at(m_currentFTPFileUpload).fileName());
608
        fic->close();
607
    m_fileListToUpload.clear();
608
    m_fileListToUploadIndex.clear();
609
    m_currentFTPFileUpload = 0;
610
    parcoursRecursif(dir.absolutePath(),"");
611
    qDebug() << m_fileListToUpload;
612
}
613

  
614
void original::uploadRecursif()
615
{
616
    qDebug() << "uploadRecursif : ";
617
    if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
618
        QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
619
        if(fi.isDir()) {
620
            QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath() + "/www");
621
            qDebug() << "mkdir : " << ladest;
622
            m_ftp->mkdir(ladest);
623
        }
624
        else {
625
            QFile *fic = new QFile(fi.absoluteFilePath());
626
            fic->open(QIODevice::ReadOnly);
627
            QString ladest = ui->leFTPDirectory->text() + "/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
628
            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
629
            m_ftp->put(fic,ladest);
630
            fic->close();
631
        }
609 632
        m_currentFTPFileUpload++;
610 633
    }
634
}
635

  
636
void original::parcoursRecursif(QString rep, QString repertoireServeur)
637
{
638
    qDebug() << "parcoursRecursif : " << rep;
639
    QDir dir(rep);
640
    dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
641
    QFileInfoList list = dir.entryInfoList();
642
    for(int i = 0; i < list.count(); i++) {
643
        qDebug() << "Ajout de ... " << list.at(i).absoluteFilePath();
644
        m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur);
645
        m_fileListToUploadIndex << list.at(i).absoluteFilePath();
646
        if(list.at(i).isDir()) {
647
            parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath() + "/www"));
648
        }
649
    }
650
}
611 651

  
652
void original::on_btnUpload_clicked()
653
{
654
    uploadRecursif();
612 655
}
original.h
73 73
                                    qint64 totalBytes);
74 74

  
75 75
    void on_btnPHP_clicked();
76
    void uploadRecursif();
77
    void parcoursRecursif(QString rep, QString repertoireServeur);
78

  
79
    void on_btnUpload_clicked();
76 80

  
77 81
private:
78 82
    Ui::original *ui;
......
80 84
    QMenu *m_menu;
81 85
    QLabel *m_labelDeposez;
82 86
    QString m_currentProjectDir;
87
    QStringList m_fileListToUploadIndex;
88
    QMap<QString,QString> m_fileListToUpload;
83 89
    int m_currentProjectPictureNumber;
84 90
    int m_currentFTPFileUpload;
85 91
    QFtp *m_ftp;
original.ui
217 217
         <item row="0" column="1">
218 218
          <widget class="QLineEdit" name="leFTPLogin">
219 219
           <property name="text">
220
            <string>rober_10820507</string>
220
            <string>webopenphoto</string>
221 221
           </property>
222 222
          </widget>
223 223
         </item>
......
231 231
         <item row="1" column="1">
232 232
          <widget class="QLineEdit" name="leFTPPass">
233 233
           <property name="text">
234
            <string>EedmuOn1</string>
234
            <string>MowlUcDyach6</string>
235 235
           </property>
236 236
          </widget>
237 237
         </item>
......
245 245
         <item row="2" column="1">
246 246
          <widget class="QLineEdit" name="leFTPServeur">
247 247
           <property name="text">
248
            <string>ftp.hebergratuit.com</string>
248
            <string>ftpperso.free.fr</string>
249 249
           </property>
250 250
          </widget>
251 251
         </item>
......
259 259
         <item row="3" column="1">
260 260
          <widget class="QLineEdit" name="leFTPDirectory">
261 261
           <property name="text">
262
            <string>/htdocs/gallery</string>
262
            <string>/gallery</string>
263 263
           </property>
264 264
          </widget>
265 265
         </item>
......
277 277
           </property>
278 278
          </widget>
279 279
         </item>
280
         <item row="4" column="4">
281
          <widget class="QPushButton" name="btnUpload">
282
           <property name="text">
283
            <string>Upload</string>
284
           </property>
285
          </widget>
286
         </item>
280 287
        </layout>
281 288
       </widget>
282 289
      </widget>

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux