~ubuntu-branches/debian/sid/calligraplan/sid

« back to all changes in this revision

Viewing changes to src/libs/ui/kptsummarytaskdialog.cpp

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2018-02-01 18:20:19 UTC
  • Revision ID: package-import@ubuntu.com-20180201182019-1qo7qaim5wejm5k9
Tags: upstream-3.1.0
ImportĀ upstreamĀ versionĀ 3.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2002 Bo Thorsen  bo@sonofthor.dk
 
3
   Copyright (C) 2004 - 2010 Dag Andersen <danders@get2net.dk>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This library 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 GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this library; see the file COPYING.LIB.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
*/
 
20
 
 
21
#include "kptsummarytaskdialog.h"
 
22
#include "kptsummarytaskgeneralpanel.h"
 
23
#include "kptcommand.h"
 
24
#include "kptnode.h"
 
25
#include "kpttask.h"
 
26
#include "kptproject.h"
 
27
 
 
28
#include <KLocalizedString>
 
29
 
 
30
 
 
31
namespace KPlato
 
32
{
 
33
 
 
34
SummaryTaskDialog::SummaryTaskDialog(Task &task, QWidget *p)
 
35
    : KoDialog(p),
 
36
    m_node( &task )
 
37
{
 
38
    setCaption( i18n("Summary Task Settings") );
 
39
    setButtons( Ok|Cancel );
 
40
    setDefaultButton( Ok );
 
41
    showButtonSeparator( true );
 
42
    m_generalTab = new SummaryTaskGeneralPanel(task, this);
 
43
    setMainWidget(m_generalTab);
 
44
    enableButtonOk(false);
 
45
 
 
46
    connect(m_generalTab, SIGNAL(obligatedFieldsFilled(bool)), SLOT(enableButtonOk(bool)));
 
47
 
 
48
    Project *proj = static_cast<Project*>( task.projectNode() );
 
49
    if ( proj ) {
 
50
        connect(proj, SIGNAL(nodeRemoved(Node*)), this, SLOT(slotTaskRemoved(Node*)));
 
51
    }
 
52
}
 
53
 
 
54
void SummaryTaskDialog::slotTaskRemoved( Node *node )
 
55
{
 
56
    if ( node == m_node ) {
 
57
        reject();
 
58
    }
 
59
}
 
60
 
 
61
 
 
62
MacroCommand *SummaryTaskDialog::buildCommand() {
 
63
    MacroCommand *m = new MacroCommand(kundo2_i18n("Modify Summary Task"));
 
64
    bool modified = false;
 
65
    MacroCommand *cmd = m_generalTab->buildCommand();
 
66
    if (cmd) {
 
67
        m->addCommand(cmd);
 
68
        modified = true;
 
69
    }
 
70
    if (!modified) {
 
71
        delete m;
 
72
        return 0;
 
73
    }
 
74
    return m;
 
75
}
 
76
 
 
77
void SummaryTaskDialog::slotButtonClicked(int button) {
 
78
    if (button == KoDialog::Ok) {
 
79
        if (!m_generalTab->ok())
 
80
            return;
 
81
        accept();
 
82
    } else {
 
83
        KoDialog::slotButtonClicked(button);
 
84
    }
 
85
}
 
86
 
 
87
 
 
88
}  //KPlato namespace