1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
<file>themes/default/mIconWaitingForLayerType.png</file>
<file>themes/default/mIconWms.png</file>
<file>themes/default/mIconWmsLayer.png</file>
<file>themes/default/mIconWarn.png</file>
<file>themes/default/mMapserverExport.png</file>
<file>themes/default/plugin.png</file>
<file>themes/default/propertyicons/action.png</file>
Expand Down
1 change: 0 additions & 1 deletion images/themes/default/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

FILE (GLOB IMAGES *.png)

INSTALL (FILES ${IMAGES}
Expand Down
Binary file added images/themes/default/mIconWarn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ void myMessageOutput( QtMsgType type, const char *msg )
|| 0 == strncmp( msg, "QWidget::", 9 )
|| 0 == strncmp( msg, "QPainter::", 10 ) )
{
#if 0
#ifdef linux
fprintf( stderr, "Stacktrace (run through c++filt):\n" );
void *buffer[256];
int nptrs = backtrace( buffer, sizeof( buffer ) / sizeof( *buffer ) );
backtrace_symbols_fd( buffer, nptrs, STDERR_FILENO );
#endif
#endif
QgsMessageLog::logMessage( msg, "Qt" );
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mpGpsDock->setWidget( mpGpsWidget );
mpGpsDock->hide();

mLogViewer = new QgsMessageLogViewer();
mLogViewer = new QgsMessageLogViewer( statusBar(), this );

mLogDock = new QDockWidget( tr( "Log Messages" ), this );
mLogDock->setObjectName( "MessageLog" );
Expand Down
84 changes: 81 additions & 3 deletions src/gui/qgsmessagelogviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,52 @@

#include "qgsmessagelogviewer.h"
#include "qgsmessagelog.h"
#include "qgsapplication.h"

#include <QSettings>
#include <QTableWidget>
#include <QFile>
#include <QDateTime>
#include <QTableWidget>
#include <QToolButton>
#include <QStatusBar>
#include <QToolTip>
#include <QDockWidget>

static QgsMessageLogViewer *gmInstance = 0;

QgsMessageLogViewer::QgsMessageLogViewer( QWidget *parent, Qt::WFlags fl )
static QIcon icon( QString icon )
{
// try active theme
QString path = QgsApplication::activeThemePath();
if ( QFile::exists( path + icon ) )
path += icon;
else
path = QgsApplication::defaultThemePath() + icon;

return QIcon( path );
}

QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mButton( 0 )
, mCount( 0 )
{
setupUi( this );
gmInstance = this;
QgsMessageLog::setLogger( logger );

if ( statusBar )
{
mButton = new QToolButton( parent );
mButton->setObjectName( "mMessageLogViewerButton" );
mButton->setMaximumWidth( 20 );
mButton->setMaximumHeight( 20 );
mButton->setIcon( icon( "/mIconWarn.png" ) );
mButton->setToolTip( tr( "No messages." ) );
mButton->setCheckable( true );
connect( mButton, SIGNAL( toggled( bool ) ), this, SLOT( buttonToggled( bool ) ) );
statusBar->addPermanentWidget( mButton, 0 );
}

connect( tabWidget, SIGNAL( tabCloseRequested( int ) ), this, SLOT( closeTab( int ) ) );
}

Expand All @@ -39,6 +71,35 @@ QgsMessageLogViewer::~QgsMessageLogViewer()
QgsMessageLog::setLogger( 0 );
}

void QgsMessageLogViewer::hideEvent( QHideEvent * )
{
if ( mButton )
{
mButton->setChecked( false );
}
}

void QgsMessageLogViewer::showEvent( QShowEvent * )
{
if ( mButton )
{
mButton->setChecked( true );
}
}

void QgsMessageLogViewer::buttonToggled( bool checked )
{
QWidget *w = qobject_cast<QDockWidget *>( parent() );

if ( !w )
w = this;

if ( checked )
w->show();
else
w->hide();
}

void QgsMessageLogViewer::logger( QString message, QString tag, int level )
{
if ( !gmInstance )
Expand All @@ -49,6 +110,13 @@ void QgsMessageLogViewer::logger( QString message, QString tag, int level )

void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
{
mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );

if ( mButton && !isVisible() )
{
QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
}

if ( tag.isNull() )
tag = tr( "General" );

Expand All @@ -60,6 +128,7 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
if ( i < tabWidget->count() )
{
w = qobject_cast<QTableWidget *>( tabWidget->widget( i ) );
tabWidget->setCurrentIndex( i );
}
else
{
Expand All @@ -72,6 +141,8 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
w->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
tabWidget->addTab( w, tag );

tabWidget->setCurrentIndex( tabWidget->count() - 1 );
}

int n = w->rowCount();
Expand All @@ -86,5 +157,12 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )

void QgsMessageLogViewer::closeTab( int index )
{
QTableWidget *w = qobject_cast<QTableWidget *>( tabWidget->widget( index ) );
if ( w )
{
mCount -= w->rowCount();
if ( mButton )
mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
}
tabWidget->removeTab( index );
}
15 changes: 14 additions & 1 deletion src/gui/qgsmessagelogviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

#include <QString>

class QStatusBar;
class QToolButton;
class QShowEvent;
class QHideEvent;

/** \ingroup gui
* A generic message for displaying QGIS log messages.
* \note added in 1.8
Expand All @@ -31,15 +36,23 @@ class GUI_EXPORT QgsMessageLogViewer: public QDialog, public QgsMessageLog, priv
{
Q_OBJECT
public:
QgsMessageLogViewer( QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
QgsMessageLogViewer( QStatusBar *statusBar = 0, QWidget *parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
~QgsMessageLogViewer();

void logMessage( QString message, QString tag = QString::null, int level = 0 );

static void logger( QString message, QString tag, int level );

private:
void showEvent( QShowEvent * );
void hideEvent( QHideEvent * );

QToolButton *mButton;
int mCount;

private slots:
void closeTab( int index );
void buttonToggled( bool checked );
};

#endif
7 changes: 4 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,11 @@ bool QgsPostgresProvider::getFeature( QgsPostgresResult &queryResult, int row, b
switch ( mPrimaryKeyType )
{
case pktOid:
case pktInt:
case pktTid:
case pktInt:
fid = mConnectionRO->getBinaryInt( queryResult, row, col++ );
if ( mPrimaryKeyType == pktInt && fetchAttributes.contains( mPrimaryKeyAttrs[0] ) )
feature.addAttribute( mPrimaryKeyAttrs[0], fid );
break;

case pktFidMap:
Expand Down Expand Up @@ -2658,7 +2660,7 @@ bool QgsPostgresProvider::getGeometryDetails()

if ( srid.isEmpty() )
{
srid = layerProperty.srid;
srid = QString::number( layerProperty.srid );
}

if ( type.isEmpty() && !type.contains( "," ) )
Expand Down Expand Up @@ -2698,7 +2700,6 @@ bool QgsPostgresProvider::getGeometryDetails()
mEnabledCapabilities &= ~( QgsVectorDataProvider::ChangeGeometries | QgsVectorDataProvider::AddFeatures );
}


QgsDebugMsg( "Detected SRID is " + mDetectedSrid );
QgsDebugMsg( "Requested SRID is " + mRequestedSrid );
QgsDebugMsg( "Detected type is " + QString::number( mDetectedGeomType ) );
Expand Down