Skip to content

Commit

Permalink
Merge pull request #6275 from 3nids/messagelevel
Browse files Browse the repository at this point in the history
unite QgsMessageLog::Level and QgsMessageBar::MessageLevel in Qgis::MessageLevel
  • Loading branch information
3nids committed Feb 6, 2018
2 parents 8f2c857 + 3dc3d9d commit 3205c96
Show file tree
Hide file tree
Showing 142 changed files with 610 additions and 603 deletions.
7 changes: 7 additions & 0 deletions doc/api_break.dox
Expand Up @@ -1605,9 +1605,16 @@ QgsMarkerSymbolLayer {#qgis_api_break_3_0_QgsMarkerSymbolLayer}
- bounds() is now pure virtual and must be implemented in all subclasses.


QgsMessageBar {#qgis_api_break_3_0_QgsMessageBar}
---------------------------

- MessageLevel has been removed. Use Qgis::MessageLevel instead


QgsMessageLog {#qgis_api_break_3_0_QgsMessageLog}
---------------------------

- MessageLevel has been removed. Use Qgis::MessageLevel instead
- This class is no longer a singleton and instance() has been removed. Instead use QgsApplication::messageLog() to access an application-wide log.

QgsMessageLogViewer {#qgis_api_break_3_0_QgsMessageLogViewer}
Expand Down
8 changes: 6 additions & 2 deletions external/libdxfrw/CMakeLists.txt
@@ -1,6 +1,10 @@
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_BINARY_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/geometry

${CMAKE_BINARY_DIR}/src/core
${CMAKE_BINARY_DIR}/src/core/geometry

${Qt5Core_INCLUDE_DIRS}
)

Expand Down
4 changes: 2 additions & 2 deletions python/console/console_editor.py
Expand Up @@ -22,7 +22,7 @@
from qgis.PyQt.QtGui import QFont, QFontMetrics, QColor, QKeySequence, QCursor, QFontDatabase
from qgis.PyQt.QtWidgets import QShortcut, QMenu, QApplication, QWidget, QGridLayout, QSpacerItem, QSizePolicy, QFileDialog, QTabWidget, QTreeWidgetItem, QFrame, QLabel, QToolButton, QMessageBox
from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython, QsciAPIs, QsciStyle
from qgis.core import QgsApplication, QgsSettings
from qgis.core import Qgis, QgsApplication, QgsSettings
from qgis.gui import QgsMessageBar
from qgis.utils import OverrideCursor
import sys
Expand Down Expand Up @@ -1265,7 +1265,7 @@ def changeLastDirPath(self, tab):
self.settings.setValue("pythonConsole/lastDirPath", tabWidget.path)

def widgetMessageBar(self, iface, text, level, timed=True):
messageLevel = [QgsMessageBar.INFO, QgsMessageBar.WARNING, QgsMessageBar.CRITICAL]
messageLevel = [Qgis.Info, Qgis.Warning, Qgis.Critical]
if timed:
timeout = iface.messageTimeout()
else:
Expand Down
4 changes: 2 additions & 2 deletions python/console/console_output.py
Expand Up @@ -25,7 +25,7 @@
from qgis.PyQt.QtGui import QColor, QFont, QKeySequence, QFontDatabase
from qgis.PyQt.QtWidgets import QGridLayout, QSpacerItem, QSizePolicy, QShortcut, QMenu, QApplication
from qgis.PyQt.Qsci import QsciScintilla, QsciLexerPython
from qgis.core import QgsApplication, QgsSettings
from qgis.core import Qgis, QgsApplication, QgsSettings
from qgis.gui import QgsMessageBar
import sys

Expand Down Expand Up @@ -293,4 +293,4 @@ def keyPressEvent(self, e):

def widgetMessageBar(self, iface, text):
timeout = iface.messageTimeout()
self.infoBar.pushMessage(text, QgsMessageBar.INFO, timeout)
self.infoBar.pushMessage(text, Qgis.Info, timeout)
2 changes: 1 addition & 1 deletion python/core/__init__.py
Expand Up @@ -139,7 +139,7 @@ def referencedColumns(self, node):
msg = QCoreApplication.translate("UserExpressions",
"The user expression {0} already exists and could not be unregistered.").format(
name)
QgsMessageLog.logMessage(msg + "\n", msgtitle, QgsMessageLog.WARNING)
QgsMessageLog.logMessage(msg + "\n", msgtitle, Qgis.Warning)
return None

function.__name__ = name
Expand Down
9 changes: 9 additions & 0 deletions python/core/qgis.sip.in
Expand Up @@ -35,6 +35,15 @@ The Qgis class provides global constants for use throughout the application.
static const char *QGIS_DEV_VERSION;


enum MessageLevel
{
Info,
Warning,
Critical,
Success,
None
};

enum DataType
{
UnknownDataType,
Expand Down
15 changes: 3 additions & 12 deletions python/core/qgsmessagelog.sip.in
Expand Up @@ -29,27 +29,18 @@ QgsMessageLog is not usually directly created, but rather accessed through
%End
public:

enum MessageLevel
{
ALL,
INFO,
WARNING,
CRITICAL,
NONE
};

QgsMessageLog();
%Docstring
Constructor for QgsMessageLog.
%End

static void logMessage( const QString &message, const QString &tag = QString(), MessageLevel level = QgsMessageLog::WARNING );
static void logMessage( const QString &message, const QString &tag = QString(), Qgis::MessageLevel level = Qgis::Warning );
%Docstring
add a message to the instance (and create it if necessary)
%End

signals:
void messageReceived( const QString &message, const QString &tag, QgsMessageLog::MessageLevel level );
void messageReceived( const QString &message, const QString &tag, Qgis::MessageLevel level );

void messageReceived( bool received );

Expand All @@ -71,7 +62,7 @@ be the right choice for apps without GUI.
QgsMessageLogConsole();

public slots:
void logMessage( const QString &message, const QString &tag, QgsMessageLog::MessageLevel level );
void logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level );
};

/************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmapcanvas.sip.in
Expand Up @@ -930,7 +930,7 @@ Emitted when the canvas has been assigned a different map theme.
.. versionadded:: 3.0
%End

void messageEmitted( const QString &title, const QString &message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
void messageEmitted( const QString &title, const QString &message, Qgis::MessageLevel = Qgis::Info );
%Docstring
emit a message (usually to be displayed in a message bar)
%End
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmaptool.sip.in
Expand Up @@ -187,7 +187,7 @@ The values is calculated from searchRadiusMM().
%End

signals:
void messageEmitted( const QString &message, QgsMessageBar::MessageLevel = QgsMessageBar::INFO );
void messageEmitted( const QString &message, Qgis::MessageLevel = Qgis::Info );
%Docstring
emit a message
%End
Expand Down
15 changes: 4 additions & 11 deletions python/gui/qgsmessagebar.sip.in
Expand Up @@ -21,13 +21,6 @@ A bar for displaying non-blocking messages to the user.
#include "qgsmessagebar.h"
%End
public:
enum MessageLevel
{
INFO,
WARNING,
CRITICAL,
SUCCESS
};

QgsMessageBar( QWidget *parent /TransferThis/ = 0 );
%Docstring
Expand All @@ -43,13 +36,13 @@ The message bar will take ownership of the item.
:param item: Item to display
%End

QgsMessageBarItem *pushWidget( QWidget *widget /Transfer/, MessageLevel level = INFO, int duration = 0 );
QgsMessageBarItem *pushWidget( QWidget *widget /Transfer/, Qgis::MessageLevel level = Qgis::Info, int duration = 0 );
%Docstring
Display a widget as a message on the bar after hiding the currently visible one
and putting it in a stack.

:param widget: message widget to display
:param level: is QgsMessageBar.INFO, WARNING, CRITICAL or SUCCESS
:param level: is Qgis.Info, Warning, Critical or Success
:param duration: timeout duration of message in seconds, 0 value indicates no timeout
%End

Expand All @@ -76,11 +69,11 @@ make out a widget containing title and message to be displayed on the bar
make out a widget containing title and message to be displayed on the bar
%End

void pushMessage( const QString &text, MessageLevel level = INFO, int duration = 5 );
void pushMessage( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 5 );
%Docstring
convenience method for pushing a message to the bar
%End
void pushMessage( const QString &title, const QString &text, MessageLevel level = INFO, int duration = 5 );
void pushMessage( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 5 );
%Docstring
convenience method for pushing a message with title to the bar
%End
Expand Down
12 changes: 6 additions & 6 deletions python/gui/qgsmessagebaritem.sip.in
Expand Up @@ -17,22 +17,22 @@ class QgsMessageBarItem : QWidget
#include "qgsmessagebaritem.h"
%End
public:
QgsMessageBarItem( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent /TransferThis/ = 0 );
QgsMessageBarItem( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent /TransferThis/ = 0 );
%Docstring
make out a widget containing a message to be displayed on the bar
%End

QgsMessageBarItem( const QString &title, const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent /TransferThis/ = 0 );
QgsMessageBarItem( const QString &title, const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent /TransferThis/ = 0 );
%Docstring
make out a widget containing title and message to be displayed on the bar
%End

QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent /TransferThis/ = 0 );
QgsMessageBarItem( const QString &title, const QString &text, QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent /TransferThis/ = 0 );
%Docstring
make out a widget containing title, message and widget to be displayed on the bar
%End

QgsMessageBarItem( QWidget *widget, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = 0, QWidget *parent /TransferThis/ = 0 );
QgsMessageBarItem( QWidget *widget, Qgis::MessageLevel level = Qgis::Info, int duration = 0, QWidget *parent /TransferThis/ = 0 );
%Docstring
make out a widget containing a widget to be displayed on the bar
%End
Expand All @@ -51,9 +51,9 @@ Returns the text for the message.
Returns the title for the message.
%End

QgsMessageBarItem *setLevel( QgsMessageBar::MessageLevel level );
QgsMessageBarItem *setLevel( Qgis::MessageLevel level );

QgsMessageBar::MessageLevel level() const;
Qgis::MessageLevel level() const;
%Docstring
Returns the message level for the message.
%End
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsmessagelogviewer.sip.in
Expand Up @@ -29,7 +29,7 @@ QgsApplication.messageLog() instance.

public slots:

void logMessage( const QString &message, const QString &tag, QgsMessageLog::MessageLevel level );
void logMessage( const QString &message, const QString &tag, Qgis::MessageLevel level );
%Docstring
Logs a ``message`` to the viewer.
%End
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgspluginmanagerinterface.sip.in
Expand Up @@ -56,7 +56,7 @@ add repository to the repository listWidget
show the Plugin Manager window and optionally open tab tabIndex
%End

virtual void pushMessage( const QString &text, QgsMessageBar::MessageLevel level = QgsMessageBar::INFO, int duration = -1 ) = 0;
virtual void pushMessage( const QString &text, Qgis::MessageLevel level = Qgis::Info, int duration = -1 ) = 0;
%Docstring
show the given message in the Plugin Manager internal message bar
%End
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/db_manager/db_manager.py
Expand Up @@ -29,7 +29,7 @@
from qgis.PyQt.QtGui import QIcon, QKeySequence

from qgis.gui import QgsMessageBar
from qgis.core import QgsSettings, QgsMapLayer
from qgis.core import Qgis, QgsSettings, QgsMapLayer
from qgis.utils import OverrideCursor

from .info_viewer import InfoViewer
Expand Down Expand Up @@ -146,7 +146,7 @@ def importActionSlot(self):
db = self.tree.currentDatabase()
if db is None:
self.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."),
QgsMessageBar.INFO, self.iface.messageTimeout())
Qgis.Info, self.iface.messageTimeout())
return

outUri = db.uri()
Expand All @@ -162,15 +162,15 @@ def importActionSlot(self):
def exportActionSlot(self):
table = self.tree.currentTable()
if table is None:
self.infoBar.pushMessage(self.tr("Select the table you want export to file."), QgsMessageBar.INFO,
self.infoBar.pushMessage(self.tr("Select the table you want export to file."), Qgis.Info,
self.iface.messageTimeout())
return

inLayer = table.toMapLayer()
if inLayer.type() != QgsMapLayer.VectorLayer:
self.infoBar.pushMessage(
self.tr("Select a vector or a tabular layer you want export."),
QgsMessageBar.WARNING, self.iface.messageTimeout())
Qgis.Warning, self.iface.messageTimeout())
return

from .dlg_export_vector import DlgExportVector
Expand All @@ -184,7 +184,7 @@ def runSqlWindow(self):
db = self.tree.currentDatabase()
if db is None:
self.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."),
QgsMessageBar.INFO, self.iface.messageTimeout())
Qgis.Info, self.iface.messageTimeout())
# force displaying of the message, it appears on the first tab (i.e. Info)
self.tabs.setCurrentIndex(0)
return
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/gpkg/plugin.py
Expand Up @@ -27,7 +27,7 @@
from qgis.PyQt.QtCore import Qt, QFileInfo
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import QApplication, QAction, QFileDialog
from qgis.core import QgsDataSourceUri, QgsSettings
from qgis.core import Qgis, QgsDataSourceUri, QgsSettings
from qgis.gui import QgsMessageBar

from ..plugin import DBPlugin, Database, Table, VectorTable, RasterTable, TableField, TableIndex, TableTrigger, \
Expand Down Expand Up @@ -143,7 +143,7 @@ def runVacuumActionSlot(self, item, action, parent):
try:
if not isinstance(item, (DBPlugin, Table)) or item.database() is None:
parent.infoBar.pushMessage(self.tr("No database selected or you are not connected to it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down
18 changes: 9 additions & 9 deletions python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -27,7 +27,7 @@
from qgis.PyQt.QtGui import QKeySequence, QIcon

from qgis.gui import QgsMessageBar
from qgis.core import QgsSettings
from qgis.core import Qgis, QgsSettings
from ..db_plugins import createDbPlugin


Expand Down Expand Up @@ -357,7 +357,7 @@ def deleteActionSlot(self, item, action, parent):
else:
QApplication.restoreOverrideCursor()
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
QApplication.setOverrideCursor(Qt.WaitCursor)

def createSchemaActionSlot(self, item, action, parent):
Expand All @@ -366,7 +366,7 @@ def createSchemaActionSlot(self, item, action, parent):
if not isinstance(item, (DBPlugin, Schema, Table)) or item.database() is None:
parent.infoBar.pushMessage(
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
(schema, ok) = QInputDialog.getText(parent, QApplication.translate("DBManagerPlugin", "New schema"),
QApplication.translate("DBManagerPlugin", "Enter new schema name"))
Expand All @@ -383,7 +383,7 @@ def deleteSchemaActionSlot(self, item, action, parent):
if not isinstance(item, Schema):
parent.infoBar.pushMessage(
QApplication.translate("DBManagerPlugin", "Select an empty schema for deletion."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
QApplication.translate("DBManagerPlugin",
Expand Down Expand Up @@ -414,7 +414,7 @@ def createTableActionSlot(self, item, action, parent):
if not hasattr(item, 'database') or item.database() is None:
parent.infoBar.pushMessage(
QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
from ..dlg_create_table import DlgCreateTable

Expand All @@ -426,7 +426,7 @@ def editTableActionSlot(self, item, action, parent):
try:
if not isinstance(item, Table) or item.isView:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table to edit."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
from ..dlg_table_properties import DlgTableProperties

Expand All @@ -440,7 +440,7 @@ def deleteTableActionSlot(self, item, action, parent):
if not isinstance(item, Table):
parent.infoBar.pushMessage(
QApplication.translate("DBManagerPlugin", "Select a table/view for deletion."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
QApplication.translate("DBManagerPlugin",
Expand All @@ -458,7 +458,7 @@ def emptyTableActionSlot(self, item, action, parent):
try:
if not isinstance(item, Table) or item.isView:
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table to empty it."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"),
QApplication.translate("DBManagerPlugin",
Expand All @@ -485,7 +485,7 @@ def moveTableToSchemaActionSlot(self, item, action, parent, new_schema):
try:
if not isinstance(item, Table):
parent.infoBar.pushMessage(QApplication.translate("DBManagerPlugin", "Select a table/view."),
QgsMessageBar.INFO, parent.iface.messageTimeout())
Qgis.Info, parent.iface.messageTimeout())
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down

0 comments on commit 3205c96

Please sign in to comment.