summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/selectordialog.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-04-27 11:36:28 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-06-02 09:50:16 +0000
commite072922d8082660f6fbf3eec3d334ad754bf1681 (patch)
treedc4248390d511419e03418cceb207d43aeb9661d /src/ui/dialog/selectordialog.cpp
parentadd unhandled multiselector (diff)
downloadinkscape-e072922d8082660f6fbf3eec3d334ad754bf1681.tar.gz
inkscape-e072922d8082660f6fbf3eec3d334ad754bf1681.zip
fix merge
Diffstat (limited to 'src/ui/dialog/selectordialog.cpp')
-rw-r--r--src/ui/dialog/selectordialog.cpp50
1 files changed, 39 insertions, 11 deletions
diff --git a/src/ui/dialog/selectordialog.cpp b/src/ui/dialog/selectordialog.cpp
index 7d0e0f29d..b92c0d82a 100644
--- a/src/ui/dialog/selectordialog.cpp
+++ b/src/ui/dialog/selectordialog.cpp
@@ -467,7 +467,8 @@ void SelectorDialog::_readStyleElement()
coltype colType = SELECTOR;
for (auto tok : tokensplus) {
REMOVE_SPACES(tok);
- if (tok.find(" ") != -1 || tok.erase(0, 1).find(".") != -1) {
+ if (SPAttributeRelSVG::isSVGElement(tok) || tok.find(" ") != -1 || tok[0] == '>' || tok[0] == '+' ||
++ tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) {
colType = UNHANDLED;
}
}
@@ -818,7 +819,8 @@ std::vector<SPObject *> SelectorDialog::_getObjVec(Glib::ustring selector) {
bool unhandled = false;
for (auto tok : tokensplus) {
REMOVE_SPACES(tok);
- if (tok.find(" ") != -1 || tok.erase(0, 1).find(".") != -1) {
+ if (SPAttributeRelSVG::isSVGElement(tok) || tok.find(" ") != -1 || tok[0] == '>' || tok[0] == '+' ||
+ tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) {
unhandled = true;
std::vector<SPObject *> objVecSplited = SP_ACTIVE_DOCUMENT->getObjectsBySelector(tok);
objVec.insert(objVec.end(), objVecSplited.begin(), objVecSplited.end());
@@ -978,19 +980,45 @@ void SelectorDialog::_addSelector()
* set to ".Class1"
*/
selectorValue = textEditPtr->get_text();
- Glib::ustring firstWord = selectorValue.substr(0, selectorValue.find_first_of(" >+~"));
- if (firstWord != selectorValue) {
- handled = false;
- }
if (!_stylemode) {
del->set_sensitive(true);
}
- if (selectorValue[0] == '.' || selectorValue[0] == '#' || selectorValue[0] == '*' ||
- SPAttributeRelSVG::isSVGElement(selectorValue)) {
- invalid = false;
- } else {
- textLabelPtr->show();
+ std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[,]+", selectorValue);
+ bool unhandled = false;
+ bool partialinvalid = false;
+ for (auto tok : tokensplus) {
+ REMOVE_SPACES(tok);
+ if (SPAttributeRelSVG::isSVGElement(tok) || tok.find(" ") != -1 || tok[0] == '>' || tok[0] == '+' ||
+ tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) {
+ unhandled = true;
+ Glib::ustring firstWord = tok.substr(0, tok.find_first_of(" >+~"));
+ if (firstWord != tok) {
+ handled = false;
+ }
+ if (!partialinvalid &&
+ (tok[0] == '.' || tok[0] == '#' || tok[0] == '*' || SPAttributeRelSVG::isSVGElement(tok))) {
+ partialinvalid = false;
+ } else {
+ partialinvalid = true;
+ }
+ }
}
+ if (!unhandled) {
+ Glib::ustring firstWord = selectorValue.substr(0, selectorValue.find_first_of(" >+~"));
+ if (firstWord != selectorValue) {
+ handled = false;
+ }
+ if (selectorValue[0] == '.' || selectorValue[0] == '#' || selectorValue[0] == '*' ||
+ SPAttributeRelSVG::isSVGElement(selectorValue)) {
+ invalid = false;
+ } else {
+ textLabelPtr->show();
+ }
+ } else if (partialinvalid) {
+ textLabelPtr->show();
+ } else {
+ invalid = false;
+ }
}
delete textDialogPtr;
// ==== Handle response ====