• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/kopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • kopete
  • config
  • appearance
contactlistlayouteditwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2009 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3  * Copyright (c) 2009 Roman Jarosz <kedgedev@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "contactlistlayouteditwidget.h"
22 #include "TokenDropTarget.h"
23 #include "contactlistlayoutmanager.h"
24 #include "contactlisttoken.h"
25 
26 #include <KHBox>
27 #include <KLocale>
28 #include <KDebug>
29 
30 #include <QCheckBox>
31 #include <QSpinBox>
32 
33 using namespace ContactList;
34 
35 LayoutEditWidget::LayoutEditWidget( QWidget *parent )
36 : KVBox(parent)
37 {
38  m_tokenFactory = new ContactListTokenFactory;
39  m_tokenDropTarget = new TokenDropTarget( "application/x-kopete-contactlist-token", this );
40  m_tokenDropTarget->setCustomTokenFactory( m_tokenFactory );
41  connect( m_tokenDropTarget, SIGNAL(focussed(QWidget*)), this, SIGNAL(focussed(QWidget*)) );
42  connect( m_tokenDropTarget, SIGNAL(changed()), this, SIGNAL(changed()) );
43 
44  m_showIconCheckBox = new QCheckBox( i18n( "Show Icon" ) , this );
45  connect( m_showIconCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
46 }
47 
48 
49 LayoutEditWidget::~LayoutEditWidget()
50 {
51 // delete m_tokenFactory; m_tokenFactory = 0;
52 }
53 
54 void LayoutEditWidget::readLayout( ContactList::LayoutItemConfig config )
55 {
56  int rowCount = config.rows();
57 
58  m_showIconCheckBox->setChecked( config.showIcon() );
59 
60  m_tokenDropTarget->clear();
61 
62  for( int i = 0; i < rowCount; i++ )
63  {
64  //get the row config
65  ContactList::LayoutItemConfigRow rowConfig = config.row( i );
66 
67  int elementCount = rowConfig.count();
68 
69  //FIXME! for now, each element get the same size. This needs extensions to the token stuff
70  //qreal size = 1.0 / (qreal) elementCount;
71 
72  for( int j = 0; j < elementCount; j++ )
73  {
74  ContactList::LayoutItemConfigRowElement element = rowConfig.element( j );
75  ContactList::ContactListTokenConfig clToken = ContactList::LayoutManager::instance()->token( element.value() );
76  ContactListToken *token = new ContactListToken( clToken.mName, clToken.mIconName, element.value(), m_tokenDropTarget );
77  token->setBold( element.bold() );
78  token->setSmall( element.small() );
79  token->setOptimalSize( element.optimalSize() );
80  token->setItalic( element.italic() );
81  token->setAlignment( element.alignment() );
82  m_tokenDropTarget->insertToken( token, i, j );
83  token->setWidth( element.size() * 100.0 );
84  }
85 
86  }
87 }
88 
89 ContactList::LayoutItemConfig LayoutEditWidget::config()
90 {
91 
92  LayoutItemConfig config;
93  config.setShowIcon( m_showIconCheckBox->isChecked() );
94 
95  int noOfRows = m_tokenDropTarget->rows();
96 
97  for( int i = 0; i < noOfRows; i++ )
98  {
99 
100  LayoutItemConfigRow currentRowConfig;
101 
102  QList<Token *> tokens = m_tokenDropTarget->drags( i );
103 
104  foreach( Token * token, tokens ) {
105  if ( ContactListToken *twl = dynamic_cast<ContactListToken *>( token ) )
106  {
107  qreal width = 0.0;
108  if ( twl->widthForced() && twl->width() > 0.01) {
109  width = twl->width();
110  }
111  currentRowConfig.addElement( LayoutItemConfigRowElement( twl->value(), width, twl->bold(), twl->italic(), twl->small(),
112  twl->optimalSize(), twl->alignment(), twl->prefix(), twl->suffix() ) );
113  }
114  }
115 
116  config.addRow( currentRowConfig );
117 
118  }
119  return config;
120 }
121 
122 
123 #include "contactlistlayouteditwidget.moc"
124 
ContactList::LayoutItemConfigRowElement::alignment
Qt::Alignment alignment() const
Definition: contactlistlayoutitemconfig.h:42
ContactList::LayoutItemConfig::row
LayoutItemConfigRow row(int at) const
Definition: contactlistlayoutitemconfig.cpp:74
KVBox
ContactList::LayoutEditWidget::config
ContactList::LayoutItemConfig config()
Definition: contactlistlayouteditwidget.cpp:89
ContactList::LayoutItemConfigRowElement::small
bool small() const
Definition: contactlistlayoutitemconfig.h:45
ContactList::LayoutEditWidget::LayoutEditWidget
LayoutEditWidget(QWidget *parent)
Definition: contactlistlayouteditwidget.cpp:35
contactlistlayoutmanager.h
ContactListToken::setSmall
void setSmall(bool small)
Definition: contactlisttoken.cpp:74
TokenDropTarget::clear
void clear()
Definition: TokenDropTarget.cpp:186
TokenDropTarget::setCustomTokenFactory
void setCustomTokenFactory(TokenFactory *factory)
Definition: TokenDropTarget.cpp:425
ContactList::LayoutItemConfigRowElement::optimalSize
bool optimalSize() const
Definition: contactlistlayoutitemconfig.h:46
ContactList::LayoutEditWidget::focussed
void focussed(QWidget *)
TokenWithLayout::setBold
void setBold(bool bold)
Definition: TokenWithLayout.cpp:219
ContactList::LayoutItemConfigRowElement::size
qreal size() const
Definition: contactlistlayoutitemconfig.h:39
contactlistlayouteditwidget.h
ContactList::LayoutItemConfig::setShowIcon
void setShowIcon(bool showIcon)
Definition: contactlistlayoutitemconfig.cpp:89
QWidget
ContactList::LayoutItemConfig::rows
int rows() const
Definition: contactlistlayoutitemconfig.cpp:68
TokenDropTarget
Definition: TokenDropTarget.h:32
ContactList::LayoutItemConfig
This class wraps the data needed to paint a LayoutItemDelegate.
Definition: contactlistlayoutitemconfig.h:73
ContactList::LayoutItemConfigRow
Definition: contactlistlayoutitemconfig.h:59
ContactList::LayoutItemConfig::showIcon
bool showIcon() const
Definition: contactlistlayoutitemconfig.cpp:84
ContactListToken
Definition: contactlisttoken.h:29
TokenDropTarget::rows
int rows() const
Definition: TokenDropTarget.cpp:375
ContactList::LayoutManager::instance
static LayoutManager * instance()
Definition: contactlistlayoutmanager.cpp:47
TokenWithLayout::setWidth
void setWidth(int width)
Definition: TokenWithLayout.cpp:249
ContactListToken::setOptimalSize
void setOptimalSize(bool optimalSize)
Definition: contactlisttoken.cpp:92
ContactList::ContactListTokenConfig::mName
QString mName
Definition: contactlistlayoutmanager.h:49
ContactList::LayoutItemConfigRow::count
int count() const
Definition: contactlistlayoutitemconfig.cpp:46
TokenDropTarget.h
ContactList::ContactListTokenConfig
Definition: contactlistlayoutmanager.h:37
ContactList::LayoutItemConfigRow::addElement
void addElement(LayoutItemConfigRowElement element)
Definition: contactlistlayoutitemconfig.cpp:41
TokenWithLayout::setItalic
void setItalic(bool italic)
Definition: TokenWithLayout.cpp:273
ContactList::LayoutEditWidget::~LayoutEditWidget
~LayoutEditWidget()
Definition: contactlistlayouteditwidget.cpp:49
ContactList::LayoutItemConfigRow::element
LayoutItemConfigRowElement element(int at) const
Definition: contactlistlayoutitemconfig.cpp:51
ContactListTokenFactory
Definition: contactlisttoken.h:23
ContactList::LayoutItemConfigRowElement::bold
bool bold() const
Definition: contactlistlayoutitemconfig.h:40
ContactList::LayoutItemConfigRowElement::italic
bool italic() const
Definition: contactlistlayoutitemconfig.h:41
TokenDropTarget::insertToken
void insertToken(Token *, int row=-1, int col=-1)
Definition: TokenDropTarget.cpp:346
ContactList::LayoutItemConfigRowElement
Definition: contactlistlayoutitemconfig.h:31
ContactList::ContactListTokenConfig::mIconName
QString mIconName
Definition: contactlistlayoutmanager.h:50
Token
Definition: Token.h:38
ContactList::LayoutEditWidget::changed
void changed()
TokenDropTarget::drags
QList< Token * > drags(int row=-1)
Definition: TokenDropTarget.cpp:240
QCheckBox
ContactList::LayoutItemConfig::addRow
void addRow(LayoutItemConfigRow row)
Definition: contactlistlayoutitemconfig.cpp:79
ContactList::LayoutItemConfigRowElement::value
int value() const
Definition: contactlistlayoutitemconfig.h:38
TokenWithLayout::setAlignment
void setAlignment(Qt::Alignment alignment)
Definition: TokenWithLayout.cpp:186
contactlisttoken.h
ContactList::LayoutManager::token
ContactListTokenConfig token(int tokenType) const
Definition: contactlistlayoutmanager.h:81
ContactList::LayoutEditWidget::readLayout
void readLayout(ContactList::LayoutItemConfig config)
Definition: contactlistlayouteditwidget.cpp:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal