Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

dcctransfertab.cpp

Go to the documentation of this file.
00001 #include <qlist.h>
00002 #include <qlabel.h>
00003 #include <qstring.h>
00004 #include <qvbox.h>
00005 #include <qmessagebox.h>
00006 
00007 #include "dcctransfer.h"
00008 #include "dccprogress.h"
00009 #include "mainwindow.h"
00010 #include "dcctransfertab.h"
00011 
00012 #include <stdio.h>
00013 
00014 DCCTransferTab::DCCTransferTab(QWidget *parent, const char *name, WFlags f)
00015     :IRCTab(parent, name, f), m_hbox(new QHBox(this)), m_parent(static_cast<MainWindow*>(parent))
00016 {
00017     m_description->setText("");
00018     m_layout->add(m_hbox);
00019     m_hbox->show();
00020 }
00021 
00022 DCCTransferTab::~DCCTransferTab()
00023 {
00024     if(m_hbox)
00025         delete m_hbox;
00026 }
00027 
00028 QString DCCTransferTab::title()
00029 {
00030     return "DCC";
00031 }
00032 
00033 void DCCTransferTab::remove()
00034 {
00035     //Clean finished transfers
00036     for(QListIterator <DCCProgress> it(m_progressList); it.current(); ++it) {
00037         DCCProgress *current = it.current();
00038         if (current->finished()) {
00039             m_progressList.remove(current);
00040             current->hide();
00041             delete current;
00042         }
00043     }
00044     
00045     if (m_progressList.count() > 0) {
00046         int retval = QMessageBox::information( parentWidget() , tr("DCC Transfers in Progress"),
00047                             tr( "There are transfers in progress. <br>If you close this tab, they will be canceled."
00048                                 "<br>Do you want to close it anyway?"),
00049                             tr("&Close"), tr("&Don't Close"));
00050         if ( retval != 0 ) {
00051             return;
00052         }
00053         //Cancel active transfers (user accepted)
00054         for(QListIterator <DCCProgress> itr(m_progressList); itr.current(); ++itr) {
00055             DCCProgress *current = itr.current();
00056             m_progressList.remove(current);
00057             current->hide();
00058             current->cancel();
00059             delete current;
00060         }
00061     }
00062                                                         
00063     //Remove
00064     m_parent->killTab(this);
00065 }
00066 
00067 bool DCCTransferTab::confirm(QWidget *parent, const QString &nickname, const QString &filename, unsigned int size)
00068 {
00069     int retval = QMessageBox::information(parent, tr("DCC Transfer from %1").arg(nickname),
00070             tr( "%1 is trying to send you the file %2\n(%3 bytes)").arg(nickname).arg(filename).arg(size),
00071             tr("&Accept"), tr("&Reject"));
00072     
00073     return ( 0 == retval);
00074     
00075 }
00076 
00077 void DCCTransferTab::addTransfer(DCCTransfer::Type type, Q_UINT32 ip4Addr, Q_UINT16 port,
00078     const QString &filename, const QString &nickname, unsigned int size)
00079 {
00080    m_progressList.append(new DCCProgress(type, ip4Addr, port, filename, nickname, size, this));
00081 }

Generated on Sat Nov 5 16:17:40 2005 for OPIE by  doxygen 1.4.2