File indexing completed on 2024-05-12 16:39:25
0001 /* This file is part of the KDE project 0002 Copyright (C) 2009, 2011, 2012 Dag Andersen <danders@get2net.dk> 0003 Copyright (C) 2019 Dag Andersen <danders@get2net.dk> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 // clazy:excludeall=qstring-arg 0022 #include "taskcompletiondialog.h" 0023 #include "workpackage.h" 0024 0025 #include "kpttaskprogresspanel.h" 0026 #include "kptusedefforteditor.h" 0027 #include "kptcommand.h" 0028 #include "kptitemmodelbase.h" 0029 0030 #include <KoIcon.h> 0031 0032 #include <KLocalizedString> 0033 0034 #include <QComboBox> 0035 #include <QVBoxLayout> 0036 0037 #include "debugarea.h" 0038 0039 using namespace KPlatoWork; 0040 0041 0042 TaskCompletionDialog::TaskCompletionDialog(WorkPackage &package, ScheduleManager *sm, QWidget *parent) 0043 : KoDialog(parent) 0044 { 0045 setCaption(i18n("Task Progress")); 0046 setButtons(Ok|Cancel); 0047 setDefaultButton(Ok); 0048 showButtonSeparator(true); 0049 m_panel = new TaskCompletionPanel(package, sm, this); 0050 0051 setMainWidget(m_panel); 0052 0053 enableButtonOk(false); 0054 0055 connect(m_panel, &TaskCompletionPanel::changed, this, &TaskCompletionDialog::slotChanged); 0056 } 0057 0058 void TaskCompletionDialog::slotChanged(bool state) 0059 { 0060 enableButtonOk(state); 0061 } 0062 0063 KUndo2Command *TaskCompletionDialog::buildCommand() 0064 { 0065 //debugPlanWork; 0066 return m_panel->buildCommand(); 0067 } 0068 0069 TaskCompletionPanel::TaskCompletionPanel(WorkPackage &package, ScheduleManager *sm, QWidget *parent) 0070 : QWidget(parent) 0071 { 0072 Q_ASSERT(sm); 0073 if (package.task()->completion().entrymode() != KPlato::Completion::EnterEffortPerResource) { 0074 package.task()->completion().setEntrymode(KPlato::Completion::EnterEffortPerResource); 0075 } 0076 if (package.task()->completion().resources().isEmpty()) { 0077 foreach (Resource *r, package.task()->assignedResources(sm->scheduleId())) { 0078 if (r->id() == package.task()->workPackage().ownerId()) { 0079 package.task()->completion().addUsedEffort(r); 0080 } 0081 } 0082 } 0083 QVBoxLayout *l = new QVBoxLayout(this); 0084 m_panel = new KPlato::TaskProgressPanel(*(package.task()), sm, nullptr, this); 0085 m_panel->editModeWidget->setVisible(false); 0086 m_panel->addResourceWidget->setVisible(false); 0087 m_panel->resourceTable->verticalHeader()->hide(); 0088 QSize size = m_panel->resourceTable->sizeHint(); 0089 size.setHeight(120); 0090 m_panel->resourceTable->setSizeHint(size); 0091 l->addWidget(m_panel); 0092 connect(m_panel, &KPlato::TaskProgressPanelImpl::changed, this, &TaskCompletionPanel::slotChanged); 0093 } 0094 0095 KUndo2Command *TaskCompletionPanel::buildCommand() 0096 { 0097 return m_panel->buildCommand(); 0098 } 0099 0100 void TaskCompletionPanel::slotChanged() 0101 { 0102 emit changed(true); //FIXME 0103 } 0104