Skip to content

Commit

Permalink
more log messages and auto-resize cells
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 27, 2011
1 parent 6c90891 commit 22677dc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
21 changes: 8 additions & 13 deletions src/app/qgisapp.cpp
Expand Up @@ -580,6 +580,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,

mSplash->showMessage( tr( "QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom );

QgsMessageLog::logMessage( QgsApplication::showSettings() );

QgsMessageLog::logMessage( tr( "QGIS Ready!" ) );

mMapTipsVisible = false;
Expand Down Expand Up @@ -613,11 +615,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// supposedly all actions have been added, now register them to the shortcut manager
QgsShortcutsManager::instance()->registerAllChildrenActions( this );

//finally show all the application settings as initialised above
QgsDebugMsg( "\n\n\nApplication Settings:\n--------------------------\n" );
QgsDebugMsg( QgsApplication::showSettings() );
QgsDebugMsg( "\n--------------------------\n\n\n" );

// request notification of FileOpen events (double clicking a file icon in Mac OS X Finder)
QgsApplication::setFileOpenEventReceiver( this );

Expand Down Expand Up @@ -1755,7 +1752,7 @@ bool QgisApp::createDB()

if ( !isDbFileCopied )
{
QgsDebugMsg( "[ERROR] Can not make qgis.db private copy" );
QgsMessageLog::logMessage( tr( "[ERROR] Can not make qgis.db private copy" ) );
return false;
}
}
Expand Down Expand Up @@ -2332,7 +2329,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons
}
else
{
QgsDebugMsg(( layerPath ) + " is an invalid layer - not loaded" );
QgsMessageLog::logMessage( tr( "%1 is an invalid layer - not loaded" ).arg( layerPath ) );
QMessageBox::critical( this, tr( "Invalid Layer" ), tr( "%1 is an invalid layer and cannot be loaded." ).arg( layerPath ) );
delete layer;
}
Expand Down Expand Up @@ -2928,7 +2925,7 @@ bool QgisApp::openLayer( const QString & fileName, bool allowInteractive )
if ( !ok )
{
// we have no idea what this file is...
QgsDebugMsg( "Unable to load " + fileName );
QgsMessageLog::logMessage( tr( "Unable to load %1" ).arg( fileName ) );
}

return ok;
Expand Down Expand Up @@ -4539,12 +4536,10 @@ void QgisApp::loadPythonSupport()
pythonlib.setLoadHints( QLibrary::ResolveAllSymbolsHint | QLibrary::ExportExternalSymbolsHint );
if ( !pythonlib.load() )
{
//using stderr on purpose because we want end users to see this [TS]
QgsDebugMsg( "Couldn't load Python support library: " + pythonlib.errorString() );
pythonlib.setFileName( pythonlibName );
if ( !pythonlib.load() )
{
qWarning( "Couldn't load Python support library: %s", pythonlib.errorString().toUtf8().data() );
QgsMessageLog::logMessage( tr( "Couldn't load Python support library: %1" ).arg( pythonlib.errorString() ) );
return;
}
}
Expand All @@ -4555,7 +4550,7 @@ void QgisApp::loadPythonSupport()
if ( !pythonlib_inst )
{
//using stderr on purpose because we want end users to see this [TS]
QgsDebugMsg( "Couldn't resolve python support library's instance() symbol." );
QgsMessageLog::logMessage( tr( "Couldn't resolve python support library's instance() symbol." ) );
return;
}

Expand All @@ -4570,7 +4565,7 @@ void QgisApp::loadPythonSupport()
// init python runner
QgsPythonRunner::setInstance( new QgsPythonRunnerImpl( mPythonUtils ) );

std::cout << "Python support ENABLED :-) " << std::endl; // OK
QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ) );
}
else
{
Expand Down
20 changes: 10 additions & 10 deletions src/core/qgsapplication.cpp
Expand Up @@ -504,22 +504,22 @@ void QgsApplication::exitQgis()

QString QgsApplication::showSettings()
{
QString myState = QString( "Application state:\n"
"Prefix : %1\n"
"Plugin Path : %2\n"
"Package Data Path : %3\n"
"Active Theme Name : %4\n"
"Active Theme Path : %5\n"
"Default Theme Path : %6\n"
"SVG Search Paths : %7\n"
"User DB Path : %8\n" )
QString myState = tr( "Application state:\n"
"Prefix:\t\t%1\n"
"Plugin Path:\t\t%2\n"
"Package Data Path:\t%3\n"
"Active Theme Name:\t%4\n"
"Active Theme Path:\t%5\n"
"Default Theme Path:\t%6\n"
"SVG Search Paths:\t%7\n"
"User DB Path:\t%8\n" )
.arg( mPrefixPath )
.arg( mPluginPath )
.arg( mPkgDataPath )
.arg( themeName() )
.arg( activeThemePath() )
.arg( defaultThemePath() )
.arg( svgPaths().join( "\n" ) )
.arg( svgPaths().join( "\n\t\t" ) )
.arg( qgisMasterDbFilePath() );
return myState;
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsmessagelog.cpp
Expand Up @@ -14,6 +14,8 @@
***************************************************************************/

#include "qgsmessagelog.h"
#include <qgslogger.h>
#include <QDateTime>
#include <iostream>

class QgsMessageLogConsole;
Expand All @@ -27,6 +29,8 @@ void QgsMessageLog::setLogger( void (*f)( QString message, QString tag, int leve

void QgsMessageLog::logMessage( QString message, QString tag, int level )
{
QgsDebugMsg( QString( "%1 %2[%3] %4" ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ) ).arg( tag ).arg( level ).arg( message ) );

if( !gmLogger )
QgsMessageLogConsole::logger( message, tag, level );
else
Expand Down
9 changes: 3 additions & 6 deletions src/gui/qgsmessagelogviewer.cpp
Expand Up @@ -17,7 +17,6 @@

#include "qgsmessagelogviewer.h"
#include "qgsmessagelog.h"
#include "qgslogger.h"

#include <QSettings>
#include <QTableWidget>
Expand Down Expand Up @@ -66,25 +65,23 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
{
w = new QTableWidget( 0, 3, this );
w->verticalHeader()->setDefaultSectionSize( 16 );
w->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
w->verticalHeader()->setVisible( false );
w->setGridStyle( Qt::DotLine );
w->setEditTriggers( QAbstractItemView::NoEditTriggers );
w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
w->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
tabWidget->addTab( w, tag );
}

int n = w->rowCount();

QgsDebugMsg( QString( "%1: %2[%3] %4" ).arg( n ).arg( QDateTime::currentDateTime().toString( Qt::ISODate ) ).arg( level ).arg( level ) );

w->setRowCount( n + 1 );
QTableWidgetItem *item = new QTableWidgetItem( QDateTime::currentDateTime().toString( Qt::ISODate ) );
w->setItem( n, 0, item );
w->setItem( n, 1, new QTableWidgetItem( message ) );
w->setItem( n, 2, new QTableWidgetItem( QString::number( level ) ) );
w->scrollToItem( item );

w->resizeColumnsToContents();
w->scrollToBottom();
}

void QgsMessageLogViewer::closeTab( int index )
Expand Down

0 comments on commit 22677dc

Please sign in to comment.