#ifndef _TRANSFER_VIEW_H_ #define _TRANSFER_VIEW_H_ #include #include "transfer_storage.h" // // Extension of QListViewItem that allows making one column a status-column with a progress bar. // Gets its values on the fly from the associated gdl or transfer. // class transfer_lvi : public QListViewItem { public: enum TRNSFR_LVI_CLMN_TYPES { CT_FNAME=0, CT_FSIZE, CT_UNAME, CT_STATUS, CT_PROGRESS, CT_RATE, CT_ETA, CT_TARGET, CT_EMPTY }; enum TRNSFR_LVI_LAYOUTS { A_GDL, // Active GDL A_GDL_SRC, // Active GDL's running download A_GDL_DONE,// Active GDL's complete download range Q_GDL, // Queued GDL Q_GDL_SRC, // Queued GDL's source UL, // Upload INVALID_LAYOUT_TYPE }; protected: gdl_item *gdl; transfer_item *udl; int column_type[CT_EMPTY]; int layout; public: transfer_lvi( QListView * parent ) : QListViewItem(parent) { gdl=0; udl=0; memset(column_type, 0, sizeof(int)*(int)CT_EMPTY); } transfer_lvi( QListViewItem * parent ) : QListViewItem(parent) { gdl=0; udl=0; memset(column_type, 0, sizeof(int)*(int)CT_EMPTY); } transfer_lvi( QListView * parent, QListViewItem * after ) : QListViewItem(parent, after) { gdl=0; udl=0; memset(column_type, 0, sizeof(int)*(int)CT_EMPTY); } transfer_lvi( QListViewItem * parent, QListViewItem * after ) : QListViewItem(parent, after) { gdl=0; udl=0; memset(column_type, 0, sizeof(int)*(int)CT_EMPTY); } virtual ~transfer_lvi() { gdl=0; udl=0; } void set_column_type(const int column, const int ct); void set_layout(int lo, gdl_item *g=0); void set_layout(int lo, transfer_item *d=0); gdl_item *GDL() { return gdl; } transfer_item *UDL() { return udl; } unsigned int ID() const { if (gdl) return gdl->id(); else if (udl) return udl->id; else return 0; } // Overload text() function to get data from gdl/udl, to avoid calling setText() manually. virtual QString text(int column) const; // Overload paint function of a column with the progressbar. void paintCell ( QPainter * p, const QColorGroup & cg, int column, int width, int align ); // Overload width() to support the custom progressbar column. int width ( const QFontMetrics & fm, const QListView * lv, int c ) const { if (column_type[c]==CT_STATUS) { int w = QListViewItem::width(fm, lv, c); return w<6 ? 6 : w; } else return QListViewItem::width(fm, lv, c); } }; QString bytes_to_string(ULLINT size); #endif /* * * $Log: transfer_view.h,v $ * Revision 1.3 2004/02/22 06:48:53 estrato * Bugfixes, cleaning up * * Revision 1.2 2003/08/16 21:34:19 estrato * New transfer dialog update, almost all internal functions done. Will replaceold transferdlg in next commit. * * Revision 1.1 2003/08/14 23:30:45 estrato * New transfer widget, basic storage and view functionality, no signals connected yet. * * */