Skip to content

Commit 952407b

Browse files
author
jef
committedMar 17, 2008
reindentation of GRASS plugin and provider
git-svn-id: http://svn.osgeo.org/qgis/trunk@8240 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent fe44a23 commit 952407b

13 files changed

+7362
-7322
lines changed
 

‎src/plugins/grass/qgsgrassedit.cpp

Lines changed: 278 additions & 237 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassedittools.cpp

Lines changed: 98 additions & 100 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassmapcalc.cpp

Lines changed: 1625 additions & 1628 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassmodel.cpp

Lines changed: 709 additions & 710 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassnewmapset.cpp

Lines changed: 1148 additions & 1152 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassplugin.cpp

Lines changed: 215 additions & 217 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassregion.cpp

Lines changed: 310 additions & 313 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassselect.cpp

Lines changed: 367 additions & 368 deletions
Large diffs are not rendered by default.

‎src/plugins/grass/qgsgrassshell.cpp

Lines changed: 138 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
9090

9191
#ifdef WIN32
9292
QMessageBox::warning( 0, "Warning",
93-
"GRASS Shell is not supported on Windows." );
93+
"GRASS Shell is not supported on Windows." );
9494
return;
9595
#else
9696

@@ -100,7 +100,7 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
100100
mText = new QgsGrassShellText( this, mTextFrame);
101101
layout->addWidget ( mText, 0 , 0 );
102102
mText->show();
103-
103+
104104
connect(mCloseButton, SIGNAL(clicked()), this, SLOT(closeShell()));
105105

106106
mFont = QFont ( "Courier", 10 );
@@ -197,7 +197,7 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
197197
if ( fd < 0 )
198198
{
199199
QMessageBox::warning( 0, "Warning", "Cannot open slave file "
200-
"in child process" );
200+
"in child process" );
201201
return;
202202
}
203203

@@ -252,11 +252,11 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
252252
//execle ( (char*)shell.ascii(), (char *)si.fileName().ascii(),
253253
// norc, (char *) 0, envar);
254254
execl ( (char*)shell.ascii(), (char *)si.fileName().ascii(),
255-
norc, (char *) 0);
255+
norc, (char *) 0);
256256

257257
// Failed (QMessageBox here does not work)
258258
fprintf ( stderr, "GRASS_INFO_ERROR(1,1): Cannot start shell %s\n",
259-
(char*)shell.ascii() );
259+
(char*)shell.ascii() );
260260
exit(1);
261261
}
262262

@@ -266,7 +266,7 @@ QDialog(parent), QgsGrassShellBase(), mTools(tools)
266266
mOutNotifier = new QSocketNotifier ( mFdMaster, QSocketNotifier::Read, this);
267267

268268
QObject::connect ( mOutNotifier, SIGNAL(activated(int)),
269-
this, SLOT(readStdout(int)));
269+
this, SLOT(readStdout(int)));
270270

271271
// Set tab stops ???
272272
mTabStop.resize(200);
@@ -295,20 +295,20 @@ QgsGrassShell::~QgsGrassShell()
295295
#ifndef WIN32
296296
// This was old trick to write history
297297
/*
298-
write( mFdMaster, "exit\015\012", 6);
299-
while ( 1 )
300-
{
301-
readStdout(0);
298+
write( mFdMaster, "exit\015\012", 6);
299+
while ( 1 )
300+
{
301+
readStdout(0);
302302
303-
int status;
304-
if ( waitpid ( mPid, &status, WNOHANG ) > 0 ) break;
303+
int status;
304+
if ( waitpid ( mPid, &status, WNOHANG ) > 0 ) break;
305305
306-
struct timespec t, r;
307-
t.tv_sec = 0;
308-
t.tv_nsec = 10000000; // 0.01 s
309-
nanosleep ( &t, &r );
310-
}
311-
*/
306+
struct timespec t, r;
307+
t.tv_sec = 0;
308+
t.tv_nsec = 10000000; // 0.01 s
309+
nanosleep ( &t, &r );
310+
}
311+
*/
312312

313313
// Write history
314314
if ( kill(mPid,SIGUSR1) == -1 )
@@ -356,25 +356,25 @@ void QgsGrassShell::keyPressEvent( QKeyEvent * e )
356356
{
357357
switch ( e->key() )
358358
{
359-
case Qt::Key_Up :
360-
strcpy ( s, "\033[A" );
361-
length = 3;
362-
break;
359+
case Qt::Key_Up :
360+
strcpy ( s, "\033[A" );
361+
length = 3;
362+
break;
363363

364-
case Qt::Key_Down :
365-
strcpy ( s, "\033[B" );
366-
length = 3;
367-
break;
364+
case Qt::Key_Down :
365+
strcpy ( s, "\033[B" );
366+
length = 3;
367+
break;
368368

369-
case Qt::Key_Right :
370-
strcpy ( s, "\033[C" );
371-
length = 3;
372-
break;
369+
case Qt::Key_Right :
370+
strcpy ( s, "\033[C" );
371+
length = 3;
372+
break;
373373

374-
case Qt::Key_Left :
375-
strcpy ( s, "\033[D" );
376-
length = 3;
377-
break;
374+
case Qt::Key_Left :
375+
strcpy ( s, "\033[D" );
376+
length = 3;
377+
break;
378378
}
379379
}
380380

