Qt5: added QCompleter class to C bindings

This commit is contained in:
Željan Rikalo 2022-11-16 17:19:40 +01:00
parent aca205317b
commit 8d525e3eb7
5 changed files with 449 additions and 0 deletions

View File

@ -0,0 +1,217 @@
//******************************************************************************
// Copyright (c) 2022 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#include "qcompleter_c.h"
QCompleterH QCompleter_Create()
{
return (QCompleterH) new QCompleter();
}
QCompleterH QCompleter_Create2(QObjectH parent)
{
return (QCompleterH) new QCompleter((QObject*)parent);
}
QCompleterH QCompleter_Create3(QAbstractItemModelH model, QObjectH parent)
{
return (QCompleterH) new QCompleter((QAbstractItemModel *) model, (QObject *) parent);
}
QCompleterH QCompleter_Create4(QStringListH list, QObjectH parent)
{
return (QCompleterH) new QCompleter(*(const QStringList *) list, (QObject *)parent);
}
void QCompleter_Destroy(QCompleterH handle)
{
delete (QCompleter *)handle;
}
Qt::CaseSensitivity QCompleter_caseSensitivity(QCompleterH handle)
{
return (Qt::CaseSensitivity) ((QCompleter *)handle)->caseSensitivity();
}
int QCompleter_completionColumn(QCompleterH handle)
{
return (int) ((QCompleter *)handle)->completionColumn();
}
int QCompleter_completionCount(QCompleterH handle)
{
return (int) ((QCompleter *)handle)->completionCount();
}
QCompleter::CompletionMode QCompleter_completionMode(QCompleterH handle)
{
return (QCompleter::CompletionMode) ((QCompleter *)handle)->completionMode();
}
QAbstractItemModelH QCompleter_completionModel(QCompleterH handle)
{
return (QAbstractItemModelH) ((QCompleter *)handle)->completionModel();
}
void QCompleter_completionPrefix(QCompleterH handle, PWideString retval)
{
QString t_retval;
t_retval = ((QCompleter *)handle)->completionPrefix();
copyQStringToPWideString(t_retval, retval);
}
int QCompleter_completionRole(QCompleterH handle)
{
return (int) ((QCompleter *)handle)->completionRole();
}
void QCompleter_currentCompletion(QCompleterH handle, PWideString retval)
{
QString t_retval;
t_retval = ((QCompleter *)handle)->currentCompletion();
copyQStringToPWideString(t_retval, retval);
}
void QCompleter_currentIndex(QCompleterH handle, QModelIndexH retval)
{
*(QModelIndex*)retval = ((QCompleter *)handle)->currentIndex();
}
int QCompleter_currentRow(QCompleterH handle)
{
return (int) ((QCompleter *)handle)->currentRow();
}
Qt::MatchFlags QCompleter_filterMode(QCompleterH handle)
{
return (Qt::MatchFlags) ((QCompleter *)handle)->filterMode();
}
int QCompleter_maxVisibleItems(QCompleterH handle)
{
return (int) ((QCompleter *)handle)->maxVisibleItems();
}
QAbstractItemModelH QCompleter_model(QCompleterH handle)
{
return (QAbstractItemModelH) ((QCompleter *)handle)->model();
}
QCompleter::ModelSorting QCompleter_modelSorting(QCompleterH handle)
{
return (QCompleter::ModelSorting) ((QCompleter *)handle)->modelSorting();
}
void QCompleter_pathFromIndex(QCompleterH handle, QModelIndexH model, PWideString retval)
{
QString t_retval;
t_retval = ((QCompleter *)handle)->pathFromIndex(*(QModelIndex *)model);
copyQStringToPWideString(t_retval, retval);
}
QAbstractItemViewH QCompleter_popup(QCompleterH handle)
{
return (QAbstractItemViewH) ((QCompleter *)handle)->popup();
}
void QCompleter_setCaseSensitivity(QCompleterH handle, Qt::CaseSensitivity caseSensitivity)
{
((QCompleter *)handle)->setCaseSensitivity(caseSensitivity);
}
void QCompleter_setCompletionColumn(QCompleterH handle, int column)
{
((QCompleter *)handle)->setCompletionColumn(column);
}
void QCompleter_setCompletionMode(QCompleterH handle, QCompleter::CompletionMode mode)
{
((QCompleter *)handle)->setCompletionMode(mode);
}
void QCompleter_setCompletionRole(QCompleterH handle, int role)
{
((QCompleter *)handle)->setCompletionRole(role);
}
void QCompleter_setCurrentRow(QCompleterH handle, int row)
{
((QCompleter *)handle)->setCurrentRow(row);
}
void QCompleter_setFilterMode(QCompleterH handle, Qt::MatchFlags filterMode)
{
((QCompleter *)handle)->setFilterMode(filterMode);
}
void QCompleter_setMaxVisibleItems(QCompleterH handle, int maxItems)
{
((QCompleter *)handle)->setMaxVisibleItems(maxItems);
}
void QCompleter_setModel(QCompleterH handle, QAbstractItemModelH model)
{
((QCompleter *)handle)->setModel((QAbstractItemModel*)model);
}
void QCompleter_setModelSorting(QCompleterH handle, QCompleter::ModelSorting sorting)
{
((QCompleter *)handle)->setModelSorting(sorting);
}
void QCompleter_setPopup(QCompleterH handle, QAbstractItemViewH popup)
{
((QCompleter *)handle)->setPopup((QAbstractItemView *)popup);
}
void QCompleter_setWidget(QCompleterH handle, QWidgetH widget)
{
((QCompleter *)handle)->setWidget((QWidget *)widget);
}
void QCompleter_splitPath(QCompleterH handle, PWideString path, QStringListH retval)
{
QString t_path;
copyPWideStringToQString(path, t_path);
*(QStringList *)retval = ((QCompleter *)handle)->splitPath(t_path);
}
QWidgetH QCompleter_widget(QCompleterH handle)
{
return (QWidgetH) ((QCompleter *)handle)->widget();
}
bool QCompleter_wrapAround(QCompleterH handle)
{
return (bool) ((QCompleter *)handle)->wrapAround();
}
void QCompleter_complete(QCompleterH handle, PRect rect)
{
QRect t_rect;
copyPRectToQRect(rect, t_rect);
((QCompleter *)handle)->complete(t_rect);
}
void QCompleter_setCompletionPrefix(QCompleterH handle, PWideString prefix)
{
QString t_prefix;
copyPWideStringToQString(prefix, t_prefix);
((QCompleter *)handle)->setCompletionPrefix(t_prefix);
}
void QCompleter_setWrapAround(QCompleterH handle, bool wrap)
{
((QCompleter *)handle)->setWrapAround(wrap);
}

