Diffstat (limited to 'noncore/net/opieirc/dcctransfertab.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/dcctransfertab.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/noncore/net/opieirc/dcctransfertab.cpp b/noncore/net/opieirc/dcctransfertab.cpp new file mode 100644 index 0000000..ea0ff1f --- a/dev/null +++ b/noncore/net/opieirc/dcctransfertab.cpp | |||
@@ -0,0 +1,81 @@ | |||
1 | #include <qlist.h> | ||
2 | #include <qlabel.h> | ||
3 | #include <qstring.h> | ||
4 | #include <qvbox.h> | ||
5 | #include <qmessagebox.h> | ||
6 | |||
7 | #include "dcctransfer.h" | ||
8 | #include "dccprogress.h" | ||
9 | #include "mainwindow.h" | ||
10 | #include "dcctransfertab.h" | ||
11 | |||
12 | #include <stdio.h> | ||
13 | |||
14 | DCCTransferTab::DCCTransferTab(QWidget *parent, const char *name, WFlags f) | ||
15 | :IRCTab(parent, name, f), m_hbox(new QHBox(this)), m_parent(static_cast<MainWindow*>(parent)) | ||
16 | { | ||
17 | m_description->setText(""); | ||
18 | m_layout->add(m_hbox); | ||
19 | m_hbox->show(); | ||
20 | } | ||
21 | |||
22 | DCCTransferTab::~DCCTransferTab() | ||
23 | { | ||
24 | if(m_hbox) | ||
25 | delete m_hbox; | ||
26 | } | ||
27 | |||
28 | QString DCCTransferTab::title() | ||
29 | { | ||
30 | return "DCC"; | ||
31 | } | ||
32 | |||
33 | void DCCTransferTab::remove() | ||
34 | { | ||
35 | //Clean finished transfers | ||
36 | for(QListIterator <DCCProgress> it(m_progressList); it.current(); ++it) { | ||
37 | DCCProgress *current = it.current(); | ||
38 | if (current->finished()) { | ||
39 | m_progressList.remove(current); | ||
40 | current->hide(); | ||
41 | delete current; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | if (m_progressList.count() > 0) { | ||
46 | int retval = QMessageBox::information( parentWidget() , tr("DCC Transfers in Progress"), | ||
47 | tr( "There are transfers in progress. <br>If you close this tab, they will be canceled." | ||
48 | "<br>Do you want to close it anyway?"), | ||
49 | tr("&Close"), tr("&Don't Close")); | ||
50 | if ( retval != 0 ) { | ||
51 | return; | ||
52 | } | ||
53 | //Cancel active transfers (user accepted) | ||
54 | for(QListIterator <DCCProgress> itr(m_progressList); itr.current(); ++itr) { | ||
55 | DCCProgress *current = itr.current(); | ||
56 | m_progressList.remove(current); | ||
57 | current->hide(); | ||
58 | current->cancel(); | ||
59 | delete current; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | //Remove | ||
64 | m_parent->killTab(this); | ||
65 | } | ||
66 | |||
67 | bool DCCTransferTab::confirm(QWidget *parent, const QString &nickname, const QString &filename, unsigned int size) | ||
68 | { | ||
69 | int retval = QMessageBox::information(parent, tr("DCC Transfer from %1").arg(nickname), | ||
70 | tr( "%1 is trying to send you the file %2\n(%3 bytes)").arg(nickname).arg(filename).arg(size), | ||
71 | tr("&Accept"), tr("&Reject")); | ||
72 | |||
73 | return ( 0 == retval); | ||
74 | |||
75 | } | ||
76 | |||
77 | void DCCTransferTab::addTransfer(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port, | ||
78 | const QString &filename, const QString &nickname, unsigned int size) | ||
79 | { | ||
80 | m_progressList.append(new DCCProgress(type, ip4Addr, port, filename, nickname, size, this)); | ||
81 | } | ||