From ccc435df049ddd6d2a535d7b9f2c3dc99247de23 Mon Sep 17 00:00:00 2001 From: gsherman Date: Sun, 28 Nov 2004 05:46:10 +0000 Subject: [PATCH] Dialog for editing column names prior to loading into postgresql git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2358 c8812cc2-4d05-0410-92ff-de0c093fc19c --- plugins/spit/qgseditreservedwordsbase.ui | 218 ++++++++++++++++++++ plugins/spit/qgseditreservedwordsdialog.cpp | 71 +++++++ plugins/spit/qgseditreservedwordsdialog.h | 20 ++ 3 files changed, 309 insertions(+) create mode 100644 plugins/spit/qgseditreservedwordsbase.ui create mode 100644 plugins/spit/qgseditreservedwordsdialog.cpp create mode 100644 plugins/spit/qgseditreservedwordsdialog.h diff --git a/plugins/spit/qgseditreservedwordsbase.ui b/plugins/spit/qgseditreservedwordsbase.ui new file mode 100644 index 00000000000..4afc48c594f --- /dev/null +++ b/plugins/spit/qgseditreservedwordsbase.ui @@ -0,0 +1,218 @@ + +QgsEditReservedWordsBase + + + QgsEditReservedWordsBase + + + + 0 + 0 + 343 + 351 + + + + Edit Reserved Words + + + true + + + + unnamed + + + + + Status + + + true + + + true + + + + + Column name + + + true + + + true + + + + + Index + + + false + + + true + + + + lvColumns + + + Accept + + + + + txtExplanation + + + + 32676 + 75 + + + + This shapefile contains reserved words. These may affect the import into PostgreSQL. Edit the column names so none of the reserved words listed at the right are used. You may also change any column name if desired. + + + true + + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + buttonHelp + + + &Help + + + F1 + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 20 + 20 + + + + + + buttonOk + + + &OK + + + + + + true + + + true + + + + + buttonCancel + + + &Cancel + + + + + + true + + + + + + + groupBox1 + + + Reserved Words + + + + unnamed + + + + lstReservedWords + + + + 120 + 32767 + + + + + + + + + + buttonOk + clicked() + QgsEditReservedWordsBase + accept() + + + buttonCancel + clicked() + QgsEditReservedWordsBase + reject() + + + lvColumns + itemRenamed(QListViewItem*,int,const QString&) + QgsEditReservedWordsBase + checkWord(QListViewItem*,int,const QString&) + + + lvColumns + clicked(QListViewItem*) + QgsEditReservedWordsBase + editWord(QListViewItem*) + + + + checkWord(QListViewItem*,int,const QString&) + editWord(QListViewItem*) + + + diff --git a/plugins/spit/qgseditreservedwordsdialog.cpp b/plugins/spit/qgseditreservedwordsdialog.cpp new file mode 100644 index 00000000000..e3cf60cee98 --- /dev/null +++ b/plugins/spit/qgseditreservedwordsdialog.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include "../../src/qgspgutil.h" +#include "spit_icons.h" + +#include "qgseditreservedwordsdialog.h" +QgsEditReservedWordsDialog::QgsEditReservedWordsDialog(QWidget *parent, const char *name) + : QgsEditReservedWordsBase(parent, name) +{ + // set focus indicator to span all columns + lvColumns->setAllColumnsShowFocus(true); +} + +QgsEditReservedWordsDialog::~QgsEditReservedWordsDialog() +{ +} +void QgsEditReservedWordsDialog::setReservedWords(const QStringList &words) +{ + lstReservedWords->insertStringList(words); +} +void QgsEditReservedWordsDialog::checkWord(QListViewItem *lvi, int col, const QString &word) +{ + QgsPgUtil *pgu = QgsPgUtil::instance(); + if(pgu->isReserved(word)) + { + lvi->setPixmap(0, QPixmap(icon_reserved)); + } + else + { + lvi->setPixmap(0, QPixmap(icon_ok)); + } + +} +void QgsEditReservedWordsDialog::addColumn(QString column, bool isReserved, int index) +{ + QString indexNumber; + indexNumber = indexNumber.setNum(index); + QListViewItem *lvi = new QListViewItem(lvColumns,"",column, indexNumber); +// lvi-setText(1, column); + lvi->setRenameEnabled(1, true); + if(isReserved) + { + lvi->setPixmap(0, QPixmap(icon_reserved)); + } + else + { + lvi->setPixmap(0, QPixmap(icon_ok)); + } +} +void QgsEditReservedWordsDialog::editWord(QListViewItem *lvi) +{ + if(lvi) + { + lvi->startRename(1); + } + +} +QStringList QgsEditReservedWordsDialog::columnNames() +{ + QStringList cols; + lvColumns->setSorting(2); + lvColumns->sort(); + QListViewItem *lvi = lvColumns->firstChild(); + while(lvi) + { + cols << lvi->text(1); + lvi = lvi->nextSibling(); + } + return QStringList(cols); +} diff --git a/plugins/spit/qgseditreservedwordsdialog.h b/plugins/spit/qgseditreservedwordsdialog.h new file mode 100644 index 00000000000..90ac64b0ef3 --- /dev/null +++ b/plugins/spit/qgseditreservedwordsdialog.h @@ -0,0 +1,20 @@ +#ifndef QGSEDITRESERVEDWORDSDIALOG_H +#define QGSEDITRESERVEDWORDSDIALOG_H +#include "qgseditreservedwordsbase.h" +class QgsEditReservedWordsDialog : public QgsEditReservedWordsBase +{ + Q_OBJECT + public: + QgsEditReservedWordsDialog(QWidget *parent=0, const char *name=0); + ~QgsEditReservedWordsDialog(); + void addColumn(QString column, bool isReserved, int index); + void setReservedWords(const QStringList &); + QStringList columnNames(); + public slots: + void checkWord(QListViewItem *, int , const QString&); + void editWord(QListViewItem *); + + + +}; +#endif //QGSEDITRESERVEDWORDSDIALOG_H