Skip to content

Commit f4a9d81

Browse files
author
rblazek
committedFeb 10, 2006
usability fixes
git-svn-id: http://svn.osgeo.org/qgis/trunk@4815 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 57206fa commit f4a9d81

File tree

5 files changed

+1331
-221
lines changed

5 files changed

+1331
-221
lines changed
 

‎src/plugins/grass/qgsgrassnewmapset.cpp

Lines changed: 85 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ QgsGrassNewMapset::QgsGrassNewMapset ( QgisApp *qgisApp, QgisIface *iface,
101101
setHelpEnabled ( page(MAPSET), false );
102102
setHelpEnabled ( page(FINISH), false );
103103

104+
setTitle ( page(DATABASE), "GRASS database" );
105+
setTitle ( page(LOCATION), "GRASS location" );
106+
setTitle ( page(PROJECTION), "Projection" );
107+
setTitle ( page(REGION), "Default GRASS Region" );
108+
setTitle ( page(MAPSET), "Mapset" );
109+
setTitle ( page(FINISH), "Create New Mapset" );
110+
104111
setError ( mDatabaseErrorLabel, "" );
105112
setError ( mLocationErrorLabel, "" );
106113
setError ( mProjErrorLabel, "" );
@@ -134,18 +141,18 @@ QgsGrassNewMapset::QgsGrassNewMapset ( QgisApp *qgisApp, QgisIface *iface,
134141
dbi->setOpen(true);
135142

136143
// First inserted is last in the view
137-
Q3ListViewItem *l = new Q3ListViewItem( dbi, "New Zealand", "Location 1" );
144+
Q3ListViewItem *l = new Q3ListViewItem( dbi, "New Zealand", "Location 2" );
138145
l->setOpen(true);
139-
Q3ListViewItem *m = new Q3ListViewItem( l, "Klima", "User's mapset");
146+
Q3ListViewItem *m = new Q3ListViewItem( l, "Cimrman", "User's mapset");
140147
m->setOpen(true);
141148
m = new Q3ListViewItem( l, "PERMANENT", "System mapset" );
142149
m->setOpen(true);
143150

144-
l = new Q3ListViewItem( dbi, "Mexico", "Location 2" );
151+
l = new Q3ListViewItem( dbi, "Mexico", "Location 1" );
145152
m->setOpen(true);
146-
m = new Q3ListViewItem( l, "Jirovec", "User's mapset");
153+
m = new Q3ListViewItem( l, "Juan", "User's mapset");
147154
l->setOpen(true);
148-
m = new Q3ListViewItem( l, "Cimrman", "User's mapset");
155+
m = new Q3ListViewItem( l, "Alejandra", "User's mapset");
149156
m->setOpen(true);
150157
m = new Q3ListViewItem( l, "PERMANENT", "System mapset" );
151158
m->setOpen(true);
@@ -197,48 +204,52 @@ void QgsGrassNewMapset::databaseChanged()
197204
QSettings settings("QuantumGIS", "qgis");
198205
settings.writeEntry("/GRASS/lastGisdbase", mDatabaseLineEdit->text() );
199206

207+
setNextEnabled ( page(DATABASE), false );
200208
setError ( mDatabaseErrorLabel, "" );
209+
210+
QString database = mDatabaseLineEdit->text().trimmed();
211+
212+
if ( database.length() == 0 )
213+
{
214+
setError ( mDatabaseErrorLabel, "Enter path to GRASS database");
215+
return;
216+
}
217+
201218
QFileInfo databaseInfo ( mDatabaseLineEdit->text() );
202219

203-
if ( databaseInfo.exists() )
204-
{
205-
// Check if at least one writable location exists or
206-
// database is writable
207-
bool locationExists = false;
208-
QDir d ( mDatabaseLineEdit->text() );
209-
for ( int i = 0; i < d.count(); i++ )
210-
{
211-
if ( d[i] == "." || d[i] == ".." ) continue;
220+
if ( !databaseInfo.exists() )
221+
{
222+
setError ( mDatabaseErrorLabel, "The directory doesn't exist!");
223+
return;
224+
}
212225

213-
QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
214-
QString locationName = mDatabaseLineEdit->text() + "/" + d[i];
215-
QFileInfo locationInfo ( locationName );
226+
// Check if at least one writable location exists or
227+
// database is writable
228+
bool locationExists = false;
229+
QDir d ( mDatabaseLineEdit->text() );
230+
for ( int i = 0; i < d.count(); i++ )
231+
{
232+
if ( d[i] == "." || d[i] == ".." ) continue;
216233

217-
if ( QFile::exists ( windName ) && locationInfo.isWritable () )
218-
{
219-
locationExists = true;
220-
break;
221-
}
222-
}
234+
QString windName = mDatabaseLineEdit->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
235+
QString locationName = mDatabaseLineEdit->text() + "/" + d[i];
236+
QFileInfo locationInfo ( locationName );
223237

224-
if ( locationExists || databaseInfo.isWritable() )
225-
{
226-
setNextEnabled ( page(DATABASE), true );
227-
}
228-
else
238+
if ( QFile::exists ( windName ) && locationInfo.isWritable () )
229239
{
230-
setNextEnabled ( page(DATABASE), false );
231-
setError ( mDatabaseErrorLabel, "No writable "
232-
"locations, the database not writable!");
240+
locationExists = true;
241+
break;
233242
}
234243
}
244+
245+
if ( locationExists || databaseInfo.isWritable() )
246+
{
247+
setNextEnabled ( page(DATABASE), true );
248+
}
235249
else
236250
{
237-
setNextEnabled ( page(DATABASE), false );
238-
if ( mDatabaseLineEdit->text().stripWhiteSpace().length() > 0 )
239-
{
240-
setError ( mDatabaseErrorLabel, "The directory doesn't exist!");
241-
}
251+
setError ( mDatabaseErrorLabel, "No writable "
252+
"locations, the database not writable!");
242253
}
243254
}
244255

@@ -331,14 +342,17 @@ void QgsGrassNewMapset::checkLocation()
331342
{
332343
// TODO?: Check spaces in the name
333344

334-
QString location = mLocationLineEdit->text().stripWhiteSpace();
345+
QString location = mLocationLineEdit->text().trimmed();
335346

336-
if ( location.length() > 0 )
347+
if ( location.length() == 0 )
337348
{
349+
setNextEnabled ( page(LOCATION), false );
350+
setError ( mLocationErrorLabel, "Enter location name!");
351+
}
352+
else
353+
{
338354
QDir d ( mDatabaseLineEdit->text() );
339355

340-
setNextEnabled ( page(LOCATION), true );
341-
342356
for ( int i = 0; i < d.count(); i++ )
343357
{
344358
if ( d[i] == "." || d[i] == ".." ) continue;
@@ -350,11 +364,7 @@ void QgsGrassNewMapset::checkLocation()
350364
break;
351365
}
352366
}
353-
}
354-
else
355-
{
356-
setNextEnabled ( page(LOCATION), false );
357-
}
367+
}
358368
}
359369
}
360370

