1 | /* This file is part of the KDE project |
2 | * Copyright (C) 2007 Fredy Yanardi <fyanardi@gmail.com> |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "kptviewlistdocker.h" |
21 | |
22 | #include "kptviewlist.h" |
23 | |
24 | #include "kptview.h" |
25 | #include "kptdebug.h" |
26 | |
27 | #include <KoToolManager.h> |
28 | #include <KoShapeManager.h> |
29 | |
30 | #include <klocale.h> |
31 | |
32 | namespace KPlato |
33 | { |
34 | |
35 | ViewListDocker::ViewListDocker(View *view) |
36 | { |
37 | updateWindowTitle( false ); |
38 | setView(view); |
39 | } |
40 | |
41 | ViewListDocker::~ViewListDocker() |
42 | { |
43 | } |
44 | |
45 | View *ViewListDocker::view() |
46 | { |
47 | return m_view; |
48 | } |
49 | |
50 | void ViewListDocker::setView(View *view) |
51 | { |
52 | m_view = view; |
53 | QWidget *wdg = widget(); |
54 | if (wdg) |
55 | delete wdg; |
56 | m_viewlist = new ViewListWidget(view->getPart(), this); |
57 | setWidget(m_viewlist); |
58 | m_viewlist->setProject( &( view->getProject() ) ); |
59 | connect( m_viewlist, SIGNAL(selectionChanged(ScheduleManager*)), view, SLOT(slotSelectionChanged(ScheduleManager*)) ); |
60 | connect( view, SIGNAL(currentScheduleManagerChanged(ScheduleManager*)), m_viewlist, SLOT(setSelectedSchedule(ScheduleManager*)) ); |
61 | connect( m_viewlist, SIGNAL(updateViewInfo(ViewListItem*)), view, SLOT(slotUpdateViewInfo(ViewListItem*)) ); |
62 | |
63 | } |
64 | |
65 | void ViewListDocker::slotModified() |
66 | { |
67 | setWindowTitle( i18nc( "@title:window" , "View Selector [modified]" ) ); |
68 | } |
69 | |
70 | void ViewListDocker::updateWindowTitle( bool modified ) |
71 | { |
72 | if ( modified ) { |
73 | setWindowTitle( i18nc( "@title:window" , "View Selector [modified]" ) ); |
74 | } else { |
75 | setWindowTitle(i18nc( "@title:window" , "View Selector" )); |
76 | } |
77 | } |
78 | |
79 | //---------- |
80 | ViewListDockerFactory::ViewListDockerFactory(View *view) |
81 | { |
82 | m_view = view; |
83 | } |
84 | |
85 | QString ViewListDockerFactory::id() const |
86 | { |
87 | return QString("KPlatoViewList" ); |
88 | } |
89 | |
90 | QDockWidget* ViewListDockerFactory::createDockWidget() |
91 | { |
92 | ViewListDocker *widget = new ViewListDocker(m_view); |
93 | widget->setObjectName(id()); |
94 | |
95 | return widget; |
96 | } |
97 | |
98 | } //namespace KPlato |
99 | |
100 | #include "kptviewlistdocker.moc" |
101 | |
102 | |