File indexing completed on 2024-04-28 16:24:40
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2007 Fredy Yanardi <fyanardi@gmail.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 // clazy:excludeall=qstring-arg 0021 #include "kptviewlistdocker.h" 0022 0023 #include "kptviewlist.h" 0024 0025 #include "kptview.h" 0026 #include "Help.h" 0027 #include "kptdebug.h" 0028 0029 #include <KLocalizedString> 0030 0031 0032 namespace KPlato 0033 { 0034 0035 ViewListDocker::ViewListDocker(View *view) 0036 { 0037 updateWindowTitle(false); 0038 setView(view); 0039 } 0040 0041 ViewListDocker::~ViewListDocker() 0042 { 0043 } 0044 0045 View *ViewListDocker::view() 0046 { 0047 return m_view; 0048 } 0049 0050 void ViewListDocker::setView(View *view) 0051 { 0052 m_view = view; 0053 QWidget *wdg = widget(); 0054 if (wdg) 0055 delete wdg; 0056 m_viewlist = new ViewListWidget(view->getPart(), this); 0057 setWhatsThis(m_viewlist->whatsThis()); 0058 setWidget(m_viewlist); 0059 m_viewlist->setProject(&(view->getProject())); 0060 connect(m_viewlist, &ViewListWidget::selectionChanged, view, &View::slotSelectionChanged); 0061 connect(view, &View::currentScheduleManagerChanged, m_viewlist, &ViewListWidget::setSelectedSchedule); 0062 connect(m_viewlist, &ViewListWidget::updateViewInfo, view, &View::slotUpdateViewInfo); 0063 0064 } 0065 0066 void ViewListDocker::slotModified() 0067 { 0068 setWindowTitle(xi18nc("@title:window", "View Selector [modified]")); 0069 } 0070 0071 void ViewListDocker::updateWindowTitle(bool modified) 0072 { 0073 if (modified) { 0074 setWindowTitle(xi18nc("@title:window", "View Selector [modified]")); 0075 } else { 0076 setWindowTitle(xi18nc("@title:window", "View Selector")); 0077 } 0078 } 0079 0080 //---------- 0081 ViewListDockerFactory::ViewListDockerFactory(View *view) 0082 { 0083 m_view = view; 0084 } 0085 0086 QString ViewListDockerFactory::id() const 0087 { 0088 return QString("KPlatoViewList"); 0089 } 0090 0091 QDockWidget* ViewListDockerFactory::createDockWidget() 0092 { 0093 ViewListDocker *widget = new ViewListDocker(m_view); 0094 widget->setObjectName(id()); 0095 0096 return widget; 0097 } 0098 0099 } //namespace KPlato