@@ -381,6 +391,7 @@ void QgsGrassNewMapset::setProjectionPage()
381391
#ifdef QGISDEBUG
382392
std::cerr << "QgsGrassNewMapset::setProjectionPage()" << std::endl;
383393
#endif
394+
setGrassProjection();
384395
}
385396

386397
void QgsGrassNewMapset::sridSelected(QString theSRID)
@@ -618,13 +629,15 @@ void QgsGrassNewMapset::setRegionPage()
618629
mCurrentRegionButton->hide();
619630
mRegionsComboBox->hide();
620631
mRegionButton->hide();
632+
mSetRegionFrame->hide();
621633
}
622634
else
623635
{
624636
mRegionMap->show();
625637
mCurrentRegionButton->show();
626638
mRegionsComboBox->show();
627639
mRegionButton->show();
640+
mSetRegionFrame->show();
628641

629642
QgsRect ext = mQgisApp->getMapCanvas()->extent();
630643

@@ -635,7 +648,11 @@ void QgsGrassNewMapset::setRegionPage()
635648
}
636649

637650
checkRegion();
638-
drawRegion();
651+
652+
if ( !mNoProjRadioButton->isChecked() )
653+
{
654+
drawRegion();
655+
}
639656
}
640657

641658
void QgsGrassNewMapset::setGrassRegionDefaults()
@@ -1254,43 +1271,42 @@ void QgsGrassNewMapset::mapsetChanged()
12541271
setNextEnabled ( page(MAPSET), false );
12551272
setError ( mMapsetErrorLabel, "");
12561273

1257-
QString mapset = mMapsetLineEdit->text().stripWhiteSpace();
1274+
QString mapset = mMapsetLineEdit->text().trimmed();
12581275

