~ubuntu-branches/ubuntu/saucy/filezilla/saucy-proposed

« back to all changes in this revision

Viewing changes to src/interface/queue.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adrien Cunin
  • Date: 2010-12-12 16:11:49 UTC
  • mfrom: (1.1.27 upstream) (3.2.9 sid)
  • Revision ID: james.westby@ubuntu.com-20101212161149-0tsniecmy8o1f6yc
Tags: 3.3.5.1-1ubuntu1
* Merge from Debian unstable. Remaining changes:
   - 02_use-decimal-si-by-default.patch: by default, display file sizes using
     decimal base and SI units instead of just bytes; complies with Ubuntu
     UnitsPolicy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#include "queueview_failed.h"
5
5
#include "queueview_successful.h"
6
6
#include "sizeformatting.h"
 
7
#include "themeprovider.h"
7
8
 
8
9
CQueueItem::CQueueItem()
9
10
{
278
279
        return index + pParent->GetItemIndex();
279
280
}
280
281
 
281
 
CFileItem::CFileItem(CServerItem* parent, bool queued, bool download, const wxString& localFile,
 
282
CFileItem::CFileItem(CServerItem* parent, bool queued, bool download,
 
283
                                         const CLocalPath& localPath, const wxString& localFile,
282
284
                                         const wxString& remoteFile, const CServerPath& remotePath, wxLongLong size)
283
 
        : m_localFile(localFile), m_remoteFile(remoteFile), m_remotePath(remotePath), m_size(size)
 
285
        : m_localFile(localFile), m_remoteFile(remoteFile)
 
286
        , m_localPath(localPath), m_remotePath(remotePath)
 
287
        , m_size(size)
284
288
{
285
289
        m_parent = parent;
286
290
        m_priority = priority_normal;
287
291
 
288
 
        m_download = download;
289
 
        m_queued = queued;
290
 
        m_active = false;
 
292
        flags = 0;
 
293
        if (download)
 
294
                flags |= flag_download;
 
295
        if (queued)
 
296
                flags |= flag_queued;
291
297
        m_errorCount = 0;
292
 
        m_remove = false;
293
298
        m_pEngineData = 0;
294
299
        m_defaultFileExistsAction = CFileExistsNotification::unknown;
295
300
        m_edit = CEditHandler::none;
296
 
        m_madeProgress = false;
297
301
        m_onetime_action = CFileExistsNotification::unknown;
298
302
}
299
303
 
323
327
 
324
328
void CFileItem::SetActive(const bool active)
325
329
{
326
 
        if (active && !m_active)
 
330
        if (active && !IsActive())
327
331
        {
328
332
                AddChild(new CStatusItem);
 
333
                flags |= flag_active;
329
334
        }
330
 
        else if (!active && m_active)
 
335
        else if (!active && IsActive())
331
336
        {
332
337
                CQueueItem* pItem = GetChild(0, false);
333
338
                RemoveChild(pItem);
 
339
                flags &= ~flag_active;
334
340
        }
335
 
        m_active = active;
336
341
}
337
342
 
338
343
void CFileItem::SaveItem(TiXmlElement* pElement) const
342
347
 
343
348
        TiXmlElement *file = pElement->LinkEndChild(new TiXmlElement("File"))->ToElement();
344
349
 
345
 
        AddTextElement(file, "LocalFile", m_localFile);
 
350
        AddTextElement(file, "LocalFile", m_localPath.GetPath() + m_localFile);
346
351
        AddTextElement(file, "RemoteFile", m_remoteFile);
347
352
        AddTextElement(file, "RemotePath", m_remotePath.GetSafePath());
348
 
        AddTextElementRaw(file, "Download", m_download ? "1" : "0");
 
353
        AddTextElementRaw(file, "Download", Download() ? "1" : "0");
349
354
        if (m_size != -1)
350
355
                AddTextElement(file, "Size", m_size.ToString());
351
356
        if (m_errorCount)
362
367
        if (!IsActive())
363
368
                return true;
364
369
 
365
 
        m_remove = true;
 
370
        set_pending_remove(true);
366
371
        return false;
367
372
}
368
373
 
378
383
        m_remoteFile = file;
379
384
}
380
385
 
381
 
CFolderItem::CFolderItem(CServerItem* parent, bool queued, const wxString& localFile)
382
 
        : CFileItem(parent, queued, true, localFile, _T(""), CServerPath(), -1)
 
386
CFolderItem::CFolderItem(CServerItem* parent, bool queued, const CLocalPath& localPath)
 
387
        : CFileItem(parent, queued, true, localPath, _T(""), _T(""), CServerPath(), -1)
383
388
{
384
389
}
385
390
 
386
391
CFolderItem::CFolderItem(CServerItem* parent, bool queued, const CServerPath& remotePath, const wxString& remoteFile)
387
 
        : CFileItem(parent, queued, false, _T(""), remoteFile, remotePath, -1)
 
392
        : CFileItem(parent, queued, false, CLocalPath(), _T(""), remoteFile, remotePath, -1)
388
393
{
389
394
}
390
395
 
392
397
{
393
398
        TiXmlElement *file = new TiXmlElement("Folder");
394
399
 
395
 
        if (m_download)
 
400
        if (Download())
396
401
                AddTextElement(file, "LocalFile", m_localFile);
397
402
        else
398
403
        {
399
404
                AddTextElement(file, "RemoteFile", m_remoteFile);
400
405
                AddTextElement(file, "RemotePath", m_remotePath.GetSafePath());
401
406
        }
402
 
        AddTextElementRaw(file, "Download", m_download ? "1" : "0");
 
407
        AddTextElementRaw(file, "Download", Download() ? "1" : "0");
403
408
 
404
409
        pElement->LinkEndChild(file);
405
410
}
406
411
 
407
412
void CFolderItem::SetActive(const bool active)
408
413
{
409
 
        m_active = active;
 
414
        if (active)
 
415
                flags |= flag_active;
 
416
        else
 
417
                flags &= ~flag_active;
410
418
}
411
419
 
412
420
CServerItem::CServerItem(const CServer& server)
442
450
        if (!pItem)
443
451
                return;
444
452
 
445
 
        m_fileList[pItem->m_queued ? 0 : 1][pItem->GetPriority()].push_back(pItem);
 
453
        m_fileList[pItem->queued() ? 0 : 1][pItem->GetPriority()].push_back(pItem);
446
454
}
447
455
 
448
456
void CServerItem::RemoveFileItemFromList(CFileItem* pItem)
449
457
{
450
 
        std::list<CFileItem*>& fileList = m_fileList[pItem->m_queued ? 0 : 1][pItem->GetPriority()];
 
458
        std::list<CFileItem*>& fileList = m_fileList[pItem->queued() ? 0 : 1][pItem->GetPriority()];
451
459
        for (std::list<CFileItem*>::iterator iter = fileList.begin(); iter != fileList.end(); iter++)
452
460
        {
453
461
                if (*iter == pItem)
557
565
                for (std::list<CFileItem*>::reverse_iterator iter = fileList.rbegin(); iter != fileList.rend(); iter++)
558
566
                {
559
567
                        CFileItem* item = *iter;
560
 
                        wxASSERT(!item->m_queued);
 
568
                        wxASSERT(!item->queued());
561
569
                        if (item->IsActive())
562
570
                                activeList.push_front(item);
563
571
                        else
564
572
                        {
565
 
                                item->m_queued = true;
 
573
                                item->set_queued(true);
566
574
                                m_fileList[0][i].push_front(item);
567
575
                        }
568
576
                }
572
580
 
573
581
void CServerItem::QueueImmediateFile(CFileItem* pItem)
574
582
{
575
 
        if (pItem->m_queued)
 
583
        if (pItem->queued())
576
584
                return;
577
585
 
578
586
        std::list<CFileItem*>& fileList = m_fileList[1][pItem->GetPriority()];
581
589
                if (*iter != pItem)
582
590
                        continue;
583
591
 
584
 
                pItem->m_queued = true;
 
592
                pItem->set_queued(true);
585
593
                fileList.erase(iter);
586
594
                m_fileList[0][pItem->GetPriority()].push_front(pItem);
587
595
                return;
703
711
 
704
712
void CServerItem::SetChildPriority(CFileItem* pItem, enum QueuePriority oldPriority, enum QueuePriority newPriority)
705
713
{
706
 
        int i = pItem->Queued() ? 0 : 1;
 
714
        int i = pItem->queued() ? 0 : 1;
707
715
 
708
716
        for (std::list<CFileItem*>::iterator iter = m_fileList[i][oldPriority].begin(); iter != m_fileList[i][oldPriority].end(); iter++)
709
717
        {
718
726
        wxFAIL;
719
727
}
720
728
 
721
 
CFolderScanItem::CFolderScanItem(CServerItem* parent, bool queued, bool download, const wxString& localPath, const CServerPath& remotePath)
 
729
CFolderScanItem::CFolderScanItem(CServerItem* parent, bool queued, bool download, const CLocalPath& localPath, const CServerPath& remotePath)
722
730
{
723
731
        m_parent = parent;
724
732
 
772
780
        m_folderScanCountChanged = false;
773
781
 
774
782
        // Create and assign the image list for the queue
775
 
        wxImageList* pImageList = new wxImageList(16, 16);
 
783
        wxSize s = CThemeProvider::GetIconSize(iconSizeSmall);
 
784
        wxImageList* pImageList = new wxImageList(s.x, s.y);
776
785
 
777
 
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_SERVER"),  wxART_OTHER, wxSize(16, 16)));
778
 
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FILE"),  wxART_OTHER, wxSize(16, 16)));
779
 
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FOLDERCLOSED"),  wxART_OTHER, wxSize(16, 16)));
780
 
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FOLDER"),  wxART_OTHER, wxSize(16, 16)));
 
786
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_SERVER"), wxART_OTHER, CThemeProvider::GetIconSize(iconSizeSmall)));
 
787
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FILE"), wxART_OTHER, CThemeProvider::GetIconSize(iconSizeSmall)));
 
788
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FOLDERCLOSED"), wxART_OTHER, CThemeProvider::GetIconSize(iconSizeSmall)));
 
789
        pImageList->Add(wxArtProvider::GetBitmap(_T("ART_FOLDER"), wxART_OTHER, CThemeProvider::GetIconSize(iconSizeSmall)));
781
790
 
782
791
        AssignImageList(pImageList, wxIMAGE_LIST_SMALL);
783
792
 
855
864
                        switch (column)
856
865
                        {
857
866
                        case 0:
858
 
                                return pFileItem->GetIndent() + pFileItem->GetLocalFile();
 
867
                                return pFileItem->GetIndent() + pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile();
859
868
                        case 1:
860
869
                                if (pFileItem->Download())
861
 
                                        if (pFileItem->Queued())
 
870
                                        if (pFileItem->queued())
862
871
                                                return _T("<--");
863
872
                                        else
864
873
                                                return _T("<<--");
865
874
                                else
866
 
                                        if (pFileItem->Queued())
 
875
                                        if (pFileItem->queued())
867
876
                                                return _T("-->");
868
877
                                        else
869
878
                                                return _T("-->>");
907
916
                        switch (column)
908
917
                        {
909
918
                        case 0:
910
 
                                return _T("  ") + pFolderItem->GetLocalPath();
 
919
                                return _T("  ") + pFolderItem->GetLocalPath().GetPath();
911
920
                        case 1:
912
921
                                if (pFolderItem->Download())
913
 
                                        if (pFolderItem->Queued())
 
922
                                        if (pFolderItem->queued())
914
923
                                                return _T("<--");
915
924
                                        else
916
925
                                                return _T("<<--");
917
926
                                else
918
 
                                        if (pFolderItem->Queued())
 
927
                                        if (pFolderItem->queued())
919
928
                                                return _T("-->");
920
929
                                        else
921
930
                                                return _T("-->>");
936
945
                        {
937
946
                        case 0:
938
947
                                if (pFolderItem->Download())
939
 
                                        return pFolderItem->GetIndent() + pFolderItem->GetLocalFile();
 
948
                                        return pFolderItem->GetIndent() + pFolderItem->GetLocalPath().GetPath() + pFolderItem->GetLocalFile();
940
949
                                break;
941
950
                        case 1:
942
951
                                if (pFolderItem->Download())
943
 
                                        if (pFolderItem->Queued())
 
952
                                        if (pFolderItem->queued())
944
953
                                                return _T("<--");
945
954
                                        else
946
955
                                                return _T("<<--");
947
956
                                else
948
 
                                        if (pFolderItem->Queued())
 
957
                                        if (pFolderItem->queued())
949
958
                                                return _T("-->");
950
959
                                        else
951
960
                                                return _T("-->>");