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
This commit is contained in:
gsherman 2004-11-28 05:46:10 +00:00
parent c3b0a0a3fb
commit ccc435df04
3 changed files with 309 additions and 0 deletions

View File

@ -0,0 +1,218 @@
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>QgsEditReservedWordsBase</class>
<widget class="QDialog">
<property name="name">
<cstring>QgsEditReservedWordsBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>343</width>
<height>351</height>
</rect>
</property>
<property name="caption">
<string>Edit Reserved Words</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QListView" row="1" column="0">
<column>
<property name="text">
<string>Status</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
<column>
<property name="text">
<string>Column name</string>
</property>
<property name="clickable">
<bool>true</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
<column>
<property name="text">
<string>Index</string>
</property>
<property name="clickable">
<bool>false</bool>
</property>
<property name="resizable">
<bool>true</bool>
</property>
</column>
<property name="name">
<cstring>lvColumns</cstring>
</property>
<property name="defaultRenameAction">
<enum>Accept</enum>
</property>
</widget>
<widget class="QTextEdit" row="0" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>txtExplanation</cstring>
</property>
<property name="maximumSize">
<size>
<width>32676</width>
<height>75</height>
</size>
</property>
<property name="text">
<string>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.</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>Layout1</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
<property name="accel">
<string>F1</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
<widget class="QGroupBox" row="1" column="1">
<property name="name">
<cstring>groupBox1</cstring>
</property>
<property name="title">
<string>Reserved Words</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QListBox" row="0" column="0">
<property name="name">
<cstring>lstReservedWords</cstring>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>32767</height>
</size>
</property>
</widget>
</grid>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>QgsEditReservedWordsBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>QgsEditReservedWordsBase</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>lvColumns</sender>
<signal>itemRenamed(QListViewItem*,int,const QString&amp;)</signal>
<receiver>QgsEditReservedWordsBase</receiver>
<slot>checkWord(QListViewItem*,int,const QString&amp;)</slot>
</connection>
<connection>
<sender>lvColumns</sender>
<signal>clicked(QListViewItem*)</signal>
<receiver>QgsEditReservedWordsBase</receiver>
<slot>editWord(QListViewItem*)</slot>
</connection>
</connections>
<slots>
<slot>checkWord(QListViewItem*,int,const QString&amp;)</slot>
<slot>editWord(QListViewItem*)</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -0,0 +1,71 @@
#include <qlistbox.h>
#include <qpixmap.h>
#include <qlistview.h>
#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);
}

View File

@ -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