@@ -512,87 +512,87 @@ void QgsGrassShell::printStdout()
512512

513513
switch ( final )
514514
{
515-
case 'l' : // RM - Reset Mode
516-
case 'h' : // SM - Set Mode
515+
case 'l' : // RM - Reset Mode
516+
case 'h' : // SM - Set Mode
517+
{
518+
int mode = -1;
519+
switch ( rx.cap(2).toInt() )
517520
{
518-
int mode = -1;
519-
switch ( rx.cap(2).toInt() )
520-
{
521-
case 4 :
522-
mode = Insert;
523-
break;
524-
525-
default:
526-
std::cerr << "ESC ignored: " << rx.cap(0).local8Bit().data() << std::endl;
527-
break;
528-
}
529-
if ( mode >= 0 )
530-
{
531-
if ( final == 'l' )
532-
resetMode ( mode );
533-
else
534-
setMode ( mode );
535-
}
521+
case 4 :
522+
mode = Insert;
536523
break;
537-
}
538524

539-
case 'm' : // SGR - Select Graphic Rendition
540-
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
541-
{
542-
for ( int i = 0; i < RendetionCount; i++ )
543-
{
544-
mRendetion[i] = false;
545-
}
525+
default:
526+
std::cerr << "ESC ignored: " << rx.cap(0).local8Bit().data() << std::endl;
527+
break;
546528
}
547-
else
529+
if ( mode >= 0 )
548530
{
549-
std::cerr << "ESC SGR ignored: " << rx.cap(0).local8Bit().data() << std::endl;
531+
if ( final == 'l' )
532+
resetMode ( mode );
533+
else
534+
setMode ( mode );
550535
}
551536
break;
537+
}
552538

553-
case 'P' : // DCH - Delete Character
539+
case 'm' : // SGR - Select Graphic Rendition
540+
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
541+
{
542+
for ( int i = 0; i < RendetionCount; i++ )
554543
{
555-
int n = rx.cap(2).toInt();
556-
mText->setSelection ( mParagraph, mIndex, mParagraph, mIndex+n, 0 );
557-
mText->removeSelectedText ( 0 );
558-
break;
544+
mRendetion[i] = false;
559545
}
546+
}
547+
else
548+
{
549+
std::cerr << "ESC SGR ignored: " << rx.cap(0).local8Bit().data() << std::endl;
550+
}
551+
break;
560552

561-
case 'K' : // EL - Erase In Line
562-
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
563-
{
564-
//mText->setSelectionAttributes ( 1, QColor(255,255,255), true );
565-
mText->setSelection ( mParagraph, mIndex, mParagraph,
566-
mText->paragraphLength(mParagraph), 0 );
567-
mText->removeSelectedText ( 0 );
568-
}
553+
case 'P' : // DCH - Delete Character
554+
{
555+
int n = rx.cap(2).toInt();
556+
mText->setSelection ( mParagraph, mIndex, mParagraph, mIndex+n, 0 );
557+
mText->removeSelectedText ( 0 );
569558
break;
559+
}
570560

571-
// TODO: multiple tab stops
572-
case 'H' : // Horizontal Tabulation Set (HTS)
573-
mTabStop[mIndex] = true;
574-
std::cerr << "TAB set on " << mIndex << std::endl;
575-
break;
561+
case 'K' : // EL - Erase In Line
562+
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
563+
{
564+
//mText->setSelectionAttributes ( 1, QColor(255,255,255), true );
565+
mText->setSelection ( mParagraph, mIndex, mParagraph,
566+
mText->paragraphLength(mParagraph), 0 );
567+
mText->removeSelectedText ( 0 );
568+
}
569+
break;
576570

577-
case 'g' : // Tabulation Clear (TBC)
578-
// ESC [ g Clears tab stop at the cursor
579-
// ESC [ 2 g Clears all tab stops in the line
580-
// ESC [ 3 g Clears all tab stops in the Page
581-
std::cerr << "TAB reset" << std::endl;
582-
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
583-
{
571+
// TODO: multiple tab stops
572+
case 'H' : // Horizontal Tabulation Set (HTS)
573+
mTabStop[mIndex] = true;
574+
std::cerr << "TAB set on " << mIndex << std::endl;
575+
break;
576+
577+
case 'g' : // Tabulation Clear (TBC)
578+
// ESC [ g Clears tab stop at the cursor
579+
// ESC [ 2 g Clears all tab stops in the line
580+
// ESC [ 3 g Clears all tab stops in the Page
581+
std::cerr << "TAB reset" << std::endl;
582+
if ( rx.cap(2).isEmpty() || rx.cap(2).toInt() == 0 )
583+
{
584+
mTabStop[mIndex] = false;
585+
}
586+
else
587+
{
588+
for (int i = 0; i < (int)mTabStop.size(); i++ )
584589
mTabStop[mIndex] = false;
585-
}
586-
else
587-
{
588-
for (int i = 0; i < (int)mTabStop.size(); i++ )
589-
mTabStop[mIndex] = false;
590-
}
591-
break;
590+
}
591+
break;
592592

593-
default:
594-
std::cerr << "ESC ignored: " << rx.cap(0).local8Bit().data() << std::endl;
595-
break;
593+
default:
594+
std::cerr << "ESC ignored: " << rx.cap(0).local8Bit().data() << std::endl;
595+
break;
596596
}
597597

