diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp index 0fa58df14945f6f13ca08f17c4df94d1e388073d..ed3ecd8a29937a0cb7330377891ef900aafd9894 100644 --- a/kde/src/CallView.cpp +++ b/kde/src/CallView.cpp @@ -48,6 +48,43 @@ #include "klib/ConfigurationSkeleton.h" #include "SFLPhoneAccessibility.h" +///@class CallTreeItemDelegate Delegates for CallTreeItem +class CallTreeItemDelegate : public QStyledItemDelegate +{ +public: +CallTreeItemDelegate(CallView* widget) + : QStyledItemDelegate(widget) + , m_tree(widget) + { + } + + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { + QSize sh = QStyledItemDelegate::sizeHint(option, index); + /*if (!index.parent().isValid()) { + sh.rheight() += 2 * m_categoryDrawer.leftMargin(); + } else { + sh.rheight() += m_categoryDrawer.leftMargin(); + } + if (index.column() == 0) { + sh.rwidth() += m_categoryDrawer.leftMargin(); + } else if (index.column() == 1) { + sh.rwidth() = 150; + } else { + sh.rwidth() += m_categoryDrawer.leftMargin(); + }*/ + QTreeWidgetItem* item = (m_tree)->itemFromIndex(index); + if (item) { + CallTreeItem* widget = (CallTreeItem*)m_tree->itemWidget(item,0); + if (widget) + sh.rheight() = widget->sizeHint().height()+4; + } + + return sh; + } +private: + CallView* m_tree; +}; + ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop CallView::CallView(QWidget* parent) : QTreeWidget(parent),m_pActiveOverlay(0),m_pCallPendingTransfer(0) @@ -56,7 +93,9 @@ CallView::CallView(QWidget* parent) : QTreeWidget(parent),m_pActiveOverlay(0),m_ setAcceptDrops(true); setDragEnabled(true); setAnimated (true); - CallTreeItemDelegate *delegate = new CallTreeItemDelegate(); + setUniformRowHeights(false); + + CallTreeItemDelegate *delegate = new CallTreeItemDelegate(this); setItemDelegate(delegate); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); diff --git a/kde/src/CallView.h b/kde/src/CallView.h index 78bbb78a5a624b4fd81aeba0c942d21a083c06bf..4a4825cfa711c76aa3d4d09159d4308f71589f28 100644 --- a/kde/src/CallView.h +++ b/kde/src/CallView.h @@ -20,9 +20,9 @@ #ifndef CALL_VIEW #define CALL_VIEW -#include <QtGui/QItemDelegate> #include <QtGui/QTreeWidget> #include <QtGui/QPainter> +#include <QtGui/QStyledItemDelegate> #include <QtCore/QTimer> #include "lib/CallModel.h" @@ -35,26 +35,15 @@ class KLineEdit; //SFLPhone class CallTreeItem; +class CallTreeItemDelegate; //Typedef typedef CallModel<CallTreeItem*,QTreeWidgetItem*> TreeWidgetCallModel; -///@class CallTreeItemDelegate Delegates for CallTreeItem -class CallTreeItemDelegate : public QItemDelegate -{ - public: - CallTreeItemDelegate() { } - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index ) const - { - Q_UNUSED(option) - Q_UNUSED(index) - return QSize(0,60); - } -}; - ///@class CallViewOverlay Display overlay on top of the call tree class CallViewOverlay : public QWidget { Q_OBJECT + public: //Constructor CallViewOverlay(QWidget* parent); @@ -84,6 +73,8 @@ private slots: ///@class CallView Central tree widget managing active calls class CallView : public QTreeWidget { Q_OBJECT + friend class CallTreeItemDelegate; + public: CallView ( QWidget* parent = 0 ); ~CallView ( ); diff --git a/kde/src/conf/dlggeneral.cpp b/kde/src/conf/dlggeneral.cpp index 46f76599d90733a196b18c461c6007428c6698f8..53f0ee4a50ec62a605178a64de6dcf24487866a0 100755 --- a/kde/src/conf/dlggeneral.cpp +++ b/kde/src/conf/dlggeneral.cpp @@ -32,6 +32,7 @@ DlgGeneral::DlgGeneral(QWidget *parent) connect(toolButton_historyClear, SIGNAL(clicked()), this, SIGNAL(clearCallHistoryAsked())); kcfg_historyMax->setValue(ConfigurationSkeleton::historyMax()); + kcfg_minimumRowHeight->setEnabled(ConfigurationSkeleton::limitMinimumRowHeight()); } DlgGeneral::~DlgGeneral() diff --git a/kde/src/conf/dlggeneralbase.ui b/kde/src/conf/dlggeneralbase.ui index 042fcfb26906a392eeada4b1c13a4d97ba1b4a5b..331a8843bb6c566e7683b9d768c2fba3a8fc7a74 100755 --- a/kde/src/conf/dlggeneralbase.ui +++ b/kde/src/conf/dlggeneralbase.ui @@ -150,41 +150,72 @@ <string>Visible call details</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> + <item row="1" column="0"> <widget class="QCheckBox" name="kcfg_displayCallIcon"> <property name="text"> <string>Display Icon</string> </property> </widget> </item> - <item row="0" column="1"> + <item row="1" column="1"> <widget class="QCheckBox" name="kcfg_displayCallNumber"> <property name="text"> <string>DisplayCallNumber</string> </property> </widget> </item> - <item row="1" column="0"> + <item row="2" column="0"> <widget class="QCheckBox" name="kcfg_displayCallSecure"> <property name="text"> <string>Display Security</string> </property> </widget> </item> - <item row="1" column="1"> + <item row="2" column="1"> <widget class="QCheckBox" name="kcfg_displayCallPeer"> <property name="text"> <string>Display Peer name</string> </property> </widget> </item> - <item row="2" column="0"> + <item row="3" column="0"> <widget class="QCheckBox" name="kcfg_displayCallCodec"> <property name="text"> <string>Display Codec</string> </property> </widget> </item> + <item row="0" column="0" colspan="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="kcfg_limitMinimumRowHeight"> + <property name="text"> + <string>Minimum item height</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="kcfg_minimumRowHeight"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </widget> </item> @@ -213,5 +244,22 @@ <resources> <include location="../qrc/resources.qrc"/> </resources> - <connections/> + <connections> + <connection> + <sender>kcfg_limitMinimumRowHeight</sender> + <signal>clicked(bool)</signal> + <receiver>kcfg_minimumRowHeight</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>131</x> + <y>213</y> + </hint> + <hint type="destinationlabel"> + <x>203</x> + <y>214</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/kde/src/klib/sflphone-client-kde.kcfg b/kde/src/klib/sflphone-client-kde.kcfg index cdf68c18c0a78bb608d9e10cb41fe5e68c06d014..27aa0a4229b614443ee773dbbeb2479a3a8e0f2d 100755 --- a/kde/src/klib/sflphone-client-kde.kcfg +++ b/kde/src/klib/sflphone-client-kde.kcfg @@ -41,6 +41,14 @@ <label>Should CallCodec be visible by default for calls</label> <default> false </default> </entry> + <entry name="limitMinimumRowHeight" type="Bool"> + <label>The minimum number of pixel for a call item</label> + <default> false </default> + </entry> + <entry name="minimumRowHeight" type="int"> + <label>The minimum number of pixel for a call item</label> + <default> 48 </default> + </entry> <!-- Display Settings --> diff --git a/kde/src/widgets/CallTreeItem.cpp b/kde/src/widgets/CallTreeItem.cpp index 5e9d6fa3c2084820d493876331f964942d47effc..2b8b2e1b38457a80fa22a39fcabca17384090643 100644 --- a/kde/src/widgets/CallTreeItem.cpp +++ b/kde/src/widgets/CallTreeItem.cpp @@ -25,6 +25,7 @@ #include <QtCore/QStringList> #include <QtCore/QMimeData> #include <QtCore/QTimer> +#include <QtGui/QPainter> #include <QtGui/QClipboard> #include <QtGui/QApplication> #include <QtGui/QWidget> @@ -37,6 +38,7 @@ #include <QtGui/QDragLeaveEvent> #include <QtGui/QPushButton> #include <QtGui/QTreeWidgetItem> +#include <QtGui/QFontMetrics> //KDE #include <KLocale> @@ -61,9 +63,10 @@ const char * CallTreeItem::callStateIcons[12] = {ICON_INCOMING, ICON_RINGING, IC ///Constructor CallTreeItem::CallTreeItem(QWidget *parent) : QWidget(parent), m_pItemCall(0), m_Init(false),m_pBtnConf(0), m_pBtnTrans(0),m_pTimer(0),m_pPeerL(0),m_pIconL(0),m_pCallNumberL(0),m_pSecureL(0),m_pCodecL(0),m_pHistoryPeerL(0) - , m_pTransferPrefixL(0),m_pTransferNumberL(0),m_pElapsedL(0) + , m_pTransferPrefixL(0),m_pTransferNumberL(0),m_pElapsedL(0),m_Height(0) { - setMaximumSize(99999,50); + setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + connect(AkonadiBackend::getInstance(),SIGNAL(collectionChanged()),this,SLOT(updated())); } ///Destructor @@ -94,6 +97,47 @@ Call* CallTreeItem::call() const return m_pItemCall; } +///Return the real size hint +QSize CallTreeItem::sizeHint () const +{ + uint height =0; + if (m_pItemCall && !m_pItemCall->isConference()) { + if ( m_pPeerL ) { + QFontMetrics fm(m_pPeerL->font()); + height += fm.height(); + } + if ( m_pCallNumberL ) { + QFontMetrics fm(m_pCallNumberL->font()); + height += fm.height(); + } + if ( m_pSecureL ) { + QFontMetrics fm(m_pSecureL->font()); + height += fm.height(); + } + if ( m_pCodecL ) { + QFontMetrics fm(m_pCodecL->font()); + height += fm.height(); + } + } + else { + height = 32; + } + + if (ConfigurationSkeleton::limitMinimumRowHeight() && height < (uint)ConfigurationSkeleton::minimumRowHeight()) { + height = (uint)ConfigurationSkeleton::minimumRowHeight(); + } + + if (height != m_Height) { + ((CallTreeItem*)this)->m_Height=height; + if (m_pIconL && height) { + m_pIconL->setMinimumSize(m_Height,m_Height); + m_pIconL->setMaximumSize(m_Height,m_Height); + m_pIconL->resize(m_Height,m_Height); + ((CallTreeItem*)this)->updated(); + } + } + return QSize(0,height); +} /***************************************************************************** * * @@ -113,22 +157,22 @@ void CallTreeItem::setCall(Call *call) if (m_pItemCall->isConference()) { if (!m_Init) { m_pHistoryPeerL = new QLabel(i18n("Conference"),this); - m_pIconL = new QLabel("",this); + m_pIconL = new QLabel(" ",this); QHBoxLayout* mainLayout = new QHBoxLayout(); mainLayout->addWidget(m_pIconL); mainLayout->addWidget(m_pHistoryPeerL); setLayout(mainLayout); m_Init = true; } - m_pIconL->setPixmap(QPixmap(ICON_CONFERENCE).scaled(QSize(48,48))); m_pIconL->setVisible(true); + m_pIconL->setStyleSheet("margin-top:"+(height()-32)/2); m_pHistoryPeerL->setVisible(true); return; } m_pTransferPrefixL = new QLabel(i18n("Transfer to : ")); - m_pTransferNumberL = new QLabel(); - m_pElapsedL = new QLabel(); + m_pTransferNumberL = new QLabel(" "); + m_pElapsedL = new QLabel(" "); QSpacerItem* verticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); m_pTransferPrefixL->setVisible(false); @@ -162,13 +206,16 @@ void CallTreeItem::setCall(Call *call) transfer->setSpacing(0); if (ConfigurationSkeleton::displayCallIcon()) { - m_pIconL = new QLabel(); + m_pIconL = new QLabel(" "); mainLayout->addWidget(m_pIconL); } - if(ConfigurationSkeleton::displayCallPeer()&& ! m_pItemCall->getPeerName().isEmpty()) { - m_pPeerL = new QLabel(); + if(ConfigurationSkeleton::displayCallPeer()/*&& ! m_pItemCall->getPeerName().isEmpty()*/) { + m_pPeerL = new QLabel(" "); m_pPeerL->setText(m_pItemCall->getPeerName()); + if (m_pItemCall->getPeerName().isEmpty()) { + m_pPeerL->setVisible(true); + } descr->addWidget(m_pPeerL); } @@ -178,12 +225,12 @@ void CallTreeItem::setCall(Call *call) } if (ConfigurationSkeleton::displayCallSecure()) { - m_pSecureL = new QLabel(this); + m_pSecureL = new QLabel(" ",this); descr->addWidget(m_pSecureL); } if (ConfigurationSkeleton::displayCallCodec()) { - m_pCodecL = new QLabel(this); + m_pCodecL = new QLabel(" ",this); descr->addWidget(m_pCodecL); } @@ -196,53 +243,78 @@ void CallTreeItem::setCall(Call *call) setLayout(mainLayout); - connect(m_pItemCall, SIGNAL(changed()), this, SLOT(updated())); - - updated(); + connect(m_pItemCall, SIGNAL(changed()), this, SLOT(updated())); + sizeHint(); } //setCall ///Update data void CallTreeItem::updated() { - kDebug() << "Updating tree item"; - Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(m_pItemCall->getPeerPhoneNumber()); - if (contact) { - if (m_pIconL&&contact->getPhoto()) - m_pIconL->setPixmap(*contact->getPhoto()); - if (m_pPeerL) - m_pPeerL->setText("<b>"+contact->getFormattedName()+"</b>"); + call_state state = m_pItemCall->getState(); + bool recording = m_pItemCall->getRecording(); + Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(m_pItemCall->getPeerPhoneNumber(),true); + if (contact && m_pPeerL) { + m_pPeerL->setText("<b>"+contact->getFormattedName()+"</b>"); + m_pPeerL->setVisible(true); } else { - if (m_pIconL) - m_pIconL->setPixmap(QPixmap(KIcon("user-identity").pixmap(QSize(48,48)))); - - if(m_pPeerL && ! m_pItemCall->getPeerName().trimmed().isEmpty()) { + if( m_pPeerL && ! m_pItemCall->getPeerName().trimmed().isEmpty()) { m_pPeerL->setText("<b>"+m_pItemCall->getPeerName()+"</b>"); + m_pPeerL->setVisible(true); } - else if (m_pPeerL) { + else if (m_pPeerL && !(state == CALL_STATE_RINGING || state == CALL_STATE_DIALING)) { m_pPeerL->setText(i18n("<b>Unknown</b>")); + m_pPeerL->setVisible(true); + } + else if (m_pPeerL) { + m_pPeerL->setText(i18n("")); + m_pPeerL->setVisible(false); } } - call_state state = m_pItemCall->getState(); - bool recording = m_pItemCall->getRecording(); if(state != CALL_STATE_OVER) { if(m_pIconL && state == CALL_STATE_CURRENT && recording) { - m_pIconL->setPixmap(QPixmap(ICON_CURRENT_REC)); + if (contact && !m_pItemCall->isConference()) { + QPixmap pxm = (*contact->getPhoto()).scaled(QSize(m_Height,m_Height)); + QPainter painter(&pxm); + QPixmap status(ICON_CURRENT_REC); + painter.drawPixmap(pxm.width()-status.width(),pxm.height()-status.height(),status); + m_pIconL->setPixmap(pxm); + } + else if (!m_pItemCall->isConference()) { + m_pIconL->setPixmap(QPixmap(ICON_CURRENT_REC)); + } } else if (m_pIconL) { QString str = QString(callStateIcons[state]); - m_pIconL->setPixmap(QPixmap(str)); + if (contact && !m_pItemCall->isConference()) { + QPixmap pxm = (*contact->getPhoto()).scaled(QSize(m_Height,m_Height)); + QPainter painter(&pxm); + QPixmap status(str); + painter.drawPixmap(pxm.width()-status.width(),pxm.height()-status.height(),status); + m_pIconL->setPixmap(pxm); + } + else if (!m_pItemCall->isConference()) { + m_pIconL->setPixmap(QPixmap(str)); + } } + + if (m_pIconL && m_pItemCall->isConference()) { + m_pIconL->setPixmap(QPixmap(ICON_CONFERENCE).scaled(QSize(m_Height,m_Height))); + } + bool transfer = state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD; - m_pTransferPrefixL->setVisible(transfer); - m_pTransferNumberL->setVisible(transfer); + if (m_pTransferPrefixL && m_pTransferNumberL) { + m_pTransferPrefixL->setVisible(transfer); + m_pTransferNumberL->setVisible(transfer); + } - if(!transfer) { + if(!transfer && m_pTransferNumberL) { m_pTransferNumberL->setText(""); } - m_pTransferNumberL->setText(m_pItemCall->getTransferNumber()); + if (m_pTransferNumberL) + m_pTransferNumberL->setText(m_pItemCall->getTransferNumber()); if (m_pCallNumberL) m_pCallNumberL->setText(m_pItemCall->getPeerPhoneNumber()); diff --git a/kde/src/widgets/CallTreeItem.h b/kde/src/widgets/CallTreeItem.h index 5304aa8f57bd8449a667296a9d546d84ceb128a8..9e312af5ec884994394d85aae83f1f3f3a8a9491 100644 --- a/kde/src/widgets/CallTreeItem.h +++ b/kde/src/widgets/CallTreeItem.h @@ -50,7 +50,8 @@ class CallTreeItem : public QWidget ~CallTreeItem(); //Getters - Call* call() const; + Call* call() const; + virtual QSize sizeHint () const; //Setters void setCall(Call *call); @@ -73,6 +74,7 @@ class CallTreeItem : public QWidget QLabel* m_pHistoryPeerL ; QLabel* m_pElapsedL ; QTimer* m_pTimer ; + uint m_Height ; TranslucentButtons* m_pBtnConf ; TranslucentButtons* m_pBtnTrans; diff --git a/kde/src/widgets/CategorizedTreeWidget.cpp b/kde/src/widgets/CategorizedTreeWidget.cpp index e67f4b42cc7e29222238db507b43e6f973fe987b..fe03b6c2275a842490921f7ad1798821a285eebc 100644 --- a/kde/src/widgets/CategorizedTreeWidget.cpp +++ b/kde/src/widgets/CategorizedTreeWidget.cpp @@ -125,6 +125,14 @@ class KateColorTreeDelegate : public QStyledItemDelegate if (option.state & QStyle::State_Selected) { QStyledItemDelegate::paint(painter,option,index); } + + QTreeWidgetItem* item = m_tree->itemFromIndex(index); + if (item) { + QWidget* widget = m_tree->itemWidget(item,0); + if (widget) { + widget->setMinimumSize((m_tree->viewport()->width() - m_categoryDrawer.leftMargin() - m_categoryDrawer.rightMargin()),10); + } + } } private: @@ -139,6 +147,7 @@ CategorizedTreeWidget::CategorizedTreeWidget(QWidget *parent) setItemDelegate(new KateColorTreeDelegate(this)); setHeaderHidden(true); setRootIsDecorated(false); + //setUniformRowHeights(false); setIndentation(25); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerItem); diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp index 13a7e00f0845e965e2f446680e2d5d6612e654c3..54ce39c013a5fda13e67d936f474eb681631138c 100644 --- a/kde/src/widgets/HistoryTreeItem.cpp +++ b/kde/src/widgets/HistoryTreeItem.cpp @@ -354,8 +354,8 @@ void HistoryTreeItem::showRecordPlayer() r2->addItem ( hSpacer ); r2->addWidget( m_pNote ); - m_pPlayer->setMinimumSize(width(),height()); - m_pPlayer->setMaximumSize(width(),height()); + m_pPlayer->setMinimumSize(width()-14,height()); + m_pPlayer->setMaximumSize(width()-14,height()); l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding)); m_pPlayer->setVisible(true); @@ -438,8 +438,8 @@ void HistoryTreeItem::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); if (m_pPlayer) { - m_pPlayer->setMinimumSize(width(),height()); - m_pPlayer->setMaximumSize(width(),height()); + m_pPlayer->setMinimumSize(width()-14,height()); + m_pPlayer->setMaximumSize(width()-14,height()); } }