Commit 254851a5 authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

[ #13801 ] Fix indentation, beautify the code, add comment

parent 62b69203
......@@ -2,6 +2,7 @@
* Copyright (C) 2009-2012 by Savoir-Faire Linux *
* Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> *
* Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>*
* ^^ Refuse any liability for this code *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......
......@@ -36,13 +36,10 @@ class AccountWizard : public QWizard
Q_OBJECT
public:
enum { Page_Intro, Page_AutoMan, Page_Type, Page_Email, Page_SIPForm, Page_IAXForm, Page_Stun, Page_Conclusion };
AccountWizard(QWidget * parent = 0);
~AccountWizard();
void accept();
};
/***************************************************************************
......
......@@ -69,7 +69,6 @@ CallTreeItemDelegate(CallView* widget)
if (index.parent().isValid() && !index.parent().child(index.row()+1,0).isValid())
sh.rheight() += 15;
}
return sh;
......@@ -113,7 +112,6 @@ CallTreeItemDelegate(CallView* widget)
for (int i =0;i < childCount;i++) {
r.setHeight(r.height() + sizeHint(option,index).height());
}
// qDebug() << "\n\nFINAL SIZE" << r;
}
r.setTop(r.top() + m_ConferenceDrawer.leftMargin());
......
......@@ -18,10 +18,13 @@
#ifndef CALL_VIEW
#define CALL_VIEW
//Qt
#include <QtGui/QTreeWidget>
#include <QtGui/QPainter>
#include <QtGui/QStyledItemDelegate>
#include <QtCore/QTimer>
//SFLPhone
#include "lib/CallModel.h"
//Qt
......
......@@ -252,35 +252,37 @@ void SFLPhone::setupActions()
action_configureSflPhone = KStandardAction::preferences(m_pView, SLOT(configureSflPhone()), this);
action_configureSflPhone->setText(i18n("Configure SFLphone"));
action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad"), this);
action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad") , this);
action_displayMessageBox = new KAction(KIcon("mail-message-new"), i18n("Display text message box") , this);
action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this);
action_pastenumber = new KAction(KIcon("edit-paste"), i18n("Paste") , this);
action_showContactDock = new KAction(KIcon("edit-find-user") , i18n("Display Contact") , this);
action_showHistoryDock = new KAction(KIcon("view-history") , i18n("Display history") , this);
action_showBookmarkDock = new KAction(KIcon("bookmark-new-list"), i18n("Display bookmark") , this);
action_accountCreationWizard = new KAction(i18n("Account creation wizard") , this);
action_displayDialpad->setCheckable( true );
action_displayDialpad->setChecked ( ConfigurationSkeleton::displayDialpad() );
action_configureSflPhone->setText(i18n("Configure SFLphone"));
action_displayMessageBox = new KAction(KIcon("mail-message-new"), i18n("Display text message box"), this);
action_displayMessageBox->setCheckable( true );
action_displayMessageBox->setChecked ( ConfigurationSkeleton::displayMessageBox() );
action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this);
action_displayVolumeControls->setCheckable( true );
action_displayVolumeControls->setChecked ( ConfigurationSkeleton::displayVolume() );
action_pastenumber = new KAction(KIcon("edit-paste"), i18n("Paste"), this);
action_pastenumber->setShortcut ( Qt::CTRL + Qt::Key_V );
action_showContactDock = new KAction(KIcon("edit-find-user") , i18n("Display Contact") , this);
action_showContactDock->setCheckable( true );
action_showContactDock->setChecked(ConfigurationSkeleton::displayContactDock());
action_showHistoryDock = new KAction(KIcon("view-history") , i18n("Display history") , this);
action_showHistoryDock->setCheckable( true );
action_showHistoryDock->setChecked(ConfigurationSkeleton::displayHistoryDock());
action_showBookmarkDock = new KAction(KIcon("bookmark-new-list"), i18n("Display bookmark"), this);
action_showBookmarkDock->setCheckable( true );
action_showBookmarkDock->setChecked(ConfigurationSkeleton::displayBookmarkDock());
action_accountCreationWizard = new KAction(i18n("Account creation wizard"), this);
action_configureShortcut = new KAction(KIcon(KIcon("configure-shortcuts")), i18n("Configure Shortcut"), this);
......
......@@ -28,18 +28,18 @@ SFLPhoneAccessibility* SFLPhoneAccessibility::m_pInstance=nullptr;
SFLPhoneAccessibility::SFLPhoneAccessibility() : QObject(0),QList<KAction*>()
{
KAction* action = new KAction(0);
action->setObjectName("listCall");
action->setShortcut( Qt::CTRL + Qt::Key_L );
action->setText("List all current calls");
action->setIcon(KIcon("text-speak"));
action->setObjectName ( "listCall" );
action->setShortcut ( Qt::CTRL + Qt::Key_L );
action->setText ( "List all current calls" );
action->setIcon ( KIcon("text-speak") );
*this << action;
connect(action,SIGNAL(triggered(bool)),this,SLOT(listCall()));
action = new KAction(0);
action->setObjectName("currentCallDetails");
action->setShortcut( Qt::CTRL + Qt::Key_I );
action->setText("Get current call details");
action->setIcon(KIcon("text-speak"));
action->setObjectName ( "currentCallDetails" );
action->setShortcut ( Qt::CTRL + Qt::Key_I );
action->setText ( "Get current call details" );
action->setIcon ( KIcon("text-speak") );
*this << action;
connect(action,SIGNAL(triggered(bool)),this,SLOT(currentCallDetails()));
}
......
......@@ -26,10 +26,14 @@ class SFLPhoneAccessibility : public QObject, public QList<KAction*>
{
Q_OBJECT
public:
//Singleton
static SFLPhoneAccessibility* getInstance();
private:
//Constructor
SFLPhoneAccessibility();
QString numberToDigit(QString number);
//Static attributes
static SFLPhoneAccessibility* m_pInstance;
public slots:
......
......@@ -414,15 +414,18 @@ void SFLPhoneView::updateWindowCallState()
actionTexts [ SFLPhone::Refuse ] = ACTION_LABEL_REFUSE ;
m_pMessageBoxW->setVisible(false || IM_ACTIVE) ;
break;
case CALL_STATE_RINGING:
enabledActions [ SFLPhone::Hold ] = false ;
enabledActions [ SFLPhone::Transfer ] = false ;
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_CURRENT:
buttonIconFiles [ SFLPhone::Record ] = ICON_REC_DEL_ON ;
m_pMessageBoxW->setVisible((true && ConfigurationSkeleton::displayMessageBox()) || IM_ACTIVE);
break;
case CALL_STATE_DIALING:
enabledActions [ SFLPhone::Hold ] = false ;
enabledActions [ SFLPhone::Transfer ] = false ;
......@@ -431,11 +434,13 @@ void SFLPhoneView::updateWindowCallState()
buttonIconFiles [ SFLPhone::Accept ] = ICON_ACCEPT ;
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_HOLD:
buttonIconFiles [ SFLPhone::Hold ] = ICON_UNHOLD ;
actionTexts [ SFLPhone::Hold ] = ACTION_LABEL_UNHOLD ;
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_FAILURE:
enabledActions [ SFLPhone::Accept ] = false ;
enabledActions [ SFLPhone::Hold ] = false ;
......@@ -443,6 +448,7 @@ void SFLPhoneView::updateWindowCallState()
enabledActions [ SFLPhone::Record ] = false ;
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_BUSY:
enabledActions [ SFLPhone::Accept ] = false ;
enabledActions [ SFLPhone::Hold ] = false ;
......@@ -450,6 +456,7 @@ void SFLPhoneView::updateWindowCallState()
enabledActions [ SFLPhone::Record ] = false ;
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_TRANSFERRED:
buttonIconFiles [ SFLPhone::Accept ] = ICON_EXEC_TRANSF ;
actionTexts [ SFLPhone::Transfer ] = ACTION_LABEL_GIVE_UP_TRANSF ;
......@@ -457,6 +464,7 @@ void SFLPhoneView::updateWindowCallState()
m_pMessageBoxW->setVisible(false || IM_ACTIVE) ;
transfer = true;
break;
case CALL_STATE_TRANSF_HOLD:
buttonIconFiles [ SFLPhone::Accept ] = ICON_EXEC_TRANSF ;
buttonIconFiles [ SFLPhone::Hold ] = ICON_UNHOLD ;
......@@ -465,25 +473,31 @@ void SFLPhoneView::updateWindowCallState()
m_pMessageBoxW->setVisible(false) ;
transfer = true;
break;
case CALL_STATE_OVER:
kDebug() << "Error : Reached CALL_STATE_OVER with call " << call->getCallId() << "!";
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_ERROR:
kDebug() << "Error : Reached CALL_STATE_ERROR with call " << call->getCallId() << "!";
m_pMessageBoxW->setVisible(false) ;
break;
case CALL_STATE_CONFERENCE:
enabledActions [ SFLPhone::Transfer ] = false ;
m_pMessageBoxW->setVisible(false || IM_ACTIVE) ;
break;
case CALL_STATE_CONFERENCE_HOLD:
enabledActions [ SFLPhone::Transfer ] = false ;
m_pMessageBoxW->setVisible(false) ;
break;
default:
kDebug() << "Error : Reached unexisting state for call " << call->getCallId() << "(" << call->toHumanStateName() << "!";
break;
}
}
......
/***************************************************************************
* Copyright (C) 2009-2012 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Valle <emmanuel.lepage@savoirfairelinux.com >*
* Nokia *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......
/***************************************************************************
* Copyright (C) 2009-2012 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Valle <emmanuel.lepage@savoirfairelinux.com >*
* Nokia *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
......
......@@ -69,26 +69,26 @@ BookmarkDock::BookmarkDock(QWidget* parent) : QDockWidget(parent)
setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
setMinimumSize(250,0);
m_pFilterLE = new KLineEdit(this);
m_pSplitter = new QSplitter(Qt::Vertical,this);
m_pItemView = new CategorizedTreeWidget(this);
m_pMostUsedCK = new QCheckBox(this);
m_pFilterLE = new KLineEdit ( this );
m_pSplitter = new QSplitter ( Qt::Vertical,this );
m_pItemView = new CategorizedTreeWidget( this );
m_pMostUsedCK = new QCheckBox ( this );
QWidget* mainWidget = new QWidget ( this );
QVBoxLayout* mainLayout = new QVBoxLayout ( mainWidget );
m_pFilterLE->setPlaceholderText(i18n("Filter"));
m_pMostUsedCK->setChecked(ConfigurationSkeleton::displayContactCallHistory());
QWidget* mainWidget = new QWidget(this);
setWidget(mainWidget);
m_pMostUsedCK->setText(i18n("Show most called contacts"));
QVBoxLayout* mainLayout = new QVBoxLayout(mainWidget);
mainLayout->addWidget(m_pMostUsedCK);
mainLayout->addWidget(m_pSplitter);
m_pSplitter->addWidget(m_pItemView);
mainLayout->addWidget(m_pFilterLE);
mainLayout->addWidget ( m_pMostUsedCK );
mainLayout->addWidget ( m_pSplitter );
m_pSplitter->addWidget( m_pItemView );
mainLayout->addWidget ( m_pFilterLE );
m_pSplitter->setChildrenCollapsible(true);
m_pSplitter->setStretchFactor(0,7);
......
......@@ -194,12 +194,14 @@ void CallTreeItem::setCall(Call *call)
baseColor.setRed (baseColor.red() + (textColor.red() -baseColor.red()) *0.6);
baseColor.setGreen(baseColor.green()+ (textColor.green()-baseColor.green())*0.6);
m_pHistoryPeerL = new QLabel(i18n("<b>Conference</b>"),this);
m_pHistoryPeerL->setStyleSheet("color:"+baseColor.name());
m_pIconL = new QLabel(" ",this);
m_pHistoryPeerL = new QLabel( i18n("<b>Conference</b>"),this );
m_pIconL = new QLabel( " ",this );
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->addWidget(m_pIconL);
mainLayout->addWidget(m_pHistoryPeerL);
m_pHistoryPeerL->setStyleSheet("color:"+baseColor.name());
mainLayout->addWidget( m_pIconL );
mainLayout->addWidget( m_pHistoryPeerL );
setLayout(mainLayout);
m_Init = true;
}
......@@ -220,7 +222,6 @@ void CallTreeItem::setCall(Call *call)
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->setContentsMargins ( 3, 1, 2, 1);
m_pBtnConf = new TranslucentButtons(this);
m_pBtnConf->setVisible(false);
m_pBtnConf->setParent(this);
......@@ -238,10 +239,10 @@ void CallTreeItem::setCall(Call *call)
mainLayout->setSpacing(4);
QVBoxLayout* descr = new QVBoxLayout();
descr->setMargin(1);
descr->setSpacing(1);
QHBoxLayout* transfer = new QHBoxLayout();
transfer->setMargin(0);
descr->setMargin (1);
descr->setSpacing (1);
transfer->setMargin (0);
transfer->setSpacing(0);
if (ConfigurationSkeleton::displayCallIcon()) {
......@@ -499,12 +500,12 @@ void CallTreeItem::dropEvent(QDropEvent *e)
void CallTreeItem::resizeEvent ( QResizeEvent *e )
{
if (m_pBtnConf) {
m_pBtnConf->setMinimumSize(width()/2-15,height()-4);
m_pBtnConf->setMaximumSize(width()/2-15,height()-4);
m_pBtnTrans->setMinimumSize(width()/2-15,height()-4);
m_pBtnTrans->setMaximumSize(width()/2-15,height()-4);
m_pBtnTrans->move(width()/2+10,m_pBtnTrans->y()+2);
m_pBtnConf->move(10,m_pBtnConf->y()+2);
m_pBtnConf->setMinimumSize ( width()/2-15,height()-4 );
m_pBtnConf->setMaximumSize ( width()/2-15,height()-4 );
m_pBtnTrans->setMinimumSize( width()/2-15,height()-4 );
m_pBtnTrans->setMaximumSize( width()/2-15,height()-4 );
m_pBtnTrans->move ( width()/2+10,m_pBtnTrans->y()+2);
m_pBtnConf->move ( 10,m_pBtnConf->y()+2 );
}
e->accept();
......@@ -539,11 +540,11 @@ void CallTreeItem::copy()
{
kDebug() << "Copying contact";
QMimeData* mimeData = new QMimeData();
mimeData->setData(MIME_CALLID, m_pItemCall->getCallId().toUtf8());
QString numbers(m_pItemCall->getPeerName()+": "+m_pItemCall->getPeerPhoneNumber());
QString numbersHtml("<b>"+m_pItemCall->getPeerName()+"</b><br />"+m_pItemCall->getPeerPhoneNumber());
mimeData->setData("text/plain", numbers.toUtf8());
mimeData->setData("text/html", numbersHtml.toUtf8());
mimeData->setData( MIME_CALLID , m_pItemCall->getCallId().toUtf8() );
mimeData->setData( "text/plain" , numbers.toUtf8() );
mimeData->setData( "text/html" , numbersHtml.toUtf8() );
QClipboard* clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData);
}
......@@ -552,7 +553,7 @@ void CallTreeItem::copy()
void CallTreeItem::hide()
{
if (!m_isHover) {
m_pBtnConf->setVisible(false);
m_pBtnConf->setVisible (false);
m_pBtnTrans->setVisible(false);
}
}
......
......@@ -97,11 +97,11 @@ class CallTreeItem : public QWidget
virtual void mouseDoubleClickEvent ( QMouseEvent *e );
private slots:
void transferEvent(QMimeData* data);
void transferEvent (QMimeData* data);
void conversationEvent(QMimeData* data);
void hide();
void incrementTimer();
void copy();
void hide ( );
void incrementTimer ( );
void copy ( );
public slots:
void updated();
......
......@@ -31,6 +31,7 @@
#include <QKeyEvent>
//BEGIN KateColorTreeDelegate
///Code taken from Kate and adapted to render categorized lists
class KateColorTreeDelegate : public QStyledItemDelegate
{
public:
......@@ -154,6 +155,7 @@ class KateColorTreeDelegate : public QStyledItemDelegate
};
//END KateColorTreeDelegate
///Constructor
CategorizedTreeWidget::CategorizedTreeWidget(QWidget *parent)
: QTreeWidget(parent)
{
......@@ -166,20 +168,21 @@ CategorizedTreeWidget::CategorizedTreeWidget(QWidget *parent)
setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
}
///Do not draw branches
void CategorizedTreeWidget::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const
{
Q_UNUSED(painter)
Q_UNUSED(rect)
Q_UNUSED(index)
/*if (index.parent().parent().isValid())
QTreeWidget::drawBranches(painter,rect,index);*/
Q_UNUSED( painter )
Q_UNUSED( rect )
Q_UNUSED( index )
}
///Get the item list
QVector<QTreeWidgetItem*> CategorizedTreeWidget::realItems() const
{
return m_lItems;
}
///Remove an item from the list
void CategorizedTreeWidget::removeItem(QTreeWidgetItem* item)
{
for (int i=0;i<topLevelItemCount();i++) {
......
......@@ -51,6 +51,7 @@ class CategorizedTreeWidget : public QTreeWidget
QVector<QTreeWidgetItem*> m_lItems;
};
///Add new item to the list
template <class T> T* CategorizedTreeWidget::addItem(QString category,bool top)
{
QTreeWidgetItem* categoryItem = 0;
......@@ -74,7 +75,7 @@ template <class T> T* CategorizedTreeWidget::addItem(QString category,bool top)
return iwdg;
}
///Add a category to the list
template <class T> T* CategorizedTreeWidget::addCategory(QString name)
{
T* categoryItem = new T(this);
......
......@@ -24,16 +24,18 @@
#include <QApplication>
#include <QStyleOption>
///Constructor
CategoryDrawer::CategoryDrawer()
{
setLeftMargin ( 7 );
setRightMargin( 7 );
}
void CategoryDrawer::drawCategory(const QModelIndex &index,
///Draw a category style
void CategoryDrawer::drawCategory(const QModelIndex& index ,
int sortRole,
const QStyleOption &option,
QPainter *painter) const
const QStyleOption& option ,
QPainter* painter ) const
{
Q_UNUSED( sortRole )
......@@ -258,6 +260,7 @@ void CategoryDrawer::drawCategory(const QModelIndex &index,
//END: draw text
}
///Return category height
int CategoryDrawer::categoryHeight(const QModelIndex &index, const QStyleOption &option) const
{
Q_UNUSED( index );
......
......@@ -21,8 +21,10 @@
#ifndef CATEGORYDRAWER_H
#define CATEGORYDRAWER_H
//KDE
#include <KCategoryDrawer>
//Qt
class QPainter;
class QModelIndex;
class QStyleOption;
......
......@@ -26,16 +26,18 @@
#include <QModelIndex>
#include <QDebug>
///Constructor
ConferenceBox::ConferenceBox()
{
setLeftMargin ( 7 );
setRightMargin( 7 );
}
void ConferenceBox::drawCategory(const QModelIndex &index,
///Draw a conference box
void ConferenceBox::drawCategory(const QModelIndex& index ,
int sortRole,
const QStyleOption &option,
QPainter *painter) const
const QStyleOption& option ,
QPainter* painter ) const
{
Q_UNUSED( sortRole )
Q_UNUSED( index )
......@@ -277,25 +279,9 @@ void ConferenceBox::drawCategory(const QModelIndex &index,
painter->fillRect(QRect(start, rectSize), gradient);
}
//END: horizontal line
//BEGIN: draw text
// {
// const QString category = index.model()->data(index, Qt::DisplayRole).toString();
// QRect textRect = QRect(option.rect.topLeft(), QSize(option.rect.width() - 2 - 3 - 3, height));
// textRect.setTop(textRect.top() + 2 + 3 /* corner */);
// textRect.setLeft(textRect.left() + 2 + 3 /* corner */ + 3 /* a bit of margin */);
// painter->save();
// painter->setFont(font);
// QColor penColor(option.palette.text().color());
// penColor.setAlphaF(0.6);
// painter->setPen(penColor);
// painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, category);
// painter->restore();
// }
//END: draw text
}
///Draw the bottom border of the box
void ConferenceBox::drawBoxBottom(const QModelIndex &index, int sortRole, const QStyleOption &option, QPainter *painter) const {
Q_UNUSED(index)
Q_UNUSED(sortRole)
......@@ -327,6 +313,7 @@ void ConferenceBox::drawBoxBottom(const QModelIndex &index, int sortRole, const
//END: bottom right corner
}
///Return the height of the conference box
int ConferenceBox::categoryHeight(const QModelIndex &index, const QStyleOption &option) const
{
Q_UNUSED( index );
......
......@@ -20,13 +20,15 @@
// Rafael agreet to relicense it under LGPLv2 or LGPLv3, just as we need it,
// see: http://lists.kde.org/?l=kwrite-devel&m=133061943317199&w=2
//KDE
#include <KCategoryDrawer>
//Qt
class QPainter;
class QModelIndex;
class QStyleOption;
///CategoryDrawer: A better looking widget than the plain QListWidget
///ConferenceBox: Draw a nice box instead of using plain tree
class ConferenceBox : public KCategoryDrawerV2
{
public:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment