fix i18n issues in feature pick panel

This commit is contained in:
wmayer 2016-10-24 00:34:56 +02:00
parent 16b948ba3a
commit d5f02ffde3

View File

@ -70,14 +70,15 @@ const QString TaskFeaturePick::getFeatureStatusString(const featureStatus st)
case afterTip: return tr("Feature is located after the tip feature");
}
return tr("");
return QString();
}
TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
const std::vector<featureStatus>& status,
QWidget* parent)
const std::vector<featureStatus>& status,
QWidget* parent)
: TaskBox(Gui::BitmapFactory().pixmap("edit-select-box"),
QString::fromLatin1("Select feature"), true, parent), ui(new Ui_TaskFeaturePick)
tr("Select feature"), true, parent)
, ui(new Ui_TaskFeaturePick)
{
proxy = new QWidget(this);
@ -100,25 +101,30 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
assert(status.size() == objects.size());
for (; statusIt != status.end(); ++statusIt, ++objIt) {
QListWidgetItem* item = new QListWidgetItem(
QString::fromLatin1((*objIt)->getNameInDocument()) +
QString::fromLatin1(" (") + getFeatureStatusString(*statusIt) + QString::fromLatin1(")") );
QString::fromLatin1("%1 (%2)")
.arg(QString::fromUtf8((*objIt)->Label.getValue()))
.arg(getFeatureStatusString(*statusIt)
)
);
item->setData(Qt::UserRole, QString::fromLatin1((*objIt)->getNameInDocument()));
ui->listWidget->addItem(item);
//check if we need to set any origin in temporary visibility mode
if (*statusIt != invalidShape && (*objIt)->isDerivedFrom ( App::OriginFeature::getClassTypeId () )) {
App::Origin *origin = static_cast<App::OriginFeature*> (*objIt)->getOrigin ();
if (origin) {
if ((*objIt)->isDerivedFrom ( App::Plane::getClassTypeId () )) {
if ((*objIt)->isDerivedFrom (App::Plane::getClassTypeId())) {
originVisStatus[ origin ].set (planeBit, true);
} else if ( (*objIt)->isDerivedFrom ( App::Line::getClassTypeId () ) ) {
}
else if ( (*objIt)->isDerivedFrom (App::Line::getClassTypeId())) {
originVisStatus[ origin ].set (axisBit, true);
}
}
}
}
// Setup the origin's temporary visability
for ( const auto & originPair: originVisStatus ) {
// Setup the origin's temporary visibility
for (const auto & originPair: originVisStatus) {
const auto &origin = originPair.first;
Gui::ViewProviderOrigin* vpo = static_cast<Gui::ViewProviderOrigin*> (
@ -170,7 +176,7 @@ void TaskFeaturePick::updateList()
void TaskFeaturePick::onUpdate(bool)
{
bool enable = false;
if(ui->checkOtherBody->isChecked() || ui->checkOtherPart->isChecked())
if (ui->checkOtherBody->isChecked() || ui->checkOtherPart->isChecked())
enable = true;
ui->radioDependent->setEnabled(enable);
@ -180,31 +186,30 @@ void TaskFeaturePick::onUpdate(bool)
updateList();
}
std::vector<App::DocumentObject*> TaskFeaturePick::getFeatures() {
std::vector<App::DocumentObject*> TaskFeaturePick::getFeatures()
{
features.clear();
QListIterator<QListWidgetItem*> i(ui->listWidget->selectedItems());
while (i.hasNext()) {
auto item = i.next();
if(item->isHidden())
if (item->isHidden())
continue;
QString t = item->text();
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
QString t = item->data(Qt::UserRole).toString();
features.push_back(t);
}
std::vector<App::DocumentObject*> result;
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); s++)
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); ++s)
result.push_back(App::GetApplication().getActiveDocument()->getObject(s->toLatin1().data()));
return result;
}
std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures()
{
int index = 0;
std::vector<App::DocumentObject*> result;
auto activeBody = PartDesignGui::getBody(false);
@ -215,30 +220,26 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
for (std::vector<featureStatus>::const_iterator st = statuses.begin(); st != statuses.end(); st++) {
QListWidgetItem* item = ui->listWidget->item(index);
if(item->isSelected() && !item->isHidden()) {
QString t = item->text();
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
if (item->isSelected() && !item->isHidden()) {
QString t = item->data(Qt::UserRole).toString();
auto obj = App::GetApplication().getActiveDocument()->getObject(t.toLatin1().data());
//build the dependend copy or reference if wanted by the user
if(*st == otherBody ||
*st == otherPart ||
*st == notInBody ) {
if(!ui->radioXRef->isChecked()) {
if (*st == otherBody || *st == otherPart || *st == notInBody) {
if (!ui->radioXRef->isChecked()) {
auto copy = makeCopy(obj, "", ui->radioIndependent->isChecked());
if(*st == otherBody)
if (*st == otherBody) {
activeBody->addFeature(copy);
else if(*st == otherPart) {
}
else if (*st == otherPart) {
auto oBody = PartDesignGui::getBodyFor(obj, false);
if(!oBody)
if (!oBody)
activePart->addObject(copy);
else
activeBody->addFeature(copy);
}
else if(*st == notInBody) {
else if (*st == notInBody) {
activeBody->addFeature(copy);
// doesn't supposed to get here anything but sketch but to be on the safe side better to check
if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
@ -248,11 +249,13 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
}
result.push_back(copy);
}
else
else {
result.push_back(obj);
}
}
else
else {
result.push_back(obj);
}
break;
}
@ -385,22 +388,19 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& /*msg*/)
{
ui->listWidget->clearSelection();
for(Gui::SelectionSingleton::SelObj obj : Gui::Selection().getSelection()) {
for(int row = 0; row < ui->listWidget->count(); row++) {
for (Gui::SelectionSingleton::SelObj obj : Gui::Selection().getSelection()) {
for (int row = 0; row < ui->listWidget->count(); row++) {
QListWidgetItem *item = ui->listWidget->item(row);
QString t = item->text();
t = t.left(t.indexOf(QString::fromLatin1("(")) - 1);
if(t.compare(QString::fromLatin1(obj.FeatName))==0) {
QString t = item->data(Qt::UserRole).toString();
if (t.compare(QString::fromLatin1(obj.FeatName))==0) {
ui->listWidget->setItemSelected(item, true);
}
}
}
}
void TaskFeaturePick::showExternal(bool val) {
void TaskFeaturePick::showExternal(bool val)
{
ui->checkOtherBody->setChecked(val);
ui->checkOtherPart->setChecked(val);
updateList();
@ -429,7 +429,7 @@ TaskDlgFeaturePick::~TaskDlgFeaturePick()
{
//do the work now as before in accept() the dialog is still open, hence the work
//function could not open annother dialog
if(accepted)
if (accepted)
workFunction(pick->buildFeatures());
}
@ -449,7 +449,6 @@ void TaskDlgFeaturePick::clicked(int)
bool TaskDlgFeaturePick::accept()
{
accepted = acceptFunction(pick->getFeatures());
return accepted;
}
@ -459,7 +458,8 @@ bool TaskDlgFeaturePick::reject()
return true;
}
void TaskDlgFeaturePick::showExternal(bool val) {
void TaskDlgFeaturePick::showExternal(bool val)
{
pick->showExternal(val);
}