12591276
// TODO?: Check spaces in the name
1260-
if ( mapset.length() > 0 )
1277+
if ( mapset.length() == 0 )
12611278
{
1262-
// Check if exists
1263-
if ( mSelectLocationRadioButton->isChecked() )
1264-
{
1265-
bool exists = false;
1266-
QString locationPath = mDatabaseLineEdit->text() + "/" + mLocationComboBox->currentText();
1267-
QDir d ( locationPath );
1279+
setError ( mMapsetErrorLabel, "Enter mapset name.");
1280+
return;
1281+
}
12681282

1269-
for ( int i = 0; i < d.count(); i++ )
1270-
{
1271-
if ( d[i] == "." || d[i] == ".." ) continue;
1283+
// Check if exists
1284+
if ( mSelectLocationRadioButton->isChecked() )
1285+
{
1286+
bool exists = false;
1287+
QString locationPath = mDatabaseLineEdit->text() + "/" + mLocationComboBox->currentText();
1288+
QDir d ( locationPath );
12721289

1273-
if ( d[i] == mapset )
1274-
{
1275-
setError ( mMapsetErrorLabel, "The mapset already exists");
1276-
exists = true;
1277-
break;
1278-
}
1279-
}
1290+
for ( int i = 0; i < d.count(); i++ )
1291+
{
1292+
if ( d[i] == "." || d[i] == ".." ) continue;
12801293

1281-
if ( !exists )
1294+
if ( d[i] == mapset )
12821295
{
1283-
setNextEnabled ( page(MAPSET), true );
1296+
setError ( mMapsetErrorLabel, "The mapset already exists");
1297+
exists = true;
1298+
break;
12841299
}
12851300
}
1286-
else
1301+
1302+
if ( !exists )
12871303
{
1288-
setNextEnabled ( page(MAPSET), true );
1304+
setNextEnabled ( page(MAPSET), true );
12891305
}
12901306
}
12911307
else
12921308
{
1293-
setNextEnabled ( page(MAPSET), false );
1309+
setNextEnabled ( page(MAPSET), true );
12941310
}
12951311
}
12961312

‎src/plugins/grass/qgsgrassnewmapset.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public slots:
8585

8686
//! Database changed
8787
void on_mDatabaseLineEdit_returnPressed() { databaseChanged(); }
88+
void on_mDatabaseLineEdit_textChanged() { databaseChanged(); }
8889
void databaseChanged();
8990

9091
/***************** LOCATION *****************/
@@ -106,6 +107,7 @@ public slots:
106107

107108
//! New location name has changed
108109
void on_mLocationLineEdit_returnPressed() { newLocationChanged(); }
110+
void on_mLocationLineEdit_textChanged() { newLocationChanged(); }
109111
void newLocationChanged();
110112

111113
//! Check location
@@ -137,9 +139,13 @@ public slots:
137139

138140
//! Region Changed
139141
void on_mNorthLineEdit_returnPressed() { regionChanged(); }
142+
void on_mNorthLineEdit_textChanged() { regionChanged(); }
140143
void on_mSouthLineEdit_returnPressed() { regionChanged(); }
144+
void on_mSouthLineEdit_textChanged() { regionChanged(); }
141145
void on_mEastLineEdit_returnPressed() { regionChanged(); }
146+
void on_mEastLineEdit_textChanged() { regionChanged(); }
142147
void on_mWestLineEdit_returnPressed() { regionChanged(); }
148+
void on_mWestLineEdit_textChanged() { regionChanged(); }
143149
void regionChanged();
144150

145151
//! Set current QGIS region
@@ -160,6 +166,7 @@ public slots:
160166

161167
//! Mapset name changed
162168
void on_mMapsetLineEdit_returnPressed() { mapsetChanged(); }
169+
void on_mMapsetLineEdit_textChanged() { mapsetChanged(); }
163170
void mapsetChanged();
164171

165172
/******************** FINISH ******************/

‎src/plugins/grass/qgsgrassnewmapsetbase.ui

Lines changed: 1229 additions & 144 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassplugin.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void QgsGrassPlugin::initGui()
129129
{
130130
toolBarPointer = 0;
131131
mTools = 0;
132+
mNewMapset = 0;
132133

133134
QSettings settings("QuantumGIS", "qgis");
134135

@@ -678,16 +679,14 @@ void QgsGrassPlugin::closeMapset()
678679

679680
void QgsGrassPlugin::newMapset()
680681
{
681-
if ( QgsGrassNewMapset::isRunning() )
682+
if ( !QgsGrassNewMapset::isRunning() )
682683
{
683-
QMessageBox::warning( 0, "Warning",
684-
"New GRASS Mapset wizard is already running." );
685-
return;
684+
mNewMapset = new QgsGrassNewMapset (
685+
qgisMainWindowPointer, qGisInterface,
686+
this, qgisMainWindowPointer );
686687
}
687-
688-
QgsGrassNewMapset *nm = new QgsGrassNewMapset (
689-
qgisMainWindowPointer, qGisInterface, this, qgisMainWindowPointer );
690-
nm->show();
688+
mNewMapset->show();
689+
mNewMapset->raise();
691690
}
692691

693692
// Unload the plugin by cleaning up the GUI

‎src/plugins/grass/qgsgrassplugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <vector>
2626

2727
class QgsGrassTools;
28+
class QgsGrassNewMapset;
2829
class QToolBar;
2930
/**
3031
* \class QgsGrassPlugin
@@ -126,6 +127,8 @@ public slots:
126127
QPen mRegionPen;
127128
//! GRASS tools
128129
QgsGrassTools *mTools;
130+
//! Pointer to QgsGrassNewMapset
131+
QgsGrassNewMapset *mNewMapset;
129132

130133
// Actions
131134
QAction *mOpenMapsetAction;

0 commit comments

Comments
 (0)
Please sign in to comment.