RedPanda-CPP/RedPandaIDE/widgets/functiontooltipwidget.h

83 lines
2.3 KiB
C
Raw Normal View History

2021-12-26 23:18:28 +08:00
/*
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2021-09-22 17:43:21 +08:00
#ifndef FUNCTIONTOOLTIPWIDGET_H
#define FUNCTIONTOOLTIPWIDGET_H
#include <QLabel>
#include <QToolButton>
#include <QWidget>
2022-01-04 16:50:54 +08:00
#include <memory>
2021-09-22 17:43:21 +08:00
struct FunctionInfo {
QString name;
QString fullname;
QStringList params;
QStringList nonameParams;
QString returnType;
};
using PFunctionInfo = std::shared_ptr<FunctionInfo>;
2021-09-25 21:34:10 +08:00
class FunctionTooltipWidget : public QFrame
2021-09-22 17:43:21 +08:00
{
Q_OBJECT
public:
explicit FunctionTooltipWidget(QWidget *parent = nullptr);
void addTip(const QString& name, const QString& fullName,
const QString& returnType, const QString& args,
const QString& noNameArgs);
void clearTips();
2021-09-24 22:49:36 +08:00
int tipCount();
2021-09-22 17:43:21 +08:00
int paramPos() const;
void setParamPos(int newParamPos);
2021-09-24 11:41:14 +08:00
void nextTip();
void previousTip();
void updateTip();
2021-09-25 08:41:11 +08:00
void guessFunction(int commas);
2021-09-24 11:41:14 +08:00
int paramIndex() const;
void setParamIndex(int newParamIndex);
const QString &functionFullName() const;
void setFunctioFullName(const QString &newFunctioFullName);
2021-09-22 17:43:21 +08:00
int minWidth() const;
void setMinWidth(int newMinWidth);
2021-09-22 17:43:21 +08:00
private:
QStringList splitArgs(QString args);
2021-09-22 17:43:21 +08:00
private:
QLabel* mInfoLabel;
QLabel* mTotalLabel;
QToolButton* mUpButton;
QToolButton* mDownButton;
int mParamPos;
2021-09-24 11:41:14 +08:00
int mInfoIndex;
int mParamIndex;
QString mFunctioFullName;
2021-09-22 17:43:21 +08:00
QList<PFunctionInfo> mInfos;
int mMinWidth;
2021-09-24 11:41:14 +08:00
// QWidget interface
protected:
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
2021-09-22 17:43:21 +08:00
};
#endif // FUNCTIONTOOLTIPWIDGET_H