598598
mStdoutBuffer.remove ( 0, mlen+1 );
@@ -639,49 +639,49 @@ void QgsGrassShell::printStdout()
639639
// control character
640640
switch ( c )
641641
{
642-
case '\015' : // CR
643-
//std::cerr << "CR" << std::endl;
644-
mStdoutBuffer.remove ( 0, 1 );
645-
// TODO : back tab stops?
646-
mIndex = 0;
647-
break;
642+
case '\015' : // CR
643+
//std::cerr << "CR" << std::endl;
644+
mStdoutBuffer.remove ( 0, 1 );
645+
// TODO : back tab stops?
646+
mIndex = 0;
647+
break;
648648

649-
case '\012' : // NL
650-
//std::cerr << "NL" << std::endl;
651-
newLine();
652-
mStdoutBuffer.remove ( 0, 1 );
653-
break;
649+
case '\012' : // NL
650+
//std::cerr << "NL" << std::endl;
651+
newLine();
652+
mStdoutBuffer.remove ( 0, 1 );
653+
break;
654654

655-
case '\010' : // BS
656-
//std::cerr << "BS" << std::endl;
657-
mIndex--;
658-
mStdoutBuffer.remove ( 0, 1 );
659-
break;
655+
case '\010' : // BS
656+
//std::cerr << "BS" << std::endl;
657+
mIndex--;
658+
mStdoutBuffer.remove ( 0, 1 );
659+
break;
660660

661-
case '\011' : // HT (tabulator)
661+
case '\011' : // HT (tabulator)
662+
{
663+
//std::cerr << "HT" << std::endl;
664+
QString space;
665+
for ( int i = mIndex; i < (int)mTabStop.size(); i++ )
662666
{
663-
//std::cerr << "HT" << std::endl;
664-
QString space;
665-
for ( int i = mIndex; i < (int)mTabStop.size(); i++ )
666-
{
667-
space.append ( " " );
668-
if ( mTabStop[i] ) break;
669-
}
670-
insert (space);
671-
mStdoutBuffer.remove ( 0, 1 );
672-
break;
667+
space.append ( " " );
668+
if ( mTabStop[i] ) break;
673669
}
674-
675-
case '>' : // Keypad Numeric Mode
676-
std::cerr << "Keypad Numeric Mode ignored: "
677-
<< QString::number(c,8).local8Bit().data() << std::endl;
678-
mStdoutBuffer.remove ( 0, 2 );
679-
break;
680-
681-
default : // unknown control, do nothing
682-
std::cerr << "UNKNOWN control char ignored: " << QString::number(c,8).local8Bit().data() << std::endl;
670+
insert (space);
683671
mStdoutBuffer.remove ( 0, 1 );
684672
break;
673+
}
674+
675+
case '>' : // Keypad Numeric Mode
676+
std::cerr << "Keypad Numeric Mode ignored: "
677+
<< QString::number(c,8).local8Bit().data() << std::endl;
678+
mStdoutBuffer.remove ( 0, 2 );
679+
break;
680+
681+
default : // unknown control, do nothing
682+
std::cerr << "UNKNOWN control char ignored: " << QString::number(c,8).local8Bit().data() << std::endl;
683+
mStdoutBuffer.remove ( 0, 1 );
684+
break;
685685
}
686686
}
687687
continue;
@@ -794,7 +794,7 @@ void QgsGrassShell::printStdout()
794794
void QgsGrassShell::removeEmptyParagraphs()
795795
{
796796
while ( mParagraph >= 0
797-
&& mText->text(mParagraph).stripWhiteSpace().length() <= 0 )
797+
&& mText->text(mParagraph).stripWhiteSpace().length() <= 0 )
798798
{
799799
mText->removeParagraph ( mParagraph );
800800
mParagraph--;
@@ -824,7 +824,7 @@ void QgsGrassShell::insert ( QString s )
824824
// to the right
825825
// mText->setOverwriteMode ( !mMode[Insert] ); // does not work
826826
if ( !mMode[Insert] && !mNewLine && mParagraph >= 0 &&
827-
mText->paragraphLength(mParagraph) > mIndex )
827+
mText->paragraphLength(mParagraph) > mIndex )
828828
{
829829
#ifdef QGISDEBUG
830830
std::cerr << "erase old " << mIndex+s.length() << " chars " << std::endl;
@@ -953,7 +953,7 @@ void QgsGrassShell::closeShell()
953953
#ifdef QGISDEBUG
954954
std::cerr << "QgsGrassShell::closeShell()" << std::endl;
955955
#endif
956-
956+
957957
mTabWidget->removePage (this );
958958
delete this;
959959
}

0 commit comments

Comments
 (0)
Please sign in to comment.