[QGIS Commit] r11118 - in trunk/qgis/src: plugins/grass
plugins/grass/qtermwidget providers/grass
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jul 20 11:42:30 EDT 2009
Author: rugginoso
Date: 2009-07-20 11:42:30 -0400 (Mon, 20 Jul 2009)
New Revision: 11118
Modified:
trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
trunk/qgis/src/plugins/grass/qgsgrassshell.h
trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.cpp
trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.h
trunk/qgis/src/providers/grass/qgsgrass.cpp
trunk/qgis/src/providers/grass/qgsgrass.h
Log:
Various enhancements into GRASS shell:
- Uses directly GRASS
- Starts with a minimum size of 80x25 characters
Modified: trunk/qgis/src/plugins/grass/qgsgrassshell.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassshell.cpp 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/plugins/grass/qgsgrassshell.cpp 2009-07-20 15:42:30 UTC (rev 11118)
@@ -22,6 +22,7 @@
#include "qgsgrasstools.h"
#include "qtermwidget/qtermwidget.h"
#include "qgsapplication.h"
+#include "qgsgrass.h"
#include "qgsgrassshell.h"
@@ -31,27 +32,30 @@
}
QgsGrassShell::QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent, const char *name )
- : QFrame( parent )
+ : QFrame( parent ), mTools(tools), mTabWidget(parent)
{
- mTools = tools;
- mTabWidget = parent;
-
QVBoxLayout *mainLayout = new QVBoxLayout( this );
QTermWidget *mTerminal = new QTermWidget( 0, this );
initTerminal( mTerminal );
- QPushButton *closeButton = new QPushButton( tr( "Close" ), this );
QShortcut *pasteShortcut = new QShortcut( QKeySequence( tr( "Ctrl+Shift+V" ) ), mTerminal );
QShortcut *copyShortcut = new QShortcut( QKeySequence( tr( "Ctrl+Shift+C" ) ), mTerminal );
mainLayout->addWidget( mTerminal );
- mainLayout->addWidget( closeButton );
setLayout( mainLayout );
- connect( closeButton, SIGNAL( clicked() ), this, SLOT( closeShell() ) );
connect( mTerminal, SIGNAL( finished() ), this, SLOT( closeShell() ) );
connect( pasteShortcut, SIGNAL( activated() ), mTerminal, SLOT( pasteClipboard() ) );
connect( copyShortcut, SIGNAL( activated() ), mTerminal, SLOT( copyClipboard() ) );
+ // TODO: find a better way to manage the lockfile.
+ mLockFilename = QgsGrass::lockFileParh();
+ QFile::remove(mLockFilename + ".qgis");
+ if (!QFile::rename(mLockFilename, mLockFilename + ".qgis"))
+ {
+ QMessageBox::warning(this, tr("Warning"), tr("Cannot rename the lock file %1").arg(mLockFilename));
+ }
+
+ mTerminal->setSize(80, 25);
mTerminal->startShellProgram();
mTerminal->setFocus( Qt::MouseFocusReason );
}
@@ -60,55 +64,35 @@
{
}
-
-/* TODO: Implement something that resizes the terminal without
- * crashes.
-void QgsGrassShell::resizeTerminal()
-{
- //mTerminal->setSize(80, 25);
- //mTerminal->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-}
-*/
-
void QgsGrassShell::closeShell()
{
int index = mTabWidget->indexOf( this );
mTabWidget->removeTab( index );
- delete this;
-}
-void QgsGrassShell::initTerminal( QTermWidget *terminal )
-{
- QStringList args( "" );
- QStringList env( "" );
- // Set the shell program
- QString shell = ::getenv( "SHELL" );
- if ( shell.isEmpty() || shell.isNull() )
+ // TODO: find a better way to manage the lockfile.
+ if(!QFile::rename(mLockFilename + ".qgis", mLockFilename))
{
- // if the shell isn't specified use the default one (/bin/bash)
- terminal->setShellProgram( shell );
+ QMessageBox::warning(this, tr("Warning"), tr("Cannot rename the lock file %1").arg(mLockFilename));
}
- // Set shell program arguments
- QFileInfo shellInfo( shell );
- if ( shellInfo.fileName() == "bash" || shellInfo.fileName() == "sh" )
- {
- args << "--norc";
- }
- else if ( shellInfo.fileName() == "tcsh" || shellInfo.fileName() == "csh" )
- {
- args << "-f";
- }
- terminal->setArgs( args );
+ this->deleteLater();
+}
- // Set shell program enviroment variables
- env << "GRASS_MESSAGE_FORMAT=";
- env << "GRASS_UI_TERM=1";
- env << "GISRC_MODE_MEMORY";
- env << "PS1=GRASS > ";
+void QgsGrassShell::initTerminal( QTermWidget *terminal )
+{
+ QStringList env("");
+ QStringList args("");
+
+ terminal->setShellProgram("/usr/bin/grass64");
env << "TERM=vt100";
- terminal->setEnvironment( env );
+ env << "GISRC_MODE_MEMORY";
+ args << "-text";
+ args << QString("%1/%2/%3").arg(QgsGrass::getDefaultGisdbase()).arg(QgsGrass::getDefaultLocation()).arg(QgsGrass::getDefaultMapset());
+
+ terminal->setArgs(args);
+ terminal->setEnvironment(env);
+
// Look & Feel
terminal->setScrollBarPosition( QTermWidget::ScrollBarRight );
}
Modified: trunk/qgis/src/plugins/grass/qgsgrassshell.h
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrassshell.h 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/plugins/grass/qgsgrassshell.h 2009-07-20 15:42:30 UTC (rev 11118)
@@ -27,12 +27,6 @@
QgsGrassShell( QgsGrassTools *tools, QTabWidget *parent = 0, const char *name = 0 );
virtual ~QgsGrassShell();
- /* TODO: Implement something that resizes the terminal without
- * crashes.
- public slots:
- void resizeTerminal();
- */
-
private slots:
void closeShell();
@@ -42,4 +36,5 @@
QTermWidget *mTerminal;
QgsGrassTools *mTools;
QTabWidget *mTabWidget;
+ QString mLockFilename;
};
Modified: trunk/qgis/src/plugins/grass/qgsgrasstools.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qgsgrasstools.cpp 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/plugins/grass/qgsgrasstools.cpp 2009-07-20 15:42:30 UTC (rev 11118)
@@ -150,25 +150,6 @@
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, hist.toAscii().constData() );
- putenv( histChar );
-
- // csh/tcsh
-#ifndef WIN32
- hist = "histfile=" + mapsetPath + "/.history";
- histChar = new char[hist.length()+1];
- strcpy( histChar, hist.toAscii().constData() );
- putenv( histChar );
-#endif
-
#ifdef WIN32
if ( !QProcess::startDetached( getenv( "COMSPEC" ) ) )
{
Modified: trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.cpp
===================================================================
--- trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.cpp 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.cpp 2009-07-20 15:42:30 UTC (rev 11118)
@@ -259,6 +259,16 @@
}
}
+QSize QTermWidget::minimumSizeHint() const
+{
+ return m_impl->m_terminalDisplay->sizeHint();
+}
+
+QSize QTermWidget::sizeHint() const
+{
+ return m_impl->m_terminalDisplay->sizeHint();
+}
+
void QTermWidget::setEnvironment(const QStringList& environment)
{
m_impl->m_session->setEnvironment(environment);
Modified: trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.h
===================================================================
--- trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.h 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/plugins/grass/qtermwidget/qtermwidget.h 2009-07-20 15:42:30 UTC (rev 11118)
@@ -106,6 +106,9 @@
*/
void setFlowControlWarningEnabled(bool enabled);
+ QSize minimumSizeHint() const;
+ QSize sizeHint() const;
+
signals:
void finished();
void receivedData(const QString &data);
Modified: trunk/qgis/src/providers/grass/qgsgrass.cpp
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.cpp 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/providers/grass/qgsgrass.cpp 2009-07-20 15:42:30 UTC (rev 11118)
@@ -1081,3 +1081,8 @@
return false;
}
+
+QString GRASS_EXPORT QgsGrass::lockFileParh()
+{
+ return mMapsetLock;
+}
Modified: trunk/qgis/src/providers/grass/qgsgrass.h
===================================================================
--- trunk/qgis/src/providers/grass/qgsgrass.h 2009-07-20 15:24:14 UTC (rev 11117)
+++ trunk/qgis/src/providers/grass/qgsgrass.h 2009-07-20 15:42:30 UTC (rev 11118)
@@ -151,6 +151,9 @@
// ! test if the directory is mapset
static GRASS_EXPORT bool isMapset( QString path );
+ // ! Get the lock file
+ static GRASS_EXPORT QString lockFileParh();
+
//! Library version
static GRASS_EXPORT int versionMajor();
static GRASS_EXPORT int versionMinor();
More information about the QGIS-commit
mailing list