OSDN Git Service

[denncoCreator] Implement plugin cell edit feature. The work is in progress.
[dennco/denncoCreator.git] / Source / dccellcode.cpp
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Sep-30, 2012.
18 //
19 #include "dccellcode.h"
20
21 #include "dcvccellcode.h"
22 #include "dccontainer.h"
23 #include "utils/dcutil.h"
24
25 DCCellCode::DCCellCode(DCContainer *container, std::string theName, std::string theCellAPIName)
26     : TKCellCode(theName, theCellAPIName), d_container(container)
27 {
28 }
29
30 DCCellCode::~DCCellCode()
31 {
32 }
33
34 QString DCCellCode::getOwnScript() const
35 {
36     return d_container->readCellCodeScriptFromFile(this);
37 }
38
39 QString DCCellCode::getWorkFilePathForCellCodeScript() const
40 {
41     DCContainer *container = dynamic_cast<DCContainer*>(getContainer());
42     if (container)
43     {
44         return container->getWorkFilePathForCellCode(this);
45     }
46     return "";
47 }
48
49 bool DCCellCode::saveScript(const QString &script)
50 {
51     return d_container->saveClassScriptToWorkFile(this, script.toStdString());
52 }
53
54 DCVCPage* DCCellCode::getPageBelonging() const
55 {
56     return d_vComponent->getPageBelonging();
57 }
58
59 void DCCellCode::changeName(const QString &newName)
60 {
61     QString fqnString = DCUtil::getFQNPath(getPageBelonging()->getLocationPath(), newName);
62     mFQNName = fqnString.toStdString();
63 }
64
65 void DCCellCode::changePath(const QString& newPath)
66 {
67     QString name = DCUtil::getNameFromFQNPath(QString::fromStdString(mFQNName));
68     QString fqnString = DCUtil::getFQNPath(newPath, name);
69     mFQNName = fqnString.toStdString();
70 }
71
72 void DCCellCode::changeType(const QString &newType)
73 {
74     mCellAPIName = newType.toStdString();
75 }
76