Results 1 to 4 of 4

Thread: QUrlOperator bug or what?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QUrlOperator bug or what?

    Hi Everyone,
    I have been trying to use QUrlOperator to copy some files from one loaction to another. The strange thing is that I keep on receiving dataTransferProgress signal and the progress bar advances but no file is created and everything goes normal untill I get a finished signal but nothing is copied. After waiting for some more time I found out that I keep on receiving dataTransferProgress signal and then a finished signal and this time the file is copied! This second time gets started without any interaction from me.

    I am using Qt 3.3.7 under Linux Kubuntu feisty.

    Here is my code:

    Qt Code:
    1. void MyClass::CopyMarked(bool move)
    2. {
    3. // m_currDir = "/tmp";
    4. if (m_markedList.isEmpty())
    5. return;
    6.  
    7. QString msg = (move) ?
    8. tr("Moving marked files...") : tr("Copying marked files...");
    9.  
    10. //.....
    11. // Here a seelctor dialog appears to choose the destination
    12. //......
    13. if(selector.exec() == QDialog::Accepted){
    14. QUrlOperator* copyOperator = new QUrlOperator;
    15.  
    16. int size = 0;
    17. QString msg;
    18. //m_markedList contains the names of the files to be copied or moved
    19. for (unsigned int i = 0; i < m_markedList.count() ; i++)
    20. {
    21. QFile file(*m_markedList.at(i));
    22. size += file.size();
    23. }
    24.  
    25. m_copyProgress = new MythProgressDialog(msg, size);
    26.  
    27. connect(copyOperator,SIGNAL(dataTransferProgress(int,int,QNetworkOperation*)),
    28. this,SLOT(dataTransferProgress(int,int,QNetworkOperation*)));
    29.  
    30. connect(copyOperator,SIGNAL(finished(QNetworkOperation*)),
    31. this,SLOT(finished(QNetworkOperation*)));
    32.  
    33. copyOperator->copy(m_markedList,selector.getSelected(),move);
    34. }
    35. }
    36.  
    37. void MyClass::dataTransferProgress(int bytesDone, int, QNetworkOperation*)
    38. {
    39. m_copyProgress->setProgress(bytesDone);
    40. }
    41.  
    42. void MyClass::finished(QNetworkOperation*)
    43. {
    44. m_copyProgress->close();
    45. }
    To copy to clipboard, switch view to plain text mode 

    Thanx in advance,
    Ahmed Toulan.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QUrlOperator bug or what?

    dataTransferProgress will be particular for every file in the list you pass to copy.
    Also, you have to examine the QNetworkOperation pointer that is passed to you with each finished signal. BTW, you also get a finished signal after each single file copy operation is done.


    So:
    1. Your progress handling is wrong.
    2. Look at the type of QNetworkOperation in finished, to see what exactly has finished.
    For copy I think QNetworkProtocol::OpGet is what you should have.

    Regards

  3. #3
    Join Date
    Jan 2007
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QUrlOperator bug or what?

    Quote Originally Posted by marcel View Post
    dataTransferProgress will be particular for every file in the list you pass to copy.
    Also, you have to examine the QNetworkOperation pointer that is passed to you with each finished signal. BTW, you also get a finished signal after each single file copy operation is done.


    So:
    1. Your progress handling is wrong.
    2. Look at the type of QNetworkOperation in finished, to see what exactly has finished.
    For copy I think QNetworkProtocol::OpGet is what you should have.

    Regards
    Thanx for replying.

    It seems that my progress handling is wrong, but the behavior I am describing happens when I am trying to copy a single file.

    Also, how can we know that we finished copying all file?

    Regards,
    Ahmed Toulan.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QUrlOperator bug or what?

    Quote Originally Posted by thelinuxer View Post
    Thanx for replying.
    It seems that my progress handling is wrong, but the behavior I am describing happens when I am trying to copy a single file.
    Weird.

    [/quote]
    Also, how can we know that we finished copying all file?
    [/quote]

    You always have the startedNextCopy signal that you can connect to.
    Another solution is to use the other version of copy, for a single file, in conjunction with the finished signal.
    When you get the finished signal for a copy operation, then you know that it is ok to start the next one.
    For this you will have to queue your files.

    Regards

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.