tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / dbaccess / source / ui / inc / sqlmessage.hxx
blob481732985d12f9ff6c264091301778764cc7097b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <connectivity/dbexception.hxx>
23 #include <vcl/weld.hxx>
24 #include <memory>
26 // some forwards
27 namespace com::sun::star {
28 namespace sdb {
29 class SQLContext;
31 namespace sdbc {
32 class SQLException;
36 namespace dbaui
39 enum MessageType
41 Info,
42 Error,
43 Warning,
44 Query,
45 AUTO
48 enum class MessBoxStyle {
49 NONE = 0x0000,
50 Ok = 0x0001,
51 OkCancel = 0x0002,
52 YesNo = 0x0004,
53 YesNoCancel = 0x0008,
54 RetryCancel = 0x0010,
55 DefaultOk = 0x0020,
56 DefaultCancel = 0x0040,
57 DefaultRetry = 0x0080,
58 DefaultYes = 0x0100,
59 DefaultNo = 0x0200,
64 namespace o3tl {
65 template<> struct typed_flags<dbaui::MessBoxStyle> : is_typed_flags<dbaui::MessBoxStyle, 0x03ff> {};
69 namespace dbaui
72 // OSQLMessageBox
73 struct SQLMessageBox_Impl;
74 class OSQLMessageBox : public weld::DialogController
76 std::unique_ptr<weld::MessageDialog> m_xDialog;
77 std::unique_ptr<weld::Button> m_xMoreButton;
78 std::unique_ptr<SQLMessageBox_Impl> m_pImpl;
79 OUString m_sHelpURL;
81 virtual weld::Dialog* getDialog() override { return m_xDialog.get(); }
82 public:
83 /** display an SQLException with auto-recognizing a main and a detailed message
85 The first two messages from the exception chain are used as main and detailed message (recognizing the
86 detailed field of an <type scope="css::sdb">SQLContext</type>).
88 OSQLMessageBox(
89 weld::Window* pParent,
90 const dbtools::SQLExceptionInfo& _rException,
91 MessBoxStyle _nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
92 OUString _sHelpURL = OUString()
95 /** display a database related error message
97 @param rTitle the title to display
98 @param rMessage the detailed message to display
99 @param _eType determines the image to use. AUTO is disallowed in this constructor version
101 OSQLMessageBox(weld::Window* pParent,
102 const OUString& rTitle,
103 const OUString& rMessage,
104 MessBoxStyle nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
105 MessageType _eType = Info,
106 const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = nullptr );
108 void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
109 void add_button(const OUString& rText, int nResponse, const OUString& rHelpId = {}) { m_xDialog->add_button(rText, nResponse, rHelpId); }
110 void set_default_response(int nResponse) { m_xDialog->set_default_response(nResponse); }
112 virtual ~OSQLMessageBox() override;
114 private:
115 void Construct(weld::Window* pParent, MessBoxStyle nStyle, MessageType eImage);
117 DECL_LINK(ButtonClickHdl, weld::Button&, void);
119 private:
120 void impl_fillMessages();
121 void impl_createStandardButtons( MessBoxStyle _nStyle );
122 void impl_addDetailsButton();
125 // OSQLWarningBox
126 class OSQLWarningBox : public OSQLMessageBox
128 public:
129 OSQLWarningBox( weld::Window* pParent,
130 const OUString& _rMessage,
131 MessBoxStyle _nStyle = MessBoxStyle::Ok | MessBoxStyle::DefaultOk,
132 const ::dbtools::SQLExceptionInfo* _pAdditionalErrorInfo = nullptr );
135 // OSQLErrorBox
136 class OSQLErrorBox : public OSQLMessageBox
138 public:
139 OSQLErrorBox( weld::Window* pParent,
140 const OUString& _rMessage );
143 } // namespace dbaui
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */