diff options
| author | 2008-09-14 11:05:08 +0000 | |
|---|---|---|
| committer | 2008-09-14 11:05:08 +0000 | |
| commit | bde3a74dfcbd9a065f22568640339927a5402502 (patch) | |
| tree | afb3b3b7478eacce04319d052ee9a18a9773c40f | |
| parent | more work on http class (added auto redirect handling) (diff) | |
| download | KVIrc-bde3a74dfcbd9a065f22568640339927a5402502.tar.gz KVIrc-bde3a74dfcbd9a065f22568640339927a5402502.tar.bz2 KVIrc-bde3a74dfcbd9a065f22568640339927a5402502.zip | |
fixes to the filetransferwindow
ported the windowlist_tree to inherit qt styles
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2459 17fca916-40b9-46aa-a4ea-0a15b648b75c
| -rw-r--r-- | src/kvirc/ui/kvi_windowlist_tree.cpp | 437 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_windowlist_tree.h | 69 | ||||
| -rw-r--r-- | src/modules/dcc/send.cpp | 12 | ||||
| -rw-r--r-- | src/modules/filetransferwindow/filetransferwindow.cpp | 2 |
4 files changed, 96 insertions, 424 deletions
diff --git a/src/kvirc/ui/kvi_windowlist_tree.cpp b/src/kvirc/ui/kvi_windowlist_tree.cpp index 7e4dd51e4..3c12f8233 100644 --- a/src/kvirc/ui/kvi_windowlist_tree.cpp +++ b/src/kvirc/ui/kvi_windowlist_tree.cpp @@ -1,7 +1,7 @@ //=============================================================================================== // // File : kvi_windowlist_tree.cpp -// Last major modification : Thu Jan 7 1999 03:59:43 CEST by Szymon Stefanek +// Last major modification : Sat Sep 13 2008 18:00:00 CEST by Fabio Bas // // This file is part of the KVirc irc client distribution // Copyright (C) 1999-2008 Szymon Stefanek (pragma at kvirc dot net) @@ -35,7 +35,6 @@ #include <QHeaderView> #include <QMouseEvent> #include <QPainter> -#include <QTimer> #ifdef COMPILE_PSEUDO_TRANSPARENCY extern QPixmap * g_pShadedChildGlobalDesktopBackground; @@ -43,21 +42,17 @@ extern QPixmap * g_pActivityMeterPixmap; -#define KVI_NUM_STEPS 20 -#define KVI_TIMER_DELAY 18 - - // KviTreeWindowListItem KviTreeWindowListItem::KviTreeWindowListItem(KviTalTreeWidget * par,KviWindow * wnd) : KviTalTreeWidgetItem(par) , KviWindowListItem(wnd) { - m_iStepNumber=0; - m_bIncreasing=0; - m_pInternal=new KviTreeWindowListItemInternal(this); - m_pAnimTimer=new QTimer(); - QObject::connect( m_pAnimTimer, SIGNAL(timeout()), m_pInternal, SLOT(timerShot())); - applyOptions(); + if(wnd->type()==KVI_WINDOW_TYPE_CONSOLE) + { + QFont myfont(font(0)); + myfont.setBold(true); + setFont(0, myfont); + } //sort the widget treeWidget()->sortItems(0,Qt::AscendingOrder); } @@ -65,33 +60,11 @@ KviTreeWindowListItem::KviTreeWindowListItem(KviTalTreeWidget * par,KviWindow * KviTreeWindowListItem::KviTreeWindowListItem(KviTreeWindowListItem * par,KviWindow * wnd) : KviTalTreeWidgetItem(par) , KviWindowListItem(wnd) { - m_iStepNumber=0; - m_bIncreasing=0; - m_pInternal=new KviTreeWindowListItemInternal(this); - m_pAnimTimer=new QTimer(); - QObject::connect( m_pAnimTimer, SIGNAL(timeout()), m_pInternal, SLOT(timerShot())); - applyOptions(); //sort the widget treeWidget()->sortItems(0,Qt::AscendingOrder); } -KviTreeWindowListItem::~KviTreeWindowListItem() -{ - KviTalTreeWidget* pView=(KviTalTreeWidget *)treeWidget(); - if(pView) - if(((KviTreeWindowListTreeWidget*)(pView))->m_pPrevItem==this) ((KviTreeWindowListTreeWidget*)(treeWidget()))->m_pPrevItem=0; - delete m_pAnimTimer; - delete m_pInternal; -} - -void KviTreeWindowListItem::applyOptions() -{ - setData(0, KVI_TTBID_REDDIFF, (KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground).red()-KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).red())/KVI_NUM_STEPS); - setData(0, KVI_TTBID_GREENDIFF, (KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground).green()-KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).green())/KVI_NUM_STEPS); - setData(0, KVI_TTBID_BLUEDIFF, (KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground).blue()-KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).blue())/KVI_NUM_STEPS); -} - -QString KviTreeWindowListItem::currentCaption() const +void KviTreeWindowListItem::captionChanged() { QString szText; @@ -115,59 +88,55 @@ QString KviTreeWindowListItem::currentCaption() const break; } - return szText; -} - -void KviTreeWindowListItem::captionChanged() -{ - QString szText=currentCaption(); if(m_pWindow->isMinimized()) szText.prepend('(').append(')'); + setText(0, szText); + + if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIcons)) + { + setIcon(0, QIcon(*kviWindow()->myIconPtr())); + } + //sort the widget treeWidget()->sortItems(0,Qt::AscendingOrder); +} - setData(0, Qt::DisplayRole, szText); +void KviTreeWindowListItem::refreshBrush() +{ + if(this == treeWidget()->currentItem()) + { + setForeground(0, KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveForeground)); + } else { + int iLevel; + switch(m_iHighlightLevel) + { + case 1: iLevel = KviOption_colorTreeWindowListHighlight1Foreground; break; + case 2: iLevel = KviOption_colorTreeWindowListHighlight2Foreground; break; + case 3: iLevel = KviOption_colorTreeWindowListHighlight3Foreground; break; + case 4: iLevel = KviOption_colorTreeWindowListHighlight4Foreground; break; + case 5: iLevel = KviOption_colorTreeWindowListHighlight5Foreground; break; + default: iLevel = KviOption_colorTreeWindowListForeground; break; + } + setForeground(0, KVI_OPTION_COLOR(iLevel)); + } } void KviTreeWindowListItem::unhighlight() { if(m_iHighlightLevel < 1)return; m_iHighlightLevel = 0; - setData(0, KVI_TTBID_HIGHLIGHT, m_iHighlightLevel); - + refreshBrush(); if(g_pFrame->dockExtension())g_pFrame->dockExtension()->refresh(); } void KviTreeWindowListItem::highlight(int iLevel) { if(iLevel <= m_iHighlightLevel)return; - if(isSelected() && g_pFrame->isActiveWindow())return; + if((this == treeWidget()->currentItem()) && g_pFrame->isActiveWindow())return; m_iHighlightLevel = iLevel; - setData(0, KVI_TTBID_HIGHLIGHT, m_iHighlightLevel); - + refreshBrush(); if(g_pFrame->dockExtension())g_pFrame->dockExtension()->refresh(); - if(isSelected())return; -} - -void KviTreeWindowListItem::setProgress(int progress) -{ - if(progress == m_iProgress)return; - m_iProgress = progress; - setData(0, KVI_TTBID_PROGRESS, m_iProgress); -} - -void KviTreeWindowListItem::setActive(bool bActive) -{ - if(bActive) - { - m_iHighlightLevel = 0; - } else { - if(isSelected()) - m_iHighlightLevel = 0; - } - - setData(0, KVI_TTBID_HIGHLIGHT, m_iHighlightLevel); } QString KviTreeWindowListItem::key() const @@ -184,91 +153,41 @@ QString KviTreeWindowListItem::key() const return ret; } -void KviTreeWindowListItem::timerShot() -{ - if(m_bIncreasing) - m_iStepNumber++; - else - m_iStepNumber--; - - if((m_iStepNumber>=KVI_NUM_STEPS) && m_bIncreasing) - { - if(m_pAnimTimer->isActive()) m_pAnimTimer->stop(); - m_iStepNumber=KVI_NUM_STEPS; //make shure, that we cannot get out of range - } else if((m_iStepNumber<=0) && !m_bIncreasing) { - if(m_pAnimTimer->isActive()) m_pAnimTimer->stop(); - m_iStepNumber=0; //make shure, that we cannot get out of range - } - setData(0, KVI_TTBID_STEPNUM, m_iStepNumber); - - QRect rect = treeWidget()->visualItemRect(this); - treeWidget()->update(QRect(0, rect.top(), rect.left()+rect.width(), rect.height())); -} - -void KviTreeWindowListItem::mouseEnter() -{ - if(KVI_OPTION_BOOL(KviOption_boolEnableVisualEffects)) - { - m_bIncreasing=true; - if(!m_pAnimTimer->isActive()) m_pAnimTimer->start(KVI_TIMER_DELAY); - } -} - -void KviTreeWindowListItem::mouseLeave() -{ - if(KVI_OPTION_BOOL(KviOption_boolEnableVisualEffects)) - { - m_bIncreasing=false; - if(!m_pAnimTimer->isActive()) m_pAnimTimer->start(KVI_TIMER_DELAY); - } -} - // KviTreeWindowListTreeWidget KviTreeWindowListTreeWidget::KviTreeWindowListTreeWidget(QWidget * par) : KviTalTreeWidget(par) { - header()->setSortIndicatorShown(false); - setFrameShape(NoFrame); - viewport()->setMouseTracking(TRUE); - m_pPrevItem=0; + setRootIsDecorated(true); + //Animation creates problem with the background painting on expande/collapse + //setAnimated(true); + setAllColumnsShowFocus(true); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setSelectionBehavior(QAbstractItemView::SelectItems); setSelectionMode(QAbstractItemView::SingleSelection); -} - -KviTreeWindowListTreeWidget::~KviTreeWindowListTreeWidget() -{ -} - -void KviTreeWindowListTreeWidget::mouseMoveEvent ( QMouseEvent * e ) -{ - KviTreeWindowListItem* pCur=(KviTreeWindowListItem*)(itemAt(e->pos())); - if(pCur!=m_pPrevItem) - { - if(m_pPrevItem)m_pPrevItem->mouseLeave(); - if(pCur) pCur->mouseEnter(); - setCursor(Qt::PointingHandCursor); - m_pPrevItem=pCur; - } else if(!pCur) { - setCursor(Qt::ArrowCursor); - } -} - -void KviTreeWindowListTreeWidget::leaveEvent(QEvent *) -{ - if(m_pPrevItem) m_pPrevItem->mouseLeave(); - m_pPrevItem=0; - setCursor(Qt::ArrowCursor); + setFrameShape(NoFrame); } void KviTreeWindowListTreeWidget::mousePressEvent(QMouseEvent *e) { - KviTalTreeWidgetItem * it = (KviTalTreeWidgetItem *)itemAt(e->pos()); + KviTreeWindowListItem * it = (KviTreeWindowListItem *)itemAt(e->pos()); if(it) { - if(e->button() & Qt::LeftButton)emit leftMousePress(it); - else if(e->button() & Qt::RightButton)emit rightMousePress(it); + KviWindow* wnd = it->kviWindow(); + if(e->button() & Qt::LeftButton) + { + if(e->modifiers() & Qt::ShiftModifier) + { + wnd->delayedClose(); + } else { + if((g_pActiveWindow != wnd) || (wnd->isMinimized())) + g_pFrame->setActiveWindow(wnd); + else wnd->minimize(); + } + } else if(e->button() & Qt::RightButton) + { + wnd->contextPopup(); + } } else { if(e->button() & Qt::RightButton) { @@ -278,18 +197,7 @@ void KviTreeWindowListTreeWidget::mousePressEvent(QMouseEvent *e) pPopup->popup(QCursor::pos()); } } -} - -void KviTreeWindowListTreeWidget::mouseDoubleClickEvent(QMouseEvent * e) -{ - KviTalTreeWidgetItem * it = (KviTalTreeWidgetItem *)itemAt(e->pos()); - if(it) - { - if(e->button() & Qt::LeftButton) - { - it->setExpanded(!(it->isExpanded())); - } - } + QTreeWidget::mousePressEvent(e); } void KviTreeWindowListTreeWidget::sort() @@ -305,7 +213,6 @@ void KviTreeWindowListTreeWidget::reverseSort() void KviTreeWindowListTreeWidget::paintEvent(QPaintEvent * event) { QPainter *p = new QPainter(viewport()); - QStyleOptionViewItem option = viewOptions(); QRect rect = event->rect(); #ifdef COMPILE_PSEUDO_TRANSPARENCY @@ -319,7 +226,7 @@ void KviTreeWindowListTreeWidget::paintEvent(QPaintEvent * event) if(pix) { QPoint pnt = rect.topLeft(); - + KviPixmapUtils::drawPixmapWithPainter(p,pix,KVI_OPTION_UINT(KviOption_uintTreeWindowListPixmapAlign),rect,viewport()->width(),viewport()->height(),pnt.x(),pnt.y()); } else { p->fillRect(rect,KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground)); @@ -343,10 +250,6 @@ KviTreeWindowList::KviTreeWindowList() m_pTreeWidget->addColumn(__tr2qs("Window List"),135); setWidget(m_pTreeWidget); - //ad-hoc itemdelegate for this view - m_pItemDelegate = new KviTreeWindowListItemDelegate(m_pTreeWidget); - m_pTreeWidget->setItemDelegate(m_pItemDelegate); - //minimun and maximun width of the treeview if(KVI_OPTION_UINT(KviOption_uintTreeWindowListMinimumWidth) < 48) KVI_OPTION_UINT(KviOption_uintTreeWindowListMinimumWidth) = 48; @@ -375,11 +278,10 @@ KviTreeWindowList::KviTreeWindowList() } m_pTreeWidget->header()->setResizeMode(QHeaderView::Interactive); - m_pTreeWidget->viewport()->installEventFilter(this); //tooltips - m_pToolTip = new KviDynamicToolTip(m_pTreeWidget->viewport(),"tree_windowlist_tooltip"); - connect(m_pToolTip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); +// m_pToolTip = new KviDynamicToolTip(m_pTreeWidget->viewport(),"tree_windowlist_tooltip"); +// connect(m_pToolTip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); } KviTreeWindowList::~KviTreeWindowList() @@ -414,48 +316,13 @@ void KviTreeWindowList::tipRequest(KviDynamicToolTip *,const QPoint &pnt) } } -bool KviTreeWindowList::eventFilter(QObject * o,QEvent *e) -{ - if(o == m_pTreeWidget->viewport()) - { - if(e->type() == QEvent::MouseButtonPress) - { - QMouseEvent * ev = (QMouseEvent *)e; - KviTreeWindowListItem * it = (KviTreeWindowListItem *)m_pTreeWidget->itemAt(ev->pos()); - if(!it)return false; - KviWindow * wnd = it->kviWindow(); - if(wnd) - { - if(ev->button() & Qt::LeftButton) - { - if(ev->modifiers() & Qt::ShiftModifier) - { - wnd->delayedClose(); - } else { - if((g_pActiveWindow != wnd) || (wnd->isMinimized()))g_pFrame->setActiveWindow(wnd); - else wnd->minimize(); - } - } else { - wnd->contextPopup(); - } - } - return true; - } - } - return false; -} - - KviWindowListItem * KviTreeWindowList::addItem(KviWindow * wnd) { // complex insertion task if(wnd->console()) { if(wnd->type() != KVI_WINDOW_TYPE_CONSOLE) - { - ((KviTreeWindowListItem *)(wnd->console()->m_pWindowListItem))->setExpanded(true); return new KviTreeWindowListItem(((KviTreeWindowListItem *)(wnd->console()->m_pWindowListItem)),wnd); - } } // console , or a window that has no irc context @@ -468,24 +335,24 @@ bool KviTreeWindowList::removeItem(KviWindowListItem * it) return true; } -void KviTreeWindowList::setActiveItem(KviWindowListItem * it) +void KviTreeWindowList::setActiveItem(KviWindowListItem * i) { - if(it) + if(i) { - KviTreeWindowListItem * cur = (KviTreeWindowListItem *)m_pTreeWidget->currentItem(); - if(cur && (cur != (KviTreeWindowListItem *)it)) - { - cur->setActive(false); - } - if(((KviTreeWindowListItem *)it)->parent()) + KviTreeWindowListItem *it = (KviTreeWindowListItem *)i; + KviTreeWindowListItem *cur = (KviTreeWindowListItem *)m_pTreeWidget->currentItem(); + if(cur != it) { - if(!((KviTreeWindowListItem *)it)->parent()->isExpanded())((KviTreeWindowListItem *)it)->parent()->setExpanded(true); + m_pTreeWidget->setCurrentItem(it); + m_pTreeWidget->scrollToItem(it); + it->unhighlight(); + if(cur) + { + cur->unhighlight(); + cur->refreshBrush(); + } + it->refreshBrush(); } - - //default selectionModel doesn't enforce singleselection if done from the code - m_pTreeWidget->selectionModel()->clearSelection(); - ((KviTreeWindowListItem *)it)->setActive(true); - ((KviTreeWindowListItem *)it)->setSelected(true); // this MUST go after it->setActive() if(g_pFrame->dockExtension())g_pFrame->dockExtension()->refresh(); } } @@ -555,125 +422,13 @@ void KviTreeWindowList::applyOptions() m_pTreeWidget->update(); } -// KviTreeWindowListItemDelegate - -int KviTreeWindowListItemDelegate::calculateColor(int col1,int col2, int iStepNumber) const +/* +void KviTreeWindowListItemWidget::paintEvent(QPaintEvent * e) { - int result=col1+(col2-col1)/KVI_NUM_STEPS*iStepNumber; - return result<255 ? result :255; -} - -void KviTreeWindowListItemDelegate::paint(QPainter * p, const QStyleOptionViewItem & option, const QModelIndex & index) const -{ - QRect rect=option.rect; - QRect branchRect = QRect(0, rect.top(), rect.left(), rect.height()); - QRect fullRect = QRect(0, rect.top(), rect.left()+rect.width(), rect.height()); - - QString szText=index.data(Qt::DisplayRole).toString(); - int iStepNumber=index.data(KVI_TTBID_STEPNUM).toInt(); - int iRedDiff=index.data(KVI_TTBID_REDDIFF).toInt(); - int iGreenDiff=index.data(KVI_TTBID_GREENDIFF).toInt(); - int iBlueDiff=index.data(KVI_TTBID_BLUEDIFF).toInt(); - int iHighlightLevel=index.data(KVI_TTBID_HIGHLIGHT).toInt(); - int iProgress=index.data(KVI_TTBID_PROGRESS).toInt(); - - //FIXME not exactly model/view coding style.. but we need to access data on the associated window - KviTreeWindowListTreeWidget* treeWidget = (KviTreeWindowListTreeWidget*)parent(); - KviTreeWindowListItem* item = (KviTreeWindowListItem*) treeWidget->itemFromIndex(index); - KviWindow* pWindow = item->kviWindow(); - - //paint cell background - if (option.state & QStyle::State_Selected) + QPainter p; + if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIrcContextIndicator) && (m_pParentItem->kviWindow()->type()==KVI_WINDOW_TYPE_CONSOLE)) { - //selection colored background - p->fillRect(fullRect,KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground)); - } else { - if(!iStepNumber) - { -#ifdef COMPILE_PSEUDO_TRANSPARENCY - //pseudo transparent background - if(g_pShadedChildGlobalDesktopBackground) - { - QPoint pnt = treeWidget->viewport()->mapToGlobal(fullRect.topLeft()); - p->drawTiledPixmap(fullRect,*g_pShadedChildGlobalDesktopBackground,pnt); - } else { -#endif - p->fillRect(rect,KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground)); -#ifdef COMPILE_PSEUDO_TRANSPARENCY - } -#endif - //background image (if defined) - QPixmap * pix = KVI_OPTION_PIXMAP(KviOption_pixmapTreeWindowListBackground).pixmap(); - if(pix) - { - KviPixmapUtils::drawPixmapWithPainter(p,pix,KVI_OPTION_UINT(KviOption_uintTreeWindowListPixmapAlign),fullRect,fullRect.width(),fullRect.height()); - } - } else { - // paint mouse over effect - p->fillRect(fullRect, - QColor(KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).red()+iRedDiff*iStepNumber, - KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).green()+iGreenDiff*iStepNumber, - KVI_OPTION_COLOR(KviOption_colorTreeWindowListBackground).blue()+iBlueDiff*iStepNumber - ) - ); - } - } - - //tree branches - treeWidget->drawBranches(p, branchRect, index); - - //draw window icon, irc context indicator (a colored square), set font properties for text - int im = rect.left(); - int yPixmap = (rect.top() + rect.height() - 16); - - QRect cRect(im + 3,rect.top(),rect.width(),rect.height()); - - switch(pWindow->type()) - { - case KVI_WINDOW_TYPE_CONSOLE: - { - if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIrcContextIndicator)) - { - QColor base = option.palette.window().color(); - QColor cntx = KVI_OPTION_ICCOLOR(pWindow->console()->context()->id() % KVI_NUM_ICCOLOR_OPTIONS); - base.setRgb((base.red() + cntx.red()) >> 1,(base.green() + cntx.green()) >> 1, - (base.blue() + cntx.blue()) >> 1); - p->fillRect(im + 2,yPixmap,14,15,base); - if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIcons)) - { - p->drawPixmap(im + 20,yPixmap,*(pWindow->myIconPtr())); - cRect.setLeft(cRect.left() + 37); - } else { - cRect.setLeft(cRect.left() + 20); - } - } else { - if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIcons)) - { - p->drawPixmap(im,yPixmap,*(pWindow->myIconPtr())); - cRect.setLeft(cRect.left() + 17); - } - } - //console window: bold font - QFont f = p->font(); - f.setBold(true); - p->setFont(f); - } - break; - case KVI_WINDOW_TYPE_CHANNEL: - case KVI_WINDOW_TYPE_DEADCHANNEL: - case KVI_WINDOW_TYPE_QUERY: - case KVI_WINDOW_TYPE_DEADQUERY: - default: - if(KVI_OPTION_BOOL(KviOption_boolUseWindowListIcons)) - { - p->drawPixmap(im,yPixmap,*(pWindow->myIconPtr())); - cRect.setLeft(cRect.left() + 17); - } - //channels, other windows: normal font - QFont f = p->font(); - f.setBold(false); - p->setFont(f); - break; + p.fillRect(0, 0, 16, 16, KVI_OPTION_ICCOLOR(m_pParentItem->kviWindow()->console()->context()->id() % KVI_NUM_ICCOLOR_OPTIONS)); } // paint the channel activity meter @@ -699,37 +454,9 @@ void KviTreeWindowListItemDelegate::paint(QPainter * p, const QStyleOptionViewIt if (option.state & QStyle::State_Selected) { p->setPen(KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveForeground)); - } else { - int iLevel; - switch(iHighlightLevel) - { - case 0: iLevel = KviOption_colorTreeWindowListForeground; break; - case 1: iLevel = KviOption_colorTreeWindowListHighlight1Foreground; break; - case 2: iLevel = KviOption_colorTreeWindowListHighlight2Foreground; break; - case 3: iLevel = KviOption_colorTreeWindowListHighlight3Foreground; break; - case 4: iLevel = KviOption_colorTreeWindowListHighlight4Foreground; break; - default: iLevel = KviOption_colorTreeWindowListHighlight5Foreground; break; - } - p->setPen( - QColor( - calculateColor(KVI_OPTION_COLOR(iLevel).red(),KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveForeground).red(),iStepNumber), - calculateColor(KVI_OPTION_COLOR(iLevel).green(),KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveForeground).green(),iStepNumber), - calculateColor(KVI_OPTION_COLOR(iLevel).blue(),KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveForeground).blue(),iStepNumber) - ) - ); } - - //draw window name - p->drawText(cRect,Qt::AlignLeft | Qt::AlignVCenter,szText); } - -QSize KviTreeWindowListItemDelegate::sizeHint( const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - KviTreeWindowListTreeWidget* treeWidget = (KviTreeWindowListTreeWidget*)parent(); - - return QSize(treeWidget->viewport()->size().width(), qMax(20, treeWidget->fontMetrics().xHeight() * 3)); -} - +*/ #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "kvi_windowlist_tree.moc" #endif //!COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvirc/ui/kvi_windowlist_tree.h b/src/kvirc/ui/kvi_windowlist_tree.h index b45c12d54..9958ec624 100644 --- a/src/kvirc/ui/kvi_windowlist_tree.h +++ b/src/kvirc/ui/kvi_windowlist_tree.h @@ -26,38 +26,24 @@ #include "kvi_windowlist.h" #include "kvi_tal_treewidget.h" -#include "kvi_tal_itemdelegates.h" -#include <QAbstractItemView> class KviTreeWindowList; -class KviTreeWindowListItemInternal; class KVIRC_API KviTreeWindowListItem : public KviTalTreeWidgetItem , public KviWindowListItem { friend class KviTreeWindowList; friend class KviTreeWindowListTreeWidget; - friend class KviTreeWindowListItemInternal; public: KviTreeWindowListItem(KviTalTreeWidget * par,KviWindow * wnd); KviTreeWindowListItem(KviTreeWindowListItem * par,KviWindow * wnd); - ~KviTreeWindowListItem(); -protected: - int m_iStepNumber; - bool m_bIncreasing; - QTimer* m_pAnimTimer; - KviTreeWindowListItemInternal *m_pInternal; + ~KviTreeWindowListItem() {}; public: virtual QString key() const; virtual void captionChanged(); virtual void highlight(int iLevel = 1); virtual void unhighlight(); - virtual void setProgress(int progress); - virtual void applyOptions(); protected: - void setActive(bool bActive); - void mouseEnter(); - void mouseLeave(); - void timerShot(); + void refreshBrush(); int calculateColor(int col1,int col2); QString currentCaption() const; bool operator<(const QTreeWidgetItem &other)const @@ -66,41 +52,21 @@ protected: } }; -class KviTreeWindowListItemInternal : public QObject -{ - Q_OBJECT -public: - KviTreeWindowListItemInternal(KviTreeWindowListItem* pItem):m_pItem(pItem) {}; - ~KviTreeWindowListItemInternal() {}; -protected: - KviTreeWindowListItem* m_pItem; -public slots: - void timerShot() { m_pItem->timerShot();}; -}; - class KVIRC_API KviTreeWindowListTreeWidget : public KviTalTreeWidget { friend class KviTreeWindowListItem; - friend class KviTreeWindowListItemDelegate; Q_OBJECT - KviTreeWindowListItem* m_pPrevItem; public: KviTreeWindowListTreeWidget(QWidget * par); - ~KviTreeWindowListTreeWidget(); + ~KviTreeWindowListTreeWidget() {}; protected: - virtual void mousePressEvent(QMouseEvent *e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); + virtual void mousePressEvent(QMouseEvent * e); virtual void paintEvent(QPaintEvent * event); - virtual void mouseMoveEvent (QMouseEvent * e); - virtual void leaveEvent(QEvent *); +protected slots: + void reverseSort(); + void sort(); private: KviWindowListItem * lastItem(); -signals: - void leftMousePress(KviTalTreeWidgetItem * it); - void rightMousePress(KviTalTreeWidgetItem * it); -public slots: - void sort(); - void reverseSort(); }; @@ -114,7 +80,6 @@ private: KviTreeWindowListTreeWidget * m_pTreeWidget; KviTreeWindowListItem * m_pCurrentItem; KviDynamicToolTip * m_pToolTip; - QAbstractItemDelegate* m_pItemDelegate; public: virtual KviWindowListItem * addItem(KviWindow *); virtual bool removeItem(KviWindowListItem *); @@ -125,7 +90,6 @@ public: virtual KviWindowListItem * prevItem(void); virtual bool setIterationPointer(KviWindowListItem * it); virtual void updatePseudoTransparency(); - virtual bool eventFilter(QObject * o,QEvent *e); virtual void updateActivityMeter(); virtual void applyOptions(); protected: @@ -134,23 +98,4 @@ protected slots: void tipRequest(KviDynamicToolTip *tip,const QPoint &pnt); }; -#define KVI_TTBID_STEPNUM Qt::UserRole -#define KVI_TTBID_REDDIFF Qt::UserRole + 1 -#define KVI_TTBID_GREENDIFF Qt::UserRole + 2 -#define KVI_TTBID_BLUEDIFF Qt::UserRole + 3 -#define KVI_TTBID_HIGHLIGHT Qt::UserRole + 4 -#define KVI_TTBID_PROGRESS Qt::UserRole + 5 - -class KVIRC_API KviTreeWindowListItemDelegate : public KviTalIconAndRichTextItemDelegate -{ - Q_OBJECT -public: - KviTreeWindowListItemDelegate(QAbstractItemView * pWidget=0) - : KviTalIconAndRichTextItemDelegate(pWidget) {}; - ~KviTreeWindowListItemDelegate(){}; - QSize sizeHint(const QStyleOptionViewItem &option,const QModelIndex &index) const; - void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; - int calculateColor(int col1,int col2, int iStepNumber) const; -}; - #endif //_KVI_WINDOWLIST_TREE_H_ diff --git a/src/modules/dcc/send.cpp b/src/modules/dcc/send.cpp index e70bb2d54..c8c3ce1e7 100644 --- a/src/modules/dcc/send.cpp +++ b/src/modules/dcc/send.cpp @@ -1137,7 +1137,7 @@ void KviDccFileTransfer::displayPaint(QPainter * p,int column, QRect rect) if(daW1 < daW2)daW1 = daW2; int iLineSpacing = fm.lineSpacing(); - int iY = 4; + int iY = rect.top() + 4; p->setPen(Qt::black); @@ -1155,20 +1155,20 @@ void KviDccFileTransfer::displayPaint(QPainter * p,int column, QRect rect) p->setPen(Qt::darkGray); - p->drawText(rect.left() + 4,4,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szFrom); - p->drawText(rect.left() + 4,4 + iLineSpacing,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szTo); + p->drawText(rect.left() + 4, rect.top() + 4,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szFrom); + p->drawText(rect.left() + 4, rect.top() + 4 + iLineSpacing,width - 8,height - 8,Qt::AlignTop | Qt::AlignLeft,szTo); p->setPen(QColor(180,180,200)); iLineSpacing += 2; - p->drawRect(rect.left() + 4,height - (iLineSpacing + 4),width - 8,iLineSpacing); - p->fillRect(rect.left() + 5,height - (iLineSpacing + 3),width - 10,iLineSpacing - 2,bIsTerminated ? QColor(210,210,210) : QColor(190,190,240)); + p->drawRect(rect.left() + 4, rect.top() + height - (iLineSpacing + 4),width - 8,iLineSpacing); + p->fillRect(rect.left() + 5, rect.top() + height - (iLineSpacing + 3),width - 10,iLineSpacing - 2,bIsTerminated ? QColor(210,210,210) : QColor(190,190,240)); p->setPen(Qt::black); - p->drawText(rect.left() + 7,height - (iLineSpacing + 4),width - 14,iLineSpacing,Qt::AlignVCenter | Qt::AlignLeft,m_szStatusString); + p->drawText(rect.left() + 7, rect.top() + height - (iLineSpacing + 4),width - 14,iLineSpacing,Qt::AlignVCenter | Qt::AlignLeft,m_szStatusString); } break; diff --git a/src/modules/filetransferwindow/filetransferwindow.cpp b/src/modules/filetransferwindow/filetransferwindow.cpp index 985c413e7..ad3320809 100644 --- a/src/modules/filetransferwindow/filetransferwindow.cpp +++ b/src/modules/filetransferwindow/filetransferwindow.cpp @@ -77,7 +77,7 @@ KviFileTransferItem::KviFileTransferItem(KviFileTransferWidget * v,KviFileTransf col1Item = new KviTalTableWidgetItem(v, row(), 1); col2Item = new KviTalTableWidgetItem(v, row(), 2); //FIXME fixed row height - tableWidget()->setRowHeight( row(), 70 ); + tableWidget()->setRowHeight( row(), 68 ); } KviFileTransferItem::~KviFileTransferItem() |
