Logo Search packages:      
Sourcecode: libqalculate version File versions  Download package

void Calculator::prefixNameChanged ( Prefix p,
bool  new_item = false 
)

Used internally.

Definition at line 898 of file Calculator.cc.

References Prefix::longName(), Prefix::shortName(), and Prefix::unicodeName().

Referenced by addPrefix().

                                                           {
      size_t l2;
      if(!new_item) delPrefixUFV(p);
      if(!p->longName(false).empty()) {
            l2 = p->longName(false).length();
            if(l2 > UFV_LENGTHS) {
                  size_t i = 0, l;
                  for(vector<void*>::iterator it = ufvl.begin(); ; ++it) {
                        l = 0;
                        if(it != ufvl.end()) {
                              if(ufvl_t[i] == 'v')
                                    l = ((Variable*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'f')
                                    l = ((MathFunction*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'u')
                                    l = ((Unit*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'p')
                                    l = ((Prefix*) (*it))->shortName(false).length();
                              else if(ufvl_t[i] == 'P')
                                    l = ((Prefix*) (*it))->longName(false).length();
                              else if(ufvl_t[i] == 'q')
                                    l = ((Prefix*) (*it))->unicodeName(false).length();
                        }
                        if(it == ufvl.end()) {
                              ufvl.push_back((void*) p);
                              ufvl_t.push_back('P');
                              ufvl_i.push_back(1);
                              break;
                        } else if(l <= l2) {                
                              ufvl.insert(it, (void*) p);
                              ufvl_t.insert(ufvl_t.begin() + i, 'P');
                              ufvl_i.insert(ufvl_i.begin() + i, 1);
                              break;
                        }
                        i++;
                  }
            } else if(l2 > 0) {
                  l2--;
                  ufv[0][l2].push_back((void*) p);
                  ufv_i[0][l2].push_back(1);
            }
      }
      if(!p->shortName(false).empty()) {
            l2 = p->shortName(false).length();
            if(l2 > UFV_LENGTHS) {
                  size_t i = 0, l;
                  for(vector<void*>::iterator it = ufvl.begin(); ; ++it) {
                        l = 0;
                        if(it != ufvl.end()) {
                              if(ufvl_t[i] == 'v')
                                    l = ((Variable*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'f')
                                    l = ((MathFunction*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'u')
                                    l = ((Unit*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'p')
                                    l = ((Prefix*) (*it))->shortName(false).length();
                              else if(ufvl_t[i] == 'P')
                                    l = ((Prefix*) (*it))->longName(false).length();
                              else if(ufvl_t[i] == 'q')
                                    l = ((Prefix*) (*it))->unicodeName(false).length();
                        }
                        if(it == ufvl.end()) {
                              ufvl.push_back((void*) p);
                              ufvl_t.push_back('p');
                              ufvl_i.push_back(1);
                              break;
                        } else if(l <= l2) {                
                              ufvl.insert(it, (void*) p);
                              ufvl_t.insert(ufvl_t.begin() + i, 'p');
                              ufvl_i.insert(ufvl_i.begin() + i, 1);
                              break;
                        }
                        i++;
                  }
            } else if(l2 > 0) {
                  l2--;
                  ufv[0][l2].push_back((void*) p);
                  ufv_i[0][l2].push_back(2);
            }
      }
      if(!p->unicodeName(false).empty()) {
            l2 = p->unicodeName(false).length();
            if(l2 > UFV_LENGTHS) {
                  size_t i = 0, l;
                  for(vector<void*>::iterator it = ufvl.begin(); ; ++it) {
                        l = 0;
                        if(it != ufvl.end()) {
                              if(ufvl_t[i] == 'v')
                                    l = ((Variable*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'f')
                                    l = ((MathFunction*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'u')
                                    l = ((Unit*) (*it))->getName(ufvl_i[i]).name.length();
                              else if(ufvl_t[i] == 'p')
                                    l = ((Prefix*) (*it))->shortName(false).length();
                              else if(ufvl_t[i] == 'P')
                                    l = ((Prefix*) (*it))->longName(false).length();
                              else if(ufvl_t[i] == 'q')
                                    l = ((Prefix*) (*it))->unicodeName(false).length();
                        }
                        if(it == ufvl.end()) {
                              ufvl.push_back((void*) p);
                              ufvl_t.push_back('q');
                              ufvl_i.push_back(1);
                              break;
                        } else if(l <= l2) {                
                              ufvl.insert(it, (void*) p);
                              ufvl_t.insert(ufvl_t.begin() + i, 'q');
                              ufvl_i.insert(ufvl_i.begin() + i, 1);
                              break;
                        }
                        i++;
                  }
            } else if(l2 > 0) {
                  l2--;
                  ufv[0][l2].push_back((void*) p);
                  ufv_i[0][l2].push_back(3);
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index