Skip to content

Commit

Permalink
Merge branch 'main' into fix_warning_about_SUBLANG_NEUTRAL
Browse files Browse the repository at this point in the history
  • Loading branch information
Montel authored Oct 9, 2024
2 parents 437d8ad + 36541c8 commit 828a5fd
Show file tree
Hide file tree
Showing 65 changed files with 988 additions and 2,433 deletions.
6 changes: 3 additions & 3 deletions docs/API/knut/cppdocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Inherited properties: [CodeDocument properties](../knut/codedocument.md#properti
|string |**[correspondingHeaderSource](#correspondingHeaderSource)**()|
|void |**[deleteMethod](#deleteMethod)**()|
|void |**[deleteMethod](#deleteMethod)**(string methodName)|
|void |**[deleteMethod](#deleteMethod)**(string method, string signature)|
|void |**[deleteMethod](#deleteMethod)**(string methodName, string signature)|
|int |**[gotoBlockEnd](#gotoBlockEnd)**(int count)|
|int |**[gotoBlockStart](#gotoBlockStart)**(int count)|
||**[insertCodeInMethod](#insertCodeInMethod)**(string methodName, string code, Position insertAt)|
Expand Down Expand Up @@ -142,9 +142,9 @@ Therefore, all overloads of the function will be deleted.

Also see: CppDocument::deleteMethod(string methodName, string signature)

#### <a name="deleteMethod"></a>void **deleteMethod**(string method, string signature)
#### <a name="deleteMethod"></a>void **deleteMethod**(string methodName, string signature)

Delete the method or function with the specified `method` and optional `signature`.
Delete the method or function with the specified `methodName` and `signature`.
The method definition/declaration will be deleted from the current file,
as well as the corresponding header/source file.
References to the method will not be deleted.
Expand Down
6 changes: 0 additions & 6 deletions docs/API/knut/textdocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ Inherited properties: [Document properties](../knut/document.md#properties)
||**[selectPreviousLine](#selectPreviousLine)**(int count = 1)|
||**[selectPreviousWord](#selectPreviousWord)**(int count = 1)|
||**[selectRange](#selectRange)**([RangeMark](../knut/rangemark.md) range)|
||**[selectRangeMark](#selectRangeMark)**([RangeMark](../knut/rangemark.md) mark)|
||**[selectRegion](#selectRegion)**(int from, int to)|
||**[selectStartOfLine](#selectStartOfLine)**(int count = 1)|
||**[selectStartOfWord](#selectStartOfWord)**()|
Expand Down Expand Up @@ -475,11 +474,6 @@ Selects the previous word, repeat the operation `count` times.

Selects the range passed in parameter.

#### <a name="selectRangeMark"></a>**selectRangeMark**([RangeMark](../knut/rangemark.md) mark)

Selects the text defined by the range make `mark`.


#### <a name="selectRegion"></a>**selectRegion**(int from, int to)

Selects the text between `from` and `to` positions.
Expand Down
12 changes: 6 additions & 6 deletions src/core/cppdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1594,9 +1594,9 @@ void CppDocument::deleteMethodLocal(const QString &methodName, const QString &si
}

/*!
* \qmlmethod void CppDocument::deleteMethod(string method, string signature)
* \qmlmethod void CppDocument::deleteMethod(string methodName, string signature)
*
* Delete the method or function with the specified `method` and optional `signature`.
* Delete the method or function with the specified `methodName` and `signature`.
* The method definition/declaration will be deleted from the current file,
* as well as the corresponding header/source file.
* References to the method will not be deleted.
Expand All @@ -1618,16 +1618,16 @@ void CppDocument::deleteMethodLocal(const QString &methodName, const QString &si
*
* If an empty string is provided as the `signature`, all overloads of the function are deleted as well.
*/
void CppDocument::deleteMethod(const QString &method, const QString &signature)
void CppDocument::deleteMethod(const QString &methodName, const QString &signature)
{
LOG(method, signature);
LOG(methodName, signature);

QString headerSourceName = correspondingHeaderSource();
if (!headerSourceName.isEmpty()) {
auto headerSource = qobject_cast<CppDocument *>(Project::instance()->get(headerSourceName));
headerSource->deleteMethodLocal(method, signature);
headerSource->deleteMethodLocal(methodName, signature);
}
deleteMethodLocal(method, signature);
deleteMethodLocal(methodName, signature);
}

/*!
Expand Down
4 changes: 2 additions & 2 deletions src/core/rcdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ QString extractStringForDialog(const RcCore::Data::Dialog *dialog, const QString
if (dialog) {
const auto control = findControlWithId(dialog, id);
if (!control) {
spdlog::warn("{}: control from id {} does not exist in the rc file.", FUNCTION_NAME, id);
spdlog::warn("{}: control from id \"{}\" does not exist in the rc file.", FUNCTION_NAME, id);
return {};
}
return control.value().text;
} else {
spdlog::warn("{}: id {} does not exist in the rc file.", FUNCTION_NAME, id);
spdlog::warn("{}: id \"{}\" does not exist in the rc file.", FUNCTION_NAME, id);
return {};
}
}
Expand Down
35 changes: 10 additions & 25 deletions src/core/textdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,11 @@ void TextDocument::selectRegion(int from, int to)
void TextDocument::selectRange(const RangeMark &range)
{
LOG(range);
selectRegion(range.start(), range.end());
if (range.document() != this) {
spdlog::error("{}: Can't use a range mark from another editor.", FUNCTION_NAME);
return;
}
range.select();
}

/*!
Expand Down Expand Up @@ -1017,11 +1021,11 @@ void TextDocument::deleteRegion(int from, int to)
void TextDocument::deleteRange(const RangeMark &range)
{
LOG(range);
QTextCursor cursor(m_document->document());
cursor.setPosition(range.start(), QTextCursor::MoveAnchor);
cursor.setPosition(range.end(), QTextCursor::KeepAnchor);
cursor.removeSelectedText();
m_document->setTextCursor(cursor);
if (range.document() != this) {
spdlog::error("{}: Can't use a range mark from another editor.", FUNCTION_NAME);
return;
}
range.remove();
}

/*!
Expand Down Expand Up @@ -1185,25 +1189,6 @@ Core::RangeMark TextDocument::createRangeMark()
LOG_RETURN("rangeMark", createRangeMark(start, end));
}

/**
* \qmlmethod TextDocument::selectRangeMark(RangeMark mark)
*
* Selects the text defined by the range make `mark`.
*
* \sa RangeMark
*/
void TextDocument::selectRangeMark(const Core::RangeMark &mark)
{
LOG(LOG_ARG("mark", mark));

if (mark.document() != this) {
spdlog::error("{}: Can't use a range mark from another editor.", FUNCTION_NAME);
return;
}

mark.select();
}

/*!
* \qmlmethod bool TextDocument::find(string text, int options = TextDocument.NoFindFlags)
* Searches the string `text` in the editor. Options could be a combination of:
Expand Down
11 changes: 5 additions & 6 deletions src/core/textdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,13 @@ public slots:
void paste();
void cut();

// Text handling
void remove(int length);
// Insertion
void insert(const QString &text);
void insertAtLine(const QString &text, int line = -1);
void insertAtPosition(const QString &text, int pos);
void replace(int length, const QString &text);
void replace(int from, int to, const QString &text);
void replace(const Core::RangeMark &range, const QString &text);

// Deletion
void remove(int length);
void deleteLine(int line = -1);
void deleteSelection();
void deleteEndOfLine();
Expand All @@ -171,14 +168,16 @@ public slots:
// RangeMark
Core::RangeMark createRangeMark(int from, int to);
Core::RangeMark createRangeMark();
void selectRangeMark(const Core::RangeMark &mark);

// Find
bool find(const QString &text, int options = NoFindFlags);
bool findRegexp(const QString &regexp, int options = NoFindFlags);
QString match(const QString &regexp, int options = NoFindFlags);

// Replace
void replace(int length, const QString &text);
void replace(int from, int to, const QString &text);
void replace(const Core::RangeMark &range, const QString &text);
bool replaceOne(const QString &before, const QString &after, int options = NoFindFlags);
int replaceAll(const QString &before, const QString &after, int options = NoFindFlags);
int replaceAllInRange(const QString &before, const QString &after, const Core::RangeMark &range,
Expand Down
29 changes: 11 additions & 18 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,27 +276,20 @@ MainWindow::MainWindow(QWidget *parent)
updateScriptActions();
}

static void actionsFromMenu(QMenu *menu, QList<QAction *> &actions)
{
const auto &menuActions = menu->actions();
for (QAction *action : menuActions) {
if (action->isSeparator())
continue;
else if (action->menu()) {
if (action->menu()->objectName() == "recentProjectsMenu")
continue;
actionsFromMenu(action->menu(), actions);
} else
actions.push_back(action);
}
}

QList<QAction *> MainWindow::menuActions() const
{
QList<QAction *> actions;
const auto &menus = menuBar()->findChildren<QMenu *>();
for (QMenu *menu : menus)
actionsFromMenu(menu, actions);
const auto &actionMenus = menuBar()->actions();
for (auto action : actionMenus) {
if (action->menu()) {
const auto acts = action->menu()->actions();
for (const auto &currentAction : acts) {
if (!currentAction->text().isEmpty()) {
actions.append(currentAction);
}
}
}
}
actions.append(QMainWindow::actions());
return actions;
}
Expand Down
3 changes: 3 additions & 0 deletions src/gui/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@
</item>
<item row="1" column="0" rowspan="3">
<widget class="QTreeWidget" name="languageMap">
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
Expand Down
2 changes: 1 addition & 1 deletion src/rccore/rc_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static Widget convertCheckBox(const Data &data, Data::Control &control)
return widget;
}

// TODO
// https://learn.microsoft.com/en-us/windows/desktop/menurc/combobox-control
static Widget convertComboBox(const Data &data, const QString &dialogId, Data::Control &control)
{
Widget widget;
Expand Down
3 changes: 2 additions & 1 deletion src/rccore/rc_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ static QHash<int, QString> loadResourceFile(const QString &resourceFile)

QTextStream stream(&file);
QHash<int, QString> resourceMap;
static QRegularExpression empty_spaces("\\s+");
while (!stream.atEnd()) {
const QString line = stream.readLine();
if (!line.startsWith("#define"))
continue;

QStringList fields = line.split(' ', Qt::SkipEmptyParts);
QStringList fields = line.split(empty_spaces, Qt::SkipEmptyParts);
if (fields.size() < 3)
continue;
const auto &value = fields.at(1);
Expand Down
92 changes: 92 additions & 0 deletions test_data/projects/mfc-dialog/Tutorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

// Tutorial.cpp : Defines the class behaviors for the application.
//

#include "pch.h"
#include "framework.h"
#include "Tutorial.h"
#include "TutorialDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CTutorialApp

BEGIN_MESSAGE_MAP(CTutorialApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


// CTutorialApp construction

CTutorialApp::CTutorialApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}


// The one and only CTutorialApp object

CTutorialApp theApp;


// CTutorialApp initialization

BOOL CTutorialApp::InitInstance()
{
CWinApp::InitInstance();


// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;

// Activate "Windows Native" visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));

CTutorialDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n");
TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n");
}

// Delete the shell manager created above.
if (pShellManager != nullptr)
{
delete pShellManager;
}

#if !defined(_AFXDLL) && !defined(_AFX_NO_MFC_CONTROLS_IN_DIALOGS)
ControlBarCleanUp();
#endif

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}

32 changes: 32 additions & 0 deletions test_data/projects/mfc-dialog/Tutorial.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

// Tutorial.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
#error "include 'pch.h' before including this file for PCH"
#endif

#include "resource.h" // main symbols


// CTutorialApp:
// See Tutorial.cpp for the implementation of this class
//

class CTutorialApp : public CWinApp
{
public:
CTutorialApp();

// Overrides
public:
virtual BOOL InitInstance();

// Implementation

DECLARE_MESSAGE_MAP()
};

extern CTutorialApp theApp;
Binary file added test_data/projects/mfc-dialog/Tutorial.rc
Binary file not shown.
Loading

0 comments on commit 828a5fd

Please sign in to comment.