39      , mProvider( provider )
 
   50class DatabaseQueryValueNode : 
public DatabaseQueryHistoryNode
 
   55      : DatabaseQueryHistoryNode( entry, provider )
 
   59    QVariant data( 
int role = Qt::DisplayRole )
 const override 
   83class DatabaseQueryRootNode : 
public DatabaseQueryHistoryNode
 
   88      : DatabaseQueryHistoryNode( entry, provider )
 
   92      mProviderKey = mEntry.entry.value( QStringLiteral( 
"provider" ) ).toString();
 
   95    QVariant data( 
int role = Qt::DisplayRole )
 const override 
  100        case Qt::ToolTipRole:
 
  101          return mEntry.entry.value( QStringLiteral( 
"query" ) );
 
  103        case Qt::DecorationRole:
 
  105          if ( !mProviderIcon.isNull() )
 
  106            return mProviderIcon;
 
  110            mProviderIcon = md->icon();
 
  112          return mProviderIcon;
 
  123      if ( !mConnectionNode )
 
  125        mConnectionNode = 
new DatabaseQueryValueNode( mEntry, mProvider, QObject::tr( 
"Connection: %1" ).arg( entry.
entry.value( QStringLiteral( 
"connection" ) ).toString() ) );
 
  126        addChild( mConnectionNode );
 
  128      if ( entry.
entry.contains( QStringLiteral( 
"rows" ) ) )
 
  132          mRowsNode = 
new DatabaseQueryValueNode( mEntry, mProvider, QObject::tr( 
"Row count: %1" ).arg( entry.
entry.value( QStringLiteral( 
"rows" ) ).toString() ) );
 
  133          addChild( mRowsNode );
 
  136      if ( entry.
entry.contains( QStringLiteral( 
"time" ) ) )
 
  140          mTimeNode = 
new DatabaseQueryValueNode( mEntry, mProvider, QObject::tr( 
"Execution time: %1 ms" ).arg( entry.
entry.value( QStringLiteral( 
"time" ) ).toString() ) );
 
  141          addChild( mTimeNode );
 
  149      editor->setText( mEntry.entry.value( QStringLiteral( 
"query" ) ).toString() );
 
  150      editor->setReadOnly( 
true );
 
  151      editor->setCaretLineVisible( 
false );
 
  154      editor->setEdgeMode( QsciScintilla::EdgeNone );
 
  155      editor->setWrapMode( QsciScintilla::WrapMode::WrapWord );
 
  161      mProvider->emitOpenSqlDialog( mEntry.entry.value( QStringLiteral( 
"connection" ) ).toString(),
 
  162                                    mEntry.entry.value( QStringLiteral( 
"provider" ) ).toString(),
 
  163                                    mEntry.entry.value( QStringLiteral( 
"query" ) ).toString() );
 
  169      QAction *executeAction = 
new QAction(
 
  170        QObject::tr( 
"Execute SQL Command…" ), menu );
 
  171      QObject::connect( executeAction, &QAction::triggered, menu, [ = ]
 
  173        mProvider->emitOpenSqlDialog( mEntry.entry.value( QStringLiteral( 
"connection" ) ).toString(),
 
  174                                      mEntry.entry.value( QStringLiteral( 
"provider" ) ).toString(),
 
  175                                      mEntry.entry.value( QStringLiteral( 
"query" ) ).toString() );
 
  177      menu->addAction( executeAction );
 
  179      QAction *copyAction = 
new QAction(
 
  180        QObject::tr( 
"Copy SQL Command" ), menu );
 
  182      QObject::connect( copyAction, &QAction::triggered, menu, [ = ]
 
  184        QMimeData *m = 
new QMimeData();
 
  185        m->setText( mEntry.entry.value( QStringLiteral( 
"query" ) ).toString() );
 
  186        QApplication::clipboard()->setMimeData( m );
 
  188      menu->addAction( copyAction );
 
  193    QString mProviderKey;
 
  194    mutable QIcon mProviderIcon;
 
  195    DatabaseQueryValueNode *mConnectionNode = 
nullptr;
 
  196    DatabaseQueryValueNode *mRowsNode = 
nullptr;
 
  197    DatabaseQueryValueNode *mTimeNode = 
nullptr;
 
  210  return QStringLiteral( 
"dbquery" );
 
  215  return new DatabaseQueryRootNode( entry, 
this );
 
  220  if ( DatabaseQueryRootNode *dbNode = 
dynamic_cast< DatabaseQueryRootNode * 
>( node ) )
 
  222    dbNode->setEntry( entry );
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
A SQL editor based on QScintilla2.
 
void setFoldingVisible(bool folding)
Set whether the folding controls are visible in the editor.
 
void setLineNumbersVisible(bool visible)
Sets whether line numbers should be visible in the editor.
 
History provider for operations database queries.
 
void emitOpenSqlDialog(const QString &connectionUri, const QString &provider, const QString &sql)
Causes the provider to emit the openSqlDialog() signal.
 
void updateNodeForEntry(QgsHistoryEntryNode *node, const QgsHistoryEntry &entry, const QgsHistoryWidgetContext &context) override
Updates an existing history node for the given entry.
 
QgsDatabaseQueryHistoryProvider()
 
QString id() const override
Returns the provider's unique id, which is used to associate existing history entries with the provid...
 
void openSqlDialog(const QString &connectionUri, const QString &provider, const QString &sql)
Emitted when the provider wants to trigger a SQL execution dialog.
 
QgsHistoryEntryNode * createNodeForEntry(const QgsHistoryEntry &entry, const QgsHistoryWidgetContext &context) override
Creates a new history node for the given entry.
 
Base class for history entry "group" nodes, which contain children of their own.
 
Base class for nodes representing a QgsHistoryEntry.
 
Encapsulates a history entry.
 
QVariantMap entry
Entry details.
 
Contains settings which reflect the context in which a history widget is shown, e....
 
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.