mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-20 21:28:07 +00:00
Replace color description if different (usually coming from loading)
This commit is contained in:
parent
52a65d28ad
commit
2feff509ae
2 changed files with 16 additions and 9 deletions
|
|
@ -114,8 +114,20 @@ void ColorListModel::add(std::shared_ptr<ColorModel> color){
|
|||
emit layoutChanged();
|
||||
}
|
||||
|
||||
QString ColorListModel::buildDescription(QString description){
|
||||
QStringList tokens = description.split('_');
|
||||
for(int index = 0 ; index < tokens.size() ; ++index)
|
||||
if(mKeywordsMap.contains(tokens[index]))
|
||||
tokens[index] = mKeywordsMap[tokens[index]];
|
||||
description = tokens.join(' ');
|
||||
description[0] = description[0].toUpper();
|
||||
return description;
|
||||
}
|
||||
|
||||
ColorModel * ColorListModel::add(const QString& id, const QString& idLink, QString description, QString colorValue){
|
||||
ColorModel * color = getColor(id);
|
||||
if( description == "")
|
||||
description = buildDescription(id);
|
||||
if(!color){
|
||||
if(idLink != ""){
|
||||
if( colorValue == ""){
|
||||
|
|
@ -126,19 +138,13 @@ ColorModel * ColorListModel::add(const QString& id, const QString& idLink, QStri
|
|||
}
|
||||
addLink(id, idLink);
|
||||
}
|
||||
if( description == ""){
|
||||
description = id;
|
||||
QStringList tokens = description.split('_');
|
||||
for(int index = 0 ; index < tokens.size() ; ++index)
|
||||
if(mKeywordsMap.contains(tokens[index]))
|
||||
tokens[index] = mKeywordsMap[tokens[index]];
|
||||
description = tokens.join(' ');
|
||||
description[0] = description[0].toUpper();
|
||||
}
|
||||
auto colorShared = std::make_shared<ColorModel>(id, colorValue, description);
|
||||
add(colorShared);
|
||||
color = colorShared.get();
|
||||
emit colorChanged();
|
||||
}else if( description != color->getDescription()) {
|
||||
color->setDescription(description);
|
||||
emit colorChanged();
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,6 +333,7 @@ private:
|
|||
void add(std::shared_ptr<ColorModel> imdn);
|
||||
bool removeRow (int row, const QModelIndex &parent = QModelIndex());
|
||||
virtual bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
QString buildDescription(QString description); // return a description from id by splitting '_'
|
||||
|
||||
QList<std::shared_ptr<ColorModel>> mList;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue