TransferTreeView.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2005-2007 by Peter Dimov.
00004 
00005 This file is part of Calitko (http://www.calitko.org).
00006 
00007 Calitko is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 Calitko is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Calitko; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021 */
00022 
00023 #include "Qt.h"
00024 #include "TransferTreeView.h"
00025 #include "TransferModel.h"
00026 #include "DownloadProgressBar.h"
00027 
00028 using UIs::Transfer;
00029 using UIs::TransferTreeView;
00030 using UIs::TransferTreeViewDelegate;
00031 
00032 void TransferTreeViewDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
00033 {
00034     QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
00035                            ? QPalette::Normal : QPalette::Disabled;
00036     QStyleOptionViewItem op;
00037     op = option;
00038     op.palette.setBrush (cg, QPalette::Highlight, QBrush (QColor (169, 165, 150)));
00039 
00040     if (index.column() == 2){
00041         DownloadProgressBar downloadProgressBar;
00042         downloadProgressBar.setFileSize (150);
00043         downloadProgressBar.addDownloadedRange (1, 70);
00044         downloadProgressBar.addDownloadedRange (80, 149);
00045         downloadProgressBar.addRequestedRange (70, 80);
00046         downloadProgressBar.addVerifiedRange (0, 10);
00047         downloadProgressBar.addVerifiedRange (13, 15);
00048         downloadProgressBar.addVerifiedRange (20, 30);
00049         downloadProgressBar.paint (painter, &option.rect, op);
00050     }else
00051     QItemDelegate::paint (painter, op, index);
00052 }
00053 
00054 bool TransferTreeViewDelegate::event (QEvent *e)
00055 {
00056     if (e->type() == QEvent::ToolTip) {
00057         int i;
00058         i=2;
00059     }
00060 
00061     switch (e->type()){
00062     case QEvent::ToolTip:
00063         {
00064             QHelpEvent *hE = static_cast<QHelpEvent *> (e);
00065             QPoint pos = hE->pos();
00066             QToolTip::showText (hE->globalPos(), "proba");
00067             return true;
00068         }
00069     default:
00070         break;
00071     };
00072 
00073     return QItemDelegate::event (e);
00074 }
00075 
00076 
00077 int TransferTreeView::addItem (Transfer *transfer)
00078 {
00079     (static_cast <TransferModel*> (model()))->addItem (transfer, this);
00080 
00081     return 0;
00082 }
00083 
00084 int TransferTreeView::removeItem (QString *)
00085 {
00086 //  (static_cast <TransferModel*> (model()))->removeItem (ip, this);
00087 
00088     return 0;
00089 }