Skip to content

Commit

Permalink
Merge branch 'master' of github.com:qgis/Quantum-GIS
Browse files Browse the repository at this point in the history
  • Loading branch information
kyngchaos committed Dec 26, 2011
2 parents bdd33b3 + ba2a205 commit 137a031
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
51 changes: 51 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -374,6 +374,11 @@ static void customSrsValidation_( QgsCoordinateReferenceSystem* srs )
}
}

static bool cmpByText_( QAction* a, QAction* b )
{
return QString::localeAwareCompare( a->text(), b->text() ) < 0;
}


QgisApp *QgisApp::smInstance = 0;

Expand Down Expand Up @@ -1138,6 +1143,9 @@ void QgisApp::createToolBars()
toolbarMenuActions << toolBar->toggleViewAction();
}

// sort actions in toolbar menu
qSort( toolbarMenuActions.begin(), toolbarMenuActions.end(), cmpByText_ );

mToolbarMenu->addActions( toolbarMenuActions );

// select tool button
Expand Down Expand Up @@ -7131,3 +7139,46 @@ void QgisApp::toolButtonActionTriggered( QAction *action )

bt->setDefaultAction( action );
}

QMenu* QgisApp::createPopupMenu()
{
QMenu* menu = QMainWindow::createPopupMenu();
QList< QAction* > al = menu->actions();
QList< QAction* > panels, toolbars;

if( !al.isEmpty() )
{
bool found = false;
for ( int i = 0; i < al.size(); ++i )
{
if ( al[ i ]->isSeparator() )
{
found = true;
continue;
}

if ( !found )
{
panels.append( al[ i ] );
}
else
{
toolbars.append( al[ i ] );
}
}

qSort( panels.begin(), panels.end(), cmpByText_ );
foreach( QAction* a, panels )
{
menu->addAction( a );
}
menu->addSeparator();
qSort( toolbars.begin(), toolbars.end(), cmpByText_ );
foreach( QAction* a, toolbars )
{
menu->addAction( a );
}
}

return menu;
}
5 changes: 5 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -207,6 +207,9 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
/**Deletes a composer and removes entry from Set*/
void deleteComposer( QgsComposer* c );

/** overloaded function used to sort menu entries alphabetically */
QMenu* createPopupMenu();


//! Actions to be inserted in menus and toolbars
QAction *actionNewProject() { return mActionNewProject; }
Expand Down Expand Up @@ -1132,6 +1135,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

//! project changed
void projectChanged( const QDomDocument & );

bool cmpByText( QAction* a, QAction* b );
};

#endif
2 changes: 1 addition & 1 deletion src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -367,7 +367,7 @@ QString QgsGdalProvider::metadata()
myMetadata += tr( "Dataset Description" );
myMetadata += "</p>\n";
myMetadata += "<p>";
myMetadata += QFile::decodeName( GDALGetDescription( mGdalDataset ) );
myMetadata += FROM8( GDALGetDescription( mGdalDataset ) );
myMetadata += "</p>\n";


Expand Down
2 changes: 2 additions & 0 deletions src/providers/gdal/qgsgdalprovider.h
Expand Up @@ -41,8 +41,10 @@ class QgsRasterPyramid;

#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8F(x) (x).toUtf8().constData()
#define FROM8(x) QString::fromUtf8(x)
#else
#define TO8F(x) QFile::encodeName( x ).constData()
#define FROM8(x) QString::fromLocal8Bit(x)
#endif


Expand Down

0 comments on commit 137a031

Please sign in to comment.