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

kdgantt2

  • sources
  • kde-4.12
  • kdepim
  • kdgantt2
kdganttconstraintproxy.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  ** Copyright (C) 2001-2006 Klarälvdalens Datakonsult AB. All rights reserved.
3  **
4  ** This file is part of the KD Gantt library.
5  **
6  ** This file may be distributed and/or modified under the terms of the
7  ** GNU General Public License version 2 as published by the Free Software
8  ** Foundation and appearing in the file LICENSE.GPL included in the
9  ** packaging of this file.
10  **
11  ** Licensees holding valid commercial KD Gantt licenses may use this file in
12  ** accordance with the KD Gantt Commercial License Agreement provided with
13  ** the Software.
14  **
15  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  **
18  ** See http://www.kdab.net/kdgantt for
19  ** information about KD Gantt Commercial License Agreements.
20  **
21  ** Contact info@kdab.net if any conditions of this
22  ** licensing are not clear to you.
23  **
24  **********************************************************************/
25 #include "kdganttconstraintproxy.h"
26 #include "kdganttconstraintmodel.h"
27 
28 #include <QAbstractProxyModel>
29 
30 using namespace KDGantt;
31 
36 ConstraintProxy::ConstraintProxy( QObject* parent )
37  : QObject( parent )
38 {
39 }
40 
41 ConstraintProxy::~ConstraintProxy()
42 {
43 }
44 
45 void ConstraintProxy::setSourceModel( ConstraintModel* src )
46 {
47  if ( m_source ) disconnect( m_source );
48  m_source = src;
49 
50  copyFromSource();
51 
52  connect( m_source, SIGNAL(constraintAdded(Constraint)),
53  this, SLOT(slotSourceConstraintAdded(Constraint)) );
54  connect( m_source, SIGNAL(constraintRemoved(Constraint)),
55  this, SLOT(slotSourceConstraintRemoved(Constraint)) );
56 }
57 
58 void ConstraintProxy::setDestinationModel( ConstraintModel* dest )
59 {
60  if ( m_destination ) disconnect( m_destination );
61  m_destination = dest;
62 
63  copyFromSource();
64 
65  connect( m_destination, SIGNAL(constraintAdded(Constraint)),
66  this, SLOT(slotDestinationConstraintAdded(Constraint)) );
67  connect( m_destination, SIGNAL(constraintRemoved(Constraint)),
68  this, SLOT(slotDestinationConstraintRemoved(Constraint)) );
69 }
70 
71 void ConstraintProxy::setProxyModel( QAbstractProxyModel* proxy )
72 {
73  m_proxy = proxy;
74 }
75 
76 ConstraintModel* ConstraintProxy::sourceModel() const { return m_source; }
77 ConstraintModel* ConstraintProxy::destinationModel() const { return m_destination; }
78 QAbstractProxyModel* ConstraintProxy::proxyModel() const { return m_proxy; }
79 
80 
81 void ConstraintProxy::copyFromSource()
82 {
83  if ( m_destination ) {
84  m_destination->clear();
85  if ( !m_source ) return;
86  QList<Constraint> lst = m_source->constraints();
87  Q_FOREACH( const Constraint& c, lst ) {
88  m_destination->addConstraint( Constraint( m_proxy->mapFromSource( c.startIndex() ),
89  m_proxy->mapFromSource( c.endIndex() ) ) );
90  }
91  }
92 }
93 
94 void ConstraintProxy::slotSourceConstraintAdded( const Constraint& c )
95 {
96  if ( m_destination ) m_destination->addConstraint( Constraint( m_proxy->mapFromSource( c.startIndex() ),
97  m_proxy->mapFromSource( c.endIndex() ) ) );
98 }
99 
100 void ConstraintProxy::slotSourceConstraintRemoved( const Constraint& c )
101 {
102  if ( m_destination ) m_destination->removeConstraint( Constraint( m_proxy->mapFromSource( c.startIndex() ),
103  m_proxy->mapFromSource( c.endIndex() ) ) );
104 }
105 
106 void ConstraintProxy::slotDestinationConstraintAdded( const Constraint& c )
107 {
108  if ( m_source ) m_source->addConstraint( Constraint( m_proxy->mapToSource( c.startIndex() ),
109  m_proxy->mapToSource( c.endIndex() ) ) );
110 }
111 
112 void ConstraintProxy::slotDestinationConstraintRemoved( const Constraint& c )
113 {
114  if ( m_source ) m_source->removeConstraint( Constraint( m_proxy->mapToSource( c.startIndex() ),
115  m_proxy->mapToSource( c.endIndex() ) ) );
116 }
117 
118 #include "moc_kdganttconstraintproxy.cpp"
KDGantt::Constraint::endIndex
QModelIndex endIndex() const
Definition: kdganttconstraint.cpp:113
KDGantt::ConstraintProxy::proxyModel
QAbstractProxyModel * proxyModel() const
Definition: kdganttconstraintproxy.cpp:78
KDGantt::Constraint::startIndex
QModelIndex startIndex() const
Definition: kdganttconstraint.cpp:107
QObject
KDGantt::ConstraintProxy::~ConstraintProxy
virtual ~ConstraintProxy()
Definition: kdganttconstraintproxy.cpp:41
KDGantt::ConstraintProxy::destinationModel
ConstraintModel * destinationModel() const
Definition: kdganttconstraintproxy.cpp:77
KDGantt::ConstraintProxy::sourceModel
ConstraintModel * sourceModel() const
Definition: kdganttconstraintproxy.cpp:76
KDGantt::ConstraintProxy::setSourceModel
void setSourceModel(ConstraintModel *src)
Definition: kdganttconstraintproxy.cpp:45
kdganttconstraintproxy.h
KDGantt::ConstraintProxy::setProxyModel
void setProxyModel(QAbstractProxyModel *proxy)
Definition: kdganttconstraintproxy.cpp:71
KDGantt::ConstraintProxy::setDestinationModel
void setDestinationModel(ConstraintModel *dest)
Definition: kdganttconstraintproxy.cpp:58
QAbstractProxyModel
KDGantt::Constraint
A class used to represent a dependency.
Definition: kdganttconstraint.h:38
KDGantt::ConstraintProxy::ConstraintProxy
ConstraintProxy(QObject *parent=0)
Definition: kdganttconstraintproxy.cpp:36
kdganttconstraintmodel.h
KDGantt::ConstraintModel
Definition: kdganttconstraintmodel.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdgantt2

Skip menu "kdgantt2"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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