QtHPConnect/include/texteditor.h

57 lines
1.5 KiB
C
Raw Normal View History

2020-02-02 18:13:27 +01:00
/*
* This file is part of the QtHPConnect distribution (https://github.com/Indy970/QtHPConnect.git).
* Copyright (c) 2020 Ian Gebbie.
*
* 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, version 3 or later.
*
* 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 <http://www.gnu.org/licenses/>.
*/
2019-02-10 14:32:15 +01:00
#ifndef TEXTEDITOR_H
#define TEXTEDITOR_H
2019-02-10 14:43:00 +01:00
#include <QTextEdit>
2020-02-02 18:13:27 +01:00
#include <QDir>
2019-02-10 14:32:15 +01:00
2020-01-26 18:51:44 +01:00
2019-02-10 14:43:00 +01:00
class textEditor : public QTextEdit
2019-02-10 14:32:15 +01:00
{
Q_OBJECT
public:
2020-01-26 18:51:44 +01:00
explicit textEditor(QWidget *parent = nullptr);
~textEditor() override;
2020-02-08 09:42:51 +01:00
bool save(QFileInfo file);
bool saveAs(QFileInfo file);
bool save(QString calculator);
bool saveAs(QString calculator);
2019-02-10 14:43:00 +01:00
bool saveFile(const QString &fileName);
QString userFriendlyCurrentFile();
QString currentFile() { return curFile; }
protected:
2020-02-08 09:42:51 +01:00
2019-02-10 14:43:00 +01:00
private slots:
void documentWasModified();
2019-02-10 14:32:15 +01:00
private:
2019-02-10 14:43:00 +01:00
QWidget * wParent;
2020-02-08 09:42:51 +01:00
2019-02-10 14:43:00 +01:00
void setCurrentFile(const QString &fileName);
QString strippedName(const QString &fullFileName);
QString curFile;
bool isUntitled;
2020-02-02 18:13:27 +01:00
QDir defaultPath;
2019-02-10 14:32:15 +01:00
};
#endif // TEXTEDITOR_H