summaryrefslogtreecommitdiffstats
path: root/scribus/query.cpp
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-25 21:10:44 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-25 21:10:44 +0000
commit98a30cc8b97ed2f16cc15742327ae8ea732fc9a6 (patch)
tree470e34491c4d1978df2d9700d6ce75a53d908acb /scribus/query.cpp
parent4f4d36f57f4b613364dfb18e262fb6c5e4e690e3 (diff)
downloadscribus-98a30cc8b97ed2f16cc15742327ae8ea732fc9a6.tar.gz
scribus-98a30cc8b97ed2f16cc15742327ae8ea732fc9a6.tar.xz
scribus-98a30cc8b97ed2f16cc15742327ae8ea732fc9a6.zip
#10082: Backport new Query dialog code and adjust usage to new duplicate check method, and move to declared vars
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17234 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/query.cpp')
-rw-r--r--scribus/query.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/scribus/query.cpp b/scribus/query.cpp
index 0bc8287..afae1d2 100644
--- a/scribus/query.cpp
+++ b/scribus/query.cpp
@@ -9,6 +9,7 @@ for which a new license (GPL+exception) is in place.
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
+#include <QMessageBox>
#include "commonstrings.h"
#include "util_icon.h"
@@ -44,6 +45,8 @@ Query::Query( QWidget* parent, const char* name, bool modal, Qt::WFlags fl, QSt
queryLayout->addLayout( okCancelLayout );
setMaximumSize(sizeHint());
answerEdit->setFocus();
+ checkList = QStringList();
+ checkMode = false;
// signals and slots connections
connect( okButton, SIGNAL( clicked() ), this, SLOT( Leave() ) );
@@ -58,6 +61,38 @@ void Query::Leave()
{
if (answerEdit->text().isEmpty())
return;
+ if (!forbiddenList.isEmpty())
+ {
+ if (forbiddenList.contains(answerEdit->text()))
+ {
+ QMessageBox::warning(this, CommonStrings::trWarning, tr("Name \"%1\" is not allowed.\nPlease choose another.").arg(answerEdit->text()), CommonStrings::tr_OK);
+ return;
+ }
+ }
+ if (!checkList.isEmpty())
+ {
+ if (checkList.contains(answerEdit->text()))
+ {
+ if (checkMode)
+ {
+ int ret = QMessageBox::warning(this,
+ CommonStrings::trWarning,
+ tr("Name \"%1\" already exists.\nDo you want to replace the current contents?").arg(answerEdit->text()),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No);
+ if (ret == QMessageBox::No)
+ return;
+ else
+ accept();
+ }
+ else
+ {
+ QMessageBox::warning(this, CommonStrings::trWarning, tr("Name \"%1\" is not unique.\nPlease choose another.").arg(answerEdit->text()), CommonStrings::tr_OK);
+ return;
+ }
+ }
+ accept();
+ }
else
accept();
}
@@ -73,3 +108,18 @@ void Query::setEditText(QString newText, bool setSelected)
if (setSelected)
answerEdit->selectAll();
}
+
+void Query::setTestList(QStringList tList)
+{
+ checkList = tList;
+}
+
+void Query::setForbiddenList(QStringList tList)
+{
+ forbiddenList = tList;
+}
+
+void Query::setCheckMode(bool mode)
+{
+ checkMode = mode;
+}