[QGIS Commit] r8241 - trunk/qgis/src/plugins/grass
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Mar 17 18:42:56 EDT 2008
Author: jef
Date: 2008-03-17 18:42:55 -0400 (Mon, 17 Mar 2008)
New Revision: 8241
Modified:
trunk/qgis/src/plugins/grass/qgsgrassattributes.cpp
trunk/qgis/src/plugins/grass/qgsgrassbrowser.cpp
trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
Log:
more GRASS reindentation
Modified: trunk/qgis/src/plugins/grass/qgsgrassattributes.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassattributes.cpp 2008-03-17 22:01:26 UTC (rev 8240)
+++ trunk/qgis/src/plugins/grass/qgsgrassattributes.cpp 2008-03-17 22:42:55 UTC (rev 8241)
@@ -58,339 +58,339 @@
QgsGrassAttributesKeyPress::QgsGrassAttributesKeyPress ( Q3Table *tab )
{
- mTable = tab;
+ mTable = tab;
}
QgsGrassAttributesKeyPress::~QgsGrassAttributesKeyPress () {};
bool QgsGrassAttributesKeyPress::eventFilter( QObject *o, QEvent *e )
{
- if ( e->type() == QEvent::KeyPress )
- {
- QKeyEvent *k = (QKeyEvent *)e;
-
- if ( k->key() == Qt::Key_Tab ) {
- if ( mTable->currentRow() < mTable->numRows()-1 )
- {
- mTable->setCurrentCell( mTable->currentRow()+1, mTable->currentColumn() );
- }
- return TRUE; // eat event
- }
+ if ( e->type() == QEvent::KeyPress )
+ {
+ QKeyEvent *k = (QKeyEvent *)e;
+
+ if ( k->key() == Qt::Key_Tab ) {
+ if ( mTable->currentRow() < mTable->numRows()-1 )
+ {
+ mTable->setCurrentCell( mTable->currentRow()+1, mTable->currentColumn() );
+ }
+ return TRUE; // eat event
}
- return FALSE; // standard event processing
+ }
+ return FALSE; // standard event processing
}
QgsGrassAttributes::QgsGrassAttributes ( QgsGrassEdit *edit, QgsGrassProvider *provider, int line,
QWidget * parent, const char * name, Qt::WFlags f )
: QDialog(parent, f ), QgsGrassAttributesBase ()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes()" << std::endl;
+#endif
- setupUi(this);
+ setupUi(this);
- mEdit = edit;
- mProvider = provider;
- mLine = line;
-
- resultLabel->setText ( "" );
+ mEdit = edit;
+ mProvider = provider;
+ mLine = line;
- // Remove old
- while ( tabCats->count() ) {
- tabCats->removePage( tabCats->currentPage() );
- }
+ resultLabel->setText ( "" );
- connect ( this, SIGNAL(destroyed()), mEdit, SLOT(attributesClosed()) );
+ // Remove old
+ while ( tabCats->count() ) {
+ tabCats->removePage( tabCats->currentPage() );
+ }
- // TODO: does not work:
- connect( tabCats, SIGNAL(void currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));
+ connect ( this, SIGNAL(destroyed()), mEdit, SLOT(attributesClosed()) );
- resetButtons();
- restorePosition();
+ // TODO: does not work:
+ connect( tabCats, SIGNAL(void currentChanged(QWidget *)), this, SLOT(tabChanged(QWidget *)));
+
+ resetButtons();
+ restorePosition();
}
QgsGrassAttributes::~QgsGrassAttributes ()
{
- #ifdef QGISDEBUG
- std::cerr << "~QgsGrassAttributes()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "~QgsGrassAttributes()" << std::endl;
+#endif
- saveWindowLocation();
+ saveWindowLocation();
}
void QgsGrassAttributes::restorePosition()
{
- #ifdef QGISDEBUG
+#ifdef QGISDEBUG
std::cerr << "QgsGrassAttributes::restorePosition()" << std::endl;
- #endif
+#endif
QSettings settings;
restoreGeometry(settings.value("/GRASS/windows/attributes/geometry").toByteArray());
}
void QgsGrassAttributes::saveWindowLocation()
{
- #ifdef QGISDEBUG
+#ifdef QGISDEBUG
std::cerr << "QgsGrassAttributes::saveWindowLocation()" << std::endl;
- #endif
+#endif
QSettings settings;
settings.setValue("/GRASS/windows/attributes/geometry", saveGeometry());
}
int QgsGrassAttributes::addTab ( const QString & label )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::addTab()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::addTab()" << std::endl;
+#endif
- Q3Table *tb = new Q3Table ( 2, 3 );
- tb->setColumnReadOnly ( 0, TRUE );
- tb->setColumnReadOnly ( 2, TRUE );
- tb->setRowReadOnly ( 0, TRUE );
- tb->setRowReadOnly ( 1, TRUE );
-
- tb->horizontalHeader()->setLabel( 0, tr("Column") );
- tb->horizontalHeader()->setLabel( 1, tr("Value") );
- tb->horizontalHeader()->setLabel( 2, tr("Type") ); // Internal use
+ Q3Table *tb = new Q3Table ( 2, 3 );
+ tb->setColumnReadOnly ( 0, TRUE );
+ tb->setColumnReadOnly ( 2, TRUE );
+ tb->setRowReadOnly ( 0, TRUE );
+ tb->setRowReadOnly ( 1, TRUE );
- tb->setLeftMargin(0); // hide row labels
+ tb->horizontalHeader()->setLabel( 0, tr("Column") );
+ tb->horizontalHeader()->setLabel( 1, tr("Value") );
+ tb->horizontalHeader()->setLabel( 2, tr("Type") ); // Internal use
- tb->setText ( 0, 0, tr("Layer") );
- tb->setText ( 1, 0, "Cat" );
+ tb->setLeftMargin(0); // hide row labels
- tabCats->addTab ( tb, label );
+ tb->setText ( 0, 0, tr("Layer") );
+ tb->setText ( 1, 0, "Cat" );
- // Move down with Tab, unfortunately it does not work if the cell is edited
- // TODO: catch Tab also if the cell is edited
- QgsGrassAttributesKeyPress *ef = new QgsGrassAttributesKeyPress ( tb );
- tb->installEventFilter( ef );
+ tabCats->addTab ( tb, label );
- resetButtons();
+ // Move down with Tab, unfortunately it does not work if the cell is edited
+ // TODO: catch Tab also if the cell is edited
+ QgsGrassAttributesKeyPress *ef = new QgsGrassAttributesKeyPress ( tb );
+ tb->installEventFilter( ef );
- QSettings settings;
- QString path = "/GRASS/windows/attributes/columnWidth/";
- for ( int i = 0; i < 2; i++ )
- {
- bool ok;
- int cw = settings.readNumEntry( path+QString::number(i), 30, &ok);
- if ( ok ) tb->setColumnWidth (i, cw );
- }
+ resetButtons();
- connect ( tb->horizontalHeader(), SIGNAL(sizeChange(int,int,int)),
- this, SLOT(columnSizeChanged(int,int,int)) );
+ QSettings settings;
+ QString path = "/GRASS/windows/attributes/columnWidth/";
+ for ( int i = 0; i < 2; i++ )
+ {
+ bool ok;
+ int cw = settings.readNumEntry( path+QString::number(i), 30, &ok);
+ if ( ok ) tb->setColumnWidth (i, cw );
+ }
- return ( tabCats->count() - 1 );
+ connect ( tb->horizontalHeader(), SIGNAL(sizeChange(int,int,int)),
+ this, SLOT(columnSizeChanged(int,int,int)) );
+
+ return ( tabCats->count() - 1 );
}
void QgsGrassAttributes::setField ( int tab, int field )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::setField()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::setField()" << std::endl;
+#endif
- Q3Table *tb = (Q3Table *) tabCats->page(tab);
+ Q3Table *tb = (Q3Table *) tabCats->page(tab);
- QString str;
- str.sprintf("%d", field);
-
- tb->setText ( 0, 1, str );
+ QString str;
+ str.sprintf("%d", field);
+
+ tb->setText ( 0, 1, str );
}
void QgsGrassAttributes::setCat ( int tab, const QString & name, int cat )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::setField()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::setField()" << std::endl;
+#endif
- Q3Table *tb = (Q3Table *) tabCats->page(tab);
-
- tb->setText ( 1, 0, name );
+ Q3Table *tb = (Q3Table *) tabCats->page(tab);
- QString str;
- str.sprintf("%d", cat);
-
- tb->setText ( 1, 1, str );
+ tb->setText ( 1, 0, name );
+
+ QString str;
+ str.sprintf("%d", cat);
+
+ tb->setText ( 1, 1, str );
}
-void QgsGrassAttributes::addAttribute ( int tab, const QString &name, const QString &value,
- const QString &type )
+void QgsGrassAttributes::addAttribute ( int tab, const QString &name, const QString &value,
+ const QString &type )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::addAttribute(): " << name.toLocal8Bit().data() << ": " << value.toLocal8Bit().data() << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::addAttribute(): " << name.toLocal8Bit().data() << ": " << value.toLocal8Bit().data() << std::endl;
+#endif
- Q3Table *tb = (Q3Table *) tabCats->page(tab);
+ Q3Table *tb = (Q3Table *) tabCats->page(tab);
- tb->setNumRows ( tb->numRows()+1 );
+ tb->setNumRows ( tb->numRows()+1 );
- int row = tb->numRows()-1;
- tb->setText ( row, 0, name );
+ int row = tb->numRows()-1;
+ tb->setText ( row, 0, name );
- // I have no rational explanation why fromLocal8Bit is necessary, value should be in unicode
- // because QgsGrassProvider::attributes is using mEncoding->toUnicode()
-// tb->setText ( row, 1, QString::fromLocal8Bit(value) );
- tb->setText ( row, 1, value );
- tb->setText ( row, 2, type );
+ // I have no rational explanation why fromLocal8Bit is necessary, value should be in unicode
+ // because QgsGrassProvider::attributes is using mEncoding->toUnicode()
+ // tb->setText ( row, 1, QString::fromLocal8Bit(value) );
+ tb->setText ( row, 1, value );
+ tb->setText ( row, 2, type );
- resetButtons();
+ resetButtons();
}
void QgsGrassAttributes::addTextRow ( int tab, const QString &text )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::addTextRow()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::addTextRow()" << std::endl;
+#endif
- Q3Table *tb = (Q3Table *) tabCats->page(tab);
+ Q3Table *tb = (Q3Table *) tabCats->page(tab);
- tb->setNumRows ( tb->numRows()+1 );
+ tb->setNumRows ( tb->numRows()+1 );
- int row = tb->numRows()-1;
- tb->setText ( row, 0, text );
- tb->item(row,0)->setSpan(1,3); // must be after setText() whe item exists
+ int row = tb->numRows()-1;
+ tb->setText ( row, 0, text );
+ tb->item(row,0)->setSpan(1,3); // must be after setText() whe item exists
}
void QgsGrassAttributes::updateAttributes ( )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::updateAttributes()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::updateAttributes()" << std::endl;
+#endif
- if ( tabCats->count() == 0 ) return;
+ if ( tabCats->count() == 0 ) return;
- Q3Table *tb = (Q3Table *) tabCats->currentPage();
+ Q3Table *tb = (Q3Table *) tabCats->currentPage();
- if ( tb->numRows() > 2 ) {
+ if ( tb->numRows() > 2 ) {
- // Stop editing (trick)
- tb->setColumnReadOnly ( 1, TRUE );
- tb->setColumnReadOnly ( 1, FALSE );
- tb->setRowReadOnly ( 0, TRUE );
- tb->setRowReadOnly ( 1, TRUE );
-
- QString sql;
-
- for ( int i = 2; i < tb->numRows(); i++ ) {
- if ( i > 2 ) sql.append (", ");
-
- QString val = tb->text(i, 1).stripWhiteSpace();
-
- if ( val.isEmpty() )
- {
- sql.append ( tb->text(i, 0) + " = null" );
- }
- else
- {
- if ( tb->text(i, 2) == "int" || tb->text(i, 2) == "double" ) {
- sql.append ( tb->text(i, 0) + " = " + val );
- } else {
- val.replace("'","''");
- sql.append ( tb->text(i, 0) + " = '" + val + "'" );
- }
- }
- }
+ // Stop editing (trick)
+ tb->setColumnReadOnly ( 1, TRUE );
+ tb->setColumnReadOnly ( 1, FALSE );
+ tb->setRowReadOnly ( 0, TRUE );
+ tb->setRowReadOnly ( 1, TRUE );
- #ifdef QGISDEBUG
- std::cerr << "sql: " << sql.toLocal8Bit().data() << std::endl;
- #endif
+ QString sql;
- QString *error = mProvider->updateAttributes ( tb->text(0,1).toInt(), tb->text(1,1).toInt(), sql );
+ for ( int i = 2; i < tb->numRows(); i++ ) {
+ if ( i > 2 ) sql.append (", ");
- if ( !error->isEmpty() ) {
- QMessageBox::warning( 0, tr("Warning"), *error );
- resultLabel->setText ( tr("ERROR") );
- } else {
- resultLabel->setText ( tr("OK") );
+ QString val = tb->text(i, 1).stripWhiteSpace();
+
+ if ( val.isEmpty() )
+ {
+ sql.append ( tb->text(i, 0) + " = null" );
+ }
+ else
+ {
+ if ( tb->text(i, 2) == "int" || tb->text(i, 2) == "double" ) {
+ sql.append ( tb->text(i, 0) + " = " + val );
+ } else {
+ val.replace("'","''");
+ sql.append ( tb->text(i, 0) + " = '" + val + "'" );
+ }
}
+ }
- delete error;
+#ifdef QGISDEBUG
+ std::cerr << "sql: " << sql.toLocal8Bit().data() << std::endl;
+#endif
+
+ QString *error = mProvider->updateAttributes ( tb->text(0,1).toInt(), tb->text(1,1).toInt(), sql );
+
+ if ( !error->isEmpty() ) {
+ QMessageBox::warning( 0, tr("Warning"), *error );
+ resultLabel->setText ( tr("ERROR") );
+ } else {
+ resultLabel->setText ( tr("OK") );
}
+
+ delete error;
+ }
}
void QgsGrassAttributes::addCat ( )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::addCat()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::addCat()" << std::endl;
+#endif
- mEdit->addCat( mLine );
-
- // Select new tab
- tabCats->setCurrentPage( tabCats->count()-1 );
-
- resetButtons();
+ mEdit->addCat( mLine );
+
+ // Select new tab
+ tabCats->setCurrentPage( tabCats->count()-1 );
+
+ resetButtons();
}
void QgsGrassAttributes::deleteCat ( )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::deleteCat()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::deleteCat()" << std::endl;
+#endif
- if ( tabCats->count() == 0 ) return;
-
- Q3Table *tb = (Q3Table *) tabCats->currentPage();
+ if ( tabCats->count() == 0 ) return;
- int field = tb->text(0,1).toInt();
- int cat = tb->text(1,1).toInt();
+ Q3Table *tb = (Q3Table *) tabCats->currentPage();
- mEdit->deleteCat(mLine, field, cat);
+ int field = tb->text(0,1).toInt();
+ int cat = tb->text(1,1).toInt();
- tabCats->removePage( tb );
- delete tb;
- resetButtons();
+ mEdit->deleteCat(mLine, field, cat);
+
+ tabCats->removePage( tb );
+ delete tb;
+ resetButtons();
}
void QgsGrassAttributes::clear ( )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::clear()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::clear()" << std::endl;
+#endif
- while ( tabCats->count() > 0 )
- {
- Q3Table *tb = (Q3Table *) tabCats->currentPage();
- tabCats->removePage( tb );
- delete tb;
- }
- resetButtons();
+ while ( tabCats->count() > 0 )
+ {
+ Q3Table *tb = (Q3Table *) tabCats->currentPage();
+ tabCats->removePage( tb );
+ delete tb;
+ }
+ resetButtons();
}
void QgsGrassAttributes::tabChanged ( QWidget *widget )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassAttributes::tabChanged()" << std::endl;
- #endif
-
- //Q3Table *tb = (Q3Table *) tabCats->currentPage();
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassAttributes::tabChanged()" << std::endl;
+#endif
- resultLabel->setText ( "" );
+ //Q3Table *tb = (Q3Table *) tabCats->currentPage();
+
+ resultLabel->setText ( "" );
}
void QgsGrassAttributes::setLine ( int line )
{
- mLine = line;
+ mLine = line;
}
void QgsGrassAttributes::resetButtons ( )
{
- if ( tabCats->count() == 0 )
- {
- deleteButton->setEnabled(false);
- updateButton->setEnabled(false);
- }
- else
- {
- deleteButton->setEnabled(true);
- updateButton->setEnabled(true);
- }
+ if ( tabCats->count() == 0 )
+ {
+ deleteButton->setEnabled(false);
+ updateButton->setEnabled(false);
+ }
+ else
+ {
+ deleteButton->setEnabled(true);
+ updateButton->setEnabled(true);
+ }
}
void QgsGrassAttributes::columnSizeChanged ( int section, int oldSize, int newSize )
{
- QSettings settings;
- QString path = "/GRASS/windows/attributes/columnWidth/"
- + QString::number(section);
- std::cerr << "path = " << path.ascii() << " newSize = " << newSize << std::endl;
- settings.writeEntry( path, newSize);
+ QSettings settings;
+ QString path = "/GRASS/windows/attributes/columnWidth/"
+ + QString::number(section);
+ std::cerr << "path = " << path.ascii() << " newSize = " << newSize << std::endl;
+ settings.writeEntry( path, newSize);
}
Modified: trunk/qgis/src/plugins/grass/qgsgrassbrowser.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassbrowser.cpp 2008-03-17 22:01:26 UTC (rev 8240)
+++ trunk/qgis/src/plugins/grass/qgsgrassbrowser.cpp 2008-03-17 22:42:55 UTC (rev 8241)
@@ -58,486 +58,486 @@
QWidget * parent, Qt::WFlags f )
: QMainWindow(parent, Qt::WType_Dialog), mIface(iface)
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser()" << std::endl;
+#endif
- QActionGroup *ag = new QActionGroup ( this );
- QToolBar *tb = addToolBar(tr("Tools"));
+ QActionGroup *ag = new QActionGroup ( this );
+ QToolBar *tb = addToolBar(tr("Tools"));
- QString myIconPath = QgsApplication::themePath() + "/grass/";
- mActionAddMap = new QAction(
- QIcon(myIconPath+"grass_add_map.png"),
- tr("Add selected map to canvas"), this);
- mActionAddMap->setEnabled(false);
- ag->addAction ( mActionAddMap );
- tb->addAction ( mActionAddMap );
- connect ( mActionAddMap, SIGNAL(triggered()), this, SLOT(addMap()) );
+ QString myIconPath = QgsApplication::themePath() + "/grass/";
+ mActionAddMap = new QAction(
+ QIcon(myIconPath+"grass_add_map.png"),
+ tr("Add selected map to canvas"), this);
+ mActionAddMap->setEnabled(false);
+ ag->addAction ( mActionAddMap );
+ tb->addAction ( mActionAddMap );
+ connect ( mActionAddMap, SIGNAL(triggered()), this, SLOT(addMap()) );
- mActionCopyMap = new QAction(
- QIcon(myIconPath+"grass_copy_map.png"),
- tr("Copy selected map"), this);
- mActionCopyMap->setEnabled(false);
- ag->addAction ( mActionCopyMap );
- tb->addAction ( mActionCopyMap );
- connect ( mActionCopyMap, SIGNAL(triggered()), this, SLOT(copyMap()) );
+ mActionCopyMap = new QAction(
+ QIcon(myIconPath+"grass_copy_map.png"),
+ tr("Copy selected map"), this);
+ mActionCopyMap->setEnabled(false);
+ ag->addAction ( mActionCopyMap );
+ tb->addAction ( mActionCopyMap );
+ connect ( mActionCopyMap, SIGNAL(triggered()), this, SLOT(copyMap()) );
- mActionRenameMap = new QAction(
- QIcon(myIconPath+"grass_rename_map.png"),
- tr("Rename selected map"), this);
- mActionRenameMap->setEnabled(false);
- ag->addAction ( mActionRenameMap );
- tb->addAction ( mActionRenameMap );
- connect ( mActionRenameMap, SIGNAL(triggered()), this, SLOT(renameMap()) );
+ mActionRenameMap = new QAction(
+ QIcon(myIconPath+"grass_rename_map.png"),
+ tr("Rename selected map"), this);
+ mActionRenameMap->setEnabled(false);
+ ag->addAction ( mActionRenameMap );
+ tb->addAction ( mActionRenameMap );
+ connect ( mActionRenameMap, SIGNAL(triggered()), this, SLOT(renameMap()) );
- mActionDeleteMap = new QAction(
- QIcon(myIconPath+"grass_delete_map.png"),
- tr("Delete selected map"), this);
- mActionDeleteMap->setEnabled(false);
- ag->addAction ( mActionDeleteMap );
- tb->addAction ( mActionDeleteMap );
- connect ( mActionDeleteMap, SIGNAL(triggered()), this, SLOT(deleteMap()) );
+ mActionDeleteMap = new QAction(
+ QIcon(myIconPath+"grass_delete_map.png"),
+ tr("Delete selected map"), this);
+ mActionDeleteMap->setEnabled(false);
+ ag->addAction ( mActionDeleteMap );
+ tb->addAction ( mActionDeleteMap );
+ connect ( mActionDeleteMap, SIGNAL(triggered()), this, SLOT(deleteMap()) );
- mActionSetRegion = new QAction(
- QIcon(myIconPath+"grass_set_region.png"),
- tr("Set current region to selected map"), this);
- mActionSetRegion->setEnabled(false);
- ag->addAction ( mActionSetRegion );
- tb->addAction ( mActionSetRegion );
- connect ( mActionSetRegion, SIGNAL(triggered()), this, SLOT(setRegion()) );
+ mActionSetRegion = new QAction(
+ QIcon(myIconPath+"grass_set_region.png"),
+ tr("Set current region to selected map"), this);
+ mActionSetRegion->setEnabled(false);
+ ag->addAction ( mActionSetRegion );
+ tb->addAction ( mActionSetRegion );
+ connect ( mActionSetRegion, SIGNAL(triggered()), this, SLOT(setRegion()) );
- mActionRefresh = new QAction(
- QIcon(myIconPath+"grass_refresh.png"),
- tr("Refresh"), this);
- ag->addAction ( mActionRefresh );
- tb->addAction ( mActionRefresh );
- connect ( mActionRefresh, SIGNAL(triggered()), this, SLOT(refresh()) );
+ mActionRefresh = new QAction(
+ QIcon(myIconPath+"grass_refresh.png"),
+ tr("Refresh"), this);
+ ag->addAction ( mActionRefresh );
+ tb->addAction ( mActionRefresh );
+ connect ( mActionRefresh, SIGNAL(triggered()), this, SLOT(refresh()) );
- // Add model
- mModel = new QgsGrassModel ( this );
+ // Add model
+ mModel = new QgsGrassModel ( this );
- mTree = new QTreeView(0);
- mTree->header()->hide();
- mTree->setModel(mModel);
+ mTree = new QTreeView(0);
+ mTree->header()->hide();
+ mTree->setModel(mModel);
- mTextBrowser = new QTextBrowser(0);
- mTextBrowser->setTextFormat(Qt::RichText);
- mTextBrowser->setReadOnly(TRUE);
+ mTextBrowser = new QTextBrowser(0);
+ mTextBrowser->setTextFormat(Qt::RichText);
+ mTextBrowser->setReadOnly(TRUE);
- mSplitter = new QSplitter(0);
- mSplitter->addWidget(mTree);
- mSplitter->addWidget(mTextBrowser);
+ mSplitter = new QSplitter(0);
+ mSplitter->addWidget(mTree);
+ mSplitter->addWidget(mTextBrowser);
- this->setCentralWidget(mSplitter);
+ this->setCentralWidget(mSplitter);
- connect ( mTree->selectionModel(),
- SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(selectionChanged(QItemSelection,QItemSelection)) );
+ connect ( mTree->selectionModel(),
+ SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(selectionChanged(QItemSelection,QItemSelection)) );
- connect ( mTree->selectionModel(),
- SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- this, SLOT(currentChanged(QModelIndex,QModelIndex)) );
+ connect ( mTree->selectionModel(),
+ SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this, SLOT(currentChanged(QModelIndex,QModelIndex)) );
- connect ( mTree, SIGNAL(doubleClicked(QModelIndex)),
- this, SLOT(doubleClicked(QModelIndex)) );
+ connect ( mTree, SIGNAL(doubleClicked(QModelIndex)),
+ this, SLOT(doubleClicked(QModelIndex)) );
}
QgsGrassBrowser::~QgsGrassBrowser() { }
void QgsGrassBrowser::refresh()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::refresh()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::refresh()" << std::endl;
+#endif
- mModel->refresh();
- mTree->update();
+ mModel->refresh();
+ mTree->update();
}
void QgsGrassBrowser::addMap()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::addMap()" << std::endl;
- #endif
-
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
- bool mapSelected = false;
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::addMap()" << std::endl;
+#endif
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+ bool mapSelected = false;
+
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ int type = mModel->itemType(*it);
+ QString uri = mModel->uri(*it);
+ QString mapset = mModel->itemMapset(*it);
+ QString map = mModel->itemMap(*it);
+ if ( type == QgsGrassModel::Raster )
{
- int type = mModel->itemType(*it);
- QString uri = mModel->uri(*it);
- QString mapset = mModel->itemMapset(*it);
- QString map = mModel->itemMap(*it);
- if ( type == QgsGrassModel::Raster )
- {
- std::cerr << "add raster: " << uri.ascii() << std::endl;
- mIface->addRasterLayer(uri, map);
- mapSelected = true;
- }
- else if ( type == QgsGrassModel::Vector )
- {
- QgsGrassUtils::addVectorLayers ( mIface,
- QgsGrass::getDefaultGisdbase(),
- QgsGrass::getDefaultLocation(),
- mapset, map );
- }
- else if ( type == QgsGrassModel::VectorLayer )
- {
+ std::cerr << "add raster: " << uri.ascii() << std::endl;
+ mIface->addRasterLayer(uri, map);
+ mapSelected = true;
+ }
+ else if ( type == QgsGrassModel::Vector )
+ {
+ QgsGrassUtils::addVectorLayers ( mIface,
+ QgsGrass::getDefaultGisdbase(),
+ QgsGrass::getDefaultLocation(),
+ mapset, map );
+ }
+ else if ( type == QgsGrassModel::VectorLayer )
+ {
- QStringList list = QgsGrassSelect::vectorLayers(
- QgsGrass::getDefaultGisdbase(),
- QgsGrass::getDefaultLocation(),
- mModel->itemMapset(*it), map );
+ QStringList list = QgsGrassSelect::vectorLayers(
+ QgsGrass::getDefaultGisdbase(),
+ QgsGrass::getDefaultLocation(),
+ mModel->itemMapset(*it), map );
- // TODO: common method for vector names
- QStringList split = QStringList::split ( '/', uri );
- QString layer = split.last();
+ // TODO: common method for vector names
+ QStringList split = QStringList::split ( '/', uri );
+ QString layer = split.last();
- QString name = QgsGrassUtils::vectorLayerName (
- map, layer, list.size() );
-
- mIface->addVectorLayer( uri, name, "grass");
- mapSelected = true;
- }
- else if ( type == QgsGrassModel::Region )
- {
- struct Cell_head window;
- if ( !getItemRegion (*it, &window) ) continue;
- writeRegion ( &window );
- }
+ QString name = QgsGrassUtils::vectorLayerName (
+ map, layer, list.size() );
+
+ mIface->addVectorLayer( uri, name, "grass");
+ mapSelected = true;
}
+ else if ( type == QgsGrassModel::Region )
+ {
+ struct Cell_head window;
+ if ( !getItemRegion (*it, &window) ) continue;
+ writeRegion ( &window );
+ }
+ }
}
void QgsGrassBrowser::doubleClicked(const QModelIndex & index)
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::doubleClicked()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::doubleClicked()" << std::endl;
+#endif
- addMap();
+ addMap();
}
QString QgsGrassBrowser::formatMessage( QString msg )
{
- return msg.replace("<","<").replace(">",">").replace("\n","<br>");
+ return msg.replace("<","<").replace(">",">").replace("\n","<br>");
}
void QgsGrassBrowser::copyMap()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::copyMap()" << std::endl;
- #endif
-
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::copyMap()" << std::endl;
+#endif
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ int type = mModel->itemType(*it);
+ QString mapset = mModel->itemMapset(*it);
+ QString map = mModel->itemMap(*it);
+
+ QString typeName;
+ QString element;
+ if ( type == QgsGrassModel::Raster )
{
- int type = mModel->itemType(*it);
- QString mapset = mModel->itemMapset(*it);
- QString map = mModel->itemMap(*it);
+ element = "cell";
+ typeName = "rast";
+ }
+ else if ( type == QgsGrassModel::Vector )
+ {
+ element = "vector";
+ typeName = "vect";
+ }
+ else if ( type == QgsGrassModel::Region )
+ {
+ element = "windows";
+ typeName = "region";
+ }
- QString typeName;
- QString element;
- if ( type == QgsGrassModel::Raster )
- {
- element = "cell";
- typeName = "rast";
- }
- else if ( type == QgsGrassModel::Vector )
- {
- element = "vector";
- typeName = "vect";
- }
- else if ( type == QgsGrassModel::Region )
- {
- element = "windows";
- typeName = "region";
- }
+ QgsGrassElementDialog ed;
+ bool ok;
+ QString source;
+ QString suggest;
+ if ( mapset == QgsGrass::getDefaultMapset() )
+ {
+ source = map;
+ }
+ else
+ {
+ suggest = map;
+ }
+ QString newName = ed.getItem ( element, tr("New name"),
+ tr("New name"), suggest, source, &ok );
- QgsGrassElementDialog ed;
- bool ok;
- QString source;
- QString suggest;
- if ( mapset == QgsGrass::getDefaultMapset() )
- {
- source = map;
- }
- else
- {
- suggest = map;
- }
- QString newName = ed.getItem ( element, tr("New name"),
- tr("New name"), suggest, source, &ok );
+ if ( !ok ) return;
- if ( !ok ) return;
-
- QString module = "g.copy";
+ QString module = "g.copy";
#ifdef WIN32
- module.append(".exe");
+ module.append(".exe");
#endif
- QProcess process(this);
- QStringList args(typeName + "=" + map + "@" + mapset + "," + newName );
- process.start(module, args );
- if ( !process.waitForFinished() || process.exitCode() != 0 )
- {
- QString output ( process.readAllStandardOutput () );
- QString error ( process.readAllStandardError () );
- QMessageBox::warning( 0, tr("Warning"), tr("Cannot copy map ")
- + map + "@" + mapset
- + tr("<br>command: ") + module + " " + args.join(" ")
- + "<br>" + formatMessage(output)
- + "<br>" + formatMessage(error) );
- }
- else
- {
- refresh();
- }
+ QProcess process(this);
+ QStringList args(typeName + "=" + map + "@" + mapset + "," + newName );
+ process.start(module, args );
+ if ( !process.waitForFinished() || process.exitCode() != 0 )
+ {
+ QString output ( process.readAllStandardOutput () );
+ QString error ( process.readAllStandardError () );
+ QMessageBox::warning( 0, tr("Warning"), tr("Cannot copy map ")
+ + map + "@" + mapset
+ + tr("<br>command: ") + module + " " + args.join(" ")
+ + "<br>" + formatMessage(output)
+ + "<br>" + formatMessage(error) );
}
+ else
+ {
+ refresh();
+ }
+ }
}
void QgsGrassBrowser::renameMap()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::renameMap()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::renameMap()" << std::endl;
+#endif
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ int type = mModel->itemType(*it);
+ QString mapset = mModel->itemMapset(*it);
+ QString map = mModel->itemMap(*it);
+
+ if ( mapset != QgsGrass::getDefaultMapset() ) continue; // should not happen
+
+ QString typeName;
+ QString element;
+ if ( type == QgsGrassModel::Raster )
{
- int type = mModel->itemType(*it);
- QString mapset = mModel->itemMapset(*it);
- QString map = mModel->itemMap(*it);
+ element = "cell";
+ typeName = "rast";
+ }
+ else if ( type == QgsGrassModel::Vector )
+ {
+ element = "vector";
+ typeName = "vect";
+ }
+ else if ( type == QgsGrassModel::Region )
+ {
+ element = "windows";
+ typeName = "region";
+ }
- if ( mapset != QgsGrass::getDefaultMapset() ) continue; // should not happen
+ QgsGrassElementDialog ed;
+ bool ok;
+ QString newName = ed.getItem ( element, tr("New name"),
+ tr("New name"), "", map, &ok );
- QString typeName;
- QString element;
- if ( type == QgsGrassModel::Raster )
- {
- element = "cell";
- typeName = "rast";
- }
- else if ( type == QgsGrassModel::Vector )
- {
- element = "vector";
- typeName = "vect";
- }
- else if ( type == QgsGrassModel::Region )
- {
- element = "windows";
- typeName = "region";
- }
+ if ( !ok ) return;
- QgsGrassElementDialog ed;
- bool ok;
- QString newName = ed.getItem ( element, tr("New name"),
- tr("New name"), "", map, &ok );
-
- if ( !ok ) return;
-
- QString module = "g.rename";
+ QString module = "g.rename";
#ifdef WIN32
- module.append(".exe");
+ module.append(".exe");
#endif
- QProcess process(this);
- QStringList args(typeName + "=" + map + "," + newName );
- process.start(module, QStringList( typeName + "=" + map + "," + newName ) );
- if ( !process.waitForFinished() || process.exitCode() != 0 )
- {
- QString output ( process.readAllStandardOutput () );
- QString error ( process.readAllStandardError () );
- QMessageBox::warning( 0, tr("Warning"), tr("Cannot rename map ")
- + map
- + tr("<br>command: ") + module + " " + args.join(" ")
- + "<br>" + formatMessage(output)
- + "<br>" + formatMessage(error) );
- }
- else
- {
- refresh();
- }
+ QProcess process(this);
+ QStringList args(typeName + "=" + map + "," + newName );
+ process.start(module, QStringList( typeName + "=" + map + "," + newName ) );
+ if ( !process.waitForFinished() || process.exitCode() != 0 )
+ {
+ QString output ( process.readAllStandardOutput () );
+ QString error ( process.readAllStandardError () );
+ QMessageBox::warning( 0, tr("Warning"), tr("Cannot rename map ")
+ + map
+ + tr("<br>command: ") + module + " " + args.join(" ")
+ + "<br>" + formatMessage(output)
+ + "<br>" + formatMessage(error) );
}
+ else
+ {
+ refresh();
+ }
+ }
}
void QgsGrassBrowser::deleteMap()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::deleteMap()" << std::endl;
- #endif
-
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::deleteMap()" << std::endl;
+#endif
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ int type = mModel->itemType(*it);
+ QString mapset = mModel->itemMapset(*it);
+ QString map = mModel->itemMap(*it);
+
+ QString typeName;
+ if ( type == QgsGrassModel::Raster ) typeName = "rast";
+ else if ( type == QgsGrassModel::Vector ) typeName = "vect";
+ else if ( type == QgsGrassModel::Region ) typeName = "region";
+
+ if ( mapset != QgsGrass::getDefaultMapset() )
{
- int type = mModel->itemType(*it);
- QString mapset = mModel->itemMapset(*it);
- QString map = mModel->itemMap(*it);
+ continue; // should not happen
+ }
- QString typeName;
- if ( type == QgsGrassModel::Raster ) typeName = "rast";
- else if ( type == QgsGrassModel::Vector ) typeName = "vect";
- else if ( type == QgsGrassModel::Region ) typeName = "region";
+ QMessageBox::StandardButton ret = QMessageBox::question ( 0, tr("Warning"),
+ tr("Delete map <b>") + map + "</b>",
+ QMessageBox::Ok | QMessageBox::Cancel );
- if ( mapset != QgsGrass::getDefaultMapset() )
- {
- continue; // should not happen
- }
-
- QMessageBox::StandardButton ret = QMessageBox::question ( 0, tr("Warning"),
- tr("Delete map <b>") + map + "</b>",
- QMessageBox::Ok | QMessageBox::Cancel );
+ if ( ret == QMessageBox::Cancel ) continue;
- if ( ret == QMessageBox::Cancel ) continue;
-
- QString module = "g.remove";
+ QString module = "g.remove";
#ifdef WIN32
- module.append(".exe");
+ module.append(".exe");
#endif
- QProcess process(this);
- QStringList args(typeName + "=" + map );
- process.start(module, QStringList( typeName + "=" + map ) );
- if ( !process.waitForFinished() || process.exitCode() != 0 )
- {
- QString output ( process.readAllStandardOutput () );
- QString error ( process.readAllStandardError () );
- QMessageBox::warning( 0, tr("Warning"), tr("Cannot delete map ")
- + map
- + tr("<br>command: ") + module + " " + args.join(" ")
- + "<br>" + formatMessage(output)
- + "<br>" + formatMessage(error) );
- }
- else
- {
- refresh();
- }
+ QProcess process(this);
+ QStringList args(typeName + "=" + map );
+ process.start(module, QStringList( typeName + "=" + map ) );
+ if ( !process.waitForFinished() || process.exitCode() != 0 )
+ {
+ QString output ( process.readAllStandardOutput () );
+ QString error ( process.readAllStandardError () );
+ QMessageBox::warning( 0, tr("Warning"), tr("Cannot delete map ")
+ + map
+ + tr("<br>command: ") + module + " " + args.join(" ")
+ + "<br>" + formatMessage(output)
+ + "<br>" + formatMessage(error) );
}
+ else
+ {
+ refresh();
+ }
+ }
}
void QgsGrassBrowser::setRegion()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::setRegion()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::setRegion()" << std::endl;
+#endif
- struct Cell_head window;
+ struct Cell_head window;
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
- // TODO multiple selection - extent region to all maps
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
- {
- if ( !getItemRegion (*it, &window) ) return;
- }
- writeRegion ( &window );
+ // TODO multiple selection - extent region to all maps
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ if ( !getItemRegion (*it, &window) ) return;
+ }
+ writeRegion ( &window );
}
void QgsGrassBrowser::writeRegion(struct Cell_head *window )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::writeRegion()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::writeRegion()" << std::endl;
+#endif
- QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(),
- QgsGrass::getDefaultLocation(),
- QgsGrass::getDefaultMapset() );
+ QgsGrass::setMapset( QgsGrass::getDefaultGisdbase(),
+ QgsGrass::getDefaultLocation(),
+ QgsGrass::getDefaultMapset() );
- if ( G_put_window ( window ) == -1 )
- {
- QMessageBox::warning( 0, tr("Warning"),
- tr("Cannot write new region") );
- return;
- }
- emit regionChanged();
+ if ( G_put_window ( window ) == -1 )
+ {
+ QMessageBox::warning( 0, tr("Warning"),
+ tr("Cannot write new region") );
+ return;
+ }
+ emit regionChanged();
}
bool QgsGrassBrowser::getItemRegion( QModelIndex index, struct Cell_head *window )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::setRegion()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::setRegion()" << std::endl;
+#endif
- int type = mModel->itemType(index);
- QString mapset = mModel->itemMapset(index);
- QString map = mModel->itemMap(index);
+ int type = mModel->itemType(index);
+ QString mapset = mModel->itemMapset(index);
+ QString map = mModel->itemMap(index);
- int mapType = QgsGrass::Raster; //default in case no case matches
- switch (type) {
+ int mapType = QgsGrass::Raster; //default in case no case matches
+ switch (type) {
case QgsGrassModel::Raster :
- mapType = QgsGrass::Raster;
- break;
+ mapType = QgsGrass::Raster;
+ break;
case QgsGrassModel::Vector :
- mapType = QgsGrass::Vector;
- break;
+ mapType = QgsGrass::Vector;
+ break;
case QgsGrassModel::Region :
- mapType = QgsGrass::Region;
- break;
- default:
- break;
- }
-
- return QgsGrass::mapRegion ( mapType, QgsGrass::getDefaultGisdbase(),
- QgsGrass::getDefaultLocation(), mapset, map, window );
+ mapType = QgsGrass::Region;
+ break;
+ default:
+ break;
+ }
+
+ return QgsGrass::mapRegion ( mapType, QgsGrass::getDefaultGisdbase(),
+ QgsGrass::getDefaultLocation(), mapset, map, window );
}
void QgsGrassBrowser::selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::selectionChanged()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::selectionChanged()" << std::endl;
+#endif
- mActionAddMap->setEnabled(false);
- mActionCopyMap->setEnabled(false);
- mActionRenameMap->setEnabled(false);
- mActionDeleteMap->setEnabled(false);
- mActionSetRegion->setEnabled(false);
-
- QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
+ mActionAddMap->setEnabled(false);
+ mActionCopyMap->setEnabled(false);
+ mActionRenameMap->setEnabled(false);
+ mActionDeleteMap->setEnabled(false);
+ mActionSetRegion->setEnabled(false);
- mTextBrowser->clear();
+ QModelIndexList indexes = mTree->selectionModel()->selectedIndexes();
- QList<QModelIndex>::const_iterator it = indexes.begin();
- for (; it != indexes.end(); ++it)
+ mTextBrowser->clear();
+
+ QList<QModelIndex>::const_iterator it = indexes.begin();
+ for (; it != indexes.end(); ++it)
+ {
+ mTextBrowser->append ( mModel->itemInfo(*it) );
+ mTextBrowser->verticalScrollBar()->setValue(0);
+
+ int type = mModel->itemType(*it);
+ if ( type == QgsGrassModel::Raster ||
+ type == QgsGrassModel::Vector ||
+ type == QgsGrassModel::VectorLayer )
{
- mTextBrowser->append ( mModel->itemInfo(*it) );
- mTextBrowser->verticalScrollBar()->setValue(0);
-
- int type = mModel->itemType(*it);
- if ( type == QgsGrassModel::Raster ||
- type == QgsGrassModel::Vector ||
- type == QgsGrassModel::VectorLayer )
- {
- mActionAddMap->setEnabled(true);
- }
- if ( type == QgsGrassModel::Raster || type == QgsGrassModel::Vector || type == QgsGrassModel::Region )
- {
- mActionSetRegion->setEnabled(true);
- mActionCopyMap->setEnabled(true);
+ mActionAddMap->setEnabled(true);
+ }
+ if ( type == QgsGrassModel::Raster || type == QgsGrassModel::Vector || type == QgsGrassModel::Region )
+ {
+ mActionSetRegion->setEnabled(true);
+ mActionCopyMap->setEnabled(true);
- QString mapset = mModel->itemMapset(*it);
- if ( mapset == QgsGrass::getDefaultMapset() )
- {
- mActionDeleteMap->setEnabled(true);
- mActionRenameMap->setEnabled(true);
- }
- }
+ QString mapset = mModel->itemMapset(*it);
+ if ( mapset == QgsGrass::getDefaultMapset() )
+ {
+ mActionDeleteMap->setEnabled(true);
+ mActionRenameMap->setEnabled(true);
+ }
}
+ }
}
void QgsGrassBrowser::currentChanged(const QModelIndex & current, const QModelIndex & previous)
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassBrowser::currentChanged()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassBrowser::currentChanged()" << std::endl;
+#endif
}
void QgsGrassBrowser::setLocation( const QString &gisbase, const QString &location )
{
- mModel->setLocation(gisbase, location);
+ mModel->setLocation(gisbase, location);
}
Modified: trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp 2008-03-17 22:01:26 UTC (rev 8240)
+++ trunk/qgis/src/plugins/grass/qgsgrassmodule.cpp 2008-03-17 22:42:55 UTC (rev 8241)
@@ -145,8 +145,8 @@
bool QgsGrassModule::inExecPath ( QString file )
{
- if ( findExec(file).isNull() ) return false;
- return true;
+ if ( findExec(file).isNull() ) return false;
+ return true;
}
QStringList QgsGrassModule::execArguments ( QString module )
@@ -353,7 +353,7 @@
if ( arguments.size() == 0 )
{
QMessageBox::warning( 0, tr("Warning"), tr("Cannot find module ")
- + mXName );
+ + mXName );
return;
}
@@ -367,13 +367,13 @@
// ? Does binary on Win need .exe extention ?
// Return code 255 (-1) was correct in GRASS < 6.1.0
if ( !process.waitForFinished()
- || (process.exitCode() != 0 && process.exitCode() != 255) )
+ || (process.exitCode() != 0 && process.exitCode() != 255) )
{
QgsDebugMsg("process.exitCode() = " + QString::number(process.exitCode()) );
QMessageBox::warning( 0, tr("Warning"), tr("Cannot start module ") + mXName + "<br>"
- + cmd + " " + arguments.join(" ") + "<br>"
- + QString(process.readAllStandardOutput()) + "<br>"
- + QString(process.readAllStandardError()) );
+ + cmd + " " + arguments.join(" ") + "<br>"
+ + QString(process.readAllStandardOutput()) + "<br>"
+ + QString(process.readAllStandardError()) );
return;
}
QByteArray gDescArray = process.readAllStandardOutput();
@@ -384,7 +384,7 @@
int line, column;
if ( !gDoc.setContent( (QByteArray)gDescArray, &err, &line, &column ) ) {
QString errmsg = tr("Cannot read module description (") + mXName + tr("):\n") + err + tr("\nat line ")
- + QString::number(line) + tr(" column ") + QString::number(column);
+ + QString::number(line) + tr(" column ") + QString::number(column);
QgsDebugMsg(errmsg);
QgsDebugMsg(QString(gDescArray));
QgsDebugMsg(QString(errArray));
@@ -424,7 +424,7 @@
//QgsDebugMsg("element = " + element + " age = " + age);
if ( age == "old" && ( element == "vector" || element == "cell") ) {
QgsGrassModuleInput *mi = new QgsGrassModuleInput (
- mModule, this, key, e, gDocElem, gnode, mParent );
+ mModule, this, key, e, gDocElem, gnode, mParent );
layout->addWidget ( mi );
created = true;
@@ -434,7 +434,7 @@
if ( !created ) {
QgsGrassModuleOption *so = new QgsGrassModuleOption (
- mModule, key, e, gDocElem, gnode, mParent );
+ mModule, key, e, gDocElem, gnode, mParent );
layout->addWidget ( so );
created = true;
@@ -444,46 +444,46 @@
else if ( optionType == "ogr" )
{
QgsGrassModuleGdalInput *mi = new QgsGrassModuleGdalInput (
- mModule, QgsGrassModuleGdalInput::Ogr, key, e,
- gDocElem, gnode, mParent );
+ mModule, QgsGrassModuleGdalInput::Ogr, key, e,
+ gDocElem, gnode, mParent );
layout->addWidget ( mi );
mItems.push_back(mi);
}
else if ( optionType == "gdal" )
{
QgsGrassModuleGdalInput *mi = new QgsGrassModuleGdalInput (
- mModule, QgsGrassModuleGdalInput::Gdal, key, e,
- gDocElem, gnode, mParent );
+ mModule, QgsGrassModuleGdalInput::Gdal, key, e,
+ gDocElem, gnode, mParent );
layout->addWidget ( mi );
mItems.push_back(mi);
}
else if ( optionType == "field" )
{
QgsGrassModuleField *mi = new QgsGrassModuleField (
- mModule, this, key, e,
- gDocElem, gnode, mParent );
+ mModule, this, key, e,
+ gDocElem, gnode, mParent );
layout->addWidget ( mi );
mItems.push_back(mi);
}
else if ( optionType == "selection" )
{
QgsGrassModuleSelection *mi = new QgsGrassModuleSelection (
- mModule, this, key, e,
- gDocElem, gnode, mParent );
+ mModule, this, key, e,
+ gDocElem, gnode, mParent );
layout->addWidget ( mi );
mItems.push_back(mi);
}
else if ( optionType == "file" )
{
QgsGrassModuleFile *mi = new QgsGrassModuleFile (
- mModule, key, e, gDocElem, gnode, mParent );
+ mModule, key, e, gDocElem, gnode, mParent );
layout->addWidget ( mi );
mItems.push_back(mi);
}
else if ( optionType == "flag" )
{
QgsGrassModuleFlag *flag = new QgsGrassModuleFlag (
- mModule, key, e, gDocElem, gnode, mParent );
+ mModule, key, e, gDocElem, gnode, mParent );
layout->addWidget ( flag );
mItems.push_back(flag);
@@ -854,11 +854,11 @@
int mapType;
switch ( item->type() ) {
case QgsGrassModuleInput::Raster :
- mapType = QgsGrass::Raster;
- break;
- case QgsGrassModuleInput::Vector :
- mapType = QgsGrass::Vector;
- break;
+ mapType = QgsGrass::Raster;
+ break;
+ case QgsGrassModuleInput::Vector :
+ mapType = QgsGrass::Vector;
+ break;
}
QStringList mm = item->currentMap().split("@");
@@ -972,7 +972,7 @@
int line, column;
if ( !qDoc.setContent( &qFile, &err, &line, &column ) ) {
QString errmsg = tr("Cannot read module file (") + path + tr("):\n") + err + tr("\nat line ")
- + QString::number(line) + tr(" column ") + QString::number(column);
+ + QString::number(line) + tr(" column ") + QString::number(column);
QgsDebugMsg(errmsg);
QMessageBox::warning( 0, tr("Warning"), errmsg );
qFile.close();
@@ -1146,8 +1146,8 @@
if ( outsideRegion.size() > 0 )
{
QMessageBox questionBox( QMessageBox::Question, "Warning",
- "Input " + outsideRegion.join(",") + " outside current region!",
- QMessageBox::Ok | QMessageBox::Cancel );
+ "Input " + outsideRegion.join(",") + " outside current region!",
+ QMessageBox::Ok | QMessageBox::Cancel );
QPushButton *resetButton = NULL;
if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMajor() == 6 && QgsGrass::versionMinor() >= 1 )
{
@@ -1163,7 +1163,7 @@
if ( !mOptions->inputRegion ( &tempWindow, true ) )
{
QMessageBox::warning ( 0, tr("Warning"),
- tr("Cannot get input region" ) );
+ tr("Cannot get input region" ) );
return;
}
}
@@ -1175,9 +1175,9 @@
if ( outputExists.size() > 0 )
{
QMessageBox::StandardButton ret = QMessageBox::question ( 0, "Warning",
- "Output " + outputExists.join(",")
- + " exists! Overwrite?",
- QMessageBox::Ok | QMessageBox::Cancel );
+ "Output " + outputExists.join(",")
+ + " exists! Overwrite?",
+ QMessageBox::Ok | QMessageBox::Cancel );
if ( ret == QMessageBox::Cancel ) return;
@@ -1220,12 +1220,12 @@
}
/* WARNING - TODO: there was a bug in GRASS 6.0.0 / 6.1.CVS (< 2005-04-29):
- * db_start_driver set GISRC_MODE_MEMORY eviroment variable to 1 if
- * G_get_gisrc_mode() == G_GISRC_MODE_MEMORY but the variable wasn't unset
- * if G_get_gisrc_mode() == G_GISRC_MODE_FILE. Because QGIS GRASS provider starts drivers in
- * G_GISRC_MODE_MEMORY mode, the variable remains set in variable when a module is run
- * -> unset GISRC_MODE_MEMORY. Remove later once 6.1.x / 6.0.1 is widespread.
- */
+ * db_start_driver set GISRC_MODE_MEMORY eviroment variable to 1 if
+ * G_get_gisrc_mode() == G_GISRC_MODE_MEMORY but the variable wasn't unset
+ * if G_get_gisrc_mode() == G_GISRC_MODE_FILE. Because QGIS GRASS provider starts drivers in
+ * G_GISRC_MODE_MEMORY mode, the variable remains set in variable when a module is run
+ * -> unset GISRC_MODE_MEMORY. Remove later once 6.1.x / 6.0.1 is widespread.
+ */
putenv ( "GISRC_MODE_MEMORY" ); // unset
mOutputTextBrowser->clear();
@@ -1265,7 +1265,7 @@
if ( execArguments.size() == 0 )
{
QMessageBox::warning( 0, tr("Warning"), tr("Cannot find module ")
- + mXName );
+ + mXName );
return;
}
@@ -1337,7 +1337,7 @@
if ( mProcess.state() != QProcess::Running )
{
QMessageBox::warning( 0, tr("Warning"), tr("Cannot start module: ")
- + mProcess.errorString() );
+ + mProcess.errorString() );
return;
}
@@ -1452,9 +1452,9 @@
QString map = mOutputVector.at(i);
QStringList layers = QgsGrassSelect::vectorLayers (
- QgsGrass::getDefaultGisdbase(),
- QgsGrass::getDefaultLocation(),
- QgsGrass::getDefaultMapset(), map );
+ QgsGrass::getDefaultGisdbase(),
+ QgsGrass::getDefaultLocation(),
+ QgsGrass::getDefaultMapset(), map );
// check whether there are 1_* layers
// if so, 0_* layers won't be added
@@ -2065,24 +2065,24 @@
QHBoxLayout *l = new QHBoxLayout (this);
mLayerComboBox = new QComboBox ();
mLayerComboBox->setSizePolicy (QSizePolicy::Expanding,
- QSizePolicy:: Preferred );
+ QSizePolicy:: Preferred );
l->addWidget ( mLayerComboBox );
QString region = qdesc.attribute("region");
if ( mType == Raster
- && QgsGrass::versionMajor() >= 6 && QgsGrass::versionMinor() >= 1
- && region != "no"
- )
+ && QgsGrass::versionMajor() >= 6 && QgsGrass::versionMinor() >= 1
+ && region != "no"
+ )
{
QString iconPath = QgsApplication::themePath() + "/grass/";
mRegionButton = new QPushButton(
- QIcon(iconPath+"grass_set_region.png"), "" );
+ QIcon(iconPath+"grass_set_region.png"), "" );
mRegionButton->setToolTip ( tr("Use region of this map") );
mRegionButton->setCheckable ( true );
mRegionButton->setSizePolicy (QSizePolicy::Minimum,
- QSizePolicy:: Preferred );
+ QSizePolicy:: Preferred );
l->addWidget ( mRegionButton );
}
@@ -2185,9 +2185,9 @@
int geomType = provider->geometryType();
if ( (geomType == QGis::WKBPoint && !(mVectorTypeMask & GV_POINT) ) ||
- (geomType == QGis::WKBLineString && !(mVectorTypeMask & GV_LINE) ) ||
- (geomType == QGis::WKBPolygon && !(mVectorTypeMask & GV_AREA) )
- )
+ (geomType == QGis::WKBLineString && !(mVectorTypeMask & GV_LINE) ) ||
+ (geomType == QGis::WKBPolygon && !(mVectorTypeMask & GV_AREA) )
+ )
{
continue;
}
@@ -2403,7 +2403,7 @@
void QgsGrassModuleInput::changed(int i)
{
- emit valueChanged();
+ emit valueChanged();
}
QString QgsGrassModuleInput::ready()
@@ -2567,7 +2567,7 @@
{
QgsVectorLayer *vector = (QgsVectorLayer*)layer;
if ( vector->providerType() != "ogr"
- && vector->providerType() != "postgres" ) continue;
+ && vector->providerType() != "postgres" ) continue;
QgsDataProvider *provider = vector->getDataProvider();
@@ -2650,10 +2650,10 @@
if ( mOgrLayers[current].length() > 0 )
{
QMessageBox::warning( 0, tr("Warning"),
- tr("PostGIS driver in OGR does not support schemas!<br>"
- "Only the table name will be used.<br>"
- "It can result in wrong input if more tables of the same name<br>"
- "are present in the database.") );
+ tr("PostGIS driver in OGR does not support schemas!<br>"
+ "Only the table name will be used.<br>"
+ "It can result in wrong input if more tables of the same name<br>"
+ "are present in the database.") );
}
}
#endif //GDAL_VERSION_NUM
@@ -2761,12 +2761,12 @@
QStringList QgsGrassModuleField::options()
{
- QStringList list;
+ QStringList list;
- QString opt(mKey + "=" + mFieldComboBox->currentText() );
- list.push_back( opt );
+ QString opt(mKey + "=" + mFieldComboBox->currentText() );
+ list.push_back( opt );
- return list;
+ return list;
}
QgsGrassModuleField::~QgsGrassModuleField()
@@ -2875,12 +2875,12 @@
QStringList QgsGrassModuleSelection::options()
{
- QStringList list;
+ QStringList list;
- QString opt(mKey + "=" + mLineEdit->text() );
- list.push_back( opt );
+ QString opt(mKey + "=" + mLineEdit->text() );
+ list.push_back( opt );
- return list;
+ return list;
}
QgsGrassModuleSelection::~QgsGrassModuleSelection()
@@ -2946,7 +2946,7 @@
l->addWidget ( mBrowseButton );
connect ( mBrowseButton, SIGNAL(clicked()),
- this, SLOT(browse()) );
+ this, SLOT(browse()) );
}
QStringList QgsGrassModuleFile::options()
@@ -2976,7 +2976,7 @@
void QgsGrassModuleFile::browse()
{
// TODO: unfortunately QFileDialog does not support 'new' directory
- QFileDialog *fd = new QFileDialog ( this, NULL, mLineEdit->text() );
+ QFileDialog *fd = new QFileDialog( this, NULL, mLineEdit->text());
fd->setDirectory ( QDir::current() );
Modified: trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrasstools.cpp 2008-03-17 22:01:26 UTC (rev 8240)
+++ trunk/qgis/src/plugins/grass/qgsgrasstools.cpp 2008-03-17 22:42:55 UTC (rev 8241)
@@ -72,370 +72,370 @@
#include "qgsgrassbrowser.h"
QgsGrassToolsTabWidget::QgsGrassToolsTabWidget( QWidget * parent ):
- QTabWidget(parent)
+ QTabWidget(parent)
{
- // Default height seems to be too small for our purpose
- int height = (int)(1.5 * tabBar()->iconSize().height());
- // Max width (see QgsGrassModule::pixmap for hardcoded sizes)
- int width = 3*height + 28 + 29;
- tabBar()->setIconSize( QSize(width,height) );
+ // Default height seems to be too small for our purpose
+ int height = (int)(1.5 * tabBar()->iconSize().height());
+ // Max width (see QgsGrassModule::pixmap for hardcoded sizes)
+ int width = 3*height + 28 + 29;
+ tabBar()->setIconSize( QSize(width,height) );
}
QSize QgsGrassToolsTabWidget::iconSize()
{
- return tabBar()->iconSize();
+ return tabBar()->iconSize();
}
QgsGrassToolsTabWidget::~QgsGrassToolsTabWidget() {}
QgsGrassTools::QgsGrassTools ( QgisInterface *iface,
QWidget * parent, const char * name, Qt::WFlags f )
- :QDialog ( parent )
+ : QDialog ( parent )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools()" << std::endl;
+#endif
- setWindowTitle ( tr("GRASS Tools") );
-// setupUi(this);
+ setWindowTitle ( tr("GRASS Tools") );
+ // setupUi(this);
- mIface = iface;
- mCanvas = mIface->getMapCanvas();
+ mIface = iface;
+ mCanvas = mIface->getMapCanvas();
- connect( qApp, SIGNAL(aboutToQuit()),
- this, SLOT(closeTools()) );
+ connect( qApp, SIGNAL(aboutToQuit()),
+ this, SLOT(closeTools()) );
- mTabWidget = new QgsGrassToolsTabWidget (this);
- QVBoxLayout *layout1 = new QVBoxLayout(this);
- layout1->addWidget(mTabWidget);
+ mTabWidget = new QgsGrassToolsTabWidget (this);
+ QVBoxLayout *layout1 = new QVBoxLayout(this);
+ layout1->addWidget(mTabWidget);
- mModulesListView = new QTreeWidget();
- mTabWidget->addTab( mModulesListView, tr("Modules") );
- mModulesListView->setColumnCount(1);
- QStringList headers;
- headers << tr("Modules");
- mModulesListView->setHeaderLabels(headers);
- // Set list view
- mModulesListView->clear();
- mModulesListView->setSortingEnabled(false);
- mModulesListView->setRootIsDecorated(true);
-// mModulesListView->setResizeMode(QTreeWidget::AllColumns);
- mModulesListView->header()->hide();
+ mModulesListView = new QTreeWidget();
+ mTabWidget->addTab( mModulesListView, tr("Modules") );
+ mModulesListView->setColumnCount(1);
+ QStringList headers;
+ headers << tr("Modules");
+ mModulesListView->setHeaderLabels(headers);
+ // Set list view
+ mModulesListView->clear();
+ mModulesListView->setSortingEnabled(false);
+ mModulesListView->setRootIsDecorated(true);
+ // mModulesListView->setResizeMode(QTreeWidget::AllColumns);
+ mModulesListView->header()->hide();
- connect( mModulesListView, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
- this, SLOT(moduleClicked( QTreeWidgetItem *, int)) );
+ connect( mModulesListView, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
+ this, SLOT(moduleClicked( QTreeWidgetItem *, int)) );
- QString title = tr("GRASS Tools: ") + QgsGrass::getDefaultLocation()
- + "/" + QgsGrass::getDefaultMapset();
- setCaption(title);
+ QString title = tr("GRASS Tools: ") + QgsGrass::getDefaultLocation()
+ + "/" + QgsGrass::getDefaultMapset();
+ setCaption(title);
- QString conf = QgsApplication::pkgDataPath() + "/grass/config/default.qgc";
+ QString conf = QgsApplication::pkgDataPath() + "/grass/config/default.qgc";
- restorePosition();
+ restorePosition();
- // Show before loadConfig() so that user can see loading
- mModulesListView->show();
+ // Show before loadConfig() so that user can see loading
+ mModulesListView->show();
- QApplication::setOverrideCursor(Qt::waitCursor);
- loadConfig ( conf );
- QApplication::restoreOverrideCursor();
- //statusBar()->hide();
+ QApplication::setOverrideCursor(Qt::waitCursor);
+ loadConfig ( conf );
+ QApplication::restoreOverrideCursor();
+ //statusBar()->hide();
- // Add map browser
- // Warning: if browser is on the first page modules are
- // displayed over the browser
- mBrowser = new QgsGrassBrowser ( mIface, this );
- mTabWidget->addTab( mBrowser, tr("Browser") );
+ // Add map browser
+ // Warning: if browser is on the first page modules are
+ // displayed over the browser
+ mBrowser = new QgsGrassBrowser ( mIface, this );
+ mTabWidget->addTab( mBrowser, tr("Browser") );
- connect( mBrowser, SIGNAL(regionChanged()),
- this, SLOT(emitRegionChanged()) );
+ connect( mBrowser, SIGNAL(regionChanged()),
+ this, SLOT(emitRegionChanged()) );
}
void QgsGrassTools::moduleClicked( QTreeWidgetItem * item, int column )
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::moduleClicked()" << std::endl;
- #endif
- if ( !item ) return;
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::moduleClicked()" << std::endl;
+#endif
+ if ( !item ) return;
- QString name = item->text(1);
+ QString name = item->text(1);
#ifdef QGISDEBUG
- std::cerr << "name = " << name.ascii() << std::endl;
+ std::cerr << "name = " << name.ascii() << std::endl;
#endif
-
- if ( name.length() == 0 ) return; // Section
-
+
+ if ( name.length() == 0 ) return; // Section
+
#ifndef WIN32
- QgsGrassShell* sh = 0;
+ QgsGrassShell* sh = 0;
#endif
-
- QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
- #ifdef QGISDEBUG
- std::cerr << "path = " << path.ascii() << std::endl;
- #endif
- QWidget *m;
- if ( name == "shell" )
- {
- // Set history file
- QString mapsetPath = QgsGrass::getDefaultGisdbase() + "/"
- + QgsGrass::getDefaultLocation() + "/"
- + QgsGrass::getDefaultMapset();
- // bash
- QString hist = "HISTFILE=" + mapsetPath + "/.bash_history";
- char *histChar = new char[hist.length()+1];
- strcpy ( histChar, const_cast<char *>(hist.ascii()) );
- putenv( histChar );
+ QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
+#ifdef QGISDEBUG
+ std::cerr << "path = " << path.ascii() << std::endl;
+#endif
+ QWidget *m;
+ if ( name == "shell" )
+ {
+ // Set history file
+ QString mapsetPath = QgsGrass::getDefaultGisdbase() + "/"
+ + QgsGrass::getDefaultLocation() + "/"
+ + QgsGrass::getDefaultMapset();
- // csh/tcsh
+ // bash
+ QString hist = "HISTFILE=" + mapsetPath + "/.bash_history";
+ char *histChar = new char[hist.length()+1];
+ strcpy ( histChar, const_cast<char *>(hist.ascii()) );
+ putenv( histChar );
+
+ // csh/tcsh
#ifndef WIN32
- hist = "histfile=" + mapsetPath + "/.history";
- histChar = new char[hist.length()+1];
- strcpy ( histChar, const_cast<char *>(hist.ascii()) );
- putenv( histChar );
+ hist = "histfile=" + mapsetPath + "/.history";
+ histChar = new char[hist.length()+1];
+ strcpy ( histChar, const_cast<char *>(hist.ascii()) );
+ putenv( histChar );
#endif
#ifdef WIN32
- // Run MSYS if available
- // Note: I was not able to run cmd.exe and command.com
- // with QProcess
+ // Run MSYS if available
+ // Note: I was not able to run cmd.exe and command.com
+ // with QProcess
- QString msysPath = appDir() + "/msys/bin/rxvt.exe";
- QString myArguments = "-backspacekey ^H -sl 2500 -fg white -bg black -sr -fn Courier-16 -tn msys -geometry 80x25 -e /bin/sh --login -i";
- QFile file ( msysPath );
+ QString msysPath = appDir() + "/msys/bin/rxvt.exe";
+ QString myArguments = "-backspacekey ^H -sl 2500 -fg white -bg black -sr -fn Courier-16 -tn msys -geometry 80x25 -e /bin/sh --login -i";
+ QFile file ( msysPath );
- if ( !file.exists() )
- {
- QMessageBox::warning( 0, tr("Warning"),
- tr("Cannot find MSYS (") + msysPath + ")" );
- }
- else
- {
- QProcess *proc = new QProcess(this);
- //allow msys to exist in a path with spaces
- msysPath = "\"" + msysPath + "\"" ;
- proc->start(msysPath + " " + myArguments);
- proc->waitForStarted();
- if ( proc->state() != QProcess::Running )
- {
- QMessageBox::warning( 0, "Warning",
- "Cannot start MSYS (" + msysPath + ")" );
- }
- }
- return;
+ if ( !file.exists() )
+ {
+ QMessageBox::warning( 0, tr("Warning"),
+ tr("Cannot find MSYS (") + msysPath + ")" );
+ }
+ else
+ {
+ QProcess *proc = new QProcess(this);
+ //allow msys to exist in a path with spaces
+ msysPath = "\"" + msysPath + "\"" ;
+ proc->start(msysPath + " " + myArguments);
+ proc->waitForStarted();
+ if ( proc->state() != QProcess::Running )
+ {
+ QMessageBox::warning( 0, "Warning",
+ "Cannot start MSYS (" + msysPath + ")" );
+ }
+ }
+ return;
#else
- #ifdef HAVE_OPENPTY
- sh = new QgsGrassShell(this, mTabWidget);
- m = dynamic_cast<QWidget *> ( sh );
- #else
- QMessageBox::warning( 0, tr("Warning"), tr("GRASS Shell is not compiled.") );
- #endif // HAVE_OPENPTY
+#ifdef HAVE_OPENPTY
+ sh = new QgsGrassShell(this, mTabWidget);
+ m = dynamic_cast<QWidget *> ( sh );
+#else
+ QMessageBox::warning( 0, tr("Warning"), tr("GRASS Shell is not compiled.") );
+#endif // HAVE_OPENPTY
#endif // ! WIN32
- }
- else
- {
- m = dynamic_cast<QWidget *> ( new QgsGrassModule ( this, name,
- mIface, path, mTabWidget ) );
- }
-
- int height = mTabWidget->iconSize().height();
- QPixmap pixmap = QgsGrassModule::pixmap ( path, height );
-
- // Icon size in QT4 does not seem to be variable
- // -> put smaller icons in the middle
- QPixmap pixmap2 ( mTabWidget->iconSize() );
- QPalette pal;
- pixmap2.fill ( pal.color(QPalette::Window) );
- QPainter painter(&pixmap2);
- int x = (int) ( (mTabWidget->iconSize().width()-pixmap.width())/2 );
- painter.drawPixmap ( x, 0, pixmap );
- painter.end();
+ }
+ else
+ {
+ m = dynamic_cast<QWidget *> ( new QgsGrassModule ( this, name,
+ mIface, path, mTabWidget ) );
+ }
- QIcon is;
- is.addPixmap ( pixmap2 );
- mTabWidget->addTab ( m, is, "" );
+ int height = mTabWidget->iconSize().height();
+ QPixmap pixmap = QgsGrassModule::pixmap ( path, height );
- QgsGrassToolsTabWidget tw;
-
- mTabWidget->setCurrentPage ( mTabWidget->count()-1 );
-
- // We must call resize to reset COLUMNS enviroment variable
- // used by bash !!!
+ // Icon size in QT4 does not seem to be variable
+ // -> put smaller icons in the middle
+ QPixmap pixmap2 ( mTabWidget->iconSize() );
+ QPalette pal;
+ pixmap2.fill ( pal.color(QPalette::Window) );
+ QPainter painter(&pixmap2);
+ int x = (int) ( (mTabWidget->iconSize().width()-pixmap.width())/2 );
+ painter.drawPixmap ( x, 0, pixmap );
+ painter.end();
+
+ QIcon is;
+ is.addPixmap ( pixmap2 );
+ mTabWidget->addTab ( m, is, "" );
+
+ QgsGrassToolsTabWidget tw;
+
+ mTabWidget->setCurrentPage ( mTabWidget->count()-1 );
+
+ // We must call resize to reset COLUMNS enviroment variable
+ // used by bash !!!
#ifndef WIN32
- if ( sh ) sh->resizeTerminal();
+ if ( sh ) sh->resizeTerminal();
#endif
}
bool QgsGrassTools::loadConfig(QString filePath)
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::loadConfig(): " << filePath.toLocal8Bit().data() << std::endl;
- #endif
- mModulesListView->clear();
- mModulesListView->setIconSize(QSize(80,22));
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::loadConfig(): " << filePath.toLocal8Bit().data() << std::endl;
+#endif
+ mModulesListView->clear();
+ mModulesListView->setIconSize(QSize(80,22));
- QFile file ( filePath );
+ QFile file ( filePath );
- if ( !file.exists() ) {
- QMessageBox::warning( 0, tr("Warning"), tr("The config file (") + filePath + tr(") not found.") );
- return false;
- }
- if ( ! file.open( QIODevice::ReadOnly ) ) {
- QMessageBox::warning( 0, tr("Warning"), tr("Cannot open config file (") + filePath + tr(")") );
- return false;
- }
-
- QDomDocument doc ( "qgisgrass" );
- QString err;
- int line, column;
- if ( !doc.setContent( &file, &err, &line, &column ) ) {
- QString errmsg = tr("Cannot read config file (") + filePath + "):\n" + err + tr("\nat line ")
- + QString::number(line) + tr(" column ") + QString::number(column);
- std::cerr << errmsg.toLocal8Bit().data() << std::endl;
- QMessageBox::warning( 0, tr("Warning"), errmsg );
- file.close();
- return false;
- }
+ if ( !file.exists() ) {
+ QMessageBox::warning( 0, tr("Warning"), tr("The config file (") + filePath + tr(") not found.") );
+ return false;
+ }
+ if ( ! file.open( QIODevice::ReadOnly ) ) {
+ QMessageBox::warning( 0, tr("Warning"), tr("Cannot open config file (") + filePath + tr(")") );
+ return false;
+ }
- QDomElement docElem = doc.documentElement();
- QDomNodeList modulesNodes = docElem.elementsByTagName ( "modules" );
+ QDomDocument doc ( "qgisgrass" );
+ QString err;
+ int line, column;
+ if ( !doc.setContent( &file, &err, &line, &column ) ) {
+ QString errmsg = tr("Cannot read config file (") + filePath + "):\n" + err + tr("\nat line ")
+ + QString::number(line) + tr(" column ") + QString::number(column);
+ std::cerr << errmsg.toLocal8Bit().data() << std::endl;
+ QMessageBox::warning( 0, tr("Warning"), errmsg );
+ file.close();
+ return false;
+ }
- if ( modulesNodes.count() == 0 ) {
- file.close();
- return false;
- }
+ QDomElement docElem = doc.documentElement();
+ QDomNodeList modulesNodes = docElem.elementsByTagName ( "modules" );
- QDomNode modulesNode = modulesNodes.item(0);
- QDomElement modulesElem = modulesNode.toElement();
-
- // Go through the sections and modules and add them to the list view
- addModules ( 0, modulesElem );
-
+ if ( modulesNodes.count() == 0 ) {
file.close();
- return true;
+ return false;
+ }
+
+ QDomNode modulesNode = modulesNodes.item(0);
+ QDomElement modulesElem = modulesNode.toElement();
+
+ // Go through the sections and modules and add them to the list view
+ addModules ( 0, modulesElem );
+
+ file.close();
+ return true;
}
void QgsGrassTools::addModules ( QTreeWidgetItem *parent, QDomElement &element )
{
- QDomNode n = element.firstChild();
+ QDomNode n = element.firstChild();
- QTreeWidgetItem *item;
- QTreeWidgetItem *lastItem = 0;
- while( !n.isNull() ) {
- QDomElement e = n.toElement();
- if( !e.isNull() ) {
- //std::cout << "tag = " << e.tagName() << std::endl;
+ QTreeWidgetItem *item;
+ QTreeWidgetItem *lastItem = 0;
+ while( !n.isNull() ) {
+ QDomElement e = n.toElement();
+ if( !e.isNull() ) {
+ //std::cout << "tag = " << e.tagName() << std::endl;
- if ( e.tagName() == "section" && e.tagName() == "grass" ) {
- std::cout << "Unknown tag: " << e.tagName().toLocal8Bit().data() << std::endl;
- continue;
- }
-
- if ( parent ) {
- item = new QTreeWidgetItem( parent, lastItem );
- } else {
- item = new QTreeWidgetItem( mModulesListView, lastItem );
- }
+ if ( e.tagName() == "section" && e.tagName() == "grass" ) {
+ std::cout << "Unknown tag: " << e.tagName().toLocal8Bit().data() << std::endl;
+ continue;
+ }
- if ( e.tagName() == "section" ) {
- QString label = e.attribute("label");
- std::cout << "label = " << label.toLocal8Bit().data() << std::endl;
- item->setText( 0, label );
- item->setExpanded(true); // for debuging to spare one click
+ if ( parent ) {
+ item = new QTreeWidgetItem( parent, lastItem );
+ } else {
+ item = new QTreeWidgetItem( mModulesListView, lastItem );
+ }
- addModules ( item, e );
-
- lastItem = item;
- } else if ( e.tagName() == "grass" ) { // GRASS module
- QString name = e.attribute("name");
- std::cout << "name = " << name.toLocal8Bit().data() << std::endl;
+ if ( e.tagName() == "section" ) {
+ QString label = e.attribute("label");
+ std::cout << "label = " << label.toLocal8Bit().data() << std::endl;
+ item->setText( 0, label );
+ item->setExpanded(true); // for debuging to spare one click
- QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
- QString label = QgsGrassModule::label ( path );
- QPixmap pixmap = QgsGrassModule::pixmap ( path, 25 );
+ addModules ( item, e );
- item->setText( 0, label );
- item->setIcon( 0, QIcon(pixmap) );
- item->setText( 1, name );
- lastItem = item;
- }
- }
- n = n.nextSibling();
+ lastItem = item;
+ } else if ( e.tagName() == "grass" ) { // GRASS module
+ QString name = e.attribute("name");
+ std::cout << "name = " << name.toLocal8Bit().data() << std::endl;
+
+ QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
+ QString label = QgsGrassModule::label ( path );
+ QPixmap pixmap = QgsGrassModule::pixmap ( path, 25 );
+
+ item->setText( 0, label );
+ item->setIcon( 0, QIcon(pixmap) );
+ item->setText( 1, name );
+ lastItem = item;
+ }
}
+ n = n.nextSibling();
+ }
}
void QgsGrassTools::mapsetChanged()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::mapsetChanged()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::mapsetChanged()" << std::endl;
+#endif
- QString title = tr("GRASS Tools: ") + QgsGrass::getDefaultLocation()
- + "/" + QgsGrass::getDefaultMapset();
- setCaption(title);
+ QString title = tr("GRASS Tools: ") + QgsGrass::getDefaultLocation()
+ + "/" + QgsGrass::getDefaultMapset();
+ setCaption(title);
- closeTools();
- mBrowser->setLocation( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() );
+ closeTools();
+ mBrowser->setLocation( QgsGrass::getDefaultGisdbase(), QgsGrass::getDefaultLocation() );
}
QgsGrassTools::~QgsGrassTools()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::~QgsGrassTools()" << std::endl;
- #endif
- saveWindowLocation();
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::~QgsGrassTools()" << std::endl;
+#endif
+ saveWindowLocation();
}
QString QgsGrassTools::appDir(void)
{
- return QgsApplication::applicationDirPath();
+ return QgsApplication::applicationDirPath();
}
void QgsGrassTools::close(void)
{
- saveWindowLocation();
- hide();
+ saveWindowLocation();
+ hide();
}
void QgsGrassTools::closeEvent(QCloseEvent *e)
{
- saveWindowLocation();
- e->accept();
+ saveWindowLocation();
+ e->accept();
}
void QgsGrassTools::restorePosition()
{
- QSettings settings;
- restoreGeometry(settings.value("/GRASS/windows/tools/geometry").toByteArray());
- show();
+ QSettings settings;
+ restoreGeometry(settings.value("/GRASS/windows/tools/geometry").toByteArray());
+ show();
}
void QgsGrassTools::saveWindowLocation()
{
- QSettings settings;
- settings.setValue("/GRASS/windows/tools/geometry", saveGeometry());
+ QSettings settings;
+ settings.setValue("/GRASS/windows/tools/geometry", saveGeometry());
}
void QgsGrassTools::emitRegionChanged()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::emitRegionChanged()" << std::endl;
- #endif
- emit regionChanged();
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::emitRegionChanged()" << std::endl;
+#endif
+ emit regionChanged();
}
void QgsGrassTools::closeTools()
{
- #ifdef QGISDEBUG
- std::cerr << "QgsGrassTools::closeTools()" << std::endl;
- #endif
+#ifdef QGISDEBUG
+ std::cerr << "QgsGrassTools::closeTools()" << std::endl;
+#endif
- for ( int i = mTabWidget->count()-1; i > 1; i-- )
- {
- delete mTabWidget->widget(i);
- mTabWidget->removeTab(i);
- }
+ for ( int i = mTabWidget->count()-1; i > 1; i-- )
+ {
+ delete mTabWidget->widget(i);
+ mTabWidget->removeTab(i);
+ }
}
More information about the QGIS-commit
mailing list