1 // Copyright (c) 2012 Dennco Project
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.
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.
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/>.
17 // Created by tkawata on Oct-15, 2012.
20 #include "dccellcodetypecombobox.h"
22 #include "dccreator.h"
23 #include "dccontainer.h"
24 #include "dccellcode.h"
26 DCCellCodeTypeComboBox::DCCellCodeTypeComboBox(DCCreator *creator, QWidget *parent) :
27 QComboBox(parent), d_creator(creator), d_cellCode(NULL)
29 DCContainer *container = d_creator->getCurrentContainer();
31 QList<QString> list = creator->getCurrentContainer()->getAvailableCellTypes();
32 for (int i = 0; i < list.length(); i++)
34 if (container->getIsScriptable(list.at(i)))
39 connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotCurrentIndexChanged(QString)));
42 DCCellCodeTypeComboBox::~DCCellCodeTypeComboBox()
47 void DCCellCodeTypeComboBox::changeType(const QString &newType)
49 for (int i = 0; i < count(); i++)
51 if (itemText(i) == newType)
59 void DCCellCodeTypeComboBox::setEditingCellCode(DCCellCode *cellcode)
61 d_cellCode = cellcode;
65 void DCCellCodeTypeComboBox::updateSelection()
69 changeType(QString::fromStdString(d_cellCode->getCellAPIName()));
73 void DCCellCodeTypeComboBox::slotCurrentIndexChanged(const QString &newType)
75 if (QString::fromStdString(d_cellCode->getCellAPIName()) != newType)
77 d_creator->doCommandChangeCellCodeClassType(this, d_cellCode, newType);
78 emit typeChanged(newType);