View File

@ -0,0 +1,57 @@
//******************************************************************************
// Copyright (c) 2022 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QCOMPLETER_C_H
#define QCOMPLETER_C_H
#include <QtWidgets>
#include "pascalbind.h"
C_EXPORT QCompleterH QCompleter_Create();
C_EXPORT QCompleterH QCompleter_Create2(QObjectH parent);
C_EXPORT QCompleterH QCompleter_Create3(QAbstractItemModelH model, QObjectH parent);
C_EXPORT QCompleterH QCompleter_Create4(QStringListH list, QObjectH parent);
C_EXPORT void QCompleter_Destroy(QCompleterH handle);
C_EXPORT Qt::CaseSensitivity QCompleter_caseSensitivity(QCompleterH handle);
C_EXPORT int QCompleter_completionColumn(QCompleterH handle);
C_EXPORT int QCompleter_completionCount(QCompleterH handle);
C_EXPORT QCompleter::CompletionMode QCompleter_completionMode(QCompleterH handle);
C_EXPORT QAbstractItemModelH QCompleter_completionModel(QCompleterH handle);
C_EXPORT void QCompleter_completionPrefix(QCompleterH handle, PWideString retval);
C_EXPORT int QCompleter_completionRole(QCompleterH handle);
C_EXPORT void QCompleter_currentCompletion(QCompleterH handle, PWideString retval);
C_EXPORT void QCompleter_currentIndex(QCompleterH handle,QModelIndexH retval);
C_EXPORT int QCompleter_currentRow(QCompleterH handle);
C_EXPORT Qt::MatchFlags QCompleter_filterMode(QCompleterH handle);
C_EXPORT int QCompleter_maxVisibleItems(QCompleterH handle);
C_EXPORT QAbstractItemModelH QCompleter_model(QCompleterH handle);
C_EXPORT QCompleter::ModelSorting QCompleter_modelSorting(QCompleterH handle);
C_EXPORT void QCompleter_pathFromIndex(QCompleterH handle, QModelIndexH model, PWideString retval);
C_EXPORT QAbstractItemViewH QCompleter_popup(QCompleterH handle);
C_EXPORT void QCompleter_setCaseSensitivity(QCompleterH handle, Qt::CaseSensitivity caseSensitivity);
C_EXPORT void QCompleter_setCompletionColumn(QCompleterH handle, int column);
C_EXPORT void QCompleter_setCompletionMode(QCompleterH handle, QCompleter::CompletionMode mode);
C_EXPORT void QCompleter_setCompletionRole(QCompleterH handle, int role);
C_EXPORT void QCompleter_setCurrentRow(QCompleterH handle, int row);
C_EXPORT void QCompleter_setFilterMode(QCompleterH handle, Qt::MatchFlags filterMode);
C_EXPORT void QCompleter_setMaxVisibleItems(QCompleterH handle, int maxItems);
C_EXPORT void QCompleter_setModel(QCompleterH handle, QAbstractItemModelH model);
C_EXPORT void QCompleter_setModelSorting(QCompleterH handle, QCompleter::ModelSorting sorting);
C_EXPORT void QCompleter_setPopup(QCompleterH handle, QAbstractItemViewH popup);
C_EXPORT void QCompleter_setWidget(QCompleterH handle, QWidgetH widget);
C_EXPORT void QCompleter_splitPath(QCompleterH handle, PWideString path, QStringListH retval);
C_EXPORT QWidgetH QCompleter_widget(QCompleterH handle);
C_EXPORT bool QCompleter_wrapAround(QCompleterH handle);
C_EXPORT void QCompleter_complete(QCompleterH handle, PRect rect);
C_EXPORT void QCompleter_setCompletionPrefix(QCompleterH handle, PWideString prefix);
C_EXPORT void QCompleter_setWrapAround(QCompleterH handle, bool wrap);
#endif

