swift
form.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "gui/editors/form.h"
5 
6 #include <QApplication>
7 #include <QClipboard>
8 #include <QShortcut>
9 
10 #include "gui/guiutility.h"
11 
12 using namespace swift::misc;
13 using namespace swift::misc::network;
14 
15 namespace swift::gui::editors
16 {
17  CForm::CForm(QWidget *parent) : COverlayMessagesFrame(parent) {}
18 
20 
21  void CForm::setSelectOnly() { this->setReadOnly(true); }
22 
23  CStatusMessageList CForm::validate(bool withNestedObjects) const
24  {
25  Q_UNUSED(withNestedObjects);
26  return CStatusMessageList();
27  }
28 
29  CStatusMessageList CForm::validateAsOverlayMessage(bool withNestedObjects, bool appendOldMessages,
30  std::chrono::milliseconds timeout)
31  {
32  const CStatusMessageList msgs = this->validate(withNestedObjects);
33  this->showOverlayMessages(msgs, appendOldMessages, timeout);
34  return msgs;
35  }
36 
37  void CForm::jsonPasted(const QString &json) { Q_UNUSED(json); }
38 
40  {
41  if (!QApplication::clipboard()) { return; }
42  const QString data = QApplication::clipboard()->text();
43  if (!json::looksLikeSwiftJson(data)) { return; }
44  this->jsonPasted(data);
45  }
46 
48 
49  CFormDbUser::CFormDbUser(QWidget *parent) : CForm(parent) {}
50 
52 
54 
56  {
57  // void
58  }
59 } // namespace swift::gui::editors
static void forceStyleSheetUpdate(QWidget *widget)
Forces a stylesheet update.
Definition: guiutility.cpp:833
void showOverlayMessages(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages.
Using this class provides a QFrame with the overlay functionality already integrated.
swift::misc::CDataReadOnly< swift::core::data::TAuthenticatedDbUser > m_swiftDbUser
authenticated user
Definition: form.h:89
swift::misc::network::CAuthenticatedUser getSwiftDbUser() const
Authenticated DB user.
Definition: form.cpp:53
virtual void userChanged()
User has been changed.
Definition: form.cpp:55
CFormDbUser(QWidget *parent=nullptr)
Constructor.
Definition: form.cpp:49
virtual ~CFormDbUser()
Destructor.
Definition: form.cpp:51
Form base class.
Definition: form.h:27
virtual swift::misc::CStatusMessageList validate(bool withNestedObjects=true) const
Validate, empty list means OK.
Definition: form.cpp:23
void forceStyleSheetUpdate()
Forces a stylesheet update.
Definition: form.cpp:47
void pasted()
Pasted from clipboard.
Definition: form.cpp:39
virtual void jsonPasted(const QString &json)
JSON string has been pasted.
Definition: form.cpp:37
virtual void setSelectOnly()
Read only, but entity can be selected (normally used in mapping). Use setReadOnly to reset this very ...
Definition: form.cpp:21
virtual void setReadOnly(bool readOnly)=0
Set editable.
virtual ~CForm()
Destructor.
Definition: form.cpp:19
swift::misc::CStatusMessageList validateAsOverlayMessage(bool withNestedObjects=true, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Validate as overlay message.
Definition: form.cpp:29
T get() const
Get a copy of the current value.
Definition: valuecache.h:408
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of an authentiated user.
Free functions in swift::misc.