summaryrefslogtreecommitdiffstats
path: root/konversation/src/dcctransferpanelitem.h
blob: 9ca60c7e4f8b8f87917ec8899871d38bb46d8189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
  begin:     Mit Aug 7 2002
  copyright: (C) 2002 by Dario Abatianni
  email:     eisfuchs@tigress.com
*/
// Copyright (C) 2004-2007 Shintaro Matsuoka <shin@shoegazed.org>
// Copyright (C) 2004,2005 John Tapsell <john@geola.co.uk>

/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

#ifndef DCCTRANSFERPANELITEM_H
#define DCCTRANSFERPANELITEM_H

#include "dcctransfer.h"

#include <tqdatetime.h>

#include <tdelistview.h>
#include <kurl.h>
#include <tdeio/global.h>


class TQStringList;
class TQTimer;

class KProgress;

namespace TDEIO
{
    class Job;
}

class DccTransferPanel;

class DccTransferPanelItem : public TQObject, public TDEListViewItem
{
    TQ_OBJECT
  

    public:
        DccTransferPanelItem( DccTransferPanel* panel, DccTransfer* transfer );
        virtual ~DccTransferPanelItem();

        virtual void paintCell( TQPainter* painter, const TQColorGroup& colorgroup, int column, int width, int alignment );

        virtual int compare( TQListViewItem* i, int col, bool ascending ) const;

        void runFile();
        void openFileInfoDialog();

        DccTransfer* transfer() const { return m_transfer; }

        // called from updateView()
        TQString getTypeText()                                  const;
        TQPixmap getTypeIcon()                                  const;
        TQPixmap getStatusIcon()                                const;
        TQString getStatusText()                                const;
        TQString getFileSizePrettyText()                        const;
        TQString getPositionPrettyText( bool detailed = false ) const;
        TQString getTimeLeftPrettyText()                        const;
        TQString getAverageSpeedPrettyText()                    const;
        TQString getCurrentSpeedPrettyText()                    const;
        TQString getSenderAddressPrettyText()                   const;

        static TQString getSpeedPrettyText( transferspeed_t speed );
        static TQString secToHMS( long sec );

    private slots:
        void slotStatusChanged( DccTransfer* transfer, int newStatus, int oldStatus );
        void updateView();

    private:
        DccTransferPanel* m_panel;
        DccTransfer* m_transfer;
        bool m_isTransferInstanceBackup;

    private slots:
        void startAutoViewUpdate();
        void stopAutoViewUpdate();

        void backupTransferInfo( DccTransfer* transfer );

    private:
        void updateTransferInfo();
        void updateTransferMeters();

        void showProgressBar();                   // called from printCell()

        // UI
        TQTimer* m_autoUpdateViewTimer;
        KProgress* m_progressBar;
};

#endif  // DCCTRANSFERPANELITEM_H