View File

@ -0,0 +1,106 @@
//******************************************************************************
// Copyright (c) 2022 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QCOMPLETER_HOOK_H
#define QCOMPLETER_HOOK_H
#include <qcompleter.h>
#include "qobject_hook.h"
class QCompleter_hook : public QObject_hook {
Q_OBJECT
public:
QCompleter_hook(QObject *handle) : QObject_hook(handle) {
activated_event.func = NULL;
activated2_event.func = NULL;
highlighted_event.func = NULL;
highlighted2_event.func = NULL;
}
void hook_activated(QHook &hook) {
if ( !activated_event.func )
connect(handle, SIGNAL(activated(const QModelIndex&)), this, SLOT(activated_hook(const QModelIndex&)));
activated_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(activated(const QModelIndex&)), this, SLOT(activated_hook(const QModelIndex&)));
}
void hook_activated2(QHook &hook) {
if ( !activated2_event.func )
connect(handle, SIGNAL(activated(const QString&)), this, SLOT(activated2_hook(const QString&)));
activated2_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(activated(const QString&)), this, SLOT(activated2_hook(const QString&)));
}
void hook_highlighted(QHook &hook) {
if ( !highlighted_event.func )
connect(handle, SIGNAL(highlighted(const QModelIndex&)), this, SLOT(highlighted_hook(const QModelIndex&)));
highlighted_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(highlighted(const QModelIndex&)), this, SLOT(highlighted_hook(const QModelIndex&)));
}
void hook_highlighted2(QHook &hook) {
if ( !highlighted2_event.func )
connect(handle, SIGNAL(highlighted(const QString&)), this, SLOT(highlighted2_hook(const QString&)));
highlighted2_event = hook;
if ( !hook.func )
disconnect(handle, SIGNAL(highlighted(const QString&)), this, SLOT(highlighted2_hook(const QString&)));
}
private slots:
void activated_hook(const QModelIndex& index) {
if ( activated_event.func ) {
typedef void (*func_type)(void *data, const QModelIndexH index);
(*(func_type)activated_event.func)(activated_event.data, (const QModelIndexH)&index);
}
}
void activated2_hook(const QString& AnonParam1) {
if ( activated2_event.func ) {
typedef void (*func_type)(void *data, PWideString AnonParam1);
PWideString t_AnonParam1;
initializePWideString(t_AnonParam1);
copyQStringToPWideString(AnonParam1, t_AnonParam1);
(*(func_type)activated2_event.func)(activated2_event.data, t_AnonParam1);
finalizePWideString(t_AnonParam1);
}
}
void highlighted_hook(const QModelIndex& index) {
if ( highlighted_event.func ) {
typedef void (*func_type)(void *data, const QModelIndexH index);
(*(func_type)highlighted_event.func)(highlighted_event.data, (const QModelIndexH)&index);
}
}
void highlighted2_hook(const QString& AnonParam1) {
if ( highlighted2_event.func ) {
typedef void (*func_type)(void *data, PWideString AnonParam1);
PWideString t_AnonParam1;
initializePWideString(t_AnonParam1);
copyQStringToPWideString(AnonParam1, t_AnonParam1);
(*(func_type)highlighted2_event.func)(highlighted2_event.data, t_AnonParam1);
finalizePWideString(t_AnonParam1);
}
}
private:
QHook activated_event;
QHook activated2_event;
QHook highlighted_event;
QHook highlighted2_event;
};
#endif

View File

@ -0,0 +1,45 @@
//******************************************************************************
// Copyright (c) 2022 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#include "qcompleter_hook_c.h"
QCompleter_hookH QCompleter_hook_Create(QObjectH handle)
{
return (QCompleter_hookH) new QCompleter_hook((QObject*)handle);
}
void QCompleter_hook_Destroy(QCompleter_hookH handle)
{
delete (QCompleter_hook *)handle;
}
void QCompleter_hook_hook_activated(QCompleter_hookH handle, QHookH hook)
{
((QCompleter_hook *)handle)->hook_activated(hook);
}
void QCompleter_hook_hook_activated2(QCompleter_hookH handle, QHookH hook)
{
((QCompleter_hook *)handle)->hook_activated2(hook);
}
void QCompleter_hook_hook_highlighted(QCompleter_hookH handle, QHookH hook)
{
((QCompleter_hook *)handle)->hook_highlighted(hook);
}
void QCompleter_hook_hook_highlighted2(QCompleter_hookH handle, QHookH hook)
{
((QCompleter_hook *)handle)->hook_highlighted2(hook);
}

View File

@ -0,0 +1,24 @@
//******************************************************************************
// Copyright (c) 2022 by Željan Rikalo
//
// See the included file COPYING.TXT for details about the copyright.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//******************************************************************************
#ifndef QCOMPLETER_HOOK_C_H
#define QCOMPLETER_HOOK_C_H
#include "qcompleter_hook.h"
C_EXPORT QCompleter_hookH QCompleter_hook_Create(QObjectH handle);
C_EXPORT void QCompleter_hook_Destroy(QCompleter_hookH handle);
C_EXPORT void QCompleter_hook_hook_activated(QCompleter_hookH handle, QHookH hook);
C_EXPORT void QCompleter_hook_hook_activated2(QCompleter_hookH handle, QHookH hook);
C_EXPORT void QCompleter_hook_hook_highlighted(QCompleter_hookH handle, QHookH hook);
C_EXPORT void QCompleter_hook_hook_highlighted2(QCompleter_hookH handle, QHookH hook);
#endif