├── .gitignore ├── LICENSE ├── README.md ├── cpp ├── CustomCheckBox.h ├── LICENSE ├── aboutdialog.cpp ├── aboutdialog.h ├── aboutdialog.ui ├── attachdbdialog.cpp ├── attachdbdialog.h ├── attachdbdialog.ui ├── btnfuncdelegate.cpp ├── btnfuncdelegate.h ├── checkboxdelegate.cpp ├── checkboxdelegate.h ├── cmask.cpp ├── cmask.h ├── comboboxdelegate.cpp ├── comboboxdelegate.h ├── contentwidget.cpp ├── contentwidget.h ├── copytabledialog.cpp ├── copytabledialog.h ├── copytabledialog.ui ├── cpp.cxx ├── cryptopp.pri ├── customcheckbox.cpp ├── databasemanagerform.cpp ├── databasemanagerform.h ├── databasemanagerform.ui ├── datetimeeditdelegate.cpp ├── datetimeeditdelegate.h ├── datetimeeditform.cpp ├── datetimeeditform.h ├── datetimeeditform.ui ├── dbobjectselectdialog.cpp ├── dbobjectselectdialog.h ├── dbobjectselectdialog.ui ├── driverdownloadform.cpp ├── driverdownloadform.h ├── driverdownloadform.ui ├── editdatabasedialog.cpp ├── editdatabasedialog.h ├── editdatabasedialog.ui ├── flowlayout.cpp ├── flowlayout.h ├── jarinfoeditdialog.cpp ├── jarinfoeditdialog.h ├── jarinfoeditdialog.ui ├── jarsmanagerform.cpp ├── jarsmanagerform.h ├── jarsmanagerform.ui ├── jookDB.pro ├── leftwidgetform.cpp ├── leftwidgetform.h ├── leftwidgetform.ui ├── lineeditdelegate.cpp ├── lineeditdelegate.h ├── listwidgetdelegate.cpp ├── listwidgetdelegate.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mutichkform.cpp ├── mutichkform.h ├── mutichkform.ui ├── mystyle.cpp ├── mystyle.h ├── objtimecache.cpp ├── objtimecache.h ├── optionsdialog.cpp ├── optionsdialog.h ├── passwordchgdialog.cpp ├── passwordchgdialog.h ├── passwordchgdialog.ui ├── passwordinputdialog.cpp ├── passwordinputdialog.h ├── passwordinputdialog.ui ├── queryform.h ├── readonlydelegate.cpp ├── readonlydelegate.h ├── resources.qrc ├── resultform.h ├── reversecall.cpp ├── reversecall.h ├── runsqldialog.cpp ├── runsqldialog.h ├── runsqldialog.ui ├── searchreplaceform.cpp ├── searchreplaceform.h ├── searchreplaceform.ui ├── spinboxdelegate.cpp ├── spinboxdelegate.h ├── sqllexer.h ├── sqlobject.h ├── sqlstyle.cpp ├── sqlstyle.h ├── strmappingdialog.cpp ├── strmappingdialog.h ├── strmappingdialog.ui ├── test.cpp ├── test.h ├── texteditdialog.cpp ├── texteditdialog.h └── texteditdialog.ui ├── img └── demo │ ├── data_editor.png │ ├── query_editor.png │ ├── structure_synchronization.png │ ├── table_design.png │ └── user_manager.png ├── language ├── en.qm └── en.ts └── lib ├── commons-codec-1.15.jar ├── commons-collections4-4.4.jar ├── commons-compress-1.20.jar ├── commons-csv-1.9.0.jar ├── commons-io-2.8.0.jar ├── commons-lang3-3.12.0.jar ├── commons-math3-3.6.1.jar ├── dom4j-2.1.3.jar ├── easyexcel-2.2.7.jar ├── fastjson-1.2.83.jar ├── gson-2.9.0.jar ├── h2-1.4.199.jar ├── httpclient-4.5.13.jar ├── httpcore-4.4.14.jar ├── javassist-3.28.0-GA.jar ├── jedis-3.4.1.jar ├── jookNS.jar ├── jtds-1.3.1.jar ├── lib.txt ├── mariadb-java-client-3.1.3.jar ├── mssql-jdbc-8.2.2.jre11.jar ├── poi-4.1.2.jar ├── poi-ooxml-4.1.2.jar ├── poi-ooxml-schemas-4.1.2.jar ├── postgresql-42.2.20.jar ├── slf4j-api-1.7.29.jar ├── slf4j-simple-1.7.29.jar └── xmlbeans-3.1.0.jar /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | /out 35 | /jookDB.pro.user 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jookdb 2 | JookDB is a database development tool that allows you to simultaneously connect to MySQL, MariaDB, Oracle, PostgreSQL, SQLite, MongoDB, Redis, DM, OceanBase, TiDB and SQLServer databases from a single application. You can quickly and easily build, manage and maintain your databases. 3 | [Website](https://jookdb.com) 4 | 5 | ## Query Editor 6 | ![image](https://raw.githubusercontent.com/jooksoft/jookdb/main/img/demo/query_editor.png) 7 | 8 | ## Data Editor 9 | ![image](https://raw.githubusercontent.com/jooksoft/jookdb/main/img/demo/data_editor.png) 10 | 11 | ## Structure Synchronization 12 | ![image](https://raw.githubusercontent.com/jooksoft/jookdb/main/img/demo/structure_synchronization.png) 13 | 14 | ## User Manager 15 | ![image](https://raw.githubusercontent.com/jooksoft/jookdb/main/img/demo/user_manager.png) 16 | 17 | ## Table Design 18 | ![image](https://raw.githubusercontent.com/jooksoft/jookdb/main/img/demo/table_design.png) 19 | 20 | -------------------------------------------------------------------------------- /cpp/CustomCheckBox.h: -------------------------------------------------------------------------------- 1 | #ifndef CUSTOMCHECKBOX_H 2 | #define CUSTOMCHECKBOX_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CustomCheckBox : public QWidget 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit CustomCheckBox(QWidget *parent = nullptr); 13 | 14 | void setOldChecked(bool checked); 15 | bool getOldChecked(); 16 | void setChecked(bool checked); 17 | bool getChecked(); 18 | void setText(const QString &text); 19 | QString getText() const; 20 | void setOldText(const QString &text); 21 | QString getOldText() const; 22 | 23 | void mouseReleaseEvent(QMouseEvent *event) override; 24 | 25 | bool getReadonly() const; 26 | void setReadonly(bool value); 27 | 28 | bool hasChanged(); 29 | 30 | signals: 31 | void checked(bool checked); 32 | void mouseRelease(bool checked); 33 | 34 | public slots: 35 | 36 | private: 37 | QCheckBox *chkBox=nullptr; 38 | bool readonly=false; 39 | bool old_chked=false; 40 | QString old_text; 41 | 42 | bool ignoreMouseEvent=false; 43 | public: 44 | 45 | void closeEvent(QCloseEvent *event) override; 46 | 47 | bool getIgnoreMouseEvent() const; 48 | void setIgnoreMouseEvent(bool value); 49 | 50 | private: 51 | 52 | std::atomic_bool stop=false; 53 | 54 | }; 55 | 56 | #endif // CUSTOMCHECKBOX_H 57 | -------------------------------------------------------------------------------- /cpp/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "aboutdialog.h" 2 | #include "activatedialog.h" 3 | #include "globalutils.h" 4 | #include "mainwindow.h" 5 | #include "ui_aboutdialog.h" 6 | #include "widgetutils.h" 7 | 8 | #include 9 | #include 10 | 11 | AboutDialog::AboutDialog(QWidget *parent) : 12 | QDialog(parent), 13 | ui(new Ui::AboutDialog) 14 | { 15 | ui->setupUi(this); 16 | 17 | WidgetUtils::setSafeDeleteOnClose(this); 18 | 19 | #if defined(Q_OS_MAC) 20 | this->setWindowFlag(Qt::Tool,true); 21 | #endif 22 | 23 | ui->stack_main->setCurrentIndex(0); 24 | 25 | ui->lb_home->setText(ui->lb_home->text().replace("${home_uri}",HOME_URI)); 26 | 27 | this->testLicense(); 28 | } 29 | 30 | AboutDialog::~AboutDialog() 31 | { 32 | delete ui; 33 | } 34 | 35 | void AboutDialog::testLicense() 36 | { 37 | auto runRef=WidgetUtils::createRunRef(this); 38 | 39 | QJsonObject license_json=GlobalUtils::getLicense(); 40 | QString email=Utils::getString(license_json,"email"); 41 | 42 | ui->lb_version->setText(QCoreApplication::applicationVersion()); 43 | ui->lb_username->setText(email); 44 | 45 | bool is_subscription=false; 46 | if(!email.isEmpty()){ 47 | is_subscription=true; 48 | } 49 | 50 | ui->wd_subscription->setVisible(is_subscription); 51 | ui->btn_register->setVisible(!is_subscription); 52 | } 53 | 54 | void AboutDialog::checkNewVersion() 55 | { 56 | auto runRef=WidgetUtils::createRunRef(this); 57 | 58 | ui->stack_main->setCurrentWidget(ui->page_newVersion); 59 | ui->lb_have_new_version->setHidden(true); 60 | 61 | QJsonObject json; 62 | json.insert("func_id",FUNC_DOWNLOAD_FILE); 63 | QJsonObject resJson=Utils::postEsbWithNS(MainWindow::instance(),json); 64 | 65 | if(Utils::testResult(resJson,false)){ 66 | QJsonArray arr=Utils::getArray(resJson,"download_list"); 67 | 68 | if(arr.size()>0){ 69 | QJsonObject json=arr[0].toObject(); 70 | QString version=json.value("version").toString(); 71 | if(!version.isEmpty()){ 72 | ui->lb_version_last->setText(version); 73 | if(StringUtils::equalIncase("zh_cn",MainWindow::instance()->defaultLanguage)){ 74 | ui->te_release_log->setText(json.value("release_log_cn").toString()); 75 | }else{ 76 | ui->te_release_log->setText(json.value("release_log_en").toString()); 77 | } 78 | 79 | QStringList versionList=version.split("."); 80 | QStringList localVersionList=QString{VERSION_STR}.split("."); 81 | int eq=0; 82 | for (int i=0;i<(std::max(versionList.size(),localVersionList.size()));i++) { 83 | if(eq!=0)break; 84 | int rv=(ilv){ 87 | eq=1; 88 | break; 89 | }else if(rv0){ 95 | ui->btn_download->setEnabled(true); 96 | ui->lb_have_new_version->setHidden(false); 97 | }else{ 98 | ui->btn_download->setEnabled(false); 99 | ui->lb_have_new_version->setHidden(true); 100 | } 101 | } 102 | } 103 | 104 | } 105 | } 106 | 107 | void AboutDialog::closeEvent(QCloseEvent *event) 108 | { 109 | this->hide(); 110 | 111 | stop=true; 112 | 113 | Utils::stopResEventLoop(this); 114 | 115 | QTimer *timer = new QTimer(this); 116 | // setup signal and slot 117 | connect(timer, &QTimer::timeout, 118 | this, [=](){ 119 | if(!WidgetUtils::isRunning(this)){ 120 | this->deleteLater(); 121 | } 122 | }); 123 | // msec 124 | timer->start(50); 125 | 126 | event->ignore(); 127 | } 128 | 129 | void AboutDialog::on_btn_register_clicked() 130 | { 131 | ActivateDialog *dlg=new ActivateDialog{this}; 132 | dlg->exec(); 133 | this->testLicense(); 134 | } 135 | 136 | void AboutDialog::on_btn_ok_clicked() 137 | { 138 | this->close(); 139 | } 140 | 141 | void AboutDialog::on_btn_download_clicked() 142 | { 143 | QDesktopServices::openUrl(QUrl(DOWNLOAD_URI)); 144 | } 145 | 146 | void AboutDialog::on_btn_cancel_clicked() 147 | { 148 | this->close(); 149 | } 150 | -------------------------------------------------------------------------------- /cpp/aboutdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTDIALOG_H 2 | #define ABOUTDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AboutDialog; 8 | } 9 | 10 | class AboutDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit AboutDialog(QWidget *parent = nullptr); 16 | ~AboutDialog(); 17 | 18 | void testLicense(); 19 | 20 | void checkNewVersion(); 21 | 22 | private: 23 | Ui::AboutDialog *ui; 24 | 25 | public: 26 | 27 | void closeEvent(QCloseEvent *event) override; 28 | 29 | private slots: 30 | void on_btn_register_clicked(); 31 | 32 | void on_btn_ok_clicked(); 33 | 34 | void on_btn_download_clicked(); 35 | 36 | void on_btn_cancel_clicked(); 37 | 38 | private: 39 | 40 | std::atomic_bool stop=false; 41 | }; 42 | 43 | #endif // ABOUTDIALOG_H 44 | -------------------------------------------------------------------------------- /cpp/attachdbdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "attachdbdialog.h" 2 | #include "mainwindow.h" 3 | #include "ui_attachdbdialog.h" 4 | #include "widgetutils.h" 5 | 6 | #include 7 | #include 8 | 9 | AttachDbDialog::AttachDbDialog(QSharedPointer connData,QWidget *parent) : 10 | QDialog(parent), 11 | ui(new Ui::AttachDbDialog),connData(connData) 12 | { 13 | ui->setupUi(this); 14 | 15 | this->on_ch_encrypted_stateChanged(-1); 16 | 17 | if(connData){ 18 | this->setWindowTitle(connData->connName+" - "+this->windowTitle()); 19 | } 20 | 21 | auto getFileBtnFunc=[=](){ 22 | 23 | QFileDialog fdialog(this,QObject::tr("Open File"),"",QObject::tr("All SQLite files (*.db *.sdb *.sqlite *.db3 *.s3db *.sqlite3 *.sl3);;SQLite3 files (*.db3 *.s3db *.sqlite3 *.sl3);;All files(*.*)")); 24 | fdialog.setOption(QFileDialog::DontUseNativeDialog,true); 25 | fdialog.setWindowModality(Qt::WindowModal); 26 | fdialog.setAcceptMode(QFileDialog::AcceptOpen); 27 | 28 | if (fdialog.exec() == QDialog::Accepted && fdialog.selectedFiles().length()>0){ 29 | QStringList fnames=fdialog.selectedFiles(); 30 | if(fnames.count()>0){ 31 | QString lastName=fnames.last(); 32 | 33 | this->ui->le_file->setText(lastName); 34 | QFileInfo fileInfo(lastName); 35 | this->ui->le_name->setText(fileInfo.baseName()); 36 | 37 | } 38 | 39 | } 40 | }; 41 | WidgetUtils::customLineEditWidgetAddBtnFunc(ui->le_file,getFileBtnFunc,true,QIcon {":/images/open.svg"}); 42 | } 43 | 44 | AttachDbDialog::~AttachDbDialog() 45 | { 46 | delete ui; 47 | } 48 | 49 | void AttachDbDialog::on_ch_encrypted_stateChanged(int arg1) 50 | { 51 | bool checked=ui->ch_encrypted->isChecked(); 52 | ui->lb_password->setEnabled(checked); 53 | ui->le_password->setEnabled(checked); 54 | } 55 | 56 | void AttachDbDialog::on_btn_cancel_clicked() 57 | { 58 | this->close(); 59 | } 60 | 61 | void AttachDbDialog::on_btn_ok_clicked() 62 | { 63 | if(!connData)return; 64 | 65 | if(ui->le_file->text().trimmed().isEmpty()){ 66 | QMessageBox::warning(this, QCoreApplication::applicationName(),tr("Database file cannot be empty!")); 67 | return; 68 | } 69 | if(ui->le_name->text().trimmed().isEmpty()){ 70 | QMessageBox::warning(this, QCoreApplication::applicationName(),tr("Database name cannot be empty!")); 71 | return; 72 | } 73 | 74 | switch (connData->typeId) { 75 | 76 | QString file=ui->le_file->text().trimmed(); 77 | QString name=ui->le_name->text().trimmed(); 78 | QString password; 79 | if(ui->ch_encrypted->isChecked()){ 80 | password=ui->le_password->text().trimmed(); 81 | } 82 | 83 | QString sql; 84 | sql="ATTACH DATABASE '%1' AS '%2' KEY '%3'"; 85 | sql=sql.arg(StringUtils::escapeSqlSingleQuotes(file), 86 | StringUtils::escapeSqlSingleQuotes(name), 87 | password); 88 | 89 | if(Utils::testOrReconn(connData)){ 90 | QJsonObject json=Utils::executeQuery(connData,sql,{}); 91 | if(Utils::testResult(json)){ 92 | 93 | if(this->saveCfg){ 94 | QJsonObject j; 95 | j.insert("file",file); 96 | j.insert("name",name); 97 | j.insert("encrypt",password); 98 | attachDbArr.append(j); 99 | 100 | connJson.insert("attachDb",attachDbArr); 101 | 102 | connData->connStr=Utils::jsonToString(connJson); 103 | 104 | QSettings ini(Utils::getConfigFilePath(), QSettings::IniFormat); 105 | ini.beginGroup(connData->connName); 106 | ini.setValue("connStr",connData->connStr); 107 | ini.endGroup(); 108 | 109 | auto currItem=MainWindow::getContent()->getLeftTree()->currentItem(); 110 | auto dsItem=Utils::getDsItem(currItem); 111 | if(dsItem&&currItem&&dsItem->isExpanded()){ 112 | MainWindow::getContent()->getLeftTree()->refreshItem(dsItem); 113 | } 114 | } 115 | 116 | this->accept(); 117 | }else{ 118 | 119 | } 120 | } 121 | } 122 | break; 123 | } 124 | 125 | 126 | } 127 | 128 | bool AttachDbDialog::getSaveCfg() const 129 | { 130 | return saveCfg; 131 | } 132 | 133 | void AttachDbDialog::setSaveCfg(bool value) 134 | { 135 | saveCfg = value; 136 | } 137 | 138 | QString AttachDbDialog::getFile() 139 | { 140 | return ui->le_file->text().trimmed(); 141 | } 142 | 143 | QString AttachDbDialog::getName() 144 | { 145 | return ui->le_name->text().trimmed(); 146 | } 147 | 148 | QString AttachDbDialog::getPassword() 149 | { 150 | return ui->le_password->text().trimmed(); 151 | } 152 | 153 | bool AttachDbDialog::getEncrypted() 154 | { 155 | return ui->ch_encrypted->isChecked(); 156 | } 157 | -------------------------------------------------------------------------------- /cpp/attachdbdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ATTACHDBDIALOG_H 2 | #define ATTACHDBDIALOG_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class AttachDbDialog; 10 | } 11 | 12 | class AttachDbDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit AttachDbDialog(QSharedPointer connData,QWidget *parent = nullptr); 18 | ~AttachDbDialog(); 19 | 20 | bool getSaveCfg() const; 21 | void setSaveCfg(bool value); 22 | 23 | QString getFile(); 24 | QString getName(); 25 | QString getPassword(); 26 | bool getEncrypted(); 27 | 28 | private slots: 29 | void on_ch_encrypted_stateChanged(int arg1); 30 | 31 | void on_btn_cancel_clicked(); 32 | 33 | void on_btn_ok_clicked(); 34 | 35 | private: 36 | Ui::AttachDbDialog *ui; 37 | 38 | QSharedPointer connData=nullptr; 39 | 40 | bool saveCfg=false; 41 | }; 42 | 43 | #endif // ATTACHDBDIALOG_H 44 | -------------------------------------------------------------------------------- /cpp/attachdbdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AttachDbDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 427 10 | 198 11 | 12 | 13 | 14 | Attach Database 15 | 16 | 17 | 18 | 19 | 20 | Database File: 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Database Name: 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Key: 41 | 42 | 43 | 44 | 45 | 46 | 47 | QLineEdit::Password 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | Qt::Horizontal 57 | 58 | 59 | 60 | 40 61 | 20 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | OK 70 | 71 | 72 | 73 | 74 | 75 | 76 | Cancel 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Encrypted 86 | 87 | 88 | 89 | 90 | 91 | 92 | Qt::Vertical 93 | 94 | 95 | 96 | 20 97 | 40 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /cpp/btnfuncdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "btnfuncdelegate.h" 2 | #include "strmappingdialog.h" 3 | #include "widgetutils.h" 4 | 5 | BtnFuncDelegate::BtnFuncDelegate(QObject *parent) : QStyledItemDelegate(parent) 6 | { 7 | 8 | } 9 | 10 | void BtnFuncDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 11 | { 12 | auto opt=option; 13 | opt.displayAlignment=this->textAlign; 14 | WidgetUtils::paint(painter,opt,index); 15 | } 16 | 17 | QSize BtnFuncDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 18 | { 19 | return QStyledItemDelegate::sizeHint(option, index); 20 | } 21 | 22 | QWidget *BtnFuncDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 23 | { 24 | QLineEdit *editor = new QLineEdit(parent); 25 | 26 | editor->setReadOnly(readonly); 27 | 28 | editor->setProperty("item_row",index.row()); 29 | editor->setProperty("item_col",index.column()); 30 | 31 | if(btnClkFunc){ 32 | WidgetUtils::customLineEditWidgetAddBtnFunc(editor,[=](){ 33 | btnClkFunc(editor); 34 | }); 35 | } 36 | 37 | if(lineEditInitFunc){ 38 | lineEditInitFunc(editor); 39 | } 40 | 41 | if(lineEditMousePressFunc){ 42 | CustomEventFilter *eventFilter=new CustomEventFilter(const_cast(editor)); 43 | eventFilter->setFunc([=](QObject *obj, QEvent *event){ 44 | if (event->type() == QEvent::MouseButtonPress && obj->inherits(QLineEdit::staticMetaObject.className())) 45 | { 46 | lineEditMousePressFunc((QLineEdit*)obj); 47 | } 48 | return false; 49 | }); 50 | editor->installEventFilter(eventFilter); 51 | } 52 | 53 | if(lineEditChangedFunc){ 54 | connect(editor,&QLineEdit::textChanged,this,[=](const QString text){ 55 | lineEditChangedFunc(editor,text); 56 | }); 57 | } 58 | return editor; 59 | } 60 | 61 | void BtnFuncDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 62 | { 63 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 64 | QString value = WidgetUtils::getData(index).toString(); 65 | QLineEdit *lineEdit = static_cast(editor); 66 | lineEdit->setAlignment(textAlign); 67 | lineEdit->setText(value); 68 | } 69 | } 70 | 71 | void BtnFuncDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 72 | { 73 | if(this->readonly)return; 74 | 75 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 76 | QLineEdit *lineEdit = static_cast(editor); 77 | bool changed=WidgetUtils::setData(model,index,lineEdit->text()); 78 | if(changed){ 79 | if(dataChangedFunc){ 80 | dataChangedFunc(index); 81 | } 82 | } 83 | if(dataWriteFunc){ 84 | dataWriteFunc(index,changed); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /cpp/btnfuncdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef STRMAPPINGDELEGATE_H 2 | #define STRMAPPINGDELEGATE_H 3 | 4 | #include 5 | 6 | 7 | class BtnFuncDelegate : public QStyledItemDelegate 8 | { 9 | Q_OBJECT 10 | public: 11 | BtnFuncDelegate(QObject *parent = nullptr); 12 | 13 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 14 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 15 | 16 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 17 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 18 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 19 | 20 | std::function lineEditInitFunc=nullptr; 21 | std::function lineEditMousePressFunc=nullptr; 22 | std::function lineEditChangedFunc=nullptr; 23 | 24 | std::function dataChangedFunc=nullptr; 25 | std::function dataWriteFunc=nullptr; 26 | 27 | std::function btnClkFunc=nullptr; 28 | 29 | private: 30 | 31 | bool readonly=false; 32 | Qt::Alignment textAlign=Qt::AlignLeft|Qt::AlignVCenter; 33 | }; 34 | 35 | #endif // STRMAPPINGDELEGATE_H 36 | -------------------------------------------------------------------------------- /cpp/checkboxdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "checkboxdelegate.h" 2 | #include 3 | #include "widgetutils.h" 4 | 5 | CheckBoxDelegate::CheckBoxDelegate(QObject *parent):QStyledItemDelegate(parent) 6 | { 7 | 8 | } 9 | 10 | void CheckBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 11 | { 12 | auto opt=option; 13 | WidgetUtils::paint(painter,opt,index); 14 | } 15 | 16 | QSize CheckBoxDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 17 | { 18 | return QStyledItemDelegate::sizeHint(option, index); 19 | } 20 | 21 | QWidget *CheckBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 22 | { 23 | 24 | if(readonly)return nullptr; 25 | 26 | CustomCheckBox *editor = new CustomCheckBox(parent); 27 | 28 | if(chkInitFunc){ 29 | chkInitFunc(editor); 30 | } 31 | 32 | if(chkCheckedFunc){ 33 | connect(editor,&CustomCheckBox::checked,this,[=](bool checked){ 34 | if(chkCheckedFunc && QObject::sender()->inherits(CustomCheckBox::staticMetaObject.className())){ 35 | chkCheckedFunc((CustomCheckBox*)QObject::sender(),checked); 36 | } 37 | }); 38 | } 39 | 40 | return editor; 41 | } 42 | 43 | void CheckBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 44 | { 45 | 46 | if(editor->inherits(CustomCheckBox::staticMetaObject.className())){ 47 | bool value = WidgetUtils::getData(index).toBool(); 48 | CustomCheckBox *chk = static_cast(editor); 49 | chk->setChecked(value); 50 | } 51 | } 52 | 53 | void CheckBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 54 | { 55 | if(this->readonly)return; 56 | 57 | if(editor->inherits(CustomCheckBox::staticMetaObject.className())){ 58 | CustomCheckBox *chk = static_cast(editor); 59 | bool changed=WidgetUtils::setData(model,index,chk->getChecked()); 60 | if(changed){ 61 | if(dataChangedFunc){ 62 | dataChangedFunc(index); 63 | } 64 | } 65 | if(dataWriteFunc){ 66 | dataWriteFunc(index,changed); 67 | } 68 | } 69 | } 70 | 71 | bool CheckBoxDelegate::getReadonly() const 72 | { 73 | return readonly; 74 | } 75 | 76 | void CheckBoxDelegate::setReadonly(bool value) 77 | { 78 | readonly = value; 79 | } 80 | -------------------------------------------------------------------------------- /cpp/checkboxdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKBOXDELEGATE_H 2 | #define CHECKBOXDELEGATE_H 3 | 4 | #include "customcheckbox.h" 5 | 6 | #include 7 | #include 8 | 9 | 10 | 11 | class CheckBoxDelegate : public QStyledItemDelegate 12 | { 13 | public: 14 | CheckBoxDelegate(QObject *parent = nullptr); 15 | 16 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 17 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 18 | 19 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 20 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 21 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 22 | 23 | bool findCaseSensitive=true; 24 | 25 | std::function chkInitFunc=nullptr; 26 | std::function chkCheckedFunc=nullptr; 27 | 28 | std::function dataChangedFunc=nullptr; 29 | std::function dataWriteFunc=nullptr; 30 | 31 | bool getReadonly() const; 32 | void setReadonly(bool value); 33 | 34 | public slots: 35 | 36 | private: 37 | bool readonly=false; 38 | }; 39 | 40 | #endif // CHECKBOXDELEGATE_H 41 | -------------------------------------------------------------------------------- /cpp/cmask.cpp: -------------------------------------------------------------------------------- 1 | #include "cmask.h" 2 | #include "mainwindow.h" 3 | #include "utils.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | CMask::CMask(QWidget *parent) : QWidget(parent) 12 | { 13 | 14 | this->setAttribute(Qt::WA_TransparentForMouseEvents,false); 15 | 16 | if(parent){ 17 | this->setGeometry(parent->geometry()); 18 | CustomEventFilter *resizeFilter=new CustomEventFilter{this}; 19 | resizeFilter->setFunc([=](QObject *obj, QEvent *event){ 20 | if (event->type() == QEvent::Resize) 21 | { 22 | this->setGeometry(parent->geometry()); 23 | } 24 | return false; 25 | }); 26 | parent->installEventFilter(resizeFilter); 27 | }else{ 28 | this->setGeometry(MainWindow::instance()->geometry()); 29 | } 30 | 31 | this->infoLabel =new QLabel{this}; 32 | this->infoLabel->setAlignment(Qt::AlignCenter); 33 | 34 | QWidget *loadingWid=new QWidget{this}; 35 | 36 | QHBoxLayout *mainLayout = new QHBoxLayout{}; 37 | mainLayout->setAlignment(Qt::AlignCenter); 38 | mainLayout->addWidget(loadingWid); 39 | this->setLayout(mainLayout); 40 | 41 | this->btn=new QToolButton{this}; 42 | QHBoxLayout *btnLayout = new QHBoxLayout{}; 43 | btnLayout->setAlignment(Qt::AlignCenter); 44 | this->btn->setText("Stop"); 45 | this->btn->setVisible(false); 46 | btnLayout->addWidget(this->btn); 47 | 48 | QVBoxLayout *loadingLayout = new QVBoxLayout{}; 49 | loadingLayout->setAlignment(Qt::AlignCenter); 50 | loadingLayout->setContentsMargins(0, 0, 0, 0); 51 | loadingLayout->addWidget(this->infoLabel); 52 | loadingLayout->addLayout(btnLayout); 53 | loadingWid->setLayout(loadingLayout); 54 | 55 | loadingWid->setAutoFillBackground(true); 56 | 57 | this->setGif(":/images/loading.gif"); 58 | 59 | } 60 | 61 | CMask::~CMask() 62 | { 63 | } 64 | 65 | void CMask::setGif(QString strPath) 66 | { 67 | QMovie *movie = new QMovie{this}; 68 | movie->setFileName(strPath); 69 | movie->setScaledSize(QSize(Utils::getCharGuiFontRect().height()*4,Utils::getCharGuiFontRect().height()*4)); 70 | this->infoLabel->setMovie(movie); 71 | movie->start(); 72 | } 73 | 74 | void CMask::setStopFunction(std::function stopFunc) 75 | { 76 | this->stopFunc=stopFunc; 77 | if(this->stopFunc){ 78 | this->btn->setVisible(true); 79 | 80 | connect(this->btn,&QToolButton::clicked,this,[=](){ 81 | this->btn->setEnabled(false); 82 | this->stopFunc(); 83 | this->btn->setEnabled(true); 84 | },Qt::UniqueConnection); 85 | 86 | }else{ 87 | 88 | this->btn->setVisible(false); 89 | } 90 | } 91 | 92 | void CMask::paintEvent(QPaintEvent *e) 93 | { 94 | QPainter p(this); 95 | p.setPen(Qt::NoPen); 96 | p.setBrush(QColor{0,0,0,50}); 97 | p.drawRect(rect()); 98 | } 99 | -------------------------------------------------------------------------------- /cpp/cmask.h: -------------------------------------------------------------------------------- 1 | #ifndef CMASK_H 2 | #define CMASK_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class CMask : public QWidget 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit CMask(QWidget *parent); 14 | ~CMask(); 15 | 16 | void setGif(QString strPath); 17 | void setStopFunction(std::function stopFunc); 18 | 19 | static void* operator new(std::size_t) = delete; 20 | // static void operator delete(void*) = delete; 21 | 22 | signals: 23 | 24 | public slots: 25 | 26 | private: 27 | QLabel *infoLabel; 28 | QToolButton *btn; 29 | void paintEvent(QPaintEvent* e); 30 | 31 | std::function stopFunc=nullptr; 32 | }; 33 | 34 | #endif // CMASK_H 35 | -------------------------------------------------------------------------------- /cpp/comboboxdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "comboboxdelegate.h" 2 | #include "utils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include "widgetutils.h" 8 | 9 | ComboBoxDelegate::ComboBoxDelegate(QObject *parent):QStyledItemDelegate(parent) 10 | { 11 | 12 | } 13 | 14 | void ComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 15 | { 16 | auto opt=option; 17 | WidgetUtils::paint(painter,opt,index); 18 | } 19 | 20 | QSize ComboBoxDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 21 | { 22 | return QStyledItemDelegate::sizeHint(option, index); 23 | } 24 | 25 | QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 26 | { 27 | if(readonly)return nullptr; 28 | 29 | QComboBox *editor = new QComboBox(parent); 30 | 31 | editor->setProperty("item_row",index.row()); 32 | editor->setProperty("item_col",index.column()); 33 | 34 | editor->setEditable(true); 35 | WidgetUtils::customComboBoxWidget(editor); 36 | 37 | if(comboInitFunc){ 38 | comboInitFunc(editor); 39 | } 40 | 41 | if(comboMousePressFunc){ 42 | CustomEventFilter *eventFilter=new CustomEventFilter(const_cast(editor)); 43 | eventFilter->setFunc([=](QObject *obj, QEvent *event){ 44 | if (event->type() == QEvent::MouseButtonPress && obj->inherits(QComboBox::staticMetaObject.className())) 45 | { 46 | comboMousePressFunc((QComboBox*)obj); 47 | } 48 | return false; 49 | }); 50 | editor->installEventFilter(eventFilter); 51 | } 52 | 53 | return editor; 54 | } 55 | 56 | void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 57 | { 58 | if(editor->inherits(QComboBox::staticMetaObject.className())){ 59 | QString value = WidgetUtils::getData(index).toString(); 60 | QComboBox *combox = static_cast(editor); 61 | int i2=-1; 62 | if(findCaseSensitive){ 63 | i2=combox->findText(value); 64 | }else{ 65 | i2=combox->findText(value,Qt::MatchFixedString); 66 | } 67 | if(i2>=0){ 68 | combox->setCurrentIndex(i2); 69 | }else{ 70 | combox->insertItem(0,value); 71 | combox->setCurrentIndex(0); 72 | } 73 | 74 | if(comboCurrTextChangedFunc){ 75 | connect(combox,&QComboBox::currentTextChanged,this,[=](QString str){ 76 | if(comboCurrTextChangedFunc && QObject::sender() && QObject::sender()->inherits(QComboBox::staticMetaObject.className())){ 77 | QComboBox* comb=(QComboBox*)QObject::sender(); 78 | comb->setProperty("item_row",index.row()); 79 | comb->setProperty("item_col",index.column()); 80 | comboCurrTextChangedFunc(comb,str); 81 | } 82 | }); 83 | } 84 | } 85 | } 86 | 87 | void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 88 | { 89 | if(this->readonly)return; 90 | 91 | if(editor->inherits(QComboBox::staticMetaObject.className())){ 92 | QComboBox *combox = static_cast(editor); 93 | bool changed=WidgetUtils::setData(model,index,combox->currentText()); 94 | if(changed){ 95 | if(dataChangedFunc){ 96 | dataChangedFunc(index); 97 | } 98 | } 99 | if(dataWriteFunc){ 100 | dataWriteFunc(index,changed); 101 | } 102 | } 103 | } 104 | 105 | bool ComboBoxDelegate::getReadonly() const 106 | { 107 | return readonly; 108 | } 109 | 110 | void ComboBoxDelegate::setReadonly(bool value) 111 | { 112 | readonly = value; 113 | } 114 | -------------------------------------------------------------------------------- /cpp/comboboxdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBOBOXDELEGATE_H 2 | #define COMBOBOXDELEGATE_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | class ComboBoxDelegate : public QStyledItemDelegate 11 | { 12 | Q_OBJECT 13 | public: 14 | ComboBoxDelegate(QObject *parent = nullptr); 15 | 16 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 17 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 18 | 19 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 20 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 21 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 22 | 23 | std::function comboInitFunc=nullptr; 24 | std::function comboMousePressFunc=nullptr; 25 | std::function comboCurrTextChangedFunc=nullptr; 26 | 27 | std::function dataChangedFunc=nullptr; 28 | std::function dataWriteFunc=nullptr; 29 | 30 | bool findCaseSensitive=true; 31 | 32 | bool getReadonly() const; 33 | void setReadonly(bool value); 34 | 35 | public slots: 36 | 37 | private: 38 | bool readonly=false; 39 | }; 40 | 41 | #endif // COMBOBOXDELEGATE_H 42 | -------------------------------------------------------------------------------- /cpp/contentwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTENTWIDGET_H 2 | #define CONTENTWIDGET_H 3 | 4 | #include "databasemanagerform.h" 5 | #include "leftwidgetform.h" 6 | #include "myedit.h" 7 | #include "mytreewidget.h" 8 | #include "objectmanagerform.h" 9 | #include "queryform.h" 10 | #include "tabledataform.h" 11 | #include "tableform.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | class ContentWidget : public QWidget 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit ContentWidget(QWidget *parent = nullptr); 23 | 24 | MyEdit* getCurrTextEdit(); 25 | QueryForm *getCurrQueryForm(); 26 | TableForm *getCurrTableForm(); 27 | TableDataForm *getCurrTableDataForm(); 28 | ObjectManagerForm *getCurrObjectManagerForm(); 29 | DatabaseManagerForm *getCurrDatabaseManagerForm(); 30 | MyTreeWidget* getLeftTree() const; 31 | QTabWidget *getRightTab() const; 32 | 33 | QSplitter *getSplitter(); 34 | 35 | inline int addTabWithToolTip(QWidget *wid,const QString &title, const QString &tip); 36 | QueryForm * addTab(QString title,QString db="",QString dbName=""); 37 | TableForm * addTableTab(QSharedPointer connData,QString tableName="",QString dbName="",bool readonly=false,bool isView=false); 38 | TableDataForm * addTableDataTab(QSharedPointer connData,QString tableName="",QString dbName="",bool readonly=false); 39 | bool closeTab(const int idx); 40 | 41 | ObjectManagerForm * addObjectManager(QSharedPointer connData,QString dbName,bool isDump=false,QString dumpTableName=""); 42 | 43 | DatabaseManagerForm *addDatabaseManager(QSharedPointer connData); 44 | 45 | void setTabModified(QWidget *widget,bool modified); 46 | void setTabTitle(QWidget *widget,const QString &title, const QString &tip,bool keepModify=true); 47 | 48 | void setContentSplitterSizes(const QList &sizes); 49 | 50 | signals: 51 | 52 | public slots: 53 | void documentWasModified(); 54 | void openConnDlg(const QString &connType); 55 | 56 | private: 57 | LeftWidgetForm *leftWidgetForm; 58 | QSplitter *contentSplitter; 59 | QTabWidget *rightTab; 60 | 61 | int32_t tabChgCount=0; 62 | 63 | public: 64 | 65 | void closeEvent(QCloseEvent *event) override; 66 | 67 | QLineEdit *getLeftTree_filter() const; 68 | 69 | private: 70 | 71 | std::atomic_bool stop=false; 72 | 73 | }; 74 | 75 | #endif // CONTENTWIDGET_H 76 | -------------------------------------------------------------------------------- /cpp/copytabledialog.cpp: -------------------------------------------------------------------------------- 1 | #include "autocompleteform.h" 2 | #include "copytabledialog.h" 3 | #include "mainwindow.h" 4 | #include "mytreewidget.h" 5 | #include "ui_copytabledialog.h" 6 | #include "widgetutils.h" 7 | 8 | #include 9 | 10 | CopyTableDialog::CopyTableDialog(QSharedPointer connData,QString dbName,QString tableName,bool withData,QWidget *parent) : 11 | QDialog(parent), 12 | ui(new Ui::CopyTableDialog) 13 | { 14 | ui->setupUi(this); 15 | 16 | WidgetUtils::setSafeDeleteOnClose(this); 17 | 18 | this->connData=connData; 19 | this->dbName=dbName; 20 | this->tableName=tableName; 21 | 22 | WidgetUtils::customComboBoxWidget(this->ui->cbox_dbName); 23 | 24 | StringListResult dbNameList=WidgetUtils::getDBNameList(connData); 25 | 26 | this->ui->cbox_dbName->addItems(dbNameList.list); 27 | 28 | WidgetUtils::setOrAddCurrItem(this->ui->cbox_dbName,dbName); 29 | 30 | if(connData){ 31 | this->ui->le_tableName->setText(StringUtils::unwrapObjNameOnly(connData,tableName)+"_copy"); 32 | 33 | switch(connData->typeId){ 34 | } 35 | } 36 | 37 | this->ui->ch_withData->setChecked(withData); 38 | 39 | this->ui->le_tableName->setFocus(); 40 | 41 | } 42 | 43 | CopyTableDialog::~CopyTableDialog() 44 | { 45 | delete ui; 46 | } 47 | 48 | void CopyTableDialog::closeEvent(QCloseEvent *event) 49 | { 50 | this->hide(); 51 | 52 | stop=true; 53 | if(connData){ 54 | connData->stopConn(); 55 | } 56 | 57 | QTimer *timer = new QTimer(this); 58 | // setup signal and slot 59 | connect(timer, &QTimer::timeout, 60 | this, [=](){ 61 | if(!WidgetUtils::isRunning(this)){ 62 | this->deleteLater(); 63 | } 64 | }); 65 | // msec 66 | timer->start(50); 67 | 68 | event->ignore(); 69 | } 70 | 71 | void CopyTableDialog::on_btn_cancel_clicked() 72 | { 73 | this->close(); 74 | } 75 | 76 | void CopyTableDialog::on_btn_ok_clicked() 77 | { 78 | auto runRef=WidgetUtils::createRunRef(this); 79 | this->ui->btn_ok->setEnabled(false); 80 | LastRun lr{[=](){ 81 | this->ui->btn_ok->setEnabled(true); 82 | }}; 83 | 84 | QString newDBName=this->ui->cbox_dbName->currentText(); 85 | QString newTableName=this->ui->le_tableName->text(); 86 | if(Utils::testOrReconn(this->connData)){ 87 | if(this->ui->ch_withData->isChecked()){ 88 | QString sql; 89 | auto resJson=Utils::executeSql(connData,"create",sql,{},this->dbName); 90 | if(Utils::testResult(resJson)){ 91 | 92 | auto item=MainWindow::getContent()->getLeftTree()->getTablesItem(this->connData,newDBName); 93 | if(item&&item->isExpanded()){ 94 | 95 | MainWindow::getContent()->getLeftTree()->refreshItem(item,newTableName); 96 | 97 | } 98 | 99 | this->close(); 100 | } 101 | }else{ 102 | QString sql; 103 | sql=sql.arg(StringUtils::mergeSchema(StringUtils::wrapObjName(connData,newTableName),StringUtils::wrapName(connData,newDBName))). 104 | arg(StringUtils::mergeSchema(StringUtils::wrapObjName(connData,this->tableName),StringUtils::wrapName(connData,this->dbName))); 105 | auto resJson=Utils::executeSql(connData,"create",sql,{},this->dbName); 106 | if(Utils::testResult(resJson)){ 107 | 108 | auto item=MainWindow::getContent()->getLeftTree()->getTablesItem(this->connData,newDBName); 109 | if(item&&item->isExpanded()){ 110 | 111 | MainWindow::getContent()->getLeftTree()->refreshItem(item,newTableName); 112 | } 113 | 114 | this->close(); 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /cpp/copytabledialog.h: -------------------------------------------------------------------------------- 1 | #ifndef COPYTABLEDIALOG_H 2 | #define COPYTABLEDIALOG_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class CopyTableDialog; 10 | } 11 | 12 | class CopyTableDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit CopyTableDialog(QSharedPointer connData,QString dbName,QString tableName,bool withData,QWidget *parent = nullptr); 18 | 19 | private slots: 20 | void on_btn_cancel_clicked(); 21 | 22 | void on_btn_ok_clicked(); 23 | 24 | private: 25 | Ui::CopyTableDialog *ui; 26 | 27 | ~CopyTableDialog(); 28 | 29 | QSharedPointer connData; 30 | QString dbName; 31 | QString tableName; 32 | 33 | public: 34 | 35 | void closeEvent(QCloseEvent *event) override; 36 | 37 | private: 38 | 39 | std::atomic_bool stop=false; 40 | 41 | }; 42 | 43 | #endif // COPYTABLEDIALOG_H 44 | -------------------------------------------------------------------------------- /cpp/copytabledialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | CopyTableDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 117 11 | 12 | 13 | 14 | Copy to new table 15 | 16 | 17 | 18 | 19 | 20 | Database: 21 | 22 | 23 | 24 | 25 | 26 | 27 | true 28 | 29 | 30 | 31 | 32 | 33 | 34 | New Table Name: 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Copy with data 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Qt::Horizontal 54 | 55 | 56 | 57 | 199 58 | 20 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | OK 67 | 68 | 69 | 70 | 71 | 72 | 73 | Cancel 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /cpp/cpp.cxx: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /cpp/customcheckbox.cpp: -------------------------------------------------------------------------------- 1 | #include "customcheckbox.h" 2 | #include "widgetutils.h" 3 | 4 | #include 5 | #include 6 | 7 | CustomCheckBox::CustomCheckBox(QWidget *parent) : QWidget(parent) 8 | { 9 | WidgetUtils::setSafeDeleteOnClose(this); 10 | 11 | this->setLayout(new QHBoxLayout(this)); 12 | this->layout()->setAlignment(Qt::AlignCenter); 13 | this->layout()->setContentsMargins(0,0,0,0); 14 | // this->setAutoFillBackground(true); 15 | chkBox=new QCheckBox(this); 16 | this->layout()->addWidget(chkBox); 17 | 18 | CustomEventFilter *eventFilter=new CustomEventFilter{chkBox}; 19 | eventFilter->setFunc([=](QObject *obj, QEvent *event){ 20 | switch (event->type()) 21 | { 22 | case QEvent::MouseButtonRelease:{ 23 | QTimer::singleShot(0,this,[=](){ 24 | this->mouseReleaseEvent((QMouseEvent*)event); 25 | }); 26 | return true; 27 | } 28 | break; 29 | } 30 | return false; 31 | }); 32 | chkBox->installEventFilter(eventFilter); 33 | } 34 | 35 | void CustomCheckBox::setOldChecked(bool checked) 36 | { 37 | this->old_chked=checked; 38 | } 39 | 40 | bool CustomCheckBox::getOldChecked() 41 | { 42 | return this->old_chked; 43 | } 44 | 45 | void CustomCheckBox::setChecked(bool checked) 46 | { 47 | if(readonly)return; 48 | 49 | chkBox->setChecked(checked); 50 | emit this->checked(checked); 51 | } 52 | 53 | bool CustomCheckBox::getChecked() 54 | { 55 | return chkBox->isChecked(); 56 | } 57 | 58 | void CustomCheckBox::setText(const QString &text) 59 | { 60 | if(readonly)return; 61 | chkBox->setText(text); 62 | } 63 | 64 | QString CustomCheckBox::getText() const 65 | { 66 | return chkBox->text(); 67 | } 68 | 69 | void CustomCheckBox::setOldText(const QString &text) 70 | { 71 | this->old_text=text; 72 | } 73 | 74 | QString CustomCheckBox::getOldText() const 75 | { 76 | return old_text; 77 | } 78 | 79 | void CustomCheckBox::mouseReleaseEvent(QMouseEvent *event) 80 | { 81 | if(!this->ignoreMouseEvent){ 82 | bool chked=this->getChecked(); 83 | this->setChecked(!chked); 84 | } 85 | emit this->mouseRelease(this->getChecked()); 86 | } 87 | 88 | bool CustomCheckBox::getReadonly() const 89 | { 90 | return readonly; 91 | } 92 | 93 | void CustomCheckBox::setReadonly(bool value) 94 | { 95 | readonly = value; 96 | chkBox->setDisabled(readonly); 97 | } 98 | 99 | bool CustomCheckBox::hasChanged() 100 | { 101 | return ((chkBox->isChecked()!=this->old_chked)||(!StringUtils::equalIncase(chkBox->text(),this->old_text))); 102 | } 103 | 104 | bool CustomCheckBox::getIgnoreMouseEvent() const 105 | { 106 | return ignoreMouseEvent; 107 | } 108 | 109 | void CustomCheckBox::setIgnoreMouseEvent(bool value) 110 | { 111 | ignoreMouseEvent = value; 112 | } 113 | 114 | void CustomCheckBox::closeEvent(QCloseEvent *event) 115 | { 116 | this->hide(); 117 | 118 | stop=true; 119 | 120 | QTimer *timer = new QTimer(this); 121 | // setup signal and slot 122 | connect(timer, &QTimer::timeout, 123 | this, [=](){ 124 | if(!WidgetUtils::isRunning(this)){ 125 | this->deleteLater(); 126 | } 127 | }); 128 | // msec 129 | timer->start(50); 130 | 131 | event->ignore(); 132 | } 133 | -------------------------------------------------------------------------------- /cpp/databasemanagerform.h: -------------------------------------------------------------------------------- 1 | #ifndef DATABASEMANAGERFORM_H 2 | #define DATABASEMANAGERFORM_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class DatabaseManagerForm; 10 | } 11 | 12 | class DatabaseManagerForm : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit DatabaseManagerForm(QSharedPointer connData,QWidget *parent = nullptr); 18 | ~DatabaseManagerForm(); 19 | 20 | 21 | 22 | void safeDelete(); 23 | void closeEvent(QCloseEvent *event) override; 24 | 25 | void refresh(); 26 | void refresh_process(); 27 | void refresh_variables(); 28 | 29 | QSharedPointer getConnData() const; 30 | 31 | void copyToExcel(QTableWidget * tw,bool isXlsx); 32 | 33 | void updateStatusBar(); 34 | 35 | 36 | private slots: 37 | void on_tabWidget_currentChanged(int index); 38 | 39 | void on_tw_variables_cellChanged(int row, int column); 40 | 41 | void on_le_twfilter_db_textChanged(const QString &arg1); 42 | 43 | void on_le_twfilter_proc_textChanged(const QString &arg1); 44 | 45 | void on_le_twfilter_var_textChanged(const QString &arg1); 46 | 47 | void on_le_twfilter_db_returnPressed(); 48 | 49 | void on_le_twfilter_proc_returnPressed(); 50 | 51 | void on_le_twfilter_var_returnPressed(); 52 | 53 | private: 54 | Ui::DatabaseManagerForm *ui; 55 | 56 | QMap> varMap; 57 | 58 | QSharedPointer connData; 59 | 60 | 61 | std::atomic_bool stop=false; 62 | 63 | }; 64 | 65 | #endif // DATABASEMANAGERFORM_H 66 | -------------------------------------------------------------------------------- /cpp/databasemanagerform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DatabaseManagerForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Qt::ClickFocus 15 | 16 | 17 | Form 18 | 19 | 20 | 21 | 3 22 | 23 | 24 | 3 25 | 26 | 27 | 3 28 | 29 | 30 | 3 31 | 32 | 33 | 34 | 35 | 0 36 | 37 | 38 | 39 | Databases 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 0 49 | 0 50 | 51 | 52 | 53 | Regex Filter 54 | 55 | 56 | true 57 | 58 | 59 | 60 | 61 | 62 | 63 | Qt::Horizontal 64 | 65 | 66 | 67 | 40 68 | 20 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Processes 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 0 92 | 0 93 | 94 | 95 | 96 | Regex Filter 97 | 98 | 99 | true 100 | 101 | 102 | 103 | 104 | 105 | 106 | Qt::Horizontal 107 | 108 | 109 | 110 | 40 111 | 20 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | Variables 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 0 135 | 0 136 | 137 | 138 | 139 | Regex Filter 140 | 141 | 142 | true 143 | 144 | 145 | 146 | 147 | 148 | 149 | Qt::Horizontal 150 | 151 | 152 | 153 | 40 154 | 20 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /cpp/datetimeeditdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "datetimeeditdelegate.h" 2 | #include "widgetutils.h" 3 | 4 | #include 5 | #include 6 | 7 | DateTimeEditDelegate::DateTimeEditDelegate(DateTimeEditType editType,QObject *parent) : QStyledItemDelegate(parent),editType(editType) 8 | { 9 | 10 | } 11 | 12 | void DateTimeEditDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 13 | { 14 | auto opt=option; 15 | WidgetUtils::paint(painter,opt,index); 16 | } 17 | 18 | QSize DateTimeEditDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 19 | { 20 | 21 | return QStyledItemDelegate::sizeHint(option, index); 22 | } 23 | 24 | QWidget *DateTimeEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 25 | { 26 | 27 | QLineEdit *editor = new QLineEdit(parent); 28 | editor->setReadOnly(this->readonly); 29 | WidgetUtils::customLineEditWidgetAddDateTimeEdit(this->editType,editor); 30 | 31 | if(initFunc){ 32 | initFunc(editor); 33 | } 34 | 35 | return editor; 36 | } 37 | 38 | void DateTimeEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 39 | { 40 | 41 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 42 | QString value = WidgetUtils::getData(index).toString(); 43 | QLineEdit *lineEdit = static_cast(editor); 44 | lineEdit->setText(value); 45 | } 46 | } 47 | 48 | void DateTimeEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 49 | { 50 | if(this->readonly)return; 51 | 52 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 53 | QLineEdit *lineEdit = static_cast(editor); 54 | bool changed=WidgetUtils::setData(model,index,lineEdit->text()); 55 | if(changed){ 56 | if(dataChangedFunc){ 57 | dataChangedFunc(index); 58 | } 59 | } 60 | if(dataWriteFunc){ 61 | dataWriteFunc(index,changed); 62 | } 63 | } 64 | } 65 | 66 | bool DateTimeEditDelegate::getReadonly() const 67 | { 68 | return readonly; 69 | } 70 | 71 | void DateTimeEditDelegate::setReadonly(bool value) 72 | { 73 | readonly = value; 74 | } 75 | -------------------------------------------------------------------------------- /cpp/datetimeeditdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef DATETIMEEDITDELEGATE_H 2 | #define DATETIMEEDITDELEGATE_H 3 | 4 | #include 5 | #include 6 | #include "datetimeeditform.h" 7 | 8 | class DateTimeEditDelegate : public QStyledItemDelegate 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit DateTimeEditDelegate(DateTimeEditType editType,QObject *parent = nullptr); 13 | 14 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 15 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 16 | 17 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 18 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 19 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 20 | 21 | std::function initFunc=nullptr; 22 | 23 | std::function dataChangedFunc=nullptr; 24 | std::function dataWriteFunc=nullptr; 25 | 26 | bool getReadonly() const; 27 | void setReadonly(bool value); 28 | 29 | signals: 30 | 31 | public slots: 32 | 33 | private: 34 | bool readonly=false; 35 | 36 | DateTimeEditType editType; 37 | }; 38 | 39 | #endif // DATETIMEEDITDELEGATE_H 40 | -------------------------------------------------------------------------------- /cpp/datetimeeditform.cpp: -------------------------------------------------------------------------------- 1 | #include "datetimeeditform.h" 2 | #include "ui_datetimeeditform.h" 3 | #include "utils.h" 4 | #include "mainwindow.h" 5 | #include "widgetutils.h" 6 | 7 | #include 8 | #include 9 | 10 | DateTimeEditForm::DateTimeEditForm(QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::DateTimeEditForm) 13 | { 14 | ui->setupUi(this); 15 | 16 | WidgetUtils::setSafeDeleteOnClose(this); 17 | 18 | setWindowFlag(Qt::Popup); 19 | 20 | #if defined(Q_OS_MAC) 21 | this->ui->calendarWidget->setStyle(WidgetUtils::getFusionStyle());//Macos默认风格日历等控件后台更改不刷新,所以这里用Fusion 22 | this->ui->timeEdit->setStyle(WidgetUtils::getFusionStyle()); 23 | this->setStyle(WidgetUtils::getFusionStyle()); 24 | #endif 25 | 26 | this->ui->timeEdit->setDisplayFormat("hh:mm:ss"); 27 | this->ui->timeEdit->setWrapping(true); 28 | 29 | this->ui->timeEdit->setStyleSheet("border: 1px solid #ADADAD"); 30 | 31 | this->ui->le_microTime->setMaximumWidth(Utils::getCharGuiFontRect().width()*14); 32 | 33 | // QRegularExpression regx("^[0-9]*$"); 34 | // QValidator *validator = new QRegularExpressionValidator(regx, this ); 35 | // this->ui->le_microTime->setValidator( validator ); 36 | 37 | this->ui->le_microTime->setStyleSheet("border: 1px solid #ADADAD"); 38 | 39 | { 40 | QToolButton *tools =this->ui->calendarWidget->findChild(QLatin1String("qt_calendar_prevmonth")); 41 | if(tools){ 42 | QIcon i(":/images/dark/calendar_prevmonth.svg"); 43 | tools->setIcon(i); 44 | } 45 | } 46 | { 47 | QToolButton *tools=this->ui->calendarWidget->findChild(QLatin1String("qt_calendar_nextmonth")); 48 | if(tools){ 49 | QIcon i(":/images/dark/calendar_nextmonth.svg"); 50 | tools->setIcon(i); 51 | } 52 | } 53 | 54 | } 55 | 56 | DateTimeEditForm::~DateTimeEditForm() 57 | { 58 | delete ui; 59 | } 60 | 61 | bool DateTimeEditForm::getReadonly() const 62 | { 63 | return readonly; 64 | } 65 | 66 | void DateTimeEditForm::setReadonly(bool value) 67 | { 68 | readonly = value; 69 | 70 | this->ui->btn_ok->setEnabled(!readonly); 71 | } 72 | 73 | void DateTimeEditForm::on_btn_cancel_clicked() 74 | { 75 | this->okExit=false; 76 | 77 | QWidget::close(); 78 | } 79 | 80 | QString DateTimeEditForm::getDateTime() const 81 | { 82 | if(!this->okExit){ 83 | return this->dateTime; 84 | } 85 | 86 | QString currDate=this->ui->calendarWidget->selectedDate().toString("yyyy-MM-dd"); 87 | 88 | QString curTime=this->ui->timeEdit->text(); 89 | if(this->ui->le_microTime->text().trimmed().length()>0){ 90 | curTime+="."+this->ui->le_microTime->text().trimmed(); 91 | } 92 | 93 | return currDate+" "+curTime; 94 | } 95 | 96 | void DateTimeEditForm::setDateTime(const QString &value) 97 | { 98 | this->dateTime = value.trimmed(); 99 | 100 | QStringList list=value.split('T'); 101 | if(list.size()<2){ 102 | list=value.split(' '); 103 | } 104 | if(list.size()>=2){ 105 | this->date=list.first(); 106 | list.removeFirst(); 107 | this->time=list.join(' '); 108 | }else{ 109 | this->date=value; 110 | this->time=""; 111 | } 112 | 113 | this->ui->calendarWidget->setSelectedDate(QDate::fromString(this->date,"yyyy-MM-dd")); 114 | 115 | this->ui->calendarWidget->setFocus(); 116 | 117 | int findIdx=time.indexOf('.'); 118 | if(findIdx>2){ 119 | QString t=this->time.left(findIdx); 120 | this->ui->timeEdit->setTime(QTime::fromString(t,"hh:mm:ss")); 121 | 122 | QString microTime=time.right(time.length()-findIdx-1); 123 | this->ui->le_microTime->setText(microTime); 124 | }else{ 125 | this->ui->timeEdit->setTime(QTime::fromString(this->time,"hh:mm:ss")); 126 | } 127 | 128 | this->ui->calendarWidget->show(); 129 | this->ui->wid_timeEdit->show(); 130 | } 131 | 132 | 133 | QString DateTimeEditForm::getTime() const 134 | { 135 | if(!this->okExit){ 136 | return this->time; 137 | } 138 | 139 | QString curTime=this->ui->timeEdit->text(); 140 | if(this->ui->le_microTime->text().trimmed().length()>0){ 141 | curTime+="."+this->ui->le_microTime->text().trimmed(); 142 | } 143 | return curTime; 144 | } 145 | 146 | void DateTimeEditForm::setTime(const QString &value) 147 | { 148 | time = value.trimmed(); 149 | 150 | int findIdx=time.indexOf('.'); 151 | if(findIdx>2){ 152 | QString t=this->time.left(findIdx); 153 | this->ui->timeEdit->setTime(QTime::fromString(t,"hh:mm:ss")); 154 | 155 | QString microTime=time.right(time.length()-findIdx-1); 156 | this->ui->le_microTime->setText(microTime); 157 | }else{ 158 | this->ui->timeEdit->setTime(QTime::fromString(this->time,"hh:mm:ss")); 159 | } 160 | 161 | this->ui->calendarWidget->hide(); 162 | this->ui->wid_timeEdit->show(); 163 | 164 | this->resize(this->width(),1); 165 | 166 | } 167 | 168 | QString DateTimeEditForm::getDate() const 169 | { 170 | if(!this->okExit){ 171 | return this->date; 172 | } 173 | 174 | QString currDate=this->ui->calendarWidget->selectedDate().toString("yyyy-MM-dd"); 175 | return currDate; 176 | } 177 | 178 | void DateTimeEditForm::setDate(const QString &value) 179 | { 180 | date = value; 181 | 182 | this->ui->calendarWidget->setSelectedDate(QDate::fromString(this->date,"yyyy-MM-dd")); 183 | 184 | this->ui->calendarWidget->setFocus(); 185 | 186 | this->ui->calendarWidget->show(); 187 | this->ui->wid_timeEdit->hide(); 188 | 189 | this->resize(this->width(),1); 190 | } 191 | 192 | void DateTimeEditForm::on_btn_ok_clicked() 193 | { 194 | this->okExit=true; 195 | 196 | QWidget::close(); 197 | 198 | } 199 | 200 | void DateTimeEditForm::closeEvent(QCloseEvent *event) 201 | { 202 | 203 | this->hide(); 204 | 205 | stop=true; 206 | 207 | emit editClosed(); 208 | 209 | QTimer *timer = new QTimer(this); 210 | // setup signal and slot 211 | connect(timer, &QTimer::timeout, 212 | this, [=](){ 213 | if(!WidgetUtils::isRunning(this)){ 214 | this->deleteLater(); 215 | } 216 | }); 217 | // msec 218 | timer->start(50); 219 | 220 | event->ignore(); 221 | } 222 | 223 | void DateTimeEditForm::waitExit() 224 | { 225 | auto runRef=WidgetUtils::createRunRef(this); 226 | 227 | this->okExit=false; 228 | 229 | QSharedPointer loop{new EventLoop{this}}; 230 | 231 | connect(this,&DateTimeEditForm::editClosed,[=](){loop->quit();}); 232 | 233 | loop->exec(); 234 | } 235 | 236 | void DateTimeEditForm::on_btn_now_clicked() 237 | { 238 | this->ui->calendarWidget->setSelectedDate(QDate::currentDate()); 239 | this->ui->timeEdit->setTime(QTime::currentTime()); 240 | } 241 | -------------------------------------------------------------------------------- /cpp/datetimeeditform.h: -------------------------------------------------------------------------------- 1 | #ifndef DATETIMEEDITFORM_H 2 | #define DATETIMEEDITFORM_H 3 | 4 | #include 5 | 6 | enum class DateTimeEditType{ 7 | time, 8 | date, 9 | datetime 10 | }; 11 | 12 | namespace Ui { 13 | class DateTimeEditForm; 14 | } 15 | 16 | class DateTimeEditForm : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit DateTimeEditForm(QWidget *parent = nullptr); 22 | 23 | QString getDate() const; 24 | void setDate(const QString &value); 25 | 26 | QString getTime() const; 27 | void setTime(const QString &value); 28 | 29 | QString getDateTime() const; 30 | void setDateTime(const QString &value); 31 | 32 | void waitExit(); 33 | 34 | 35 | signals: 36 | 37 | void editClosed(); 38 | 39 | private slots: 40 | void on_btn_cancel_clicked(); 41 | 42 | void on_btn_ok_clicked(); 43 | 44 | void on_btn_now_clicked(); 45 | 46 | private: 47 | Ui::DateTimeEditForm *ui; 48 | 49 | ~DateTimeEditForm(); 50 | 51 | QString date; 52 | QString time; 53 | QString dateTime; 54 | 55 | bool okExit=false; 56 | 57 | bool readonly=false; 58 | 59 | public: 60 | 61 | void closeEvent(QCloseEvent *event) override; 62 | 63 | bool getReadonly() const; 64 | void setReadonly(bool value); 65 | 66 | private: 67 | 68 | std::atomic_bool stop=false; 69 | }; 70 | 71 | #endif // DATETIMEEDITFORM_H 72 | -------------------------------------------------------------------------------- /cpp/datetimeeditform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DateTimeEditForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 241 10 | 257 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Form 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 3 28 | 29 | 30 | 3 31 | 32 | 33 | 3 34 | 35 | 36 | 3 37 | 38 | 39 | 40 | 41 | QCalendarWidget::NoVerticalHeader 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 3 50 | 51 | 52 | 0 53 | 54 | 55 | 0 56 | 57 | 58 | 0 59 | 60 | 61 | 0 62 | 63 | 64 | 65 | 66 | 67 | 0 68 | 0 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 0 78 | 0 79 | 80 | 81 | 82 | . 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 0 91 | 0 92 | 93 | 94 | 95 | 32 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Now 108 | 109 | 110 | 111 | 112 | 113 | 114 | Qt::Horizontal 115 | 116 | 117 | 118 | 40 119 | 20 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | OK 128 | 129 | 130 | 131 | 132 | 133 | 134 | Cancel 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /cpp/dbobjectselectdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "dbobjectselectdialog.h" 2 | #include "ui_dbobjectselectdialog.h" 3 | #include "widgetutils.h" 4 | 5 | #include 6 | 7 | DbObjectSelectDialog::DbObjectSelectDialog(QSharedPointer connData,QWidget *parent) : 8 | QDialog(parent), 9 | ui(new Ui::DbObjectSelectDialog), 10 | connData(connData) 11 | { 12 | ui->setupUi(this); 13 | 14 | WidgetUtils::setSafeDeleteOnClose(this); 15 | 16 | #if defined(Q_OS_MAC) 17 | this->setWindowFlag(Qt::Tool,true); 18 | #endif 19 | 20 | this->ui->tree_myTree->clear(); 21 | 22 | QTimer::singleShot(0,this,[=](){ 23 | auto runRef=WidgetUtils::createRunRef(this); 24 | if(connData){ 25 | this->ui->tree_myTree->viewport()->setHidden(true); 26 | 27 | this->ui->tree_myTree->setInSelectModel(true); 28 | 29 | this->ui->tree_myTree->refreshTree(); 30 | auto dsItem=this->ui->tree_myTree->deleteOtherDsItem(connData); 31 | if(dsItem){ 32 | this->ui->tree_myTree->expandItem(dsItem); 33 | this->ui->tree_myTree->expandItem(dsItem->parent()); 34 | } 35 | 36 | this->ui->tree_myTree->setSelectionMode(QAbstractItemView::ExtendedSelection); 37 | this->ui->tree_myTree->setDragEnabled(false); 38 | 39 | this->ui->tree_myTree->viewport()->setHidden(false); 40 | 41 | } 42 | }); 43 | 44 | 45 | } 46 | 47 | DbObjectSelectDialog::~DbObjectSelectDialog() 48 | { 49 | delete ui; 50 | } 51 | 52 | bool DbObjectSelectDialog::getIsOK() const 53 | { 54 | return isOK; 55 | } 56 | 57 | MyTreeWidget *DbObjectSelectDialog::getTree() 58 | { 59 | return this->ui->tree_myTree; 60 | } 61 | 62 | QStringList DbObjectSelectDialog::getSelect() 63 | { 64 | auto runRef=WidgetUtils::createRunRef(this); 65 | 66 | this->exec(); 67 | 68 | QStringList ret; 69 | 70 | if(this->isOK){ 71 | 72 | QList list=this->ui->tree_myTree->selectedItems(); 73 | 74 | for(auto item:list){ 75 | if(item){ 76 | QString str; 77 | switch (item->type()) { 78 | case TREE_ITEM_DB:{ 79 | str="Database: "+item->text(0); 80 | }break; 81 | case TREE_ITEM_TABLE:{ 82 | str="Table: "+this->ui->tree_myTree->getDbName(item)+"."+item->text(0); 83 | }break; 84 | case TREE_ITEM_VIEW:{ 85 | str="View: "+this->ui->tree_myTree->getDbName(item)+"."+item->text(0); 86 | }break; 87 | case TREE_ITEM_FUNCTION:{ 88 | str="Function: "+this->ui->tree_myTree->getDbName(item)+"."+item->text(0); 89 | }break; 90 | case TREE_ITEM_PROCEDURE:{ 91 | str="Procedure: "+this->ui->tree_myTree->getDbName(item)+"."+item->text(0); 92 | }break; 93 | case TREE_ITEM_COLUMN:{ 94 | str="Column: "+this->ui->tree_myTree->getDbName(item)+"."+item->parent()->text(0)+"."+item->text(0); 95 | }break; 96 | case TREE_ITEM_SEQUENCE:{ 97 | str="Sequence: "+this->ui->tree_myTree->getDbName(item)+"."+item->text(0); 98 | }break; 99 | } 100 | if(!str.isEmpty()){ 101 | ret.push_back(str); 102 | } 103 | } 104 | } 105 | 106 | } 107 | 108 | return ret; 109 | } 110 | 111 | void DbObjectSelectDialog::closeEvent(QCloseEvent *event) 112 | { 113 | this->hide(); 114 | 115 | stop=true; 116 | if(connData){ 117 | connData->stopConn(); 118 | } 119 | 120 | QTimer *timer = new QTimer(this); 121 | // setup signal and slot 122 | connect(timer, &QTimer::timeout, 123 | this, [=](){ 124 | if(!WidgetUtils::isRunning(this)){ 125 | this->deleteLater(); 126 | } 127 | }); 128 | // msec 129 | timer->start(50); 130 | 131 | event->ignore(); 132 | } 133 | 134 | void DbObjectSelectDialog::on_btn_ok_clicked() 135 | { 136 | this->isOK=true; 137 | this->close(); 138 | } 139 | 140 | void DbObjectSelectDialog::on_btn_cancel_clicked() 141 | { 142 | this->isOK=false; 143 | this->close(); 144 | } 145 | 146 | void DbObjectSelectDialog::on_le_filter_textChanged(const QString &arg1) 147 | { 148 | WidgetUtils::treeFilter(this->stop,ui->tree_myTree,ui->le_filter); 149 | } 150 | 151 | void DbObjectSelectDialog::on_le_filter_returnPressed() 152 | { 153 | this->on_le_filter_textChanged(""); 154 | } 155 | 156 | void DbObjectSelectDialog::on_btn_collapse_clicked() 157 | { 158 | QTreeWidgetItem *item=ui->tree_myTree->currentItem(); 159 | if(!item)return; 160 | item->setExpanded(false); 161 | if(item->parent()){ 162 | item->parent()->setExpanded(false); 163 | ui->tree_myTree->setCurrentItem(item->parent()); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /cpp/dbobjectselectdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef DBOBJECTSELECTDIALOG_H 2 | #define DBOBJECTSELECTDIALOG_H 3 | 4 | #include 5 | #include "mytreewidget.h" 6 | 7 | namespace Ui { 8 | class DbObjectSelectDialog; 9 | } 10 | 11 | class DbObjectSelectDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit DbObjectSelectDialog(QSharedPointer connData,QWidget *parent = nullptr); 17 | 18 | private: 19 | ~DbObjectSelectDialog(); 20 | Ui::DbObjectSelectDialog *ui; 21 | 22 | QSharedPointer connData; 23 | 24 | bool isOK=false; 25 | 26 | 27 | public: 28 | 29 | void closeEvent(QCloseEvent *event) override; 30 | 31 | bool getIsOK() const; 32 | 33 | MyTreeWidget * getTree(); 34 | 35 | QStringList getSelect(); 36 | 37 | private slots: 38 | void on_btn_ok_clicked(); 39 | 40 | void on_btn_cancel_clicked(); 41 | 42 | void on_le_filter_textChanged(const QString &arg1); 43 | 44 | void on_le_filter_returnPressed(); 45 | 46 | void on_btn_collapse_clicked(); 47 | 48 | private: 49 | 50 | std::atomic_bool stop=false; 51 | 52 | }; 53 | 54 | #endif // DBOBJECTSELECTDIALOG_H 55 | -------------------------------------------------------------------------------- /cpp/dbobjectselectdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbObjectSelectDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 358 10 | 470 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Regex Filter 23 | 24 | 25 | true 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Collapse 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Qt::Horizontal 67 | 68 | 69 | 70 | 40 71 | 20 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | OK 80 | 81 | 82 | 83 | 84 | 85 | 86 | Cancel 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | MyTreeWidget 97 | QWidget 98 |
mytreewidget.h
99 |
100 |
101 | 102 | 103 |
104 | -------------------------------------------------------------------------------- /cpp/driverdownloadform.cpp: -------------------------------------------------------------------------------- 1 | #include "driverdownloadform.h" 2 | #include "ui_driverdownloadform.h" 3 | #include "utils.h" 4 | #include "widgetutils.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | DriverDownloadForm::DriverDownloadForm(QJsonObject res,QWidget *parent) : 12 | QDialog(parent), 13 | ui(new Ui::DriverDownloadForm) 14 | { 15 | ui->setupUi(this); 16 | 17 | WidgetUtils::setSafeDeleteOnClose(this); 18 | 19 | this->setModal(true); 20 | 21 | this->ui->lb_info->setText(Utils::getString(res,"errInfo")); 22 | this->ui->le_driverClass->setText(Utils::getString(res,"driverClass")); 23 | // this->ui->le_driverJar->setText(Utils::getString(res,"driverJar")); 24 | 25 | QString target=Utils::getLibPath(); 26 | this->ui->le_lib_path->setText(target); 27 | 28 | QString downLoadUrl=Utils::getString(res,"downloadUrl"); 29 | QString downLoadPage=Utils::getString(res,"downloadPage"); 30 | if(downLoadUrl.trimmed().length()>0){ 31 | this->ui->te_downloadUrl->setText(downLoadUrl.trimmed()); 32 | 33 | this->ui->lb_urlType->setText("Download Url:"); 34 | this->ui->btn_download->setText("Download"); 35 | } 36 | if(downLoadPage.trimmed().length()>0){ 37 | this->ui->te_downloadUrl->setText(downLoadPage.trimmed()); 38 | 39 | this->ui->lb_urlType->setText("Download Page:"); 40 | this->ui->btn_download->setText("OpenPage"); 41 | } 42 | 43 | } 44 | 45 | DriverDownloadForm::~DriverDownloadForm() 46 | { 47 | delete ui; 48 | } 49 | 50 | void DriverDownloadForm::closeEvent(QCloseEvent *event) 51 | { 52 | this->hide(); 53 | 54 | stop=true; 55 | 56 | if(this->connData){ 57 | this->connData->stopConn(); 58 | } 59 | 60 | QTimer *timer = new QTimer(this); 61 | // setup signal and slot 62 | connect(timer, &QTimer::timeout, 63 | this, [=](){ 64 | if(!WidgetUtils::isRunning(this)){ 65 | this->deleteLater(); 66 | } 67 | }); 68 | // msec 69 | timer->start(50); 70 | 71 | event->ignore(); 72 | } 73 | 74 | void DriverDownloadForm::on_btn_download_clicked() 75 | { 76 | this->ui->btn_download->setEnabled(false); 77 | auto runRef=WidgetUtils::createRunRef(this); 78 | LastRun lr{[=](){ 79 | this->ui->btn_download->setEnabled(true); 80 | 81 | }}; 82 | if(this->ui->btn_download->text()=="Download"){ 83 | 84 | BtnLoadingIcon bli{this->ui->btn_download}; 85 | 86 | QStringList list=this->ui->te_downloadUrl->toPlainText().trimmed().split('\n'); 87 | 88 | if(list.isEmpty())return; 89 | 90 | int succNum=0; 91 | QString errInfo; 92 | for(QString urlStr:list){ 93 | urlStr=urlStr.trimmed(); 94 | if(urlStr.isEmpty())continue; 95 | 96 | QUrl url{urlStr}; 97 | 98 | QString target=Utils::getLibPath(); 99 | 100 | target+=url.fileName(); 101 | 102 | if(Utils::testConnData(connData)){ 103 | QJsonObject json; 104 | json.insert("funcId", DOWNLOAD_URL); 105 | json.insert("file", target); 106 | json.insert("url", url.toString()); 107 | 108 | Result res{connData->getResJson(json)}; 109 | if(res.testResult(false)){ 110 | succNum++; 111 | }else{ 112 | errInfo=res.getErrInfo(); 113 | if(res.getErrNo()==-901){//如果是文件只读导致的错误则不结束,继续其他文件下载 114 | continue; 115 | } 116 | break; 117 | } 118 | } 119 | } 120 | 121 | if(succNum<=0&&errInfo.length()>0){ 122 | QMessageBox::critical(this, QCoreApplication::applicationName(),errInfo); 123 | return; 124 | } 125 | 126 | WidgetUtils::showSuccDialog(QCoreApplication::applicationName(),tr("Download Success."),tr("OK")); 127 | this->close(); 128 | 129 | Utils::restartServer(); 130 | 131 | }else if(this->ui->btn_download->text()=="OpenPage"){ 132 | 133 | QUrl url{this->ui->te_downloadUrl->toPlainText().trimmed()}; 134 | QDesktopServices::openUrl(url); 135 | } 136 | } 137 | 138 | void DriverDownloadForm::on_btn_cancel_clicked() 139 | { 140 | this->close(); 141 | } 142 | 143 | void DriverDownloadForm::on_btn_open_clicked() 144 | { 145 | QDesktopServices::openUrl(QUrl::fromLocalFile(this->ui->le_lib_path->text())); 146 | } 147 | -------------------------------------------------------------------------------- /cpp/driverdownloadform.h: -------------------------------------------------------------------------------- 1 | #ifndef DRIVERDOWNLOADFORM_H 2 | #define DRIVERDOWNLOADFORM_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class DriverDownloadForm; 12 | } 13 | 14 | class DriverDownloadForm : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit DriverDownloadForm(QJsonObject res,QWidget *parent = nullptr); 20 | ~DriverDownloadForm(); 21 | 22 | private: 23 | Ui::DriverDownloadForm *ui; 24 | 25 | QSharedPointer connData{new ConnData}; 26 | 27 | public: 28 | 29 | void closeEvent(QCloseEvent *event) override; 30 | 31 | private slots: 32 | void on_btn_download_clicked(); 33 | 34 | void on_btn_cancel_clicked(); 35 | 36 | void on_btn_open_clicked(); 37 | 38 | private: 39 | 40 | std::atomic_bool stop=false; 41 | }; 42 | 43 | #endif // DRIVERDOWNLOADFORM_H 44 | -------------------------------------------------------------------------------- /cpp/driverdownloadform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DriverDownloadForm 4 | 5 | 6 | Qt::NonModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 587 13 | 312 14 | 15 | 16 | 17 | DriverDownload 18 | 19 | 20 | 21 | 22 | 23 | Download Java libraries 24 | 25 | 26 | 27 | 28 | 29 | 30 | Info 31 | 32 | 33 | 34 | 35 | 36 | 37 | Driver Class name: 38 | 39 | 40 | 41 | 42 | 43 | 44 | false 45 | 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | 54 | Lib Path: 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | false 64 | 65 | 66 | true 67 | 68 | 69 | 70 | 71 | 72 | 73 | View 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Download Url: 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | Qt::Horizontal 98 | 99 | 100 | 101 | 40 102 | 20 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Download 111 | 112 | 113 | 114 | 115 | 116 | 117 | Cancel 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | btn_download 130 | le_lib_path 131 | te_downloadUrl 132 | le_driverClass 133 | btn_cancel 134 | btn_open 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /cpp/editdatabasedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef EDITDATABASEDIALOG_H 2 | #define EDITDATABASEDIALOG_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class EditDatabaseDialog; 10 | } 11 | 12 | enum class EditDatabaseType{ 13 | newDatabase, 14 | editDatabase, 15 | viewDatabase 16 | }; 17 | 18 | class EditDatabaseDialog : public QDialog 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit EditDatabaseDialog(QSharedPointer connData, const QString &dbName,EditDatabaseType edtype,QWidget *parent = nullptr); 24 | 25 | QString getUpdateSql(); 26 | 27 | private slots: 28 | void on_cbox_charset_currentTextChanged(const QString &arg1); 29 | 30 | void on_btn_cancel_clicked(); 31 | 32 | void on_btn_ok_clicked(); 33 | 34 | private: 35 | Ui::EditDatabaseDialog *ui; 36 | 37 | ~EditDatabaseDialog(); 38 | 39 | QSharedPointer connData; 40 | QString dbName; 41 | EditDatabaseType edtype; 42 | 43 | public: 44 | 45 | void closeEvent(QCloseEvent *event) override; 46 | 47 | private: 48 | 49 | std::atomic_bool stop=false; 50 | 51 | }; 52 | 53 | #endif // EDITDATABASEDIALOG_H 54 | -------------------------------------------------------------------------------- /cpp/editdatabasedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditDatabaseDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 571 10 | 325 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 3 19 | 20 | 21 | 3 22 | 23 | 24 | 3 25 | 26 | 27 | 3 28 | 29 | 30 | 31 | 32 | 0 33 | 34 | 35 | 36 | General 37 | 38 | 39 | 40 | 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Default Collation: 53 | 54 | 55 | 56 | 57 | 58 | 59 | Default Character set: 60 | 61 | 62 | 63 | 64 | 65 | 66 | true 67 | 68 | 69 | 70 | 71 | 72 | 73 | Database: 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | User: 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | SQL Preview 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | Qt::Horizontal 120 | 121 | 122 | 123 | 40 124 | 20 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | OK 133 | 134 | 135 | 136 | 137 | 138 | 139 | Cancel 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | MyEdit 150 | QWidget 151 |
myedit.h
152 |
153 |
154 | 155 | tabWidget 156 | le_database 157 | cbox_charset 158 | cbox_collation 159 | btn_ok 160 | btn_cancel 161 | 162 | 163 | 164 |
165 | -------------------------------------------------------------------------------- /cpp/flowlayout.cpp: -------------------------------------------------------------------------------- 1 | #include "flowlayout.h" 2 | 3 | #include 4 | 5 | FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) 6 | : QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing) 7 | { 8 | setContentsMargins(margin, margin, margin, margin); 9 | } 10 | 11 | FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing) 12 | : m_hSpace(hSpacing), m_vSpace(vSpacing) 13 | { 14 | setContentsMargins(margin, margin, margin, margin); 15 | } 16 | 17 | FlowLayout::~FlowLayout() 18 | { 19 | QLayoutItem *item; 20 | while ((item = takeAt(0))) 21 | delete item; 22 | } 23 | 24 | void FlowLayout::addItem(QLayoutItem *item) 25 | { 26 | itemList.append(item); 27 | } 28 | 29 | int FlowLayout::horizontalSpacing() const 30 | { 31 | if (m_hSpace >= 0) 32 | return m_hSpace; 33 | else 34 | return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); 35 | } 36 | 37 | int FlowLayout::verticalSpacing() const 38 | { 39 | if (m_vSpace >= 0) 40 | return m_vSpace; 41 | else 42 | return smartSpacing(QStyle::PM_LayoutVerticalSpacing); 43 | } 44 | 45 | int FlowLayout::count() const 46 | { 47 | return itemList.size(); 48 | } 49 | 50 | QLayoutItem *FlowLayout::itemAt(int index) const 51 | { 52 | return itemList.value(index); 53 | } 54 | 55 | QLayoutItem *FlowLayout::takeAt(int index) 56 | { 57 | if (index >= 0 && index < itemList.size()) 58 | return itemList.takeAt(index); 59 | else 60 | return nullptr; 61 | } 62 | 63 | Qt::Orientations FlowLayout::expandingDirections() const 64 | { 65 | return {}; 66 | } 67 | 68 | bool FlowLayout::hasHeightForWidth() const 69 | { 70 | return true; 71 | } 72 | 73 | int FlowLayout::heightForWidth(int width) const 74 | { 75 | int height = doLayout(QRect(0, 0, width, 0), true); 76 | return height; 77 | } 78 | 79 | void FlowLayout::setGeometry(const QRect &rect) 80 | { 81 | QLayout::setGeometry(rect); 82 | doLayout(rect, false); 83 | } 84 | 85 | QSize FlowLayout::sizeHint() const 86 | { 87 | return minimumSize(); 88 | } 89 | 90 | QSize FlowLayout::minimumSize() const 91 | { 92 | QSize size; 93 | for (QLayoutItem *item : itemList) 94 | size = size.expandedTo(item->minimumSize()); 95 | 96 | int left, top, right, bottom; 97 | getContentsMargins(&left, &top, &right, &bottom); 98 | size += QSize(left + right, top + bottom); 99 | return size; 100 | } 101 | 102 | int FlowLayout::doLayout(const QRect &rect, bool testOnly) const 103 | { 104 | int left, top, right, bottom; 105 | getContentsMargins(&left, &top, &right, &bottom); 106 | QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom); 107 | int x = effectiveRect.x(); 108 | int y = effectiveRect.y(); 109 | int lineHeight = 0; 110 | 111 | for (QLayoutItem *item : itemList) { 112 | QWidget *wid = item->widget(); 113 | int spaceX = horizontalSpacing(); 114 | if (spaceX == -1) 115 | spaceX = wid->style()->layoutSpacing( 116 | QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); 117 | int spaceY = verticalSpacing(); 118 | if (spaceY == -1) 119 | spaceY = wid->style()->layoutSpacing( 120 | QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); 121 | int nextX = x + item->sizeHint().width() + spaceX; 122 | if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { 123 | x = effectiveRect.x(); 124 | y = y + lineHeight + spaceY; 125 | nextX = x + item->sizeHint().width() + spaceX; 126 | lineHeight = 0; 127 | } 128 | 129 | if (!testOnly) 130 | item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); 131 | 132 | x = nextX; 133 | lineHeight = qMax(lineHeight, item->sizeHint().height()); 134 | } 135 | return y + lineHeight - rect.y() + bottom; 136 | } 137 | 138 | int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const 139 | { 140 | QObject *parent = this->parent(); 141 | if (!parent) { 142 | return -1; 143 | } else if (parent->isWidgetType()) { 144 | auto pw = static_cast(parent); 145 | return pw->style()->pixelMetric(pm, nullptr, pw); 146 | } else { 147 | return static_cast(parent)->spacing(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /cpp/flowlayout.h: -------------------------------------------------------------------------------- 1 | #ifndef FLOWLAYOUT_H 2 | #define FLOWLAYOUT_H 3 | 4 | #include 5 | #include 6 | 7 | class FlowLayout final : public QLayout 8 | { 9 | public: 10 | explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1); 11 | FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1); 12 | ~FlowLayout() override; 13 | 14 | void addItem(QLayoutItem *item) override; 15 | int horizontalSpacing() const; 16 | int verticalSpacing() const; 17 | Qt::Orientations expandingDirections() const override; 18 | bool hasHeightForWidth() const override; 19 | int heightForWidth(int) const override; 20 | int count() const override; 21 | QLayoutItem *itemAt(int index) const override; 22 | QSize minimumSize() const override; 23 | void setGeometry(const QRect &rect) override; 24 | QSize sizeHint() const override; 25 | QLayoutItem *takeAt(int index) override; 26 | 27 | private: 28 | int doLayout(const QRect &rect, bool testOnly) const; 29 | int smartSpacing(QStyle::PixelMetric pm) const; 30 | 31 | QList itemList; 32 | int m_hSpace; 33 | int m_vSpace; 34 | }; 35 | 36 | #endif // FLOWLAYOUT_H 37 | -------------------------------------------------------------------------------- /cpp/jarinfoeditdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "conndialog.h" 2 | #include "jarinfoeditdialog.h" 3 | #include "ui_jarinfoeditdialog.h" 4 | #include "widgetutils.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | JarInfoEditDialog::JarInfoEditDialog(QWidget *parent) : 12 | QDialog(parent), 13 | ui(new Ui::JarInfoEditDialog) 14 | { 15 | ui->setupUi(this); 16 | 17 | WidgetUtils::setSafeDeleteOnClose(this); 18 | 19 | auto getFileBtnFunc=[=](){ 20 | auto runRef=WidgetUtils::createRunRef(this); 21 | 22 | QString lastPath=ui->le_file->text().trimmed(); 23 | if(lastPath.length()>0){ 24 | QFileInfo fileInfo{lastPath}; 25 | lastPath=fileInfo.path(); 26 | } 27 | QFileDialog fdialog(this,QObject::tr("Open File"),lastPath,QObject::tr("Jar (*.jar);;All files(*.*)")); 28 | fdialog.setOption(QFileDialog::DontUseNativeDialog,true); 29 | fdialog.setWindowModality(Qt::WindowModal); 30 | fdialog.setAcceptMode(QFileDialog::AcceptOpen); 31 | if (fdialog.exec() == QDialog::Accepted && fdialog.selectedFiles().length()>0){ 32 | QStringList fnames=fdialog.selectedFiles(); 33 | QString lastName=fnames.last(); 34 | 35 | ui->cbox_dbType->setCurrentText(""); 36 | ui->cbox_driverClass->clear(); 37 | this->setFile(lastName); 38 | } 39 | }; 40 | WidgetUtils::customLineEditWidgetAddBtnFunc(ui->le_file,getFileBtnFunc,true,QIcon {":/images/open.svg"}); 41 | 42 | WidgetUtils::customComboBoxWidget(ui->cbox_dbType); 43 | WidgetUtils::customComboBoxWidget(ui->cbox_driverClass); 44 | 45 | QStringList typeList={""}; 46 | typeList.append(APP_DB_TYPES_FREE); 47 | typeList.append(APP_DB_TYPES_PRO); 48 | ui->cbox_dbType->addItems(typeList); 49 | } 50 | 51 | JarInfoEditDialog::~JarInfoEditDialog() 52 | { 53 | delete ui; 54 | } 55 | 56 | QString JarInfoEditDialog::getFile() const 57 | { 58 | return ui->le_file->text().trimmed(); 59 | } 60 | 61 | void JarInfoEditDialog::setFile(const QString &value) 62 | { 63 | file = value; 64 | 65 | auto runRef=WidgetUtils::createRunRef(this); 66 | 67 | QDir libDir{Utils::getAppDataPath()+"lib/"}; 68 | 69 | ui->le_file->setText(libDir.absoluteFilePath(value)); 70 | 71 | QStringList list; 72 | if(value.trimmed().length()>0){ 73 | list.append(Utils::getDriverClasses(nullptr,ui->le_file->text())); 74 | } 75 | 76 | QString className=ui->cbox_driverClass->currentText().trimmed(); 77 | ui->cbox_driverClass->clear(); 78 | ui->cbox_driverClass->addItems(list); 79 | if(className.length()>0){ 80 | WidgetUtils::setOrAddCurrItem(ui->cbox_driverClass,className); 81 | } 82 | } 83 | 84 | QString JarInfoEditDialog::getType() const 85 | { 86 | return ui->cbox_dbType->currentText().trimmed(); 87 | } 88 | 89 | void JarInfoEditDialog::setType(const QString &value) 90 | { 91 | type = value; 92 | 93 | WidgetUtils::setCurrItem(ui->cbox_dbType,value,false); 94 | } 95 | 96 | QString JarInfoEditDialog::getClassName() const 97 | { 98 | return ui->cbox_driverClass->currentText().trimmed(); 99 | } 100 | 101 | void JarInfoEditDialog::setClassName(const QString &value) 102 | { 103 | className = value; 104 | 105 | WidgetUtils::setOrAddCurrItem(ui->cbox_driverClass,value); 106 | } 107 | 108 | void JarInfoEditDialog::closeEvent(QCloseEvent *event) 109 | { 110 | this->hide(); 111 | 112 | stop=true; 113 | 114 | QTimer *timer = new QTimer(this); 115 | // setup signal and slot 116 | connect(timer, &QTimer::timeout, 117 | this, [=](){ 118 | if(!WidgetUtils::isRunning(this)){ 119 | timer->stop(); 120 | this->deleteLater(); 121 | } 122 | }); 123 | // msec 124 | timer->start(50); 125 | 126 | event->ignore(); 127 | } 128 | 129 | void JarInfoEditDialog::on_btn_ok_clicked() 130 | { 131 | this->close(); 132 | this->accept(); 133 | } 134 | 135 | void JarInfoEditDialog::on_btn_cancel_clicked() 136 | { 137 | this->close(); 138 | } 139 | -------------------------------------------------------------------------------- /cpp/jarinfoeditdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef JARINFOEDITDIALOG_H 2 | #define JARINFOEDITDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class JarInfoEditDialog; 8 | } 9 | 10 | class JarInfoEditDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit JarInfoEditDialog(QWidget *parent = nullptr); 16 | ~JarInfoEditDialog(); 17 | 18 | QString getFile() const; 19 | void setFile(const QString &value); 20 | 21 | QString getType() const; 22 | void setType(const QString &value); 23 | 24 | QString getClassName() const; 25 | void setClassName(const QString &value); 26 | 27 | void closeEvent(QCloseEvent *event) override; 28 | 29 | private slots: 30 | void on_btn_ok_clicked(); 31 | 32 | void on_btn_cancel_clicked(); 33 | 34 | private: 35 | std::atomic_bool stop=false; 36 | 37 | QString file; 38 | QString type; 39 | QString className; 40 | 41 | private: 42 | Ui::JarInfoEditDialog *ui; 43 | }; 44 | 45 | #endif // JARINFOEDITDIALOG_H 46 | -------------------------------------------------------------------------------- /cpp/jarinfoeditdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JarInfoEditDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 584 10 | 229 11 | 12 | 13 | 14 | Drivers & Jars Dialog 15 | 16 | 17 | 18 | 19 | 20 | File: 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Database Type: 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Driver Class: 41 | 42 | 43 | 44 | 45 | 46 | 47 | true 48 | 49 | 50 | 51 | 52 | 53 | 54 | Qt::Vertical 55 | 56 | 57 | 58 | 20 59 | 40 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | Qt::Horizontal 70 | 71 | 72 | 73 | 40 74 | 20 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | OK 83 | 84 | 85 | 86 | 87 | 88 | 89 | Cancel 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /cpp/jarsmanagerform.h: -------------------------------------------------------------------------------- 1 | #ifndef JARSMANAGERFORM_H 2 | #define JARSMANAGERFORM_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class JarsManagerForm; 9 | } 10 | 11 | class JarsManagerForm : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit JarsManagerForm(QWidget *parent = nullptr); 17 | ~JarsManagerForm(); 18 | 19 | void flushLibTree(QString name=""); 20 | 21 | private: 22 | Ui::JarsManagerForm *ui; 23 | 24 | public: 25 | void closeEvent(QCloseEvent *event) override; 26 | 27 | QString getType() const; 28 | void setType(const QString &value); 29 | 30 | private slots: 31 | void on_btn_add_driver_clicked(); 32 | 33 | void on_btn_add_jar_clicked(); 34 | 35 | void on_btn_delete_clicked(); 36 | 37 | void on_btn_edit_clicked(); 38 | 39 | void on_btn_lib_path_clicked(); 40 | 41 | void on_tree_main_itemDoubleClicked(QTreeWidgetItem *item, int column); 42 | 43 | private: 44 | std::atomic_bool stop=false; 45 | 46 | QString type; 47 | }; 48 | 49 | #endif // JARSMANAGERFORM_H 50 | -------------------------------------------------------------------------------- /cpp/jarsmanagerform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JarsManagerForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 728 10 | 420 11 | 12 | 13 | 14 | Drivers & Jars 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Add JDBC Driver 23 | 24 | 25 | 26 | :/images/plus.svg:/images/plus.svg 27 | 28 | 29 | 30 | 31 | 32 | 33 | Add Jar 34 | 35 | 36 | 37 | :/images/plus.svg:/images/plus.svg 38 | 39 | 40 | 41 | 42 | 43 | 44 | Qt::Vertical 45 | 46 | 47 | 48 | 49 | 50 | 51 | Delete 52 | 53 | 54 | 55 | :/images/minus.svg:/images/minus.svg 56 | 57 | 58 | 59 | 60 | 61 | 62 | Qt::Vertical 63 | 64 | 65 | 66 | 67 | 68 | 69 | Edit 70 | 71 | 72 | 73 | :/images/edit_data.svg:/images/edit_data.svg 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Horizontal 81 | 82 | 83 | 84 | 40 85 | 20 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | Library path 94 | 95 | 96 | 97 | :/images/open.svg:/images/open.svg 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 1 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /cpp/jookDB.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-07-29T11:12:16 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui printsupport network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = jookdb 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++17 26 | 27 | !win32{ 28 | QMAKE_CXXFLAGS += -Wno-narrowing 29 | } 30 | 31 | CONFIG(release, debug|release) { 32 | } 33 | 34 | VERSION = 6.5.0 35 | DEFINES += VERSION_STR=\\\"$$VERSION\\\" 36 | 37 | QMAKE_TARGET_PRODUCT = jookdb 38 | QMAKE_TARGET_COMPANY = jooksoft 39 | 40 | win32{ 41 | RC_ICONS = $$PWD/images/icon/jookdb.ico 42 | } 43 | macx{ 44 | ICON = $$PWD/images/icon/jookdb.icns 45 | } 46 | 47 | CONFIG -= debug_and_release 48 | 49 | TRANSLATIONS += language/en.ts \ 50 | language/zh_cn.ts 51 | 52 | #include(cryptopp.pri) 53 | 54 | SOURCES += \ 55 | aboutdialog.cpp \ 56 | activatedialog.cpp \ 57 | attachdbdialog.cpp \ 58 | autocompleteform.cpp \ 59 | btnfuncdelegate.cpp \ 60 | checkboxdelegate.cpp \ 61 | cmask.cpp \ 62 | comboboxdelegate.cpp \ 63 | conndialog.cpp \ 64 | contentwidget.cpp \ 65 | copytabledialog.cpp \ 66 | customcheckbox.cpp \ 67 | databasemanagerform.cpp \ 68 | datasyncdialog.cpp \ 69 | datetimeeditdelegate.cpp \ 70 | datetimeeditform.cpp \ 71 | dbobjectselectdialog.cpp \ 72 | driverdownloadform.cpp \ 73 | editdatabasedialog.cpp \ 74 | flowlayout.cpp \ 75 | importdialog.cpp \ 76 | jarinfoeditdialog.cpp \ 77 | jarsmanagerform.cpp \ 78 | leftwidgetform.cpp \ 79 | lineeditdelegate.cpp \ 80 | listwidgetdelegate.cpp \ 81 | main.cpp \ 82 | mainwindow.cpp \ 83 | manualactivationdialog.cpp \ 84 | mutichkform.cpp \ 85 | mystyle.cpp \ 86 | objectmanagerform.cpp \ 87 | objtimecache.cpp \ 88 | passwordchgdialog.cpp \ 89 | passwordinputdialog.cpp \ 90 | readonlydelegate.cpp \ 91 | reversecall.cpp \ 92 | runsqldialog.cpp \ 93 | searchreplaceform.cpp \ 94 | spinboxdelegate.cpp \ 95 | sqlstyle.cpp \ 96 | strmappingdialog.cpp \ 97 | test.cpp \ 98 | texteditdialog.cpp \ 99 | 100 | HEADERS += \ 101 | aboutdialog.h \ 102 | attachdbdialog.h \ 103 | btnfuncdelegate.h \ 104 | checkboxdelegate.h \ 105 | cmask.h \ 106 | comboboxdelegate.h \ 107 | conndialog.h \ 108 | contentwidget.h \ 109 | copytabledialog.h \ 110 | customcheckbox.h \\ 111 | databasemanagerform.h \ 112 | datetimeeditdelegate.h \ 113 | datetimeeditform.h \ 114 | dbobjectselectdialog.h \ 115 | driverdownloadform.h \ 116 | editdatabasedialog.h \ 117 | flowlayout.h \ 118 | fulltextsearchform.h \ 119 | generatedpropeditdialog.h \ 120 | jarinfoeditdialog.h \ 121 | jarsmanagerform.h \ 122 | leftwidgetform.h \ 123 | lineeditdelegate.h \ 124 | listwidgetdelegate.h \ 125 | mainwindow.h \ 126 | manualactivationdialog.h \ 127 | mutichkform.h \ 128 | myedit.h \ 129 | mystyle.h \ 130 | objtimecache.h \ 131 | optionsdialog.h \ 132 | passwordchgdialog.h \ 133 | passwordinputdialog.h \ 134 | readonlydelegate.h \ 135 | reversecall.h \ 136 | runsqldialog.h \ 137 | searchreplaceform.h \ 138 | spinboxdelegate.h \ 139 | sqlstyle.h \ 140 | strmappingdialog.h \ 141 | structsyncdialog.h \ 142 | test.h \ 143 | texteditdialog.h \ 144 | 145 | RESOURCES = resources.qrc 146 | 147 | #INCLUDEPATH += $$(BOOST_HOME) 148 | #!build_pass:message($$(BOOST_HOME)) 149 | 150 | # Default rules for deployment. 151 | qnx: target.path = /tmp/$${TARGET}/bin 152 | else: unix:!android: target.path = /opt/$${TARGET}/bin 153 | !isEmpty(target.path): INSTALLS += target 154 | 155 | DISTFILES += 156 | 157 | FORMS += \ 158 | aboutdialog.ui \ 159 | activatedialog.ui \ 160 | attachdbdialog.ui \ 161 | autocompleteform.ui \ 162 | conndialog.ui \ 163 | copytabledialog.ui \ 164 | databasedefinitionexoprtdialog.ui \ 165 | databasemanagerform.ui \ 166 | datasyncdialog.ui \ 167 | datetimeeditform.ui \ 168 | dbobjectselectdialog.ui \ 169 | driverdownloadform.ui \ 170 | editdatabasedialog.ui \ 171 | exportdialog.ui \ 172 | importdialog.ui \ 173 | jarinfoeditdialog.ui \ 174 | jarsmanagerform.ui \ 175 | leftwidgetform.ui \ 176 | manualactivationdialog.ui \ 177 | mutichkform.ui \ 178 | optionsdialog.ui \ 179 | passwordchgdialog.ui \ 180 | passwordinputdialog.ui \ 181 | searchreplaceform.ui \ 182 | strmappingdialog.ui \ 183 | structsyncdialog.ui \ 184 | usermanagerdialog.ui 185 | 186 | -------------------------------------------------------------------------------- /cpp/leftwidgetform.cpp: -------------------------------------------------------------------------------- 1 | #include "leftwidgetform.h" 2 | #include "ui_leftwidgetform.h" 3 | #include "widgetutils.h" 4 | 5 | LeftWidgetForm::LeftWidgetForm(QWidget *parent) : 6 | QWidget(parent), 7 | ui(new Ui::LeftWidgetForm) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | LeftWidgetForm::~LeftWidgetForm() 13 | { 14 | delete ui; 15 | } 16 | 17 | MyTreeWidget *LeftWidgetForm::getLeftTree() const 18 | { 19 | return this->ui->leftTree; 20 | } 21 | 22 | QLineEdit *LeftWidgetForm::getLeftTreeFilter() const 23 | { 24 | return this->ui->le_leftTree_filter; 25 | } 26 | 27 | void LeftWidgetForm::on_le_leftTree_filter_textChanged(const QString &arg1) 28 | { 29 | WidgetUtils::treeFilter(this->stop,this->ui->leftTree,this->ui->le_leftTree_filter); 30 | } 31 | 32 | void LeftWidgetForm::on_le_leftTree_filter_returnPressed() 33 | { 34 | this->on_le_leftTree_filter_textChanged(""); 35 | } 36 | -------------------------------------------------------------------------------- /cpp/leftwidgetform.h: -------------------------------------------------------------------------------- 1 | #ifndef LEFTWIDGETFORM_H 2 | #define LEFTWIDGETFORM_H 3 | 4 | #include "mytreewidget.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class LeftWidgetForm; 10 | } 11 | 12 | class LeftWidgetForm : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit LeftWidgetForm(QWidget *parent = nullptr); 18 | ~LeftWidgetForm(); 19 | 20 | MyTreeWidget* getLeftTree() const; 21 | 22 | QLineEdit* getLeftTreeFilter() const; 23 | 24 | private slots: 25 | void on_le_leftTree_filter_textChanged(const QString &arg1); 26 | 27 | void on_le_leftTree_filter_returnPressed(); 28 | 29 | private: 30 | Ui::LeftWidgetForm *ui; 31 | 32 | std::atomic_bool stop=false; 33 | }; 34 | 35 | #endif // LEFTWIDGETFORM_H 36 | -------------------------------------------------------------------------------- /cpp/leftwidgetform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LeftWidgetForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 263 10 | 677 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 1 19 | 20 | 21 | 0 22 | 23 | 24 | 1 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 34 | 35 | Qt::ClickFocus 36 | 37 | 38 | Regex Filter 39 | 40 | 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | MyTreeWidget 53 | QWidget 54 |
mytreewidget.h
55 | 1 56 |
57 |
58 | 59 | 60 |
61 | -------------------------------------------------------------------------------- /cpp/lineeditdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "lineeditdelegate.h" 2 | #include "texteditdialog.h" 3 | #include "utils.h" 4 | #include "widgetutils.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | LineEditDelegate::LineEditDelegate(QObject *parent) : QStyledItemDelegate(parent) 13 | { 14 | 15 | } 16 | 17 | void LineEditDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 18 | { 19 | auto opt=option; 20 | opt.displayAlignment=this->textAlign; 21 | WidgetUtils::paint(painter,opt,index); 22 | 23 | } 24 | 25 | QSize LineEditDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 26 | { 27 | return QStyledItemDelegate::sizeHint(option, index); 28 | } 29 | 30 | QWidget *LineEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 31 | { 32 | QLineEdit *editor = new QLineEdit(parent); 33 | 34 | editor->setReadOnly(readonly); 35 | editor->setMaxLength(50*1024*1024); 36 | 37 | editor->setProperty("useAutoComplete",this->useAutoComplete); 38 | editor->setProperty("useLexer",this->useLexer); 39 | 40 | if(useTextEdit){ 41 | WidgetUtils::customLineEditWidgetAddTextEdit(editor); 42 | } 43 | 44 | if(lineEditInitFunc){ 45 | lineEditInitFunc(editor); 46 | } 47 | 48 | if(lineEditMousePressFunc){ 49 | CustomEventFilter *eventFilter=new CustomEventFilter(const_cast(editor)); 50 | eventFilter->setFunc([=](QObject *obj, QEvent *event){ 51 | if (event->type() == QEvent::MouseButtonPress && obj->inherits(QLineEdit::staticMetaObject.className())) 52 | { 53 | lineEditMousePressFunc((QLineEdit*)obj); 54 | } 55 | return false; 56 | }); 57 | editor->installEventFilter(eventFilter); 58 | } 59 | 60 | if(lineEditChangedFunc){ 61 | connect(editor,&QLineEdit::textChanged,this,[=](const QString text){ 62 | lineEditChangedFunc(editor,text); 63 | }); 64 | } 65 | return editor; 66 | } 67 | 68 | void LineEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 69 | { 70 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 71 | QString value = WidgetUtils::getData(index).toString(); 72 | QLineEdit *lineEdit = static_cast(editor); 73 | lineEdit->setAlignment(textAlign); 74 | lineEdit->setText(value); 75 | } 76 | } 77 | 78 | void LineEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 79 | { 80 | if(this->readonly)return; 81 | 82 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 83 | QLineEdit *lineEdit = static_cast(editor); 84 | bool changed=WidgetUtils::setData(model,index,lineEdit->text()); 85 | if(changed){ 86 | if(dataChangedFunc){ 87 | dataChangedFunc(index); 88 | } 89 | } 90 | if(dataWriteFunc){ 91 | dataWriteFunc(index,changed); 92 | } 93 | } 94 | } 95 | 96 | bool LineEditDelegate::getReadonly() const 97 | { 98 | return readonly; 99 | } 100 | 101 | void LineEditDelegate::setReadonly(bool value) 102 | { 103 | readonly = value; 104 | } 105 | 106 | bool LineEditDelegate::getUseTextEdit() const 107 | { 108 | return useTextEdit; 109 | } 110 | 111 | void LineEditDelegate::setUseTextEdit(bool value) 112 | { 113 | useTextEdit = value; 114 | } 115 | 116 | Qt::Alignment LineEditDelegate::getTextAlign() const 117 | { 118 | return textAlign; 119 | } 120 | 121 | void LineEditDelegate::setTextAlign(const Qt::Alignment &value) 122 | { 123 | textAlign = value; 124 | } 125 | 126 | bool LineEditDelegate::getUseAutoComplete() const 127 | { 128 | return useAutoComplete; 129 | } 130 | 131 | void LineEditDelegate::setUseAutoComplete(bool value) 132 | { 133 | useAutoComplete = value; 134 | } 135 | 136 | bool LineEditDelegate::getUseLexer() const 137 | { 138 | return useLexer; 139 | } 140 | 141 | void LineEditDelegate::setUseLexer(bool value) 142 | { 143 | useLexer = value; 144 | } 145 | -------------------------------------------------------------------------------- /cpp/lineeditdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEEDITDELEGATE_H 2 | #define LINEEDITDELEGATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class LineEditDelegate : public QStyledItemDelegate 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit LineEditDelegate(QObject *parent = nullptr); 14 | 15 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 16 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 17 | 18 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 19 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 20 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 21 | 22 | std::function lineEditInitFunc=nullptr; 23 | std::function lineEditMousePressFunc=nullptr; 24 | std::function lineEditChangedFunc=nullptr; 25 | 26 | std::function dataChangedFunc=nullptr; 27 | std::function dataWriteFunc=nullptr; 28 | 29 | bool getReadonly() const; 30 | void setReadonly(bool value); 31 | 32 | bool getUseTextEdit() const; 33 | void setUseTextEdit(bool value); 34 | 35 | Qt::Alignment getTextAlign() const; 36 | void setTextAlign(const Qt::Alignment &value); 37 | 38 | bool getUseAutoComplete() const; 39 | void setUseAutoComplete(bool value); 40 | 41 | bool getUseLexer() const; 42 | void setUseLexer(bool value); 43 | 44 | signals: 45 | 46 | public slots: 47 | 48 | private: 49 | 50 | bool readonly=false; 51 | bool useTextEdit=false; 52 | 53 | bool useAutoComplete=false; 54 | bool useLexer=false; 55 | 56 | Qt::Alignment textAlign=Qt::AlignLeft|Qt::AlignVCenter; 57 | }; 58 | 59 | #endif // LINEEDITDELEGATE_H 60 | -------------------------------------------------------------------------------- /cpp/listwidgetdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "listwidgetdelegate.h" 2 | #include "widgetutils.h" 3 | #include 4 | 5 | ListWidgetDelegate::ListWidgetDelegate(QObject *parent) : QStyledItemDelegate(parent) 6 | { 7 | 8 | } 9 | 10 | void ListWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 11 | { 12 | auto opt=option; 13 | WidgetUtils::paint(painter,opt,index); 14 | } 15 | 16 | QSize ListWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 17 | { 18 | return QStyledItemDelegate::sizeHint(option, index); 19 | } 20 | 21 | QWidget *ListWidgetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 22 | { 23 | 24 | QLineEdit *editor = new QLineEdit(parent); 25 | 26 | editor->setReadOnly(readonly); 27 | 28 | editor->setProperty("item_row",index.row()); 29 | editor->setProperty("item_col",index.column()); 30 | 31 | 32 | WidgetUtils::customLineEditWidgetAddMutiChk(editor,valuesFunc,rightValues); 33 | 34 | if(initFunc){ 35 | initFunc(editor); 36 | } 37 | 38 | if(mousePressFunc){ 39 | CustomEventFilter *eventFilter=new CustomEventFilter(editor); 40 | eventFilter->setFunc([=](QObject *obj, QEvent *event){ 41 | if (event->type() == QEvent::MouseButtonPress && obj->inherits(QLineEdit::staticMetaObject.className())) 42 | { 43 | mousePressFunc(editor); 44 | } 45 | return false; 46 | }); 47 | editor->installEventFilter(eventFilter); 48 | } 49 | 50 | return editor; 51 | } 52 | 53 | void ListWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 54 | { 55 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 56 | QString value = WidgetUtils::getData(index).toString(); 57 | QLineEdit *le = static_cast(editor); 58 | 59 | le->setText(value); 60 | 61 | } 62 | } 63 | 64 | void ListWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 65 | { 66 | if(this->readonly)return; 67 | 68 | if(editor->inherits(QLineEdit::staticMetaObject.className())){ 69 | QLineEdit *le = static_cast(editor); 70 | 71 | QString value=le->text(); 72 | 73 | bool changed=WidgetUtils::setData(model,index,value); 74 | if(changed){ 75 | if(dataChangedFunc){ 76 | dataChangedFunc(index); 77 | } 78 | } 79 | if(dataWriteFunc){ 80 | dataWriteFunc(index,changed); 81 | } 82 | } 83 | } 84 | 85 | bool ListWidgetDelegate::getReadonly() const 86 | { 87 | return readonly; 88 | } 89 | 90 | void ListWidgetDelegate::setReadonly(bool value) 91 | { 92 | readonly = value; 93 | } 94 | 95 | QListWidget *ListWidgetDelegate::getListWidget(QWidget *comb) 96 | { 97 | if(comb->inherits(QComboBox::staticMetaObject.className())){ 98 | QComboBox *combox = static_cast(comb); 99 | 100 | if(combox->view()&&combox->view()->inherits(QListWidget::staticMetaObject.className())){ 101 | return static_cast(combox->view()); 102 | } 103 | } 104 | return nullptr; 105 | } 106 | -------------------------------------------------------------------------------- /cpp/listwidgetdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef LISTWIDGETDELEGATE_H 2 | #define LISTWIDGETDELEGATE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ListWidgetDelegate : public QStyledItemDelegate 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit ListWidgetDelegate(QObject *parent = nullptr); 14 | 15 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 16 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 17 | 18 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 19 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 20 | void setModelData(QWidget *editor, QAbstractItemModel *model,const QModelIndex &index) const override; 21 | 22 | std::function initFunc=nullptr; 23 | std::function mousePressFunc=nullptr; 24 | 25 | std::function dataChangedFunc=nullptr; 26 | std::function dataWriteFunc=nullptr; 27 | std::function valuesFunc=nullptr; 28 | 29 | QStringList rightValues; 30 | 31 | bool findCaseSensitive=true; 32 | 33 | bool getReadonly() const; 34 | void setReadonly(bool value); 35 | 36 | public slots: 37 | 38 | private: 39 | bool readonly=false; 40 | 41 | QListWidget *getListWidget(QWidget *comb); 42 | }; 43 | 44 | #endif // LISTWIDGETDELEGATE_H 45 | -------------------------------------------------------------------------------- /cpp/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "mystyle.h" 3 | #include "test.h" 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) 9 | { 10 | 11 | //----------test start----------- 12 | // Test test; 13 | // test.test1(); 14 | // return 0; 15 | //----------test end----------- 16 | 17 | Q_INIT_RESOURCE(resources); 18 | 19 | // QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));//置于QApplication实例之前解决乱码问题 20 | 21 | // QApplication::setStyle(QStyleFactory::create("Fusion")); 22 | 23 | QApplication app(argc, argv); 24 | 25 | QCoreApplication::setApplicationName("jookdb"); 26 | QCoreApplication::setApplicationVersion(VERSION_STR); 27 | QCommandLineParser parser; 28 | parser.setApplicationDescription(QCoreApplication::applicationName()); 29 | parser.addHelpOption(); 30 | parser.addVersionOption(); 31 | parser.addPositionalArgument("file", "The file to open."); 32 | parser.process(app); 33 | 34 | if (!parser.positionalArguments().isEmpty()){ 35 | QString filename=parser.positionalArguments().first(); 36 | QObject::connect(MainWindow::instance(),&MainWindow::inited,[=](){ 37 | MainWindow::instance()->loadFile(filename); 38 | }); 39 | } 40 | MainWindow::instance()->show(); 41 | 42 | return app.exec(); 43 | } 44 | -------------------------------------------------------------------------------- /cpp/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include "contentwidget.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | class MainWindow : public QMainWindow 12 | { 13 | Q_OBJECT 14 | private: 15 | MainWindow(); 16 | 17 | public: 18 | 19 | static MainWindow* instance(); 20 | 21 | static ContentWidget* getContent(); 22 | 23 | QueryForm* loadFile(QString fileName,const QByteArray codec="",const bool logHis=true); 24 | void setCurrentTitle(const QString &fileName); 25 | bool save(); 26 | 27 | void setStatus(const QString &text, int timeout = 0); 28 | 29 | QAction *saveAct; 30 | QMenu *connMenu; 31 | 32 | QLabel codecLabel; 33 | QLabel statusLabel; 34 | QLabel sqlLabel; 35 | void clearStatusLabels(); 36 | 37 | bool qf_defaultCalcRowCout; 38 | bool td_defaultCalcRowCout; 39 | 40 | int defaultPageSize; 41 | 42 | QString defaultFontFamily; 43 | int defaultTheme; 44 | 45 | int defaultFontSize; 46 | 47 | bool defaultUseCodeCompletion; 48 | 49 | bool defaultShowLineNumber; 50 | 51 | bool defaultUseCodeFloding; 52 | 53 | bool defaultUseSyntaxHighlighting; 54 | 55 | bool defaultUseCurrLineHL; 56 | 57 | int defaultDisableIfFileLargerMib; 58 | 59 | QString defaultQfFontFamily; 60 | 61 | int defaultQfFontSize; 62 | 63 | int defaultQfTabWidth; 64 | 65 | QString defaultQfColorCommon; 66 | QString defaultQfColorKeyword; 67 | QString defaultQfColorString; 68 | QString defaultQfColorNumber; 69 | QString defaultQfColorComment; 70 | QString defaultQfColorBackground; 71 | 72 | QString defaultLanguage; 73 | 74 | int getIconThumbSize(); 75 | 76 | QString getAppQfFontFamily(); 77 | 78 | QSharedPointer loadConfig(bool useDefault=false); 79 | void loadQSS(); 80 | 81 | void loadTranslator(); 82 | 83 | QRect getGuiFontRect(const QString &text,const QWidget * wid=nullptr); 84 | QRect getCharGuiFontRect(); 85 | 86 | signals: 87 | void inited(); 88 | 89 | protected: 90 | void closeEvent(QCloseEvent *event) override; 91 | 92 | private slots: 93 | void newFile(); 94 | void open(); 95 | bool saveAs(); 96 | void about(); 97 | 98 | #ifndef QT_NO_SESSIONMANAGER 99 | void commitData(QSessionManager &); 100 | #endif 101 | 102 | private: 103 | void createActions(); 104 | void createStatusBar(); 105 | void readSettings(QSharedPointer ini); 106 | void writeSettings(); 107 | bool maybeSave(); 108 | bool saveFile(const QString &fileName,QByteArray saveCodec=""); 109 | QString strippedName(const QString &fullFileName); 110 | 111 | ContentWidget* content; 112 | }; 113 | 114 | #endif // MAINWINDOW_H 115 | -------------------------------------------------------------------------------- /cpp/mutichkform.cpp: -------------------------------------------------------------------------------- 1 | #include "mutichkform.h" 2 | #include "ui_mutichkform.h" 3 | #include "widgetutils.h" 4 | 5 | #include 6 | 7 | MutiChkForm::MutiChkForm(QWidget *parent) : 8 | QWidget(parent), 9 | ui(new Ui::MutiChkForm) 10 | { 11 | ui->setupUi(this); 12 | 13 | WidgetUtils::setSafeDeleteOnClose(this); 14 | 15 | setWindowFlag(Qt::Popup); 16 | 17 | ui->splitter->setSizes({700,300}); 18 | } 19 | 20 | MutiChkForm::~MutiChkForm() 21 | { 22 | delete ui; 23 | } 24 | 25 | void MutiChkForm::waitExit() 26 | { 27 | auto runRef=WidgetUtils::createRunRef(this); 28 | 29 | QSharedPointer loop{new EventLoop{this}}; 30 | 31 | connect(this,&MutiChkForm::editClosed,[=](){loop->quit();}); 32 | 33 | loop->exec(); 34 | } 35 | 36 | QListWidget *MutiChkForm::getListWidget() 37 | { 38 | return this->ui->listWidget; 39 | } 40 | 41 | QListWidget *MutiChkForm::getListWidgetRight() 42 | { 43 | return this->ui->listWidget_right; 44 | } 45 | 46 | void MutiChkForm::closeEvent(QCloseEvent *event) 47 | { 48 | this->hide(); 49 | 50 | stop=true; 51 | 52 | emit editClosed(); 53 | 54 | QTimer *timer = new QTimer(this); 55 | // setup signal and slot 56 | connect(timer, &QTimer::timeout, 57 | this, [=](){ 58 | if(!WidgetUtils::isRunning(this)){ 59 | this->deleteLater(); 60 | } 61 | }); 62 | // msec 63 | timer->start(50); 64 | 65 | event->ignore(); 66 | } 67 | 68 | bool MutiChkForm::getReadonly() const 69 | { 70 | return readonly; 71 | } 72 | 73 | void MutiChkForm::setReadonly(bool value) 74 | { 75 | readonly = value; 76 | 77 | this->setEnabled(!this->readonly); 78 | } 79 | 80 | void MutiChkForm::on_listWidget_itemClicked(QListWidgetItem *item) 81 | { 82 | if(item->checkState()==Qt::Checked){ 83 | item->setCheckState(Qt::Unchecked); 84 | }else{ 85 | item->setCheckState(Qt::Checked); 86 | } 87 | } 88 | 89 | void MutiChkForm::on_btn_selectAll_clicked() 90 | { 91 | for(int i=0;iui->listWidget->count();i++){ 92 | auto item=this->ui->listWidget->item(i); 93 | if(item){ 94 | item->setCheckState(Qt::Checked); 95 | } 96 | } 97 | } 98 | 99 | void MutiChkForm::on_btn_deselectAll_clicked() 100 | { 101 | for(int i=0;iui->listWidget->count();i++){ 102 | auto item=this->ui->listWidget->item(i); 103 | if(item){ 104 | item->setCheckState(Qt::Unchecked); 105 | } 106 | } 107 | } 108 | 109 | void MutiChkForm::on_btn_ok_clicked() 110 | { 111 | this->close(); 112 | } 113 | -------------------------------------------------------------------------------- /cpp/mutichkform.h: -------------------------------------------------------------------------------- 1 | #ifndef MUTICHKFORM_H 2 | #define MUTICHKFORM_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class MutiChkForm; 9 | } 10 | 11 | class MutiChkForm : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit MutiChkForm(QWidget *parent = nullptr); 17 | ~MutiChkForm(); 18 | 19 | void waitExit(); 20 | 21 | QListWidget *getListWidget(); 22 | 23 | QListWidget *getListWidgetRight(); 24 | 25 | 26 | signals: 27 | 28 | void editClosed(); 29 | 30 | private: 31 | Ui::MutiChkForm *ui; 32 | 33 | bool readonly=false; 34 | 35 | public: 36 | 37 | void closeEvent(QCloseEvent *event) override; 38 | 39 | bool getReadonly() const; 40 | void setReadonly(bool value); 41 | 42 | private slots: 43 | void on_listWidget_itemClicked(QListWidgetItem *item); 44 | 45 | void on_btn_selectAll_clicked(); 46 | 47 | void on_btn_deselectAll_clicked(); 48 | 49 | void on_btn_ok_clicked(); 50 | 51 | private: 52 | 53 | std::atomic_bool stop=false; 54 | }; 55 | 56 | #endif // MUTICHKFORM_H 57 | -------------------------------------------------------------------------------- /cpp/mutichkform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MutiChkForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 389 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 1 19 | 20 | 21 | 5 22 | 23 | 24 | 1 25 | 26 | 27 | 3 28 | 29 | 30 | 31 | 32 | 33 | 0 34 | 0 35 | 36 | 37 | 38 | Qt::Horizontal 39 | 40 | 41 | true 42 | 43 | 44 | 1 45 | 46 | 47 | 48 | 49 | 50 | 0 51 | 0 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Select All 63 | 64 | 65 | 66 | 67 | 68 | 69 | Deselect All 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Horizontal 77 | 78 | 79 | 80 | 40 81 | 20 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | OK 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /cpp/mystyle.cpp: -------------------------------------------------------------------------------- 1 | #include "mystyle.h" 2 | #include 3 | 4 | MyStyle::MyStyle(const QString &key):QProxyStyle(key) 5 | { 6 | 7 | } 8 | 9 | MyStyle *MyStyle::instance() 10 | { 11 | static MyStyle* ins=new MyStyle; 12 | return ins; 13 | } 14 | 15 | int MyStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const 16 | { 17 | switch (metric) { 18 | case PM_ListViewIconSize: 19 | return QCommonStyle::pixelMetric(metric,option,widget); 20 | break; 21 | default: 22 | return QProxyStyle::pixelMetric(metric,option,widget); 23 | break; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cpp/mystyle.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSTYLE_H 2 | #define MYSTYLE_H 3 | 4 | #include 5 | 6 | class MyStyle : public QProxyStyle 7 | { 8 | Q_OBJECT 9 | private: 10 | explicit MyStyle(const QString &key="Fusion"); 11 | 12 | public: 13 | static MyStyle *instance(); 14 | 15 | int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; 16 | 17 | signals: 18 | 19 | }; 20 | 21 | #endif // MYSTYLE_H 22 | -------------------------------------------------------------------------------- /cpp/objtimecache.cpp: -------------------------------------------------------------------------------- 1 | #include "objtimecache.h" 2 | 3 | #include 4 | #include 5 | 6 | ObjTimeCache::ObjTimeCache(int defaultExpireMs,int recycleMs):defaultExpireMs(defaultExpireMs),recycleMs(recycleMs) 7 | { 8 | 9 | } 10 | 11 | void ObjTimeCache::put(const QByteArray &key,const QVariant &value,int expireMs) 12 | { 13 | if(std::abs(QDateTime::currentMSecsSinceEpoch()-clearTime)>this->recycleMs){ 14 | clearTime=QDateTime::currentMSecsSinceEpoch(); 15 | 16 | QHash::iterator iter; 17 | for (iter=this->cacheMap.begin();iter!=this->cacheMap.end();) { 18 | ObjTimeCacheData data=iter.value(); 19 | if(data.expireTimecacheMap.erase(iter); 21 | }else{ 22 | iter++; 23 | } 24 | } 25 | } 26 | 27 | if(expireMs<0){ 28 | expireMs=this->defaultExpireMs; 29 | } 30 | ObjTimeCacheData data; 31 | data.expireTime=QDateTime::currentMSecsSinceEpoch()+expireMs; 32 | data.value=value; 33 | this->cacheMap.insert(key,data); 34 | } 35 | 36 | QVariant ObjTimeCache::get(const QByteArray &key) 37 | { 38 | ObjTimeCacheData data=this->cacheMap.value(key); 39 | 40 | if(data.expireTime>=QDateTime::currentMSecsSinceEpoch()){ 41 | return data.value; 42 | } 43 | 44 | if(data.expireTime>0){ 45 | this->cacheMap.remove(key); 46 | } 47 | 48 | return {}; 49 | } 50 | 51 | bool ObjTimeCache::contains(const QByteArray &key) const 52 | { 53 | ObjTimeCacheData data=this->cacheMap.value(key); 54 | if(data.expireTime>=QDateTime::currentMSecsSinceEpoch()){ 55 | return true; 56 | } 57 | return false; 58 | } 59 | 60 | void ObjTimeCache::clear() 61 | { 62 | this->cacheMap.clear(); 63 | } 64 | -------------------------------------------------------------------------------- /cpp/objtimecache.h: -------------------------------------------------------------------------------- 1 | #ifndef OBJTIMECACHE_H 2 | #define OBJTIMECACHE_H 3 | 4 | #include 5 | #include 6 | 7 | class ObjTimeCache 8 | { 9 | public: 10 | ObjTimeCache(int defaultExpireMs=30000,int recycleMs=35000); 11 | 12 | void put(const QByteArray &key,const QVariant &value,int expireMs=-1); 13 | QVariant get(const QByteArray &key); 14 | bool contains(const QByteArray &key) const; 15 | 16 | void clear(); 17 | 18 | struct ObjTimeCacheData{ 19 | int64_t expireTime=-1; 20 | QVariant value; 21 | }; 22 | private: 23 | int defaultExpireMs; 24 | int recycleMs; 25 | QHash cacheMap; 26 | int64_t clearTime=-1; 27 | }; 28 | 29 | #endif // OBJTIMECACHE_H 30 | -------------------------------------------------------------------------------- /cpp/optionsdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIONSDIALOG_H 2 | #define OPTIONSDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class OptionsDialog; 8 | } 9 | 10 | class OptionsDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit OptionsDialog(QWidget *parent = nullptr); 16 | 17 | void loadConfig(); 18 | 19 | void setModify(); 20 | 21 | private: 22 | Ui::OptionsDialog *ui; 23 | 24 | ~OptionsDialog(); 25 | 26 | QString defaultQfColorCommon; 27 | QString defaultQfColorKeyword; 28 | QString defaultQfColorString; 29 | QString defaultQfColorNumber; 30 | QString defaultQfColorComment; 31 | QString defaultQfColorBackground; 32 | 33 | bool modify=false; 34 | 35 | public: 36 | 37 | void closeEvent(QCloseEvent *event) override; 38 | 39 | void flushColor(); 40 | 41 | private slots: 42 | 43 | void on_btn_cancel_clicked(); 44 | 45 | void on_btn_apply_clicked(); 46 | 47 | void on_btn_ok_clicked(); 48 | 49 | void on_btn_restore_clicked(); 50 | 51 | void on_btn_qfColorCommon_clicked(); 52 | 53 | void on_btn_qfColorKeyword_clicked(); 54 | 55 | void on_btn_qfColorString_clicked(); 56 | 57 | void on_btn_qfColorNumber_clicked(); 58 | 59 | void on_btn_qfColorComment_clicked(); 60 | 61 | void on_btn_qfColorBackground_clicked(); 62 | 63 | void on_cbox_theme_currentTextChanged(const QString &arg1); 64 | 65 | private: 66 | 67 | std::atomic_bool stop=false; 68 | }; 69 | 70 | #endif // OPTIONSDIALOG_H 71 | -------------------------------------------------------------------------------- /cpp/passwordchgdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "passwordchgdialog.h" 2 | #include "ui_passwordchgdialog.h" 3 | 4 | #include 5 | 6 | PasswordChgDialog::PasswordChgDialog(QWidget *parent) : 7 | QDialog(parent), 8 | ui(new Ui::PasswordChgDialog) 9 | { 10 | ui->setupUi(this); 11 | } 12 | 13 | PasswordChgDialog::~PasswordChgDialog() 14 | { 15 | delete ui; 16 | } 17 | 18 | QString PasswordChgDialog::getOldPassword() const 19 | { 20 | return ui->le_oldPwd->text().trimmed(); 21 | } 22 | 23 | QString PasswordChgDialog::getNewPassword() const 24 | { 25 | return this->ui->le_newPwd->text().trimmed(); 26 | } 27 | 28 | void PasswordChgDialog::on_btn_ok_clicked() 29 | { 30 | if(ui->le_newPwd->text()==ui->le_confirmPwd->text()){ 31 | this->accept(); 32 | }else{ 33 | QMessageBox::warning(this, QCoreApplication::applicationName(),"New password does not match"); 34 | 35 | } 36 | } 37 | 38 | void PasswordChgDialog::on_btn_cancel_clicked() 39 | { 40 | this->close(); 41 | } 42 | -------------------------------------------------------------------------------- /cpp/passwordchgdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef PASSWORDCHGDIALOG_H 2 | #define PASSWORDCHGDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class PasswordChgDialog; 8 | } 9 | 10 | class PasswordChgDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit PasswordChgDialog(QWidget *parent = nullptr); 16 | ~PasswordChgDialog(); 17 | 18 | QString getOldPassword() const; 19 | QString getNewPassword() const; 20 | 21 | private slots: 22 | void on_btn_ok_clicked(); 23 | 24 | void on_btn_cancel_clicked(); 25 | 26 | private: 27 | Ui::PasswordChgDialog *ui; 28 | }; 29 | 30 | #endif // PASSWORDCHGDIALOG_H 31 | -------------------------------------------------------------------------------- /cpp/passwordchgdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PasswordChgDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 137 11 | 12 | 13 | 14 | Change Password 15 | 16 | 17 | 18 | 19 | 20 | Password expired. Please enter a new password 21 | 22 | 23 | 24 | 25 | 26 | 27 | Old Password 28 | 29 | 30 | 31 | 32 | 33 | 34 | QLineEdit::Password 35 | 36 | 37 | 38 | 39 | 40 | 41 | New Password: 42 | 43 | 44 | 45 | 46 | 47 | 48 | QLineEdit::Password 49 | 50 | 51 | 52 | 53 | 54 | 55 | Confirm Password: 56 | 57 | 58 | 59 | 60 | 61 | 62 | QLineEdit::Password 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Qt::Horizontal 72 | 73 | 74 | 75 | 40 76 | 20 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | OK 85 | 86 | 87 | 88 | 89 | 90 | 91 | Cancel 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /cpp/passwordinputdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "passwordinputdialog.h" 2 | #include "ui_passwordinputdialog.h" 3 | 4 | PasswordInputDialog::PasswordInputDialog(QSharedPointer connData,QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::PasswordInputDialog), 7 | connData(connData) 8 | { 9 | ui->setupUi(this); 10 | 11 | #if defined(Q_OS_MAC) 12 | this->setWindowFlag(Qt::Tool,true); 13 | #endif 14 | 15 | if(connData){ 16 | QString str="Enter password for %1(%2):"; 17 | str=str.arg(connData->userName,connData->connName); 18 | this->ui->lb_pwd->setText(str); 19 | } 20 | 21 | } 22 | 23 | PasswordInputDialog::~PasswordInputDialog() 24 | { 25 | delete ui; 26 | } 27 | 28 | QString PasswordInputDialog::getPassword() 29 | { 30 | return this->ui->le_pwd->text(); 31 | } 32 | 33 | bool PasswordInputDialog::isSave() 34 | { 35 | return this->ui->chk_savePwd->isChecked(); 36 | 37 | } 38 | 39 | QLabel *PasswordInputDialog::getPwdLabel() 40 | { 41 | return ui->lb_pwd; 42 | } 43 | -------------------------------------------------------------------------------- /cpp/passwordinputdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef PASSWORDINPUTDIALOG_H 2 | #define PASSWORDINPUTDIALOG_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace Ui { 10 | class PasswordInputDialog; 11 | } 12 | 13 | class PasswordInputDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit PasswordInputDialog(QSharedPointer connData,QWidget *parent = nullptr); 19 | ~PasswordInputDialog(); 20 | 21 | QString getPassword(); 22 | bool isSave(); 23 | 24 | QLabel * getPwdLabel(); 25 | 26 | private slots: 27 | 28 | private: 29 | Ui::PasswordInputDialog *ui; 30 | 31 | QSharedPointer connData; 32 | 33 | }; 34 | 35 | #endif // PASSWORDINPUTDIALOG_H 36 | -------------------------------------------------------------------------------- /cpp/passwordinputdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PasswordInputDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 315 10 | 107 11 | 12 | 13 | 14 | Password Input 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | Password: 24 | 25 | 26 | 27 | 28 | 29 | 30 | QLineEdit::Password 31 | 32 | 33 | 34 | 35 | 36 | 37 | Save password 38 | 39 | 40 | 41 | 42 | 43 | 44 | Qt::Horizontal 45 | 46 | 47 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | buttonBox 57 | accepted() 58 | PasswordInputDialog 59 | accept() 60 | 61 | 62 | 248 63 | 254 64 | 65 | 66 | 157 67 | 274 68 | 69 | 70 | 71 | 72 | buttonBox 73 | rejected() 74 | PasswordInputDialog 75 | reject() 76 | 77 | 78 | 316 79 | 260 80 | 81 | 82 | 286 83 | 274 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /cpp/queryform.h: -------------------------------------------------------------------------------- 1 | #ifndef QUERYFORM_H 2 | #define QUERYFORM_H 3 | 4 | #include "myedit.h" 5 | #include "sqllexer.h" 6 | #include "sqlstyle.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | enum class QueryRunType{ 15 | current, 16 | script, 17 | one_script, 18 | explain 19 | }; 20 | 21 | namespace Ui { 22 | class QueryForm; 23 | } 24 | 25 | class QueryForm : public QWidget 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit QueryForm(QWidget *parent = nullptr); 31 | ~QueryForm(); 32 | 33 | MyEdit* getMyEdit(); 34 | void clear(); 35 | void closeResults(); 36 | void deleteResultWidget(QWidget* resWidget); 37 | void addResultSet(QJsonObject res,QSharedPointer psql); 38 | void refreshDB(); 39 | void runQuery(QueryRunType runType=QueryRunType::current); 40 | bool testRes(QSharedPointer connData,QSharedPointer psql,const QJsonObject &res); 41 | QSharedPointer getCurrConnData(); 42 | QComboBox* getDbCombox(); 43 | QComboBox* getDBNameCombox(); 44 | void setCurrDbComboxItem(QString connName); 45 | void setCurrDBNameComboxItem(QString dbName); 46 | void formatSql(); 47 | QTabWidget* getResTabWidget(); 48 | void updateStatusBar(); 49 | void updateSqlStatus(); 50 | 51 | void selCurrStatement_v3(); 52 | QPair getCurrStatement(); 53 | 54 | std::atomic_bool stop=false; 55 | void safeDelete(); 56 | void closeEvent(QCloseEvent *event) override; 57 | 58 | void loadFile(const QString &fileName,const QByteArray codec); 59 | void reloadTailFile(); 60 | 61 | void stopWatchFileChange(); 62 | void watchFileChange(); 63 | 64 | void setLogForm(); 65 | 66 | void dragEnterEvent(QDragEnterEvent *ev) override; 67 | void dropEvent(QDropEvent *ev) override; 68 | 69 | static void refreshDB4All(); 70 | 71 | int64_t oldSize; 72 | QDateTime oldLastModified; 73 | 74 | public slots: 75 | void on_btn_stop_clicked(); 76 | void on_btnCommit_clicked(); 77 | void on_btnRollback_clicked(); 78 | 79 | void on_btn_explain_clicked(); 80 | 81 | private slots: 82 | void on_btn_run_clicked(); 83 | 84 | void on_chkAutoCommit_clicked(bool checked); 85 | 86 | void on_dbComboBox_activated(int index); 87 | 88 | void on_dbNameComboBox_activated(int index); 89 | 90 | void on_btn_clear_clicked(); 91 | 92 | private: 93 | Ui::QueryForm *ui; 94 | 95 | QTimer* fileWatchTimer=nullptr; 96 | 97 | std::atomic_bool inQuery=false;//查询命令正在运行 98 | 99 | void setNeedCommit(QSharedPointer connData,bool needCommit); 100 | void setAutoCommit(QSharedPointer connData,bool autoCommit); 101 | bool getNeedCommit(QSharedPointer connData); 102 | bool getAutoCommit(QSharedPointer connData); 103 | 104 | }; 105 | 106 | #endif // QUERYFORM_H 107 | -------------------------------------------------------------------------------- /cpp/readonlydelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "readonlydelegate.h" 2 | #include "widgetutils.h" 3 | 4 | 5 | void ReadOnlyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 6 | { 7 | auto opt=option; 8 | WidgetUtils::paint(painter,opt,index); 9 | } 10 | -------------------------------------------------------------------------------- /cpp/readonlydelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef READONLYDELEGATE_H 2 | #define READONLYDELEGATE_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | class ReadOnlyDelegate: public QStyledItemDelegate 9 | { 10 | 11 | public: 12 | ReadOnlyDelegate(QWidget *parent = nullptr):QStyledItemDelegate(parent) 13 | {} 14 | 15 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 16 | 17 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 18 | const QModelIndex &index) const override //final 19 | { 20 | Q_UNUSED(parent) 21 | Q_UNUSED(option) 22 | Q_UNUSED(index) 23 | return nullptr; 24 | } 25 | }; 26 | 27 | #endif // READONLYDELEGATE_H 28 | -------------------------------------------------------------------------------- /cpp/resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | images/copy.png 4 | images/cut.png 5 | images/new.png 6 | images/open.png 7 | images/paste.png 8 | images/save.png 9 | images/connection.svg 10 | images/mysql.svg 11 | images/mysql_close.svg 12 | images/wait.svg 13 | images/db_close.svg 14 | images/db.svg 15 | images/opening.svg 16 | images/closing.svg 17 | images/table.svg 18 | images/view.svg 19 | images/function.svg 20 | images/event.svg 21 | images/procedure.svg 22 | images/run.svg 23 | images/stop.svg 24 | images/format.svg 25 | images/error.svg 26 | images/commit.svg 27 | images/rollback.svg 28 | images/index.svg 29 | images/undo.svg 30 | images/redo.svg 31 | images/pri_key.svg 32 | images/key.svg 33 | images/plus.svg 34 | images/minus.svg 35 | images/down.svg 36 | images/up.svg 37 | images/trigger.svg 38 | images/textMore.svg 39 | images/nextall.svg 40 | images/next.svg 41 | images/down2.svg 42 | images/up2.svg 43 | images/pause.svg 44 | images/sort_asc.svg 45 | images/sort_desc.svg 46 | images/down3.svg 47 | images/sort.svg 48 | images/find.svg 49 | images/succ.svg 50 | images/export.svg 51 | images/first.svg 52 | images/last.svg 53 | images/import.svg 54 | images/null.svg 55 | images/loading.gif 56 | images/explain.svg 57 | images/new.svg 58 | images/clear.svg 59 | images/column.svg 60 | images/user.svg 61 | images/mariadb.svg 62 | images/mariadb_close.svg 63 | images/sqlserver.svg 64 | images/sqlserver_close.svg 65 | images/oracle_close.svg 66 | images/oracle.svg 67 | images/edit_data.svg 68 | images/view_data.svg 69 | images/seq.svg 70 | images/trans.svg 71 | images/filter.svg 72 | images/go.svg 73 | images/close.svg 74 | images/open.svg 75 | images/save.svg 76 | images/log.svg 77 | images/dark/calendar_nextmonth.svg 78 | images/dark/calendar_prevmonth.svg 79 | images/schema.svg 80 | images/schema_close.svg 81 | images/icon/jookdb.png 82 | images/run_script.svg 83 | images/swap.svg 84 | language/en.qm 85 | language/zh_cn.qm 86 | images/right2.svg 87 | images/right.svg 88 | images/left.svg 89 | images/left2.svg 90 | images/postgresql.svg 91 | images/postgresql_close.svg 92 | images/mongodb.svg 93 | images/mongodb_close.svg 94 | images/sqlite.svg 95 | images/sqlite_close.svg 96 | images/left3.svg 97 | images/right3.svg 98 | images/folder.svg 99 | images/dameng.svg 100 | images/dameng_close.svg 101 | images/refresh.svg 102 | images/count.svg 103 | images/oceanbase.svg 104 | images/oceanbase_close.svg 105 | images/tidb.svg 106 | images/tidb_close.svg 107 | 108 | 109 | -------------------------------------------------------------------------------- /cpp/resultform.h: -------------------------------------------------------------------------------- 1 | #ifndef RESULTFORM_H 2 | #define RESULTFORM_H 3 | 4 | #include "queryform.h" 5 | #include "sqllexer.h" 6 | #include "sqlobject.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Ui { 13 | class ResultForm; 14 | } 15 | 16 | class ResultForm : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ResultForm(const QJsonObject &res,QSharedPointer psql,QWidget *parent=nullptr); 22 | ~ResultForm(); 23 | 24 | QTableWidget *getTableWidget() const; 25 | 26 | QSharedPointer getPsql() const; 27 | 28 | void showRes(); 29 | void appendRs(const QJsonObject &resJson); 30 | void showStatus(); 31 | void updateHasNextStat(); 32 | void setResLabel(const QString &text); 33 | QTreeWidget *getPlanTree(); 34 | void genPlanTree(QTreeWidget *tree,QTreeWidgetItem *parentItem,QJsonObject json); 35 | 36 | void copyToExcel(bool current=true,bool isXlsx=true,int64_t rows=-1); 37 | 38 | void fetchNext(); 39 | 40 | void safeDelete(); 41 | void closeEvent(QCloseEvent *event) override; 42 | 43 | 44 | void refresh(); 45 | 46 | std::atomic_bool modified=false; 47 | 48 | void saveOldData(QTableWidgetItem *item); 49 | 50 | void itemDataChange(QTableWidgetItem *item); 51 | 52 | void setModified(const bool &value); 53 | 54 | void checkModify(); 55 | 56 | void clearOldUpdate(int row); 57 | 58 | public: 59 | std::atomic_bool hasNext=false; 60 | 61 | QSharedPointer getConnData() const; 62 | void setConnData(const QSharedPointer &value); 63 | 64 | QString getDbName() const; 65 | void setDbName(const QString &value); 66 | 67 | private slots: 68 | void on_btn_next_clicked(); 69 | 70 | void on_btn_nextall_clicked(); 71 | 72 | void on_btn_export_clicked(); 73 | 74 | void on_le_twfilter_textChanged(const QString &arg1); 75 | 76 | void on_le_twfilter_returnPressed(); 77 | 78 | void on_btn_goto_edit_clicked(); 79 | 80 | void on_btn_save_clicked(); 81 | 82 | void on_btn_close_clicked(); 83 | 84 | private: 85 | Ui::ResultForm *ui; 86 | 87 | QSharedPointer psql; 88 | QJsonObject res; 89 | QSharedPointer connData; 90 | QString dbName; 91 | QTableWidget *tw_rs=nullptr; 92 | QLabel *label=nullptr; 93 | std::atomic_bool fetchStop=false; 94 | QSet rightAlign; 95 | 96 | QueryForm *qf=nullptr; 97 | 98 | bool readonly=true; 99 | 100 | QMap tableMap; 101 | 102 | }; 103 | 104 | #endif // RESULTFORM_H 105 | -------------------------------------------------------------------------------- /cpp/reversecall.cpp: -------------------------------------------------------------------------------- 1 | #include "reversecall.h" 2 | #include "utils.h" 3 | 4 | ReverseCall::ReverseCall() 5 | { 6 | 7 | } 8 | 9 | void ReverseCall::call(const QJsonObject &json) 10 | { 11 | QJsonObject resultJson; 12 | 13 | int reverseCallFuncId=Utils::getInt(json,"RCFuncId"); 14 | switch (reverseCallFuncId) { 15 | case DECODE_PWD_FROM_B64:{ 16 | QString str=Utils::getString(json,"str"); 17 | QByteArray ba=StringUtils::decodePwdFromB64(str); 18 | resultJson.insert("str",QString{ba}); 19 | } 20 | break; 21 | } 22 | 23 | resultJson.insert("funcId", REVERSE_CALL); 24 | resultJson.insert("RCReqId",Utils::getString(json,"RCReqId")); 25 | 26 | auto connData=QSharedPointer{new ConnData()}; 27 | connData->getResJson(resultJson,false); 28 | } 29 | -------------------------------------------------------------------------------- /cpp/reversecall.h: -------------------------------------------------------------------------------- 1 | #ifndef REVERSECALL_H 2 | #define REVERSECALL_H 3 | 4 | #include 5 | 6 | 7 | #define DECODE_PWD_FROM_B64 1001 8 | 9 | class ReverseCall 10 | { 11 | public: 12 | ReverseCall(); 13 | 14 | static void call(const QJsonObject &json); 15 | }; 16 | 17 | #endif // REVERSECALL_H 18 | -------------------------------------------------------------------------------- /cpp/runsqldialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNSQLDIALOG_H 2 | #define RUNSQLDIALOG_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class RunSqlDialog; 10 | } 11 | 12 | class RunSqlDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit RunSqlDialog(QSharedPointer connData,QString dbName,QWidget *parent = nullptr); 18 | 19 | private slots: 20 | void on_btn_close_clicked(); 21 | 22 | void on_btn_detect_clicked(); 23 | 24 | void on_btn_start_clicked(); 25 | 26 | private: 27 | ~RunSqlDialog(); 28 | 29 | Ui::RunSqlDialog *ui; 30 | QSharedPointer connData; 31 | 32 | public: 33 | 34 | void closeEvent(QCloseEvent *event) override; 35 | 36 | private: 37 | 38 | std::atomic_bool stop=false; 39 | 40 | }; 41 | 42 | #endif // RUNSQLDIALOG_H 43 | -------------------------------------------------------------------------------- /cpp/runsqldialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | RunSqlDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 236 11 | 12 | 13 | 14 | Execute SQL File 15 | 16 | 17 | 18 | 19 | 20 | Datasource: 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Database: 35 | 36 | 37 | 38 | 39 | 40 | 41 | File: 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Encoding: 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Detect 68 | 69 | 70 | 71 | 72 | 73 | 74 | Qt::Horizontal 75 | 76 | 77 | 78 | 40 79 | 20 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Continue on error 90 | 91 | 92 | false 93 | 94 | 95 | 96 | 97 | 98 | 99 | AutoCommit 100 | 101 | 102 | 103 | 104 | 105 | 106 | Qt::Vertical 107 | 108 | 109 | 110 | 20 111 | 40 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 0 129 | 130 | 131 | 132 | 133 | 134 | 135 | Start 136 | 137 | 138 | 139 | 140 | 141 | 142 | Close 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | Batch size: 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 0 160 | 0 161 | 162 | 163 | 164 | 1 165 | 166 | 167 | 999999999 168 | 169 | 170 | 2000 171 | 172 | 173 | 174 | 175 | 176 | 177 | true 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /cpp/searchreplaceform.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCHREPLACEFORM_H 2 | #define SEARCHREPLACEFORM_H 3 | 4 | #include 5 | 6 | #define FIND_STATUS_SUCC 1 7 | #define FIND_STATUS_FAIL 2 8 | #define FIND_TYPE_NEXT 3 9 | #define FIND_TYPE_PRE 4 10 | 11 | namespace Ui { 12 | class SearchReplaceForm; 13 | } 14 | 15 | class SearchReplaceForm : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit SearchReplaceForm(QWidget *parent = nullptr); 21 | ~SearchReplaceForm(); 22 | 23 | void useReplace(bool use); 24 | 25 | void saveFindHis(const QString &findBa); 26 | void saveReplaceHis(const QString &replaceBa); 27 | 28 | void freshFindHis(); 29 | void freshReplaceHis(); 30 | 31 | void setCurrSelect(); 32 | 33 | private slots: 34 | void on_chb_useReplace_clicked(bool checked); 35 | 36 | void on_btn_close_clicked(); 37 | 38 | void on_btn_findNext_clicked(); 39 | 40 | void on_btn_findPre_clicked(); 41 | 42 | void on_chb_inSelection_clicked(bool checked); 43 | 44 | void on_btn_count_clicked(); 45 | 46 | void on_btn_replaceAll_clicked(); 47 | 48 | void on_cbox_find_currentTextChanged(const QString &arg1); 49 | 50 | void on_btn_replaceFind_clicked(); 51 | 52 | void on_btn_replace_clicked(); 53 | 54 | void on_btn_find_reg_clicked(); 55 | 56 | void on_btn_replace_reg_clicked(); 57 | 58 | void on_chb_useRegular_clicked(); 59 | 60 | private: 61 | Ui::SearchReplaceForm *ui; 62 | 63 | int64_t findStart=-1; 64 | int64_t findEnd=-1; 65 | 66 | int lastType=-1; 67 | QByteArray lastFindstr; 68 | int lastStat=-1; 69 | int64_t lastFindStart=-1; 70 | int64_t lastFindEnd=-1; 71 | int64_t lastCursorPos=-1; 72 | int64_t lastSelStart=-1; 73 | int64_t lastSelEnd=-1; 74 | int64_t lastModifyNum=-1; 75 | 76 | public: 77 | 78 | void closeEvent(QCloseEvent *event) override; 79 | 80 | private: 81 | 82 | std::atomic_bool stop=false; 83 | 84 | }; 85 | 86 | #endif // SEARCHREPLACEFORM_H 87 | -------------------------------------------------------------------------------- /cpp/spinboxdelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "spinboxdelegate.h" 2 | #include "widgetutils.h" 3 | 4 | #include 5 | 6 | SpinBoxDelegate::SpinBoxDelegate(QObject *parent):QStyledItemDelegate(parent) 7 | { 8 | 9 | } 10 | 11 | void SpinBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const 12 | { 13 | auto opt=option; 14 | WidgetUtils::paint(painter,opt,index,alternatingRowColors); 15 | } 16 | 17 | QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const 18 | { 19 | QSpinBox *editor = new QSpinBox(parent); 20 | 21 | editor->setFrame(false); 22 | editor->setMinimum(minVal); 23 | editor->setMaximum(maxVal); 24 | editor->setSingleStep(step); 25 | 26 | if(initFunc){ 27 | initFunc(editor); 28 | } 29 | 30 | return editor; 31 | } 32 | 33 | void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const 34 | { 35 | QSpinBox *spinBox = static_cast(editor); 36 | 37 | auto var=WidgetUtils::getData(index); 38 | if(var.isValid()&&!var.isNull()){ 39 | spinBox->setValue(var.toInt()); 40 | } 41 | 42 | } 43 | 44 | void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const 45 | { 46 | if(this->readonly)return; 47 | 48 | QSpinBox *spinBox = static_cast(editor); 49 | QVariant var; 50 | if(!spinBox->text().isEmpty()){ 51 | var=spinBox->value(); 52 | } 53 | 54 | bool changed=WidgetUtils::setData(model,index,var); 55 | if(changed){ 56 | if(dataChangedFunc){ 57 | dataChangedFunc(index); 58 | } 59 | } 60 | } 61 | 62 | void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const 63 | { 64 | editor->setGeometry(option.rect); 65 | } 66 | -------------------------------------------------------------------------------- /cpp/spinboxdelegate.h: -------------------------------------------------------------------------------- 1 | #ifndef SPINBOXDELEGATE_H 2 | #define SPINBOXDELEGATE_H 3 | 4 | #include 5 | #include 6 | 7 | class SpinBoxDelegate : public QStyledItemDelegate 8 | { 9 | public: 10 | 11 | SpinBoxDelegate(QObject *parent = nullptr); 12 | 13 | void paint(QPainter *painter, const QStyleOptionViewItem &option,const QModelIndex &index) const override; 14 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 15 | const QModelIndex &index) const override; 16 | 17 | void setEditorData(QWidget *editor, const QModelIndex &index) const override; 18 | void setModelData(QWidget *editor, QAbstractItemModel *model, 19 | const QModelIndex &index) const override; 20 | 21 | void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, 22 | const QModelIndex &index) const override; 23 | 24 | 25 | std::function initFunc=nullptr; 26 | 27 | std::function dataChangedFunc=nullptr; 28 | 29 | int minVal=INT_MIN; 30 | int maxVal=INT_MAX; 31 | int step=1; 32 | 33 | bool alternatingRowColors=true; 34 | 35 | private: 36 | bool readonly=false; 37 | 38 | }; 39 | 40 | #endif // SPINBOXDELEGATE_H 41 | -------------------------------------------------------------------------------- /cpp/sqllexer.h: -------------------------------------------------------------------------------- 1 | #ifndef SQLLEXER_H 2 | #define SQLLEXER_H 3 | 4 | #include "utils.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define MAX_SQL_SIZE 10240000 12 | 13 | enum class SqlLexType{ 14 | sql, 15 | all, 16 | }; 17 | 18 | struct ParsedSql{ 19 | QByteArray sql; 20 | QByteArray sqlType="unkonw";//unkonw,select,insert,update,delete,drop,alter,create,"rename" 21 | QByteArray sqlSimpleName; 22 | int64_t startPos; 23 | int64_t startPos_indic; 24 | int64_t len_indic; 25 | int modifyNum; 26 | int effectiveChars=0; 27 | bool isExplainCmd=false; 28 | QMap props; 29 | }; 30 | 31 | const static QSet startKeys={"go","update","delete","insert","create","alter","truncate","exec","dbcc","show","replace","merge", 32 | "grant","revoke","rename","comment","commit","rollback"}; 33 | 34 | const static QSet procTypeSqls={"procedure","function","type","package","trigger","event","declare","begin"}; 35 | 36 | class SqlLexer 37 | { 38 | public: 39 | explicit SqlLexer(const char* documentBytes,const int64_t length); 40 | static bool isZS(QByteArray &ba); 41 | bool isFGF(uint8_t c); 42 | QByteArray preEntity(bool peek=false); 43 | QByteArray nextEntity(bool peek=false); 44 | QByteArray nextDeliEntity(); 45 | //合并括号中内容,如函数、子查询等合并到一个Entity里。compoundStmt:是否支持语句块。periodStmt:是否使用句号连接(对象名、浮点数都有可能是句号连接) 46 | QByteArray nextCiFaEntity(bool compoundStmt=false,bool periodStmt=false); 47 | QByteArray nextYXEntity(QByteArray &ba,bool peek=false); 48 | QByteArray nextSqlEnd(bool peek=false); 49 | void useFormat(); 50 | QByteArray nextFormatSql(); 51 | QSharedPointer nextSqlCiFa(); 52 | QSharedPointer nextSql(); 53 | bool testTypeIsScript(); 54 | QByteArray getSqlType(); 55 | 56 | void skipSpaceLeft(int64_t &pos); 57 | static void skipSpaceLeft(const QByteArray &ba,int64_t &pos); 58 | void findKuoHaoLeft(const QByteArray &ba,int64_t &pos); 59 | void findKuoHaoLeft(const QString &ba,int64_t &pos); 60 | void findKuoHaoRight(const QByteArray &ba,int64_t &pos); 61 | bool inKuoHaoLeft(const QByteArray &ba,int64_t start,int64_t end); 62 | bool inKuoHaoRight(const QByteArray &ba,int64_t start,int64_t end); 63 | void findBianJieLeft(const QByteArray &ba_lower,int64_t &pos); 64 | void findBianJieRight(const QByteArray &ba_lower,int64_t &pos); 65 | void getWordLeft(QByteArray &ba,int64_t &pos); 66 | void getWordLeft(const QByteArray &sqlBa,QByteArray &ba,int64_t &pos); 67 | void skipSpaceRight(int64_t &pos); 68 | void skipSpaceRight(); 69 | static void skipSpaceRight(const QByteArray &ba,int64_t &pos); 70 | void getWordRight(QByteArray &ba,int64_t &pos); 71 | void getWordRight(const QByteArray &sqlBa,QByteArray &ba,int64_t &pos); 72 | QList leftWord(bool peek=false); 73 | QList rightWord(bool peek=false); 74 | 75 | //dianhao=true表示查找到的key后面不可以有'.'点号,如果有则继续查找 76 | static void leftKey(const QByteArray &ba,const QByteArray &key,int64_t &pos,bool dianhao=false); 77 | //dianhao=true表示查找到的key后面不可以有'.'点号,如果有则继续查找 78 | static void rightKey(const QByteArray &ba,const QByteArray &key,int64_t &pos,bool dianhao=false); 79 | 80 | int64_t nextKeyIdx(const QByteArray &key); 81 | 82 | QByteArray getAliasTables(QByteArray alias); 83 | QByteArray getCiFaTables(const QByteArray &preKey=""); 84 | 85 | void setPos(const int64_t pos); 86 | int64_t getPos(); 87 | 88 | QList getSqlTables(const QByteArray &sqlBa,const int64_t &khStart, const int64_t &khEnd, const int64_t &start); 89 | 90 | inline static bool leftHasNewline(const QByteArray &ba); 91 | 92 | bool isBianJieStr(const QByteArray &ba) const; 93 | 94 | SqlLexType lexType=SqlLexType::sql; 95 | 96 | const QSet objPreSet={"from","join","update","table","into","on"};//on仅指创建索引触发器等情况下指定表名 97 | 98 | QSharedPointer getConnData() const; 99 | void setConnData(const QSharedPointer &value); 100 | 101 | QSet compoundKeysSet; 102 | 103 | static QStringList getEntityList(QSharedPointer connData,QString sql,bool trim=false); 104 | private: 105 | const char* documentBytes; 106 | const int64_t length; 107 | int64_t docPos=0; 108 | 109 | bool charsEqual(int64_t pos,QByteArray str); 110 | void nextCreate(QByteArray &sqlBa); 111 | void nextALL(QByteArray &sqlBa); 112 | void nextCurrLine(QByteArray &sqlBa); 113 | void nextFenhao(QByteArray &sqlBa); 114 | 115 | bool isEnd(const QByteArray &sqlBa,const QByteArray &entityBa); 116 | 117 | void removeLastFenhao(QByteArray &sqlBa); 118 | 119 | QMap> formatFuncs; 120 | std::function getFormatFunc(const QByteArray &entityBa); 121 | 122 | QByteArray delimiter; 123 | 124 | QSharedPointer connData=nullptr; 125 | 126 | int dbType=-1; 127 | }; 128 | 129 | 130 | #endif // SQLLEXER_H 131 | -------------------------------------------------------------------------------- /cpp/sqlstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef SQLSTYLE_H 2 | #define SQLSTYLE_H 3 | 4 | #include 5 | #include "myedit.h" 6 | 7 | 8 | const QByteArray keyworks_sql="absolute action add admin after aggregate \ 9 | alias all allocate alter and any are array as asc \ 10 | assertion at authorization \ 11 | before begin binary bit blob body boolean both breadth by \ 12 | call cascade cascaded case cast catalog char character \ 13 | check class clob close collate collation column commit \ 14 | completion connect connection constraint constraints \ 15 | constructor continue corresponding create cross cube current \ 16 | current_date current_path current_role current_time current_timestamp \ 17 | current_user cursor cycle \ 18 | data date datetime day deallocate dec decimal declare default \ 19 | deferrable deferred delete depth deref desc describe descriptor \ 20 | destroy destructor deterministic dictionary diagnostics disconnect \ 21 | distinct domain double dynamic \ 22 | each else end end-exec equals escape every except \ 23 | exception exec execute exists exit external \ 24 | false fetch first float for foreign found from free full \ 25 | function \ 26 | general get global go goto grant group grouping \ 27 | having host hour \ 28 | identity if ignore immediate in indicator initialize initially \ 29 | inner inout input insert int integer intersect interval \ 30 | into is isolation iterate \ 31 | join \ 32 | key \ 33 | language large last lateral leading left less level like \ 34 | limit local localtime localtimestamp locator \ 35 | map match merge minute modifies modify module month \ 36 | names national natural nchar nclob new next no none \ 37 | not null numeric \ 38 | object of off old on only open operation option \ 39 | or order ordinality out outer output \ 40 | package pad parameter parameters partial path postfix precision prefix \ 41 | preorder prepare preserve primary \ 42 | prior privileges procedure public \ 43 | read reads real recursive ref references referencing relative \ 44 | restrict result return returns revoke right \ 45 | role rollback rollup routine row rows \ 46 | savepoint dbName scroll scope search second section select \ 47 | sequence session session_user set sets size smallint some space \ 48 | specific specifictype sql sqlexception sqlstate sqlwarning start \ 49 | state statement static structure system_user schema \ 50 | table temporary terminate than then time timestamp \ 51 | timezone_hour timezone_minute to trailing transaction translation \ 52 | treat trigger true \ 53 | under union unique unknown \ 54 | unnest update usage user using \ 55 | value values variable varying view \ 56 | when whenever where with without work write \ 57 | year \ 58 | zone \ 59 | flush leave load repeat rename show explain replace"; 60 | const QByteArray keyworks_plsql="authid between \ 61 | binary_integer \ 62 | bulk char_base cluster collect \ 63 | comment compress constant currval \ 64 | do drop elsif exclusive \ 65 | extends forall \ 66 | heap index \ 67 | interface java \ 68 | limited lock long loop minus mod mode \ 69 | naturaln nextval nocopy nowait number \ 70 | number_base ocirowid opaque operator \ 71 | organization others partition pctfree pls_integer \ 72 | positive positiven pragma private raise \ 73 | range raw record release reverse \ 74 | rowid rownum rowtype separate share \ 75 | sqlcode sqlerrm stddev subtype successful \ 76 | synonym sysdate \ 77 | type uid use validate varchar \ 78 | varchar2 variance while switch break \ 79 | truncate always generated unlock disable enable nvarchar nvarchar2 text ntext"; 80 | 81 | class SqlStyle : public QObject 82 | { 83 | Q_OBJECT 84 | public: 85 | explicit SqlStyle(); 86 | 87 | static void setStyle(MyEdit *myEdit); 88 | static void setMarginLineNumberWidth(MyEdit *myEdit); 89 | static void setMarginFlod(MyEdit *myEdit); 90 | static void clearResultIndic(MyEdit *myEdit); 91 | static void setResultIndic(MyEdit *myEdit,int64_t start,int64_t len); 92 | static void clearErrorIndic(MyEdit *myEdit); 93 | static void setErrorIndic(MyEdit *myEdit,int64_t start,int64_t len); 94 | static void clearFindIndic(MyEdit *myEdit); 95 | static void setFindIndic(MyEdit *myEdit,int64_t start,int64_t len); 96 | static void setResultIndicStyle(MyEdit *myEdit); 97 | 98 | signals: 99 | 100 | public slots: 101 | 102 | private: 103 | 104 | }; 105 | 106 | #endif // SQLSTYLE_H 107 | -------------------------------------------------------------------------------- /cpp/strmappingdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef STRMAPPINGDIALOG_H 2 | #define STRMAPPINGDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class StrMappingDialog; 9 | } 10 | 11 | class StrMappingDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit StrMappingDialog(QWidget *parent = nullptr); 17 | ~StrMappingDialog(); 18 | 19 | void setMappingStrs(QStringList srcList,QStringList tgtList,QList> mappings); 20 | QList> getMappingList(); 21 | 22 | private slots: 23 | void on_btn_ok_clicked(); 24 | 25 | void on_btn_cancel_clicked(); 26 | 27 | void on_btn_add_clicked(); 28 | 29 | void on_btn_delete_clicked(); 30 | 31 | void on_btn_auto_clicked(); 32 | 33 | void on_btn_clear_clicked(); 34 | 35 | void on_lw_src_itemClicked(QListWidgetItem *item); 36 | 37 | void on_lw_tgt_itemClicked(QListWidgetItem *item); 38 | 39 | void on_lw_mapping_itemDoubleClicked(QListWidgetItem *item); 40 | 41 | void on_btn_auto_2_clicked(); 42 | 43 | private: 44 | Ui::StrMappingDialog *ui; 45 | 46 | const QString MAP_FGF=" --> "; 47 | 48 | public: 49 | 50 | void closeEvent(QCloseEvent *event) override; 51 | 52 | private: 53 | 54 | std::atomic_bool stop=false; 55 | }; 56 | 57 | #endif // STRMAPPINGDIALOG_H 58 | -------------------------------------------------------------------------------- /cpp/test.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_H 2 | #define TEST_H 3 | 4 | #include "utils.h" 5 | 6 | class Test 7 | { 8 | public: 9 | Test(); 10 | void test1(); 11 | void test2(); 12 | void test2_2(); 13 | void test2_3(); 14 | void test3(); 15 | void test11(); 16 | }; 17 | 18 | #endif // TEST_H 19 | -------------------------------------------------------------------------------- /cpp/texteditdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTEDITDIALOG_H 2 | #define TEXTEDITDIALOG_H 3 | 4 | #include "myedit.h" 5 | 6 | #include 7 | 8 | namespace Ui { 9 | class TextEditDialog; 10 | } 11 | 12 | class TextEditDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit TextEditDialog(QWidget *parent = nullptr); 18 | 19 | MyEdit * getMyEdit(); 20 | 21 | signals: 22 | 23 | private slots: 24 | 25 | void on_btn_file2blob_clicked(); 26 | 27 | void on_btn_blob2file_clicked(); 28 | 29 | void on_btn_file2text_clicked(); 30 | 31 | void on_btn_text2file_clicked(); 32 | 33 | void on_chk_line_wrap_stateChanged(int arg1); 34 | 35 | private: 36 | Ui::TextEditDialog *ui; 37 | 38 | ~TextEditDialog() override; 39 | 40 | bool readOnly=false; 41 | 42 | public: 43 | 44 | void closeEvent(QCloseEvent *event) override; 45 | 46 | bool getReadOnly() const; 47 | void setReadOnly(bool value); 48 | 49 | private: 50 | 51 | std::atomic_bool stop=false; 52 | }; 53 | 54 | #endif // TEXTEDITDIALOG_H 55 | -------------------------------------------------------------------------------- /cpp/texteditdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | TextEditDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 687 10 | 410 11 | 12 | 13 | 14 | Text Editor 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Load BLOB 26 | 27 | 28 | 29 | 30 | 31 | 32 | Save BLOB 33 | 34 | 35 | 36 | 37 | 38 | 39 | Qt::Vertical 40 | 41 | 42 | 43 | 44 | 45 | 46 | Load Text 47 | 48 | 49 | 50 | 51 | 52 | 53 | Save Text 54 | 55 | 56 | 57 | 58 | 59 | 60 | Qt::Vertical 61 | 62 | 63 | 64 | 65 | 66 | 67 | Wrap 68 | 69 | 70 | 71 | 72 | 73 | 74 | Qt::Horizontal 75 | 76 | 77 | 78 | 40 79 | 20 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 0 91 | 0 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | Qt::Horizontal 100 | 101 | 102 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | MyEdit 111 | QWidget 112 |
myedit.h
113 |
114 |
115 | 116 | 117 | 118 | buttonBox 119 | accepted() 120 | TextEditDialog 121 | accept() 122 | 123 | 124 | 248 125 | 254 126 | 127 | 128 | 157 129 | 274 130 | 131 | 132 | 133 | 134 | buttonBox 135 | rejected() 136 | TextEditDialog 137 | reject() 138 | 139 | 140 | 316 141 | 260 142 | 143 | 144 | 286 145 | 274 146 | 147 | 148 | 149 | 150 |
151 | -------------------------------------------------------------------------------- /img/demo/data_editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/img/demo/data_editor.png -------------------------------------------------------------------------------- /img/demo/query_editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/img/demo/query_editor.png -------------------------------------------------------------------------------- /img/demo/structure_synchronization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/img/demo/structure_synchronization.png -------------------------------------------------------------------------------- /img/demo/table_design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/img/demo/table_design.png -------------------------------------------------------------------------------- /img/demo/user_manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/img/demo/user_manager.png -------------------------------------------------------------------------------- /language/en.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/language/en.qm -------------------------------------------------------------------------------- /lib/commons-codec-1.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-codec-1.15.jar -------------------------------------------------------------------------------- /lib/commons-collections4-4.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-collections4-4.4.jar -------------------------------------------------------------------------------- /lib/commons-compress-1.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-compress-1.20.jar -------------------------------------------------------------------------------- /lib/commons-csv-1.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-csv-1.9.0.jar -------------------------------------------------------------------------------- /lib/commons-io-2.8.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-io-2.8.0.jar -------------------------------------------------------------------------------- /lib/commons-lang3-3.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-lang3-3.12.0.jar -------------------------------------------------------------------------------- /lib/commons-math3-3.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/commons-math3-3.6.1.jar -------------------------------------------------------------------------------- /lib/dom4j-2.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/dom4j-2.1.3.jar -------------------------------------------------------------------------------- /lib/easyexcel-2.2.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/easyexcel-2.2.7.jar -------------------------------------------------------------------------------- /lib/fastjson-1.2.83.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/fastjson-1.2.83.jar -------------------------------------------------------------------------------- /lib/gson-2.9.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/gson-2.9.0.jar -------------------------------------------------------------------------------- /lib/h2-1.4.199.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/h2-1.4.199.jar -------------------------------------------------------------------------------- /lib/httpclient-4.5.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/httpclient-4.5.13.jar -------------------------------------------------------------------------------- /lib/httpcore-4.4.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/httpcore-4.4.14.jar -------------------------------------------------------------------------------- /lib/javassist-3.28.0-GA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/javassist-3.28.0-GA.jar -------------------------------------------------------------------------------- /lib/jedis-3.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/jedis-3.4.1.jar -------------------------------------------------------------------------------- /lib/jookNS.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/jookNS.jar -------------------------------------------------------------------------------- /lib/jtds-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/jtds-1.3.1.jar -------------------------------------------------------------------------------- /lib/lib.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/mariadb-java-client-3.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/mariadb-java-client-3.1.3.jar -------------------------------------------------------------------------------- /lib/mssql-jdbc-8.2.2.jre11.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/mssql-jdbc-8.2.2.jre11.jar -------------------------------------------------------------------------------- /lib/poi-4.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/poi-4.1.2.jar -------------------------------------------------------------------------------- /lib/poi-ooxml-4.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/poi-ooxml-4.1.2.jar -------------------------------------------------------------------------------- /lib/poi-ooxml-schemas-4.1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/poi-ooxml-schemas-4.1.2.jar -------------------------------------------------------------------------------- /lib/postgresql-42.2.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/postgresql-42.2.20.jar -------------------------------------------------------------------------------- /lib/slf4j-api-1.7.29.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/slf4j-api-1.7.29.jar -------------------------------------------------------------------------------- /lib/slf4j-simple-1.7.29.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/slf4j-simple-1.7.29.jar -------------------------------------------------------------------------------- /lib/xmlbeans-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jooksoft/jookdb/30cfa4bed44cd7cd047857d936c00eeb18d06b07/lib/xmlbeans-3.1.0.jar --------------------------------------------------------------------------------