View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010487 | Scribus | User Interface | public | 2012-01-03 21:50 | 2016-03-14 13:36 |
Reporter | dietmar83 | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | Intel GM965/Core2Duo | OS | Windows XP Professional | OS Version | SP 3 |
Product Version | 1.4.0 | ||||
Summary | 0010487: Display a message if name of PDF field is not unique | ||||
Description | I found a little "bug" which regards renaming of PDF fields. In the Field Properties dialogue window you can set the name of a PDF field. When you allocate a name that's already given to another PDF field, this circumstance should be communicated to the user through some kind of message (message box, text label etc.). This could be handled similar as it will be done in issue 0010082. | ||||
Steps To Reproduce | - Create a Scribus document. - Create a PDF field with name "name1". - Create another PDF field with "name234". - Change the name of the second PDF field to "name1". | ||||
Tags | No tags attached. | ||||
Patch | |||||
related to | 0012707 | new | Display PDF field names |
|
this exact issue seems to be solved... 1.4.1svn let's you put a name that already exists, but then refuses to apply it and goes back to the old name... but there may be a another issue related to it: - create a new document - create a first field, which will automatically be called text1 - rename it to text2 - create a second button and it will also be called text2 |
|
in Scribus 1.4.1svn this bug was not fixed. When we renamed item to name which was already exist, the old name was saved, bu there was no any warning message, and Property window close after this. I add warning message in this case, and Property window will no close until we change item name to correct variant. annot.patch file included |
|
annot.patch (1,704 bytes)
diff -r scribus_old/annot.cpp scribus/annot.cpp 30a31 > #include <QMessageBox> 1200a1202,1216 > bool Annot::FoundName(QString name) > { > bool found = false; > for (int b = 0; b < view->Doc->Items->count(); ++b) > { > if ((name == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) > { > found = true; > break; > } > } > // > return found; > } > 1203,1222c1219,1232 < QString NameNew = Name->text(); < if (NameNew.isEmpty()) < { < Name->setText(OldName); < return; < } < bool found = false; < for (int b = 0; b < view->Doc->Items->count(); ++b) < { < if ((NameNew == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) < { < found = true; < break; < } < } < if (found) < { < Name->setText(OldName); < Name->setFocus(); < } --- > QString NameNew = Name->text(); > if (NameNew.isEmpty()) > { > Name->setText(OldName); > return; > } > > if (FoundName(NameNew)) > { > QMessageBox::warning(this, CommonStrings::trWarning, tr("The item with such name is already exist"), QMessageBox::Ok); > Name->setText(OldName); > Name->setFocus(); > } > 1811,1812c1821,1822 < if (Name->text() != OldName) < item->setItemName(Name->text()); --- > if (Name->text() != OldName) > item->setItemName(Name->text()); 2035c2045 < accept(); --- > accept(); diff -r scribus_old/annot.h scribus/annot.h 220a221 > bool FoundName(QString name); |
|
In 1.4.0, there is different behaviour between the Properties Palette (press F2) and the "Field Properties" Window (double-click). Regardless the problem which reporter invercity mentions - when you rename a PDF field using the Properties Palette, Scribus will show a message when there are duplicate names. When you use "Field Properties" Window, it won't. I don't know the source code, but I think it would make sense to implement a universal check routine which checks for duplicate names, which could be called in both windows. Another idea is to have only one single place (Properties Palette) to change the name. |
|
annot2.patch (2,283 bytes)
diff -rB scribus_old/annot.cpp scribus/annot.cpp 23a24 > #include <QMessageBox> 1188c1189 < connect(Name, SIGNAL(Leaved()), this, SLOT(NewName())); --- > //connect(Name, SIGNAL(Leaved()), this, SLOT(NewName())); 1200a1202,1215 > bool Annot::FoundName(QString name) > { > bool found = false; > for (int b = 0; b < view->Doc->Items->count(); ++b) > { > if ((name == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) > { > found = true; > break; > } > } > return found; > } > 1209,1218c1224 < bool found = false; < for (int b = 0; b < view->Doc->Items->count(); ++b) < { < if ((NameNew == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) < { < found = true; < break; < } < } < if (found) --- > if (FoundName(NameNew) && (OldName != NameNew)) 1219a1226 > QMessageBox::warning(this, CommonStrings::trWarning, tr("The item with such name is already exist"), QMessageBox::Ok); 1811c1818,1819 < if (Name->text() != OldName) --- > bool enableClose = true; > if ((!FoundName(Name->text())) && (Name->text() != OldName)) { 1812a1821,1825 > } > if (FoundName(Name->text())) { > NewName(); > enableClose = false; > } 2035c2048 < accept(); --- > if (enableClose) accept(); diff -rB scribus_old/annot.h scribus/annot.h 220a221 > bool FoundName(QString name); diff -rB scribus_old/pageitem.cpp scribus/pageitem.cpp 250,252c250,255 < QString tmp; < m_Doc->TotalItems++; < AnName += tmp.setNum(m_Doc->TotalItems); --- > QString tmp; > int freeItem = m_Doc->TotalItems; > while (m_Doc->itemNameExists(AnName + tmp.setNum(freeItem))) freeItem++; > AnName += tmp.setNum(freeItem); > m_Doc->TotalItems++; > //AnName += tmp.setNum(m_Doc->TotalItems); 422c425,427 < AnName += tmp.setNum(m_Doc->TotalItems); // +" "+QDateTime::currentDateTime().toString(); --- > int freeItem = m_Doc->TotalItems; > while (m_Doc->itemNameExists(AnName + tmp.setNum(freeItem))) freeItem++; > AnName += tmp.setNum(freeItem); |
|
I make some changes to my patch, according to ale's report. Now if item with name "text2" already exist, new item will take name "text3, and so on. Also, if we'll try to rename item to name, which already exist (using "field properties"), there will be a warning message, and properties window will no close. all this changes included in "annot3.patch" |
|
annot3.patch (2,974 bytes)
Index: annot.h =================================================================== --- annot.h (revision 17424) +++ annot.h (working copy) @@ -218,6 +218,7 @@ public slots: void NewName(); + bool FoundName(QString name); void IPlace(); void RemoveNIcon(); void RemovePIcon(); Index: annot.cpp =================================================================== --- annot.cpp (revision 17424) +++ annot.cpp (working copy) @@ -21,6 +21,7 @@ #include <QSpinBox> #include <QTabWidget> #include <QWidget> +#include <QMessageBox> #include <QRadioButton> #include <QList> #include <QStringList> @@ -1185,7 +1186,7 @@ connect(PlaceIcon, SIGNAL(clicked()), this, SLOT(IPlace())); connect(ChFile, SIGNAL(clicked()), this, SLOT(GetFile())); connect(LExtern, SIGNAL(clicked()), this, SLOT(SetExternLink())); - connect(Name, SIGNAL(Leaved()), this, SLOT(NewName())); + //connect(Name, SIGNAL(Leaved()), this, SLOT(NewName())); NoSpell->setToolTip( tr( "Flag is ignored for PDF 1.3" ) ); NoScroll->setToolTip( tr( "Flag is ignored for PDF 1.3" ) ); CalcFields->setToolTip( tr( "Enter a comma separated list of fields here" ) ); @@ -1198,6 +1199,20 @@ Annot::~Annot() {} +bool Annot::FoundName(QString name) +{ + bool found = false; + for (int b = 0; b < view->Doc->Items->count(); ++b) + { + if ((name == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) + { + found = true; + break; + } + } + return found; +} + void Annot::NewName() { QString NameNew = Name->text(); @@ -1206,17 +1221,9 @@ Name->setText(OldName); return; } - bool found = false; - for (int b = 0; b < view->Doc->Items->count(); ++b) + if (FoundName(NameNew) && (OldName != NameNew)) { - if ((NameNew == view->Doc->Items->at(b)->itemName()) && (view->Doc->Items->at(b) != item)) - { - found = true; - break; - } - } - if (found) - { + QMessageBox::warning(this, CommonStrings::trWarning, tr("The item with such name is already exist"), QMessageBox::Ok); Name->setText(OldName); Name->setFocus(); } @@ -1808,8 +1815,14 @@ QString Nfo(""); bool AAct = false; item->annotation().setType(ComboBox1->currentIndex()+2); - if (Name->text() != OldName) + bool enableClose = true; + if ((!FoundName(Name->text())) && (Name->text() != OldName)) { item->setItemName(Name->text()); + } + if (FoundName(Name->text())) { + NewName(); + enableClose = false; + } item->annotation().setToolTip(Tip->text()); item->annotation().setRollOver(TextO->text()); item->annotation().setDown(DownT->text()); @@ -2032,7 +2045,7 @@ if (!item->annotation().C_act().isEmpty()) AAct = true; item->annotation().setAAact(AAct); - accept(); + if (enableClose) accept(); } void Annot::SetAnnotationType(int it) |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-01-03 21:50 | dietmar83 | New Issue | |
2012-04-13 19:59 | ale | Note Added: 0027929 | |
2012-04-13 21:36 | invercity | Note Added: 0027930 | |
2012-04-13 21:37 | invercity | File Added: annot.patch | |
2012-04-13 22:22 | dietmar83 | Note Added: 0027931 | |
2012-04-13 22:23 | dietmar83 | Note Edited: 0027931 | |
2012-04-13 22:24 | dietmar83 | Note Edited: 0027931 | |
2012-04-14 09:28 | invercity | File Added: annot2.patch | |
2012-04-14 09:29 | invercity | Note Added: 0027934 | |
2012-04-14 09:58 | invercity | Note Edited: 0027934 | |
2012-04-18 11:12 | invercity | Note Edited: 0027934 | |
2012-04-18 11:12 | invercity | File Added: annot3.patch | |
2016-03-14 13:36 | Kunda | Relationship added | related to 0012707 |