-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #13 (Implement code viewer from tivars_lib_cpp)
- Loading branch information
Showing
24 changed files
with
1,875 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "basiccodeviewerwindow.h" | ||
#include "ui_basiccodeviewerwindow.h" | ||
|
||
BasicCodeViewerWindow::BasicCodeViewerWindow(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::BasicCodeViewerWindow) | ||
{ | ||
ui->setupUi(this); | ||
setWindowTitle(tr("Variable viewer")); | ||
ui->plainTextEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); | ||
} | ||
|
||
void BasicCodeViewerWindow::setVariableName(const QString &name) | ||
{ | ||
variableName = name; | ||
setWindowTitle(tr("Variable viewer") + " | " + variableName); | ||
} | ||
|
||
void BasicCodeViewerWindow::on_pushButton_clicked() | ||
{ | ||
showingFormatted = !showingFormatted; | ||
showCode(); | ||
} | ||
|
||
void BasicCodeViewerWindow::showCode() | ||
{ | ||
ui->plainTextEdit->document()->setPlainText(showingFormatted ? formattedCode : originalCode); | ||
} | ||
|
||
BasicCodeViewerWindow::~BasicCodeViewerWindow() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef BASICCODEVIEWERWINDOW_H | ||
#define BASICCODEVIEWERWINDOW_H | ||
|
||
#include <QDialog> | ||
#include <QString> | ||
#include "tivarslib/autoloader.h" | ||
|
||
namespace Ui { | ||
class BasicCodeViewerWindow; | ||
} | ||
|
||
class BasicCodeViewerWindow : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit BasicCodeViewerWindow(QWidget *parent = 0); | ||
void setVariableName(const QString& name); | ||
void setOriginalCode(const QString& code) { | ||
originalCode = code; | ||
formattedCode = QString::fromStdString(tivars::TH_0x05::reindentCodeString(originalCode.toStdString())); | ||
showCode(); | ||
} | ||
~BasicCodeViewerWindow(); | ||
|
||
private slots: | ||
void on_pushButton_clicked(); | ||
|
||
private: | ||
void showCode(); | ||
|
||
Ui::BasicCodeViewerWindow *ui; | ||
QString variableName; | ||
QString originalCode; | ||
QString formattedCode; | ||
bool showingFormatted = false; | ||
}; | ||
|
||
#endif // BASICCODEVIEWERWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>BasicCodeViewerWindow</class> | ||
<widget class="QDialog" name="BasicCodeViewerWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>384</width> | ||
<height>349</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QPlainTextEdit" name="plainTextEdit"> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="pushButton"> | ||
<property name="text"> | ||
<string>Toggle original/reformatted</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="horizontalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Part of tivars_lib_cpp | ||
* (C) 2015 Adrien 'Adriweb' Bertrand | ||
* https://github.com/adriweb/tivars_lib_cpp | ||
* License: MIT | ||
*/ | ||
|
||
#ifndef ITIVARTYPEHANDLER_H | ||
#define ITIVARTYPEHANDLER_H | ||
|
||
#include "../utils_tivarslib.h" | ||
|
||
namespace tivars | ||
{ | ||
class ITIVarTypeHandler | ||
{ | ||
|
||
public: | ||
|
||
// We can't make virtual static methods... | ||
|
||
static data_t makeDataFromString(const std::string& str, const options_t options) | ||
{ | ||
(void)str; | ||
(void)options; | ||
std::cerr << "This type is not supported / implemented (yet?)" << std::endl; | ||
return data_t(); | ||
} | ||
|
||
static std::string makeStringFromData(const data_t& data, const options_t options) | ||
{ | ||
(void)data; | ||
(void)options; | ||
std::cerr << "This type is not supported / implemented (yet?)" << std::endl; | ||
return ""; | ||
} | ||
|
||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.