Skip to content
Snippets Groups Projects
Commit 2e5c99e9 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files

[ #11990 ] Make call item height configurable

parent be9c99ef
Branches
Tags
No related merge requests found
......@@ -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));
......
......@@ -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 ( );
......
......@@ -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()
......
......@@ -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>
......@@ -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 -->
......
......@@ -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);
}
/*****************************************************************************
* *
......@@ -120,15 +164,15 @@ void CallTreeItem::setCall(Call *call)
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);
}
......@@ -197,51 +244,76 @@ void CallTreeItem::setCall(Call *call)
setLayout(mainLayout);
connect(m_pItemCall, SIGNAL(changed()), this, SLOT(updated()));
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)
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()) {
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) {
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]);
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;
if (m_pTransferPrefixL && m_pTransferNumberL) {
m_pTransferPrefixL->setVisible(transfer);
m_pTransferNumberL->setVisible(transfer);
}
if(!transfer) {
if(!transfer && m_pTransferNumberL) {
m_pTransferNumberL->setText("");
}
if (m_pTransferNumberL)
m_pTransferNumberL->setText(m_pItemCall->getTransferNumber());
if (m_pCallNumberL)
......
......@@ -51,6 +51,7 @@ class CallTreeItem : public QWidget
//Getters
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;
......
......@@ -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);
......
......@@ -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());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment