├── listmodel.cpp ├── widgets ├── widgets.pri ├── aboutdialog.h ├── aboutdialog.cpp ├── sqlsyntaxhighlighter.h ├── sqlsyntaxhighlighter.cpp └── aboutdialog.ui ├── resources └── win.rc ├── pages ├── diypage.ui ├── page.h ├── diypage.h ├── sqlpage.h ├── diypage.cpp ├── sqlpage.ui ├── filepage.h ├── generalpage.h ├── authorgrouppage.h ├── changelogpage.h ├── editedfilespage.h ├── fileeditpage.h ├── sqlpage.cpp ├── filepage.cpp ├── filepage.ui ├── editedfilespage.cpp ├── generalpage.cpp ├── changelogpage.ui ├── editedfilespage.ui ├── changelogpage.cpp ├── authorgrouppage.cpp ├── generalpage.ui ├── authorgrouppage.ui ├── fileeditpage.cpp └── fileeditpage.ui ├── ModX.pro ├── modxapp.h ├── main.cpp ├── modxapp.cpp ├── changelogsortfilterproxymodel.h ├── modxwriter.h ├── changelogsortfilterproxymodel.cpp ├── modxreader.h ├── mainwindow.h ├── version.h ├── mainwindow.ui ├── listmodel.h ├── modxdata.h ├── modxdata.cpp ├── version.cpp ├── mainwindow.cpp ├── modxwriter.cpp └── modxreader.cpp /listmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "listmodel.h" 2 | 3 | ListModel::ListModel() 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /widgets/widgets.pri: -------------------------------------------------------------------------------- 1 | SOURCES += widgets/sqlsyntaxhighlighter.cpp \ 2 | widgets/aboutdialog.cpp 3 | HEADERS += widgets/sqlsyntaxhighlighter.h \ 4 | widgets/aboutdialog.h 5 | FORMS += widgets/aboutdialog.ui 6 | -------------------------------------------------------------------------------- /resources/win.rc: -------------------------------------------------------------------------------- 1 | 1 VERSIONINFO 2 | FILEVERSION 1,0,0,0 3 | PRODUCTVERSION 1,0,0,0 4 | FILEFLAGSMASK 0x3fL 5 | #ifdef _DEBUG 6 | FILEFLAGS 0x1L 7 | #else 8 | FILEFLAGS 0x0L 9 | #endif 10 | FILEOS 0x4L 11 | FILETYPE 0x1L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "040904e4" 17 | BEGIN 18 | VALUE "Comments", "\0" 19 | VALUE "CompanyName", "\0" 20 | VALUE "FileDescription", "ModX Editor\0" 21 | VALUE "FileVersion", "0, 0, 1, 1\0" 22 | VALUE "InternalName", "ModX Editor\0" 23 | VALUE "LegalCopyright", "APTX\0" 24 | VALUE "OriginalFilename", "modx.exe\0" 25 | VALUE "ProductName", "ModX Editor\0" 26 | VALUE "ProductVersion", "1, 0, 0, 0\0" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x409, 1252 32 | END 33 | END 34 | -------------------------------------------------------------------------------- /pages/diypage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DIYPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | Do-It-Yourself 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /ModX.pro: -------------------------------------------------------------------------------- 1 | QT += network 2 | 3 | CONFIG -= debug 4 | CONFIG += release 5 | TARGET = MODXEditor 6 | TEMPLATE = app 7 | SOURCES += main.cpp \ 8 | mainwindow.cpp \ 9 | modxapp.cpp \ 10 | modxreader.cpp \ 11 | pages/generalpage.cpp \ 12 | modxdata.cpp \ 13 | pages/changelogpage.cpp \ 14 | pages/authorgrouppage.cpp \ 15 | modxwriter.cpp \ 16 | pages/sqlpage.cpp \ 17 | pages/filepage.cpp \ 18 | pages/diypage.cpp \ 19 | pages/fileeditpage.cpp \ 20 | pages/editedfilespage.cpp \ 21 | version.cpp \ 22 | changelogsortfilterproxymodel.cpp 23 | HEADERS += mainwindow.h \ 24 | modxapp.h \ 25 | modxreader.h \ 26 | pages/generalpage.h \ 27 | modxdata.h \ 28 | pages/page.h \ 29 | pages/changelogpage.h \ 30 | pages/authorgrouppage.h \ 31 | modxwriter.h \ 32 | pages/sqlpage.h \ 33 | pages/filepage.h \ 34 | pages/diypage.h \ 35 | listmodel.h \ 36 | pages/fileeditpage.h \ 37 | pages/editedfilespage.h \ 38 | version.h \ 39 | changelogsortfilterproxymodel.h 40 | FORMS += mainwindow.ui \ 41 | pages/generalpage.ui \ 42 | pages/changelogpage.ui \ 43 | pages/authorgrouppage.ui \ 44 | pages/sqlpage.ui \ 45 | pages/filepage.ui \ 46 | pages/diypage.ui \ 47 | pages/fileeditpage.ui \ 48 | pages/editedfilespage.ui 49 | 50 | win32 { 51 | RC_FILE += resources/win.rc 52 | } 53 | 54 | include(widgets/widgets.pri) 55 | -------------------------------------------------------------------------------- /modxapp.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MODXAPP_H 22 | #define MODXAPP_H 23 | 24 | #include 25 | #include "mainwindow.h" 26 | 27 | class ModXApp : public QApplication 28 | { 29 | public: 30 | ModXApp(int &argc, char **argv); 31 | virtual ~ModXApp(); 32 | 33 | static QString currentFile; 34 | 35 | private: 36 | MainWindow *mainWin; 37 | }; 38 | 39 | #endif // MODXAPP_H 40 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "modxapp.h" 22 | 23 | int main(int argc, char **argv) 24 | { 25 | QCoreApplication::setApplicationName("MODX Editor"); 26 | QCoreApplication::setOrganizationName("phpBB Group"); 27 | QCoreApplication::setOrganizationDomain("phpbb.com"); 28 | QCoreApplication::setApplicationVersion("1.0.0A3"); 29 | 30 | ModXApp app(argc, argv); 31 | return app.exec(); 32 | } 33 | -------------------------------------------------------------------------------- /modxapp.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include 22 | #include "modxapp.h" 23 | 24 | ModXApp::ModXApp(int &argc, char **argv) : QApplication(argc, argv) 25 | { 26 | QSettings::setDefaultFormat(QSettings::IniFormat); 27 | 28 | mainWin = new MainWindow(); 29 | 30 | mainWin->show(); 31 | } 32 | 33 | ModXApp::~ModXApp() 34 | { 35 | delete mainWin; 36 | } 37 | 38 | QString ModXApp::currentFile = "Untitled"; 39 | -------------------------------------------------------------------------------- /pages/page.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef PAGE_H 22 | #define PAGE_H 23 | 24 | #include 25 | 26 | class ModXData; 27 | 28 | class Page : public QWidget 29 | { 30 | Q_OBJECT 31 | Q_DISABLE_COPY(Page) 32 | public: 33 | explicit Page(QWidget *parent) : QWidget(parent) {} 34 | virtual ~Page() {} 35 | 36 | virtual void setData(const ModXData *data) = 0; 37 | virtual void getData(ModXData *data) = 0; 38 | }; 39 | 40 | #endif // PAGE_H 41 | -------------------------------------------------------------------------------- /widgets/aboutdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef ABOUTDIALOG_H 22 | #define ABOUTDIALOG_H 23 | 24 | #include "../ui_aboutdialog.h" 25 | 26 | class AboutDialog : public QDialog { 27 | Q_OBJECT 28 | Q_DISABLE_COPY(AboutDialog); 29 | public: 30 | explicit AboutDialog(QWidget *parent = 0); 31 | 32 | protected: 33 | virtual void changeEvent(QEvent *e); 34 | 35 | private: 36 | Ui::AboutDialog m_ui; 37 | }; 38 | 39 | #endif // ABOUTDIALOG_H 40 | -------------------------------------------------------------------------------- /changelogsortfilterproxymodel.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef CHANGELOGSORTFILTERPROXYMODEL_H 22 | #define CHANGELOGSORTFILTERPROXYMODEL_H 23 | 24 | #include 25 | 26 | class ChangelogSortFilterProxyModel : public QSortFilterProxyModel 27 | { 28 | public: 29 | ChangelogSortFilterProxyModel(QObject *parent = 0); 30 | 31 | protected: 32 | 33 | bool lessThan(const QModelIndex &left, const QModelIndex &right ) const; 34 | }; 35 | 36 | #endif // CHANGELOGSORTFILTERPROXYMODEL_H 37 | -------------------------------------------------------------------------------- /pages/diypage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef DIYPAGE_H 22 | #define DIYPAGE_H 23 | 24 | #include "page.h" 25 | 26 | #include "ui_diypage.h" 27 | 28 | class DIYPage : public Page { 29 | Q_OBJECT 30 | Q_DISABLE_COPY(DIYPage) 31 | public: 32 | explicit DIYPage(QWidget *parent = 0); 33 | 34 | virtual void setData(const ModXData *data); 35 | virtual void getData(ModXData *data); 36 | 37 | protected: 38 | virtual void changeEvent(QEvent *e); 39 | 40 | private: 41 | Ui::DIYPage ui; 42 | }; 43 | 44 | #endif // DIYPAGE_H 45 | -------------------------------------------------------------------------------- /pages/sqlpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef SQLPAGE_H 22 | #define SQLPAGE_H 23 | 24 | #include "page.h" 25 | 26 | #include "ui_sqlpage.h" 27 | 28 | class SqlPage : public Page { 29 | Q_OBJECT 30 | Q_DISABLE_COPY(SqlPage) 31 | public: 32 | explicit SqlPage(QWidget *parent = 0); 33 | 34 | virtual void setData(const ModXData *data); 35 | virtual void getData(ModXData *data); 36 | 37 | protected: 38 | virtual void changeEvent(QEvent *e); 39 | 40 | private: 41 | Ui::SqlPage ui; 42 | }; 43 | 44 | #endif // SQLPAGE_H 45 | -------------------------------------------------------------------------------- /modxwriter.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MODXWRITER_H 22 | #define MODXWRITER_H 23 | 24 | #include 25 | 26 | class ModXData; 27 | 28 | class ModXWriter : public QXmlStreamWriter 29 | { 30 | public: 31 | ModXWriter(); 32 | 33 | void setData(const ModXData *data); 34 | 35 | void write(QIODevice *device); 36 | 37 | private: 38 | void writeHeader(); 39 | void writeAuthorGroup(); 40 | void writeHistory(); 41 | 42 | void writeActionGroup(); 43 | void writeOpen(); 44 | 45 | const ModXData *m_data; 46 | }; 47 | 48 | #endif // MODXWRITER_H 49 | -------------------------------------------------------------------------------- /pages/diypage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "diypage.h" 22 | 23 | #include "modxdata.h" 24 | 25 | DIYPage::DIYPage(QWidget *parent) : 26 | Page(parent){ 27 | ui.setupUi(this); 28 | } 29 | 30 | void DIYPage::setData(const ModXData *data) 31 | { 32 | ui.diy->setText(data->diy["en"]); 33 | } 34 | void DIYPage::getData(ModXData *data) 35 | { 36 | data->diy["en"] = ui.diy->toPlainText(); 37 | } 38 | 39 | void DIYPage::changeEvent(QEvent *e) 40 | { 41 | switch(e->type()) { 42 | case QEvent::LanguageChange: 43 | ui.retranslateUi(this); 44 | break; 45 | default: 46 | break; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /pages/sqlpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SqlPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | SQL 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | SQL dialect: 32 | 33 | 34 | sqlDialect 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 0 43 | 0 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Courier 55 | 56 | 57 | 58 | false 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | sqlDialect 69 | sql 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /pages/filepage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef FILEPAGE_H 22 | #define FILEPAGE_H 23 | 24 | #include "page.h" 25 | 26 | #include 27 | 28 | #include "ui_filepage.h" 29 | 30 | class QFileSystemModel; 31 | 32 | class FilePage : public Page { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(FilePage) 35 | public: 36 | explicit FilePage(QWidget *parent = 0); 37 | 38 | virtual void setData(const ModXData *data); 39 | virtual void getData(ModXData *data); 40 | 41 | protected slots: 42 | void updateFiles(bool checked); 43 | 44 | protected: 45 | virtual void changeEvent(QEvent *e); 46 | 47 | private: 48 | void setRootDir(); 49 | 50 | QFileSystemModel *fileModel; 51 | Ui::FilePage ui; 52 | }; 53 | 54 | #endif // FILEPAGE_H 55 | -------------------------------------------------------------------------------- /changelogsortfilterproxymodel.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "changelogsortfilterproxymodel.h" 22 | 23 | #include "modxdata.h" 24 | 25 | ChangelogSortFilterProxyModel::ChangelogSortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent) 26 | { 27 | } 28 | 29 | bool ChangelogSortFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right ) const 30 | { 31 | QVariant leftData = sourceModel()->data(left, sortRole()); 32 | QVariant rightData = sourceModel()->data(right, sortRole()); 33 | 34 | if (!leftData.canConvert() || !rightData.canConvert()) 35 | { 36 | return QSortFilterProxyModel::lessThan(left, right); 37 | } 38 | return leftData.value() < rightData.value(); 39 | } 40 | -------------------------------------------------------------------------------- /widgets/aboutdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "aboutdialog.h" 22 | 23 | #include "modxapp.h" 24 | 25 | AboutDialog::AboutDialog(QWidget *parent) : 26 | QDialog(parent){ 27 | m_ui.setupUi(this); 28 | m_ui.copyright->setText( 29 | tr("© 2009 by the %1") 30 | .arg(QApplication::organizationName()) 31 | .arg(QApplication::organizationDomain())); 32 | m_ui.appName->setText(QApplication::applicationName() + " v" + QApplication::applicationVersion()); 33 | setWindowTitle(tr("About %1").arg(QApplication::applicationName())); 34 | } 35 | 36 | void AboutDialog::changeEvent(QEvent *e) 37 | { 38 | switch (e->type()) { 39 | case QEvent::LanguageChange: 40 | m_ui.retranslateUi(this); 41 | break; 42 | default: 43 | break; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pages/generalpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef GENERALPAGE_H 22 | #define GENERALPAGE_H 23 | 24 | #include "page.h" 25 | #include "ui_generalpage.h" 26 | 27 | class QNetworkAccessManager; 28 | class QNetworkReply; 29 | 30 | class GeneralPage : public Page { 31 | Q_OBJECT 32 | Q_DISABLE_COPY(GeneralPage) 33 | public: 34 | explicit GeneralPage(QWidget *parent = 0); 35 | virtual ~GeneralPage(){} 36 | 37 | virtual void setData(const ModXData *data); 38 | virtual void getData(ModXData *data); 39 | 40 | protected slots: 41 | void on_setLatestVersion_clicked(); 42 | void handleNetworkReply(QNetworkReply *reply); 43 | 44 | protected: 45 | virtual void changeEvent(QEvent *e); 46 | 47 | private: 48 | QNetworkAccessManager *manager; 49 | Ui::GeneralPage ui; 50 | }; 51 | 52 | #endif // GENERALPAGE_H 53 | -------------------------------------------------------------------------------- /widgets/sqlsyntaxhighlighter.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef SQLSYNTAXHIGHLIGHTER_H 22 | #define SQLSYNTAXHIGHLIGHTER_H 23 | 24 | #include 25 | 26 | class SqlSyntaxHighlighter : public QSyntaxHighlighter 27 | { 28 | public: 29 | SqlSyntaxHighlighter(QTextDocument* parent = 0); 30 | virtual ~SqlSyntaxHighlighter(); 31 | 32 | protected: 33 | void highlightBlock(const QString &text); 34 | 35 | private: 36 | void setRules(); 37 | 38 | struct HighlightingRule 39 | { 40 | QRegExp pattern; 41 | QTextCharFormat format; 42 | }; 43 | 44 | QVector highlightingRules; 45 | QTextCharFormat keywordFormat; 46 | QTextCharFormat typeFormat; 47 | QTextCharFormat operatorFormat; 48 | QTextCharFormat stringLiteralFormat; 49 | QTextCharFormat numericLiteralFormat; 50 | static const QStringList keywords; 51 | }; 52 | 53 | #endif // SQLSYNTAXHIGHLIGHTER_H 54 | -------------------------------------------------------------------------------- /modxreader.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MODXREADER_H 22 | #define MODXREADER_H 23 | 24 | #include 25 | 26 | #include "modxdata.h" 27 | 28 | #include 29 | 30 | 31 | class ModXReader : public QXmlStreamReader 32 | { 33 | public: 34 | ModXReader(); 35 | 36 | bool read(QIODevice *device); 37 | 38 | ModXData *data() const; 39 | 40 | private: 41 | void readUnknownElement(); 42 | void readModX(); 43 | 44 | void readHeader(); 45 | void readAuthorGroup(); 46 | Author readAuthor(); 47 | 48 | void readHistory(); 49 | ChangelogEntry readEntry(); 50 | QStringList readChanges(); 51 | 52 | void readInstallation(); 53 | 54 | void readActionGroup(); 55 | 56 | QList readOpen(); 57 | QList readEdit(); 58 | 59 | QList readInlineEdit(); 60 | 61 | ModXData *m_data; 62 | 63 | }; 64 | 65 | QDebug operator<<(QDebug dbg, const QXmlStreamAttribute &a); 66 | 67 | #endif // MODXREADER_H 68 | -------------------------------------------------------------------------------- /pages/authorgrouppage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef AUTHORGROUPPAGE_H 22 | #define AUTHORGROUPPAGE_H 23 | 24 | #include "page.h" 25 | 26 | #include "modxdata.h" 27 | #include "listmodel.h" 28 | 29 | #include "ui_authorgrouppage.h" 30 | 31 | class AuthorGroupPage : public Page 32 | { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(AuthorGroupPage) 35 | public: 36 | explicit AuthorGroupPage(QWidget *parent = 0); 37 | 38 | virtual void setData(const ModXData *data); 39 | virtual void getData(ModXData *data); 40 | 41 | protected slots: 42 | void updateDetails(const QItemSelection &, const QItemSelection &); 43 | void updateUserName(const QString &newName); 44 | 45 | void addAuthor(); 46 | void removeAuthor(); 47 | void moveUp(); 48 | void moveDown(); 49 | 50 | protected: 51 | virtual void changeEvent(QEvent *e); 52 | 53 | private: 54 | 55 | ListModel *model; 56 | 57 | Ui::AuthorGroupPage ui; 58 | }; 59 | 60 | #endif // AUTHORGROUPPAGE_H 61 | -------------------------------------------------------------------------------- /pages/changelogpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef CHANGELOGPAGE_H 22 | #define CHANGELOGPAGE_H 23 | 24 | #include "page.h" 25 | #include "modxdata.h" 26 | #include "listmodel.h" 27 | 28 | #include "ui_changelogpage.h" 29 | 30 | class ChangelogSortFilterProxyModel; 31 | 32 | class ChangelogPage : public Page { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(ChangelogPage) 35 | public: 36 | explicit ChangelogPage(QWidget *parent = 0); 37 | 38 | virtual void setData(const ModXData *data); 39 | virtual void getData(ModXData *data); 40 | 41 | protected slots: 42 | void updateEntry(const QItemSelection &, const QItemSelection &); 43 | void updateVersion(const QString &newName); 44 | 45 | void addVersion(); 46 | void removeVersion(); 47 | 48 | protected: 49 | virtual void changeEvent(QEvent *e); 50 | 51 | private: 52 | ListModel *model; 53 | ChangelogSortFilterProxyModel *proxyModel; 54 | 55 | Ui::ChangelogPage ui; 56 | }; 57 | 58 | #endif // CHANGELOGPAGE_H 59 | -------------------------------------------------------------------------------- /pages/editedfilespage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef EDITEDFILESPAGE_H 22 | #define EDITEDFILESPAGE_H 23 | 24 | #include "page.h" 25 | 26 | #include "listmodel.h" 27 | 28 | #include "ui_editedfilespage.h" 29 | 30 | class QFileSystemModel; 31 | 32 | class EditedFilesPage : public Page { 33 | Q_OBJECT 34 | Q_DISABLE_COPY(EditedFilesPage) 35 | public: 36 | explicit EditedFilesPage(QWidget *parent = 0); 37 | 38 | virtual void setData(const ModXData *data); 39 | virtual void getData(ModXData *data); 40 | 41 | QAbstractItemModel *model() const 42 | { return m_model; } 43 | 44 | public slots: 45 | void on_addFile_clicked(); 46 | void on_addFiles_clicked(); 47 | void on_removeFiles_clicked(); 48 | 49 | void on_phpbbRootPath_textChanged(const QString &path); 50 | void on_browseButton_clicked(); 51 | 52 | protected: 53 | virtual void changeEvent(QEvent *e); 54 | 55 | private: 56 | ListModel *m_model; 57 | QFileSystemModel *fileModel; 58 | 59 | Ui::EditedFilesPage ui; 60 | }; 61 | 62 | #endif // EDITEDFILESPAGE_H 63 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MAINWINDOW_H 22 | #define MAINWINDOW_H 23 | 24 | #include 25 | #include "ui_mainwindow.h" 26 | 27 | class Page; 28 | class ModXData; 29 | class PagePanel; 30 | 31 | class MainWindow : public QMainWindow 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0); 37 | ~MainWindow(); 38 | 39 | public slots: 40 | void newFile(); 41 | void openFile(); 42 | void openFile(const QString &file, bool force = false); 43 | bool saveFile(); 44 | bool saveFileAs(); 45 | 46 | bool askSave(); 47 | 48 | void changePage(int i); 49 | 50 | void on_actionAbout_triggered(); 51 | 52 | protected: 53 | void closeEvent(QCloseEvent *event); 54 | 55 | private: 56 | void addPage(const QString &title, Page *page); 57 | void setData(const ModXData *data); 58 | 59 | void setCurrentFile(const QString &file); 60 | 61 | void loadSettings(); 62 | void saveSettings(); 63 | 64 | PagePanel *pagePanel; 65 | ModXData *data; 66 | 67 | Ui::MainWindowClass ui; 68 | bool init; 69 | }; 70 | 71 | #endif // MAINWINDOW_H 72 | -------------------------------------------------------------------------------- /pages/fileeditpage.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef FILEEDITPAGE_H 22 | #define FILEEDITPAGE_H 23 | 24 | #include "page.h" 25 | #include "listmodel.h" 26 | #include "modxdata.h" 27 | 28 | #include "ui_fileeditpage.h" 29 | 30 | class FileEditPage : public Page { 31 | Q_OBJECT 32 | Q_DISABLE_COPY(FileEditPage) 33 | public: 34 | explicit FileEditPage(QWidget *parent = 0); 35 | 36 | virtual void setData(const ModXData *data); 37 | virtual void getData(ModXData *data); 38 | 39 | void setFileModel(QAbstractItemModel *model); 40 | 41 | protected slots: 42 | void updateActionModel(const QString &file = ""); 43 | 44 | void updateAction(const QItemSelection &, const QItemSelection &); 45 | void on_actionType_currentIndexChanged(); 46 | void on_add_clicked(); 47 | void on_remove_clicked(); 48 | void on_moveUp_clicked(); 49 | void on_moveDown_clicked(); 50 | 51 | protected: 52 | virtual void changeEvent(QEvent *e); 53 | 54 | private: 55 | void retranslateUi(); 56 | void clearFields(); 57 | 58 | ListModel *model; 59 | 60 | QMap< QString, QList > actions; 61 | 62 | QString currentFile; 63 | 64 | Ui::FileEditPage ui; 65 | }; 66 | 67 | #endif // FILEEDITPAGE_H 68 | -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef VERSION_H 22 | #define VERSION_H 23 | 24 | #include 25 | 26 | class Version 27 | { 28 | public: 29 | 30 | enum VersionType 31 | { 32 | NormalVersion, 33 | RCVersion, 34 | BetaVersion, 35 | AlphaVersion, 36 | }; 37 | 38 | Version(int major = 0, int minor = 0, int maintenance = 0, char patch = 0, VersionType type = NormalVersion, int special = 0); 39 | Version(const QString &version); 40 | Version(const char *version); 41 | Version(const Version &other); 42 | ~Version(); 43 | 44 | bool isValid() const; 45 | 46 | operator const QString&() const; 47 | 48 | int major() const; 49 | int minor() const; 50 | int maintenance() const; 51 | int patch() const; 52 | VersionType type() const; 53 | int special() const; 54 | 55 | bool operator<(const Version &other) const; 56 | bool operator==(const Version &other) const; 57 | 58 | private: 59 | void parse(const QString &version); 60 | 61 | int m_major; 62 | int m_minor; 63 | int m_maintenance; 64 | char m_patch; 65 | VersionType m_type; 66 | int m_special; 67 | 68 | bool valid; 69 | 70 | mutable QString cache; 71 | }; 72 | 73 | #ifndef QT_NO_DEBUG 74 | #include 75 | QDebug operator<<(QDebug dbg, const Version &v); 76 | #endif 77 | 78 | #endif // VERSION_H 79 | -------------------------------------------------------------------------------- /pages/sqlpage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "sqlpage.h" 22 | 23 | #include "widgets/sqlsyntaxhighlighter.h" 24 | #include "modxdata.h" 25 | 26 | SqlPage::SqlPage(QWidget *parent) : 27 | Page(parent){ 28 | ui.setupUi(this); 29 | 30 | new SqlSyntaxHighlighter(ui.sql->document()); 31 | 32 | QStringList sqlDialects; 33 | sqlDialects 34 | << tr("SQL Parser") 35 | << tr("MySQL") 36 | << tr("MySQL 4.0") 37 | << tr("MySQL 4.1") 38 | << tr("MySQLi") 39 | << tr("MySQL 4") 40 | << tr("MS Access") 41 | << tr("Oracle") 42 | << tr("PostgreSQL") 43 | << tr("DB2") 44 | << tr("Firebird") 45 | << tr("SQLite"); 46 | ui.sqlDialect->addItems(sqlDialects); 47 | ui.sqlDialect->setCurrentIndex(0); 48 | } 49 | 50 | void SqlPage::setData(const ModXData *data) 51 | { 52 | ui.sqlDialect->setCurrentIndex(data->sqlDialect); 53 | ui.sql->setText(data->sql.join("\n\n")); 54 | } 55 | 56 | void SqlPage::getData(ModXData *data) 57 | { 58 | data->sqlDialect = (ModXData::SqlDialect) ui.sqlDialect->currentIndex(); 59 | data->sql = QStringList(ui.sql->toPlainText()); 60 | } 61 | 62 | 63 | void SqlPage::changeEvent(QEvent *e) 64 | { 65 | switch(e->type()) { 66 | case QEvent::LanguageChange: 67 | ui.retranslateUi(this); 68 | break; 69 | default: 70 | break; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /pages/filepage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "filepage.h" 22 | 23 | #include "modxapp.h" 24 | #include "modxdata.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | FilePage::FilePage(QWidget *parent) : 33 | Page(parent){ 34 | ui.setupUi(this); 35 | 36 | fileModel = new QFileSystemModel(this); 37 | fileModel->setReadOnly(true); 38 | 39 | ui.fileView->setModel(fileModel); 40 | ui.fileView->hideColumn(1); 41 | ui.fileView->hideColumn(2); 42 | ui.fileView->hideColumn(3); 43 | 44 | connect(ui.copyFiles, SIGNAL(toggled(bool)), this, SLOT(updateFiles(bool))); 45 | } 46 | 47 | void FilePage::setData(const ModXData *data) 48 | { 49 | ui.copyFiles->setChecked(data->copyFiles); 50 | setRootDir(); 51 | } 52 | 53 | void FilePage::getData(ModXData *data) 54 | { 55 | data->copyFiles = ui.copyFiles->isChecked(); 56 | } 57 | 58 | void FilePage::updateFiles(bool /*checked*/) 59 | { 60 | setRootDir(); 61 | } 62 | 63 | void FilePage::changeEvent(QEvent *e) 64 | { 65 | switch(e->type()) { 66 | case QEvent::LanguageChange: 67 | ui.retranslateUi(this); 68 | break; 69 | default: 70 | break; 71 | } 72 | } 73 | 74 | void FilePage::setRootDir() 75 | { 76 | QFileInfo rootDir = QFileInfo(ModXApp::currentFile).absoluteDir().canonicalPath() + "/root"; 77 | if (rootDir.exists()) 78 | { 79 | ui.fileViewContainer->setCurrentIndex(0); 80 | QModelIndex index = fileModel->setRootPath(rootDir.absoluteFilePath()); 81 | ui.fileView->setRootIndex(index); 82 | } 83 | else 84 | { 85 | ui.fileViewContainer->setCurrentIndex(1); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /pages/filepage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FilePage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | Copy Files 24 | 25 | 26 | 27 | 28 | 29 | NOTE: ModX <copy> structure is broken++ 30 | 31 | 32 | 33 | 34 | 35 | 36 | Copy all files from root/ to / 37 | 38 | 39 | 40 | 41 | 42 | 43 | Files in root/ : 44 | 45 | 46 | fileView 47 | 48 | 49 | 50 | 51 | 52 | 53 | 0 54 | 55 | 56 | 57 | 58 | 0 59 | 60 | 61 | 62 | 63 | true 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 0 73 | 74 | 75 | 0 76 | 77 | 78 | 0 79 | 80 | 81 | 82 | 83 | root/ does not exist. root/ must be in the same directory as the MODX file. 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindowClass 4 | 5 | 6 | 7 | 0 8 | 0 9 | 767 10 | 551 11 | 12 | 13 | 14 | ModX Editor 15 | 16 | 17 | 18 | 19 | 20 | 21 | Qt::Horizontal 22 | 23 | 24 | 25 | 26 | 0 27 | 0 28 | 29 | 30 | 31 | 32 | 50 33 | 0 34 | 35 | 36 | 37 | 38 | 100 39 | 0 40 | 41 | 42 | 43 | 44 | 45 | 46 | 10 47 | 0 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 0 60 | 0 61 | 767 62 | 22 63 | 64 | 65 | 66 | 67 | &File 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Help 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | &Open... 90 | 91 | 92 | Ctrl+O 93 | 94 | 95 | 96 | 97 | &Quit 98 | 99 | 100 | Ctrl+Q 101 | 102 | 103 | 104 | 105 | &New 106 | 107 | 108 | Ctrl+N 109 | 110 | 111 | 112 | 113 | Save As... 114 | 115 | 116 | 117 | 118 | Save 119 | 120 | 121 | Ctrl+S 122 | 123 | 124 | 125 | 126 | About MODX Editor... 127 | 128 | 129 | About MODX Editor 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /listmodel.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef LISTMODEL_H 22 | #define LISTMODEL_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | template class ListModel : public QAbstractListModel 30 | { 31 | public: 32 | ListModel(QObject *parent = 0) : QAbstractListModel(parent) {} 33 | 34 | QList list() const 35 | { 36 | return m_data; 37 | } 38 | 39 | void setList(QList data) 40 | { 41 | m_data = data; 42 | reset(); 43 | } 44 | 45 | int rowCount(const QModelIndex &parent = QModelIndex()) const 46 | { 47 | if (parent != QModelIndex()) 48 | { 49 | return 0; 50 | } 51 | 52 | return m_data.count(); 53 | } 54 | 55 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const 56 | { 57 | if (index.row() < 0 || index.row() > rowCount() - 1) 58 | return QVariant(); 59 | 60 | switch (role) 61 | { 62 | case Qt::DisplayRole: 63 | return QVariant(QString(m_data.at(index.row()))); 64 | case Qt::EditRole: 65 | return QVariant::fromValue(m_data.at(index.row())); 66 | default: 67 | return QVariant(); 68 | } 69 | } 70 | 71 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) 72 | { 73 | if (role != Qt::EditRole) 74 | return false; 75 | 76 | m_data[index.row()] = value.value(); 77 | emit dataChanged(index, index); 78 | return true; 79 | } 80 | 81 | bool insertRows(int row, int count, const QModelIndex &parent) 82 | { 83 | if (parent != QModelIndex()) 84 | return false; 85 | 86 | beginInsertRows(parent, row, row + count); 87 | for (int i = 0; i < count; ++i) 88 | { 89 | m_data.insert(row, T()); 90 | } 91 | endInsertRows(); 92 | return true; 93 | } 94 | 95 | bool removeRows(int row, int count, const QModelIndex &parent) 96 | { 97 | if (parent != QModelIndex()) 98 | return false; 99 | 100 | beginRemoveRows(parent, row, row + count); 101 | for (int i = 0; i < count; ++i) 102 | { 103 | m_data.removeAt(row); 104 | } 105 | endRemoveRows(); 106 | 107 | return true; 108 | } 109 | 110 | int moveUp(int row) 111 | { 112 | if (!row || m_data.isEmpty()) 113 | return row; 114 | 115 | m_data.swap(row, row - 1); 116 | // emit dataChanged(createIndex(row - 1, 0), createIndex(row, 0)); 117 | reset(); 118 | return row - 1; 119 | } 120 | 121 | int moveDown(int row) 122 | { 123 | if (m_data.isEmpty() || row == rowCount() - 1) 124 | return row; 125 | 126 | m_data.swap(row, row + 1); 127 | // emit dataChanged(createIndex(row, 0), createIndex(row + 1, 0)); 128 | reset(); 129 | return row + 1; 130 | } 131 | 132 | private: 133 | QList m_data; 134 | }; 135 | 136 | #endif // LISTMODEL_H 137 | -------------------------------------------------------------------------------- /pages/editedfilespage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "editedfilespage.h" 22 | 23 | #include "modxdata.h" 24 | 25 | #include 26 | #include 27 | 28 | 29 | EditedFilesPage::EditedFilesPage(QWidget *parent) : 30 | Page(parent){ 31 | ui.setupUi(this); 32 | 33 | m_model = new ListModel(this); 34 | fileModel = new QFileSystemModel(this); 35 | 36 | ui.editedFilesView->setModel(m_model); 37 | ui.allFilesView->setModel(fileModel); 38 | ui.allFilesView->hideColumn(1); 39 | ui.allFilesView->hideColumn(2); 40 | ui.allFilesView->hideColumn(3); 41 | ui.allFilesView->hideColumn(4); 42 | 43 | } 44 | 45 | void EditedFilesPage::setData(const ModXData *data) 46 | { 47 | m_model->setList(data->actions.keys()); 48 | } 49 | 50 | void EditedFilesPage::getData(ModXData *) 51 | { 52 | 53 | } 54 | 55 | void EditedFilesPage::on_addFile_clicked() 56 | { 57 | QList list = m_model->list(); 58 | if (list.contains(ui.file->text())) 59 | return; 60 | 61 | list << ui.file->text(); 62 | m_model->setList(list); 63 | ui.file->setText(""); 64 | } 65 | 66 | void EditedFilesPage::on_addFiles_clicked() 67 | { 68 | QModelIndexList list = ui.allFilesView->selectionModel()->selectedIndexes(); 69 | 70 | QString basepath = QFileInfo(ui.phpbbRootPath->text()).absoluteFilePath(); 71 | 72 | if (basepath[basepath.size() - 1] != '/') 73 | { 74 | basepath += "/"; 75 | } 76 | 77 | QSet currentfiles = m_model->list().toSet(); 78 | QSet newFiles; 79 | foreach (QModelIndex index, list) 80 | { 81 | QString newPath = fileModel->fileInfo(index).absoluteFilePath().replace(basepath, ""); 82 | newFiles.insert(newPath); 83 | } 84 | m_model->setList((currentfiles + newFiles).toList()); 85 | ui.allFilesView->clearSelection(); 86 | } 87 | 88 | void EditedFilesPage::on_removeFiles_clicked() 89 | { 90 | QModelIndexList list = ui.editedFilesView->selectionModel()->selectedIndexes(); 91 | 92 | QList currentFiles = m_model->list(); 93 | foreach (QModelIndex index, list) 94 | { 95 | currentFiles.removeAll(m_model->data(index, Qt::EditRole).toString()); 96 | } 97 | m_model->setList(currentFiles); 98 | ui.editedFilesView->clearSelection(); 99 | } 100 | 101 | void EditedFilesPage::on_phpbbRootPath_textChanged(const QString &path) 102 | { 103 | ui.allFilesView->setRootIndex(fileModel->setRootPath(path)); 104 | } 105 | 106 | void EditedFilesPage::on_browseButton_clicked() 107 | { 108 | QString path = QFileDialog::getExistingDirectory( 109 | this, 110 | tr("phpBB root")); 111 | 112 | if (path == "") 113 | return; 114 | 115 | ui.phpbbRootPath->setText(path); 116 | } 117 | 118 | 119 | void EditedFilesPage::changeEvent(QEvent *e) 120 | { 121 | switch(e->type()) { 122 | case QEvent::LanguageChange: 123 | ui.retranslateUi(this); 124 | break; 125 | default: 126 | break; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /pages/generalpage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "generalpage.h" 22 | 23 | #include "modxdata.h" 24 | 25 | #include 26 | #include 27 | 28 | GeneralPage::GeneralPage(QWidget *parent) : 29 | Page(parent){ 30 | ui.setupUi(this); 31 | 32 | QStringList licenses; 33 | licenses << "http://opensource.org/licenses/agpl-v3.html GNU Affero General Public License v3" 34 | << "http://opensource.org/licenses/gpl-license.php GNU General Public License v2" 35 | << "http://opensource.org/licenses/gpl-license.php GNU General Public License v3" 36 | << "http://www.apache.org/licenses/ Apache License, Version 2.0" 37 | << "http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License v2" 38 | << "http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License v3" 39 | << "http://opensource.org/licenses/bsd-license.php BSD License"; 40 | ui.license->addItems(licenses); 41 | 42 | QStringList installationLevels; 43 | installationLevels << tr("Easy") 44 | << tr("Intermediate") 45 | << tr("Hard"); 46 | 47 | ui.installLevel->addItems(installationLevels); 48 | 49 | manager = NULL; 50 | } 51 | 52 | void GeneralPage::setData(const ModXData *data) 53 | { 54 | ui.title->setText(data->title["en"]); 55 | ui.version->setText(data->version); 56 | ui.description->setPlainText(data->description["en"]); 57 | ui.authorNotes->setPlainText(data->authorNotes["en"]); 58 | ui.license->setEditText(data->license); 59 | 60 | ui.installLevel->setCurrentIndex(int(data->installLevel)); 61 | ui.installTime->setValue(data->installTime); 62 | ui.targetVersion->setText(data->targetVersion); 63 | } 64 | 65 | void GeneralPage::getData(ModXData *data) 66 | { 67 | data->title["en"] = ui.title->text(); 68 | data->version = ui.version->text(); 69 | data->description["en"] = ui.description->toPlainText(); 70 | data->authorNotes["en"] = ui.authorNotes->toPlainText(); 71 | data->license = ui.license->currentText(); 72 | 73 | data->installLevel = ModXData::InstallationLevel(ui.installLevel->currentIndex()); 74 | data->installTime = ui.installTime->value(); 75 | data->targetVersion = ui.targetVersion->text(); 76 | } 77 | 78 | void GeneralPage::on_setLatestVersion_clicked() 79 | { 80 | if (manager == NULL) 81 | { 82 | manager = new QNetworkAccessManager(this); 83 | connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(handleNetworkReply(QNetworkReply *))); 84 | } 85 | manager->get(QNetworkRequest(QUrl("http://www.phpbb.com/updatecheck/30x.txt"))); 86 | } 87 | 88 | void GeneralPage::handleNetworkReply(QNetworkReply *reply) 89 | { 90 | if (reply->error() != QNetworkReply::NoError) 91 | { 92 | return; 93 | } 94 | QString latestVersion(reply->readLine(1024)); 95 | ui.targetVersion->setText(latestVersion.trimmed()); 96 | } 97 | 98 | void GeneralPage::changeEvent(QEvent *e) 99 | { 100 | switch(e->type()) { 101 | case QEvent::LanguageChange: 102 | ui.retranslateUi(this); 103 | break; 104 | default: 105 | break; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /pages/changelogpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ChangelogPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | 28 | 29 | 0 30 | 0 31 | 32 | 33 | 34 | 35 | 100 36 | 16777215 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 0 45 | 46 | 47 | QLayout::SetFixedSize 48 | 49 | 50 | 51 | 52 | 53 | 20 54 | 20 55 | 56 | 57 | 58 | + 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 20 67 | 20 68 | 69 | 70 | 71 | - 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | Version Info 83 | 84 | 85 | 86 | QLayout::SetDefaultConstraint 87 | 88 | 89 | QFormLayout::AllNonFixedFieldsGrow 90 | 91 | 92 | 93 | 94 | Version: 95 | 96 | 97 | version 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Changelog: 108 | 109 | 110 | changes 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | Date: 121 | 122 | 123 | date 124 | 125 | 126 | 127 | 128 | 129 | 130 | true 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | versionList 141 | version 142 | date 143 | changes 144 | add 145 | remove 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /widgets/sqlsyntaxhighlighter.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "sqlsyntaxhighlighter.h" 22 | 23 | #include 24 | 25 | SqlSyntaxHighlighter::SqlSyntaxHighlighter(QTextDocument* parent) : QSyntaxHighlighter(parent) 26 | { 27 | setRules(); 28 | } 29 | 30 | 31 | void SqlSyntaxHighlighter::setRules() 32 | { 33 | HighlightingRule rule; 34 | 35 | highlightingRules.clear(); 36 | 37 | keywordFormat.setForeground(Qt::darkBlue); 38 | keywordFormat.setFontWeight(QFont::Bold); 39 | 40 | foreach (QString pattern, keywords) 41 | { 42 | rule.pattern = QRegExp(pattern); 43 | rule.format = keywordFormat; 44 | highlightingRules.append(rule); 45 | } 46 | 47 | QStringList types; 48 | types << "\\b(?:tiny|small|medium|big)?(int|text|blob)\\b" 49 | << "\\bvar(:?char|binary)\\b"; 50 | 51 | typeFormat.setForeground(Qt::darkYellow); 52 | typeFormat.setFontWeight(QFont::Bold); 53 | 54 | foreach (QString pattern, types) 55 | { 56 | rule.pattern = QRegExp(pattern, Qt::CaseInsensitive); 57 | rule.format = typeFormat; 58 | highlightingRules.append(rule); 59 | } 60 | 61 | 62 | numericLiteralFormat.setForeground(Qt::red); 63 | rule.pattern = QRegExp("0?[1-9][0-9]*(?:\\.[0-9])?|0x[0-9A-Fa-f]+"); 64 | rule.format = numericLiteralFormat; 65 | highlightingRules.append(rule); 66 | 67 | operatorFormat.setFontWeight(QFont::Bold); 68 | operatorFormat.setForeground(Qt::darkMagenta); 69 | rule.pattern = QRegExp("[-+\\/*<>%;,()]|\\b(?:NOT|AND|OR|DIV|XOR)\\b"); 70 | rule.format = operatorFormat; 71 | highlightingRules.append(rule); 72 | 73 | stringLiteralFormat.setForeground(Qt::darkGreen); 74 | rule.pattern = QRegExp("(['\"]).*(\\1)"); 75 | rule.format = stringLiteralFormat; 76 | highlightingRules.append(rule); 77 | 78 | // These two should be highlighted in strings. 79 | rule.pattern = QRegExp("[%_]"); 80 | rule.format = operatorFormat; 81 | highlightingRules.append(rule); 82 | } 83 | 84 | SqlSyntaxHighlighter::~SqlSyntaxHighlighter() 85 | { 86 | //dtor 87 | } 88 | 89 | void SqlSyntaxHighlighter::highlightBlock(const QString &text) 90 | { 91 | switch (previousBlockState()) 92 | { 93 | case -1: 94 | default: 95 | 96 | foreach (HighlightingRule rule, highlightingRules) 97 | { 98 | QRegExp expression(rule.pattern); 99 | expression.setPatternSyntax(QRegExp::RegExp2); 100 | int index = text.indexOf(expression); 101 | while (index >= 0) 102 | { 103 | int length = expression.matchedLength(); 104 | setFormat(index, length, rule.format); 105 | index = text.indexOf(expression, index + length); 106 | } 107 | } 108 | setCurrentBlockState(-1); 109 | 110 | break; 111 | } 112 | 113 | } 114 | 115 | const QStringList SqlSyntaxHighlighter::keywords = QStringList() << "ADD" << "ALL" << "ALTER" << "ANALYZE" << "AS" 116 | << "ASC" << "BETWEEN" << "BY" << "CALL" << "COLLATE" 117 | << "COLUMN" << "CREATE" << "CROSS" << "CURRENT_DATE" << "CURRENT_TIME" 118 | << "CURRENT_TIMESTAMP" << "DATABASE" << "DAY_HOUR" << "DECLARE" << "DEFAULT" 119 | << "DELETE" << "DESC" << "DISTINCT" << "DROP" << "DUAL" 120 | << "EXISTS" << "EXPLAIN" << "FALSE" << "FROM" << "FULLTEXT" 121 | << "GRANT" << "GROUP" << "HAVING" << "IN" << "INDEX" 122 | << "INNER" << "INSERT" << "INTO" << "IS" << "JOIN" 123 | << "KEY" << "KEYS" << "LEFT" << "LIKE" << "LIMIT" 124 | << "LOCK" << "MATCH" << "MODIFIES" << "NATURAL" << "NULL" 125 | << "ON" << "OPTIMIZE" << "OR" << "ORDER" << "OUTER" 126 | << "PRECISION" << "PRIMARY" << "PROCEDURE" << "PURGE" << "RANGE" 127 | << "RENAME" << "REPLACE" << "REQUIRE" << "RIGHT" << "SCHEMA" 128 | << "SCHEMAS" << "SELECT" << "SEPARATOR" << "SET" << "SHOW" 129 | << "SQL" << "TABLE" << "TO" << "TRUE" << "UNION" 130 | << "UNIQUE" << "UPDATE" << "USE" << "USING" << "VALUES" 131 | << "WHEN" << "WHERE" << "WHILE" << "WITH" << "WRITE"; 132 | 133 | -------------------------------------------------------------------------------- /modxdata.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #ifndef MODXDATA_H 22 | #define MODXDATA_H 23 | 24 | #include "version.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class Author; 33 | class ChangelogEntry; 34 | class Action; 35 | 36 | class ModXData : public QObject 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | enum SqlDialect 42 | { 43 | DialectSqlParser, 44 | DialectMySql, 45 | DialectMySql40, 46 | DialectMySql41, 47 | DialectMySqli, 48 | DialectMySql4, 49 | DialectMsAccess, 50 | DialectOracle, 51 | DialectPostgres, 52 | DialectDb2, 53 | DialectFirebird, 54 | DialectSqlite, 55 | }; 56 | 57 | enum InstallationLevel 58 | { 59 | LevelEasy, 60 | LevelIntermediate, 61 | LevelAdvanced 62 | }; 63 | 64 | ModXData(QObject *parent = 0); 65 | 66 | QMap title; 67 | QMap description; 68 | QMap authorNotes; 69 | QList authorGroup; 70 | QList history; 71 | 72 | QString license; 73 | 74 | Version version; 75 | Version targetVersion; 76 | InstallationLevel installLevel; 77 | quint32 installTime; 78 | 79 | SqlDialect sqlDialect; 80 | QStringList sql; 81 | 82 | bool copyFiles; 83 | QMap copyInstructions; 84 | 85 | QMap diy; 86 | 87 | QMap > actions; 88 | 89 | static QMap sqlDialects; 90 | static const QStringList installationLevels; 91 | 92 | private: 93 | static bool init; 94 | 95 | static void setUp(); 96 | }; 97 | 98 | class Author 99 | { 100 | 101 | public: 102 | 103 | Author(); 104 | 105 | operator QString() const 106 | { 107 | return userName; 108 | } 109 | 110 | bool operator<(const Author &other) const 111 | { 112 | return userName < other.userName; 113 | } 114 | 115 | QString realName; 116 | QString userName; 117 | QString email; 118 | QString homePage; 119 | QString contributionStatus; 120 | QDate contributionFrom; 121 | QDate contributionTo; 122 | }; 123 | 124 | 125 | class ChangelogEntry 126 | { 127 | 128 | public: 129 | ChangelogEntry(); 130 | 131 | operator QString() const 132 | { 133 | return version; 134 | } 135 | 136 | QDate date; 137 | Version version; 138 | QMap changes; 139 | 140 | bool operator<(const ChangelogEntry &other) const 141 | { 142 | return version < other.version; 143 | } 144 | }; 145 | 146 | class Action 147 | { 148 | 149 | public: 150 | 151 | enum Type 152 | { 153 | Find, 154 | Edit, 155 | InlineFind, 156 | InlineEdit 157 | }; 158 | 159 | enum EditType 160 | { 161 | AfterAdd, 162 | BeforeAdd, 163 | Replace, 164 | Operation 165 | }; 166 | 167 | Action(); 168 | 169 | operator QString() const 170 | { 171 | /* switch (type) 172 | { 173 | case Edit: 174 | case InlineEdit: 175 | return types[type] + ", " + editTypes[editType]; 176 | default: 177 | return types[type]; 178 | } 179 | */ 180 | return types[type]; 181 | } 182 | 183 | // All types 184 | Type type; 185 | 186 | // Find/InlineEdit type 187 | QString find; 188 | 189 | // Edit/InlinEdit type 190 | EditType editType; 191 | 192 | // Edit/InlineEdit type 193 | QString edit; 194 | 195 | static QMap types; 196 | static QMap editTypes; 197 | 198 | private: 199 | static bool init; 200 | 201 | static void setUp(); 202 | }; 203 | 204 | Q_DECLARE_METATYPE(ChangelogEntry); 205 | Q_DECLARE_METATYPE(Author); 206 | Q_DECLARE_METATYPE(Action); 207 | 208 | 209 | #ifndef QT_NO_DEBUG 210 | QDebug operator<<(QDebug dbg, const ModXData &d); 211 | QDebug operator<<(QDebug dbg, const Author &a); 212 | QDebug operator<<(QDebug dbg, const ChangelogEntry &a); 213 | QDebug operator<<(QDebug dbg, const Action &a); 214 | #endif 215 | 216 | #endif // MODXDATA_H 217 | -------------------------------------------------------------------------------- /pages/editedfilespage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditedFilesPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 0 26 | 27 | 28 | 29 | 30 | 200 31 | 16777215 32 | 33 | 34 | 35 | Files to Edit 36 | 37 | 38 | 39 | 40 | 41 | 42 | 150 43 | 16777215 44 | 45 | 46 | 47 | QAbstractItemView::ExtendedSelection 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | Remove Selected Files 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | All files 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | phpBB root: 79 | 80 | 81 | phpbbRootPath 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | ... 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | QAbstractItemView::ExtendedSelection 101 | 102 | 103 | true 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 0 112 | 0 113 | 114 | 115 | 116 | Add Selected files 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | Add file: 126 | 127 | 128 | file 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 0 140 | 0 141 | 142 | 143 | 144 | Add 145 | 146 | 147 | 148 | 149 | 150 | 151 | allFilesView 152 | 153 | addFiles 154 | 155 | 156 | 157 | 158 | 159 | editedFilesView 160 | removeFiles 161 | phpbbRootPath 162 | browseButton 163 | allFilesView 164 | addFiles 165 | file 166 | addFile 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /widgets/aboutdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AboutDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 332 10 | 232 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 0 22 | 0 23 | 24 | 25 | 26 | QFrame::StyledPanel 27 | 28 | 29 | QFrame::Plain 30 | 31 | 32 | 33 | 34 | 35 | 36 | 15 37 | 75 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | QFrame::StyledPanel 53 | 54 | 55 | QFrame::Raised 56 | 57 | 58 | 59 | 60 | 61 | 62 | 0 63 | 0 64 | 65 | 66 | 67 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 68 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 69 | p, li { white-space: pre-wrap; } 70 | </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> 71 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">A simple MODX file editor</span></p></body></html> 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 0 80 | 0 81 | 82 | 83 | 84 | 85 | 86 | 87 | true 88 | 89 | 90 | 91 | 92 | 93 | 94 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 95 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> 96 | p, li { white-space: pre-wrap; } 97 | </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> 98 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Licensed under the </span><a href="http://www.gnu.org/licenses/gpl-3.0.txt"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">GPLv3</span></a><span style=" font-size:8pt;">.</span></p></body></html> 99 | 100 | 101 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop 102 | 103 | 104 | true 105 | 106 | 107 | 108 | 109 | 110 | 111 | QDialogButtonBox::Close 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | buttonBox 124 | rejected() 125 | AboutDialog 126 | reject() 127 | 128 | 129 | 250 130 | 194 131 | 132 | 133 | 330 134 | 176 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /modxdata.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "modxdata.h" 22 | 23 | ModXData::ModXData(QObject *parent) : QObject(parent) 24 | { 25 | sqlDialect = DialectSqlParser; 26 | installTime = 60; 27 | installLevel = LevelIntermediate; 28 | if (init) 29 | return; 30 | setUp(); 31 | } 32 | 33 | void ModXData::setUp() 34 | { 35 | sqlDialects.insert(DialectSqlParser,"sql-parser"); 36 | sqlDialects.insert(DialectMySql, "mysql"); 37 | sqlDialects.insert(DialectMySql40, "mysql_40"); 38 | sqlDialects.insert(DialectMySql41, "mysql_41"); 39 | sqlDialects.insert(DialectMySqli, "mysqli"); 40 | sqlDialects.insert(DialectMySql4, "mysql4"); 41 | sqlDialects.insert(DialectMsAccess, "mssaccess"); 42 | sqlDialects.insert(DialectOracle, "oracle"); 43 | sqlDialects.insert(DialectPostgres, "postgres"); 44 | sqlDialects.insert(DialectDb2, "db2"); 45 | sqlDialects.insert(DialectFirebird, "firebird"); 46 | sqlDialects.insert(DialectSqlite, "sqlite"); 47 | } 48 | 49 | QMap ModXData::sqlDialects; 50 | const QStringList ModXData::installationLevels = QStringList() << "easy" << "intermediate" << "advanced"; 51 | bool ModXData::init = false; 52 | 53 | 54 | 55 | Action::Action() 56 | { 57 | type = Find; 58 | if (init) 59 | return; 60 | setUp(); 61 | } 62 | 63 | QMap Action::types; 64 | QMap Action::editTypes; 65 | 66 | 67 | bool Action::init = false; 68 | 69 | Author::Author() 70 | { 71 | userName = "new Author"; 72 | } 73 | 74 | ChangelogEntry::ChangelogEntry() 75 | { 76 | version = "1.0.0"; 77 | } 78 | 79 | void Action::setUp() 80 | { 81 | types.insert(Action::Find, "Find"); 82 | types.insert(Action::Edit, "Edit"); 83 | types.insert(Action::InlineFind, "Inline-Find"); 84 | types.insert(Action::InlineEdit, "Inline-Edit"); 85 | 86 | editTypes.insert(Action::AfterAdd, "after-add"); 87 | editTypes.insert(Action::BeforeAdd, "before-add"); 88 | editTypes.insert(Action::Replace, "replace-with"); 89 | editTypes.insert(Action::Operation, "operation"); 90 | } 91 | 92 | #ifndef QT_NO_DEBUG 93 | QDebug operator<<(QDebug dbg, const ModXData &d) 94 | { 95 | dbg.nospace() << "ModXData ("; 96 | dbg.nospace() << "\n\ttitle = " << d.title; 97 | dbg.nospace() << "\n\tdescription = " << d.description; 98 | dbg.nospace() << "\n\tauthorNotes = " << d.authorNotes; 99 | dbg.nospace() << "\n\tauthorGroup = " << d.authorGroup; 100 | dbg.nospace() << "\n\thistory = " << d.history; 101 | dbg.nospace() << "\n\tlicense = " << d.license; 102 | dbg.nospace() << "\n\tinstallLevel = " << d.installLevel; 103 | dbg.nospace() << "\n\tinstallTime = " << d.installTime; 104 | 105 | dbg.nospace() << "\n\tactions = " << d.actions; 106 | 107 | dbg.nospace() << "\n\tdiy = " << d.diy; 108 | 109 | dbg.nospace() << "\n)"; 110 | 111 | return dbg.space(); 112 | } 113 | 114 | QDebug operator<<(QDebug dbg, const Author &a) 115 | { 116 | dbg.nospace() << "Author ("; 117 | dbg.nospace() << "\n\t" << a.userName; 118 | dbg.nospace() << "\n\t" << a.realName; 119 | dbg.nospace() << "\n\t" << a.homePage; 120 | dbg.nospace() << "\n\t" << a.contributionStatus; 121 | dbg.nospace() << "\n\t" << a.contributionFrom; 122 | dbg.nospace() << "\n\t" << a.contributionTo; 123 | dbg.nospace() << "\n)"; 124 | return dbg.space(); 125 | } 126 | 127 | QDebug operator<<(QDebug dbg, const ChangelogEntry &e) 128 | { 129 | dbg.nospace() << "ChangelogEntry ("; 130 | dbg.nospace() << "\n\tdate = " << e.date.toString(Qt::ISODate); 131 | dbg.nospace() << "\n\tversion = " << e.version; 132 | dbg.nospace() << "\n\tChanges = " << e.changes; 133 | dbg.nospace() << "\n)"; 134 | return dbg.space(); 135 | } 136 | 137 | QDebug operator<<(QDebug dbg, const Action &a) 138 | { 139 | dbg.nospace() << "Action ("; 140 | dbg.nospace() << "\n\t Type = " << a.type; 141 | switch (a.type) 142 | { 143 | case Action::Find: 144 | case Action::InlineFind: 145 | dbg.nospace() << "\n\tfind = " << a.find; 146 | break; 147 | case Action::Edit: 148 | case Action::InlineEdit: 149 | dbg.nospace() << "\n\teditType = " << a.editType; 150 | dbg.nospace() << "\n\tedit = " << a.edit; 151 | break; 152 | } 153 | dbg.nospace() << "\n)"; 154 | return dbg.space(); 155 | } 156 | 157 | #endif // QT_BO_DEBUG 158 | -------------------------------------------------------------------------------- /pages/changelogpage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "changelogpage.h" 22 | 23 | #include "changelogsortfilterproxymodel.h" 24 | 25 | #include 26 | 27 | ChangelogPage::ChangelogPage(QWidget *parent) : 28 | Page(parent){ 29 | ui.setupUi(this); 30 | 31 | model = new ListModel(this); 32 | proxyModel = new ChangelogSortFilterProxyModel(this); 33 | proxyModel->setSourceModel(model); 34 | proxyModel->setSortRole(Qt::EditRole); 35 | proxyModel->sort(0, Qt::DescendingOrder); 36 | 37 | ui.versionList->setModel(proxyModel); 38 | ui.versionList->setSelectionMode(QAbstractItemView::SingleSelection); 39 | 40 | connect(ui.versionList->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateEntry(const QItemSelection &, const QItemSelection &))); 41 | connect(ui.version, SIGNAL(textChanged(const QString &)), this, SLOT(updateVersion(const QString &))); 42 | connect(ui.add, SIGNAL(clicked()), this, SLOT(addVersion())); 43 | connect(ui.remove, SIGNAL(clicked()), this, SLOT(removeVersion())); 44 | } 45 | 46 | 47 | void ChangelogPage::setData(const ModXData *data) 48 | { 49 | model->setList(data->history); 50 | if (data->authorGroup.isEmpty()) 51 | { 52 | updateEntry(QItemSelection(), QItemSelection()); 53 | } 54 | else 55 | { 56 | ui.versionList->selectionModel()->select(proxyModel->index(0, 0), QItemSelectionModel::SelectCurrent); 57 | } 58 | } 59 | 60 | void ChangelogPage::getData(ModXData *data) 61 | { 62 | QItemSelection selection = ui.versionList->selectionModel()->selection(); 63 | updateEntry(selection, selection); 64 | QList list = model->list(); 65 | qSort(list); 66 | data->history = list; 67 | } 68 | 69 | 70 | void ChangelogPage::updateEntry(const QItemSelection &newSelection, const QItemSelection &oldSelection) 71 | { 72 | if (oldSelection.count()) 73 | { 74 | QModelIndexList list = proxyModel->mapSelectionToSource(oldSelection).indexes(); 75 | 76 | if (!list.isEmpty()) 77 | { 78 | QModelIndex index = list.at(0); 79 | ChangelogEntry entry = model->data(index, Qt::EditRole).value(); 80 | 81 | entry.version = ui.version->text(); 82 | entry.date = ui.date->date(); 83 | entry.changes["en"] = ui.changes->toPlainText().split('\n', QString::SkipEmptyParts); 84 | 85 | model->setData(index, QVariant::fromValue(entry)); 86 | } 87 | } 88 | 89 | ChangelogEntry entry; 90 | if (newSelection.count()) 91 | { 92 | QModelIndexList list = proxyModel->mapSelectionToSource(newSelection).indexes(); 93 | if (!list.isEmpty()) 94 | { 95 | entry = model->data(list.at(0), Qt::EditRole).value(); 96 | } 97 | } 98 | ui.version->setText(entry.version); 99 | ui.date->setDate(entry.date); 100 | ui.changes->setText(entry.changes["en"].join("\n")); 101 | } 102 | 103 | void ChangelogPage::updateVersion(const QString &version) 104 | { 105 | QModelIndexList list = proxyModel->mapSelectionToSource(ui.versionList->selectionModel()->selection()).indexes(); 106 | if (list.isEmpty()) 107 | return; 108 | QModelIndex index = list.at(0); 109 | ChangelogEntry entry = model->data(index, Qt::EditRole).value(); 110 | if (entry.version == version) 111 | return; 112 | entry.version = version; 113 | model->setData(index, QVariant::fromValue(entry)); 114 | proxyModel->invalidate(); 115 | } 116 | 117 | void ChangelogPage::addVersion() 118 | { 119 | model->insertRow(model->rowCount()); 120 | proxyModel->invalidate(); 121 | ui.versionList->selectionModel()->clearSelection(); 122 | ui.versionList->selectionModel()->select(proxyModel->mapFromSource(model->index(model->rowCount() - 1, 0)), QItemSelectionModel::Select); 123 | } 124 | 125 | void ChangelogPage::removeVersion() 126 | { 127 | QModelIndexList selected = ui.versionList->selectionModel()->selection().indexes(); 128 | if (selected.isEmpty()) 129 | return; 130 | int modelRow = proxyModel->mapToSource(selected.at(0)).row(); 131 | int proxyModelRow = selected.at(0).row(); 132 | 133 | proxyModel->setSourceModel(0); 134 | model->removeRow(modelRow); 135 | proxyModel->setSourceModel(model); 136 | 137 | if (model->rowCount()) 138 | { 139 | ui.versionList->selectionModel()->select(proxyModel->index(proxyModelRow ? proxyModelRow - 1 : 0, 0), QItemSelectionModel::SelectCurrent); 140 | } 141 | } 142 | 143 | void ChangelogPage::changeEvent(QEvent *e) 144 | { 145 | switch(e->type()) { 146 | case QEvent::LanguageChange: 147 | ui.retranslateUi(this); 148 | break; 149 | default: 150 | break; 151 | } 152 | } 153 | 154 | -------------------------------------------------------------------------------- /version.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "version.h" 22 | 23 | #include 24 | #include 25 | 26 | 27 | Version::Version(int major, int minor, int maintenance, char patch, VersionType type, int special) 28 | { 29 | m_major = major; 30 | m_minor = minor; 31 | m_maintenance = maintenance; 32 | m_patch = patch; 33 | m_type = type; 34 | m_special = 0; 35 | if (m_type != NormalVersion) 36 | { 37 | m_special = special; 38 | } 39 | } 40 | 41 | Version::Version(const QString &version) 42 | { 43 | parse(version); 44 | } 45 | 46 | Version::Version(const char *version) 47 | { 48 | parse(QString(version)); 49 | } 50 | 51 | 52 | Version::Version(const Version &other) 53 | { 54 | valid = other.valid; 55 | m_major = other.m_major; 56 | m_minor = other.m_minor; 57 | m_maintenance = other.m_maintenance; 58 | m_patch = other.m_patch; 59 | m_type = other.m_type; 60 | m_special = other.m_special; 61 | } 62 | 63 | Version::~Version() 64 | { 65 | } 66 | 67 | bool Version::isValid() const 68 | { 69 | return valid; 70 | } 71 | 72 | Version::operator const QString&() const 73 | { 74 | if (cache != "") 75 | { 76 | return cache; 77 | } 78 | 79 | cache = QString::number(m_major) + "." + QString::number(m_minor) + "." + QString::number(m_maintenance); 80 | if (m_patch) 81 | { 82 | cache += QChar(m_patch); 83 | } 84 | 85 | switch(m_type) 86 | { 87 | case AlphaVersion: 88 | cache += "A" + QString::number(m_special); 89 | break; 90 | case BetaVersion: 91 | cache += "B" + QString::number(m_special); 92 | break; 93 | case RCVersion: 94 | cache += "RC" + QString::number(m_special); 95 | break; 96 | case NormalVersion: 97 | default: 98 | break; 99 | } 100 | 101 | return cache; 102 | } 103 | 104 | 105 | int Version::major() const 106 | { 107 | return m_major; 108 | } 109 | 110 | int Version::minor() const 111 | { 112 | return m_minor; 113 | } 114 | 115 | int Version::maintenance() const 116 | { 117 | return m_maintenance; 118 | } 119 | 120 | int Version::patch() const 121 | { 122 | return m_patch; 123 | } 124 | 125 | Version::VersionType Version::type() const 126 | { 127 | return m_type; 128 | } 129 | 130 | int Version::special() const 131 | { 132 | return m_special; 133 | } 134 | 135 | bool Version::operator<(const Version &other) const 136 | { 137 | 138 | if (m_major < other.m_major) 139 | return true; 140 | if (other.m_major < m_major) 141 | return false; 142 | 143 | if (m_minor < other.m_minor) 144 | return true; 145 | if (other.m_minor < m_minor) 146 | return false; 147 | 148 | if (m_maintenance < other.m_maintenance) 149 | return true; 150 | if (other.m_maintenance < m_maintenance) 151 | return false; 152 | 153 | if (m_patch < other.m_patch) 154 | return true; 155 | if (other.m_patch < m_patch) 156 | return false; 157 | 158 | if (m_type > other.m_type) 159 | return true; 160 | if (other.m_type > m_type) 161 | return false; 162 | 163 | if (m_special < other.m_special) 164 | return true; 165 | 166 | return false; 167 | } 168 | 169 | bool Version::operator==(const Version &other) const 170 | { 171 | return m_major == other.m_major && m_minor == other.m_minor && m_patch == other.m_maintenance && m_patch == other.m_patch 172 | && m_type == other.m_type && m_special == other.m_special; 173 | } 174 | 175 | 176 | void Version::parse(const QString &version) 177 | { 178 | QRegExp rx("([1-9][0-9]+|[0-9])\\.([1-9][0-9]+|[0-9])\\.([1-9][0-9]+|[0-9])([a-z])?(?:([AB]|RC)([1-9][0-9]+|[0-9]))?"); 179 | valid = false; 180 | m_major = 0; 181 | m_minor = 0; 182 | m_maintenance = 0; 183 | m_patch = 0; 184 | 185 | if (!rx.exactMatch(version)) 186 | return; 187 | 188 | valid = true; 189 | m_major = rx.cap(1).toInt(); 190 | m_minor = rx.cap(2).toInt(); 191 | m_maintenance = rx.cap(3).toInt(); 192 | 193 | if (rx.cap(4).size()) 194 | { 195 | m_patch = rx.cap(4).toAscii().at(0); 196 | } 197 | 198 | m_type = NormalVersion; 199 | m_special = 0; 200 | 201 | if (rx.cap(5).size()) 202 | { 203 | QString type = rx.cap(5); 204 | if (type == "A") 205 | { 206 | m_type = AlphaVersion; 207 | } 208 | else if (type == "B") 209 | { 210 | m_type = BetaVersion; 211 | } 212 | else if (type == "RC") 213 | { 214 | m_type = RCVersion; 215 | } 216 | } 217 | 218 | if (rx.cap(6).size()) 219 | { 220 | m_special = rx.cap(6).toInt(); 221 | } 222 | } 223 | 224 | #ifndef QT_NO_DEBUG 225 | QDebug operator<<(QDebug dbg, const Version &v) 226 | { 227 | dbg.nospace() << "Version " << QString(v); 228 | return dbg.space(); 229 | } 230 | #endif 231 | -------------------------------------------------------------------------------- /pages/authorgrouppage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "authorgrouppage.h" 22 | 23 | #include 24 | 25 | AuthorGroupPage::AuthorGroupPage(QWidget *parent) : 26 | Page(parent){ 27 | ui.setupUi(this); 28 | 29 | model = new ListModel(this); 30 | 31 | ui.authorList->setModel(model); 32 | 33 | connect(ui.authorList->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateDetails(const QItemSelection &, const QItemSelection &))); 34 | connect(ui.userName, SIGNAL(textChanged(const QString &)), this, SLOT(updateUserName(const QString &))); 35 | connect(ui.add, SIGNAL(clicked()), this, SLOT(addAuthor())); 36 | connect(ui.remove, SIGNAL(clicked()), this, SLOT(removeAuthor())); 37 | connect(ui.moveUp, SIGNAL(clicked()), this, SLOT(moveUp())); 38 | connect(ui.moveDown, SIGNAL(clicked()), this, SLOT(moveDown())); 39 | } 40 | 41 | void AuthorGroupPage::setData(const ModXData *data) 42 | { 43 | model->setList(data->authorGroup); 44 | if (data->authorGroup.isEmpty()) 45 | { 46 | updateDetails(QItemSelection(), QItemSelection()); 47 | } 48 | else 49 | { 50 | ui.authorList->selectionModel()->select(model->index(0, 0), QItemSelectionModel::SelectCurrent); 51 | } 52 | } 53 | 54 | void AuthorGroupPage::getData(ModXData *data) 55 | { 56 | QItemSelection selection = ui.authorList->selectionModel()->selection(); 57 | updateDetails(selection, selection); 58 | data->authorGroup = model->list(); 59 | } 60 | 61 | void AuthorGroupPage::updateDetails(const QItemSelection &newSelection, const QItemSelection &oldSelection) 62 | { 63 | if (oldSelection.count()) 64 | { 65 | QModelIndexList list = oldSelection.indexes(); 66 | 67 | if (!list.isEmpty()) 68 | { 69 | QModelIndex index = list.at(0); 70 | Author author = model->data(index, Qt::EditRole).value(); 71 | 72 | author.userName = ui.userName->text(); 73 | author.realName = ui.realName->text(); 74 | author.email = ui.email->text(); 75 | author.homePage = ui.homePage->text(); 76 | author.contributionStatus = ui.contributionStatus->text(); 77 | author.contributionFrom = ui.contributionFrom->date(); 78 | author.contributionTo = ui.contributionTo->date(); 79 | 80 | model->setData(index, QVariant::fromValue(author)); 81 | } 82 | } 83 | 84 | Author author; 85 | if (newSelection.count()) 86 | { 87 | QModelIndexList list = newSelection.indexes(); 88 | if (!list.isEmpty()) 89 | { 90 | author = model->data(list.at(0), Qt::EditRole).value(); 91 | } 92 | } 93 | 94 | ui.userName->setText(author.userName); 95 | ui.realName->setText(author.realName); 96 | ui.email->setText(author.email); 97 | 98 | ui.homePage->setText(author.homePage); 99 | ui.contributionStatus->setText(author.contributionStatus); 100 | ui.contributionFrom->setDate(author.contributionFrom); 101 | ui.contributionTo->setDate(author.contributionTo); 102 | 103 | } 104 | 105 | void AuthorGroupPage::updateUserName(const QString &newName) 106 | { 107 | QModelIndexList list = ui.authorList->selectionModel()->selection().indexes(); 108 | if (list.isEmpty()) 109 | return; 110 | QModelIndex index = list.at(0); 111 | Author author = model->data(index, Qt::EditRole).value(); 112 | author.userName = newName; 113 | model->setData(index, QVariant::fromValue(author)); 114 | } 115 | 116 | void AuthorGroupPage::addAuthor() 117 | { 118 | model->insertRow(model->rowCount(), QModelIndex()); 119 | ui.authorList->selectionModel()->clearSelection(); 120 | ui.authorList->selectionModel()->select(model->index(model->rowCount() - 1, 0), QItemSelectionModel::Select); 121 | } 122 | 123 | void AuthorGroupPage::removeAuthor() 124 | { 125 | QModelIndexList selected = ui.authorList->selectionModel()->selectedIndexes(); 126 | if (selected.isEmpty()) 127 | return; 128 | int row = selected.at(0).row(); 129 | model->removeRow(row); 130 | if (model->rowCount()) 131 | { 132 | ui.authorList->selectionModel()->select(model->index(row ? row - 1 : 0, 0), QItemSelectionModel::SelectCurrent); 133 | } 134 | } 135 | 136 | void AuthorGroupPage::moveUp() 137 | { 138 | QModelIndexList selected = ui.authorList->selectionModel()->selectedIndexes(); 139 | if (selected.isEmpty()) 140 | return; 141 | int row = selected.at(0).row(); 142 | 143 | row = model->moveUp(row); 144 | ui.authorList->selectionModel()->select(model->index(row, 0), QItemSelectionModel::SelectCurrent); 145 | 146 | } 147 | 148 | void AuthorGroupPage::moveDown() 149 | { 150 | QModelIndexList selected = ui.authorList->selectionModel()->selectedIndexes(); 151 | if (selected.isEmpty()) 152 | return; 153 | int row = selected.at(0).row(); 154 | 155 | row = model->moveDown(row); 156 | ui.authorList->selectionModel()->select(model->index(row, 0), QItemSelectionModel::SelectCurrent); 157 | } 158 | 159 | void AuthorGroupPage::changeEvent(QEvent *e) 160 | { 161 | switch(e->type()) { 162 | case QEvent::LanguageChange: 163 | ui.retranslateUi(this); 164 | break; 165 | default: 166 | break; 167 | } 168 | } 169 | 170 | -------------------------------------------------------------------------------- /pages/generalpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | GeneralPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 353 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | General Info 24 | 25 | 26 | 27 | 28 | 29 | Title: 30 | 31 | 32 | title 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Description: 43 | 44 | 45 | description 46 | 47 | 48 | 49 | 50 | 51 | 52 | true 53 | 54 | 55 | 56 | 57 | 58 | 59 | Autor Notes: 60 | 61 | 62 | authorNotes 63 | 64 | 65 | 66 | 67 | 68 | 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | License: 77 | 78 | 79 | license 80 | 81 | 82 | 83 | 84 | 85 | 86 | Version: 87 | 88 | 89 | version 90 | 91 | 92 | 93 | 94 | 95 | 96 | 1.0.0 97 | 98 | 99 | 100 | 101 | 102 | 103 | true 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Installation 114 | 115 | 116 | 117 | 118 | 119 | Target Version: 120 | 121 | 122 | targetVersion 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 3.0.0 132 | 133 | 134 | 135 | 136 | 137 | 138 | Set Latest Version 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | Installation Level: 148 | 149 | 150 | installLevel 151 | 152 | 153 | 154 | 155 | 156 | 157 | Installation Time: 158 | 159 | 160 | installTime 161 | 162 | 163 | 164 | 165 | 166 | 167 | QAbstractSpinBox::UpDownArrows 168 | 169 | 170 | QAbstractSpinBox::CorrectToNearestValue 171 | 172 | 173 | 60 174 | 175 | 176 | s 177 | 178 | 179 | 60 180 | 181 | 182 | 86400 183 | 184 | 185 | 10 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | title 199 | version 200 | description 201 | authorNotes 202 | license 203 | targetVersion 204 | setLatestVersion 205 | installLevel 206 | installTime 207 | 208 | 209 | 210 | 211 | -------------------------------------------------------------------------------- /pages/authorgrouppage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | AuthorGroupPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | 28 | 29 | 0 30 | 0 31 | 32 | 33 | 34 | 35 | 100 36 | 16777215 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 0 45 | 46 | 47 | QLayout::SetFixedSize 48 | 49 | 50 | 51 | 52 | 53 | 20 54 | 20 55 | 56 | 57 | 58 | + 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 20 67 | 20 68 | 69 | 70 | 71 | - 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 20 80 | 20 81 | 82 | 83 | 84 | /\ 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 20 93 | 20 94 | 95 | 96 | 97 | \/ 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | Detailed Info 111 | 112 | 113 | 114 | QFormLayout::AllNonFixedFieldsGrow 115 | 116 | 117 | 118 | 119 | User Name: 120 | 121 | 122 | userName 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | Real Name: 133 | 134 | 135 | realName 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Homepage: 146 | 147 | 148 | homePage 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | Email: 159 | 160 | 161 | email 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | Contribution 175 | 176 | 177 | 178 | 179 | 180 | Status: 181 | 182 | 183 | contributionStatus 184 | 185 | 186 | 187 | 188 | 189 | 190 | From: 191 | 192 | 193 | contributionFrom 194 | 195 | 196 | 197 | 198 | 199 | 200 | To: 201 | 202 | 203 | contributionTo 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | true 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 0 222 | 0 223 | 0 224 | 2001 225 | 1 226 | 1 227 | 228 | 229 | 230 | true 231 | 232 | 233 | 234 | 2001 235 | 1 236 | 1 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | authorList 250 | userName 251 | realName 252 | email 253 | homePage 254 | contributionStatus 255 | contributionFrom 256 | contributionTo 257 | add 258 | remove 259 | moveUp 260 | moveDown 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /pages/fileeditpage.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "fileeditpage.h" 22 | 23 | #include "modxdata.h" 24 | 25 | #include 26 | #include 27 | 28 | FileEditPage::FileEditPage(QWidget *parent) : 29 | Page(parent){ 30 | ui.setupUi(this); 31 | retranslateUi(); 32 | 33 | model = new ListModel(this); 34 | ui.actionView->setModel(model); 35 | 36 | connect(ui.actionView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(updateAction(const QItemSelection &, const QItemSelection &))); 37 | connect(ui.currentFile, SIGNAL(activated(const QString &)), this, SLOT(updateActionModel(const QString &))); 38 | } 39 | 40 | void FileEditPage::setData(const ModXData *data) 41 | { 42 | actions = data->actions; 43 | clearFields(); 44 | 45 | ui.currentFile->setCurrentIndex(0); 46 | updateActionModel(ui.currentFile->currentText()); 47 | } 48 | 49 | void FileEditPage::getData(ModXData *data) 50 | { 51 | QItemSelection selection = ui.actionView->selectionModel()->selection(); 52 | updateAction(selection, selection); 53 | 54 | if (currentFile != "") 55 | { 56 | actions[currentFile] = model->list(); 57 | } 58 | ListModel *fileModel = dynamic_cast *>(ui.currentFile->model()); 59 | if (fileModel != NULL) 60 | { 61 | QMap > newActions; 62 | 63 | foreach (QString file, fileModel->list()) 64 | { 65 | newActions[file] = actions[file]; 66 | } 67 | actions = newActions; 68 | } 69 | data->actions = actions; 70 | } 71 | 72 | void FileEditPage::updateActionModel(const QString &file) 73 | { 74 | QString nextFile = file; 75 | 76 | if (currentFile != "") 77 | { 78 | actions[currentFile] = model->list(); 79 | } 80 | currentFile = nextFile; 81 | if (nextFile == "") 82 | { 83 | model->setList(QList()); 84 | return; 85 | } 86 | model->setList(actions[nextFile]); 87 | } 88 | 89 | void FileEditPage::updateAction(const QItemSelection &newSelection, const QItemSelection &oldSelection) 90 | { 91 | if (oldSelection.count()) 92 | { 93 | QModelIndexList list = oldSelection.indexes(); 94 | 95 | if (!list.isEmpty()) 96 | { 97 | QModelIndex index = list.at(0); 98 | Action action = model->data(index, Qt::EditRole).value(); 99 | 100 | action.type = (Action::Type) ui.actionType->currentIndex(); 101 | 102 | switch (action.type) 103 | { 104 | case Action::Find: 105 | action.find = ui.find->toPlainText(); 106 | break; 107 | case Action::Edit: 108 | action.editType = (Action::EditType) ui.editType->currentIndex(); 109 | action.edit = ui.edit->toPlainText(); 110 | break; 111 | case Action::InlineFind: 112 | action.find = ui.inlineFind->text(); 113 | break; 114 | case Action::InlineEdit: 115 | action.editType = (Action::EditType) ui.inlineEditType->currentIndex(); 116 | action.edit = ui.inlineEdit->text(); 117 | break; 118 | } 119 | 120 | model->setData(index, QVariant::fromValue(action)); 121 | } 122 | } 123 | 124 | Action action; 125 | if (newSelection.count()) 126 | { 127 | QModelIndexList list = newSelection.indexes(); 128 | if (!list.isEmpty()) 129 | { 130 | action = model->data(list.at(0), Qt::EditRole).value(); 131 | } 132 | } 133 | 134 | clearFields(); 135 | 136 | ui.actionType->setCurrentIndex(action.type); 137 | 138 | switch (action.type) 139 | { 140 | case Action::Find: 141 | ui.find->setText(action.find); 142 | break; 143 | case Action::Edit: 144 | ui.editType->setCurrentIndex(action.editType); 145 | ui.edit->setText(action.edit); 146 | break; 147 | case Action::InlineFind: 148 | ui.inlineFind->setText(action.find); 149 | break; 150 | case Action::InlineEdit: 151 | ui.inlineEditType->setCurrentIndex(action.editType); 152 | ui.inlineEdit->setText(action.edit); 153 | break; 154 | } 155 | } 156 | 157 | void FileEditPage::on_actionType_currentIndexChanged() 158 | { 159 | if (!ui.actionView->selectionModel()) 160 | return; 161 | 162 | QModelIndexList list = ui.actionView->selectionModel()->selection().indexes(); 163 | if (list.isEmpty()) 164 | return; 165 | QModelIndex index = list.at(0); 166 | Action action = model->data(index, Qt::EditRole).value(); 167 | action.type = (Action::Type) ui.actionType->currentIndex(); 168 | model->setData(index, QVariant::fromValue(action)); 169 | } 170 | 171 | void FileEditPage::on_add_clicked() 172 | { 173 | model->insertRow(model->rowCount(), QModelIndex()); 174 | ui.actionView->selectionModel()->clearSelection(); 175 | ui.actionView->selectionModel()->select(model->index(model->rowCount() - 1, 0), QItemSelectionModel::Select); 176 | } 177 | 178 | void FileEditPage::on_remove_clicked() 179 | { 180 | QModelIndexList selected = ui.actionView->selectionModel()->selectedIndexes(); 181 | if (selected.isEmpty()) 182 | return; 183 | int row = selected.at(0).row(); 184 | model->removeRow(row); 185 | if (model->rowCount()) 186 | { 187 | ui.actionView->selectionModel()->select(model->index(row ? row - 1 : 0, 0), QItemSelectionModel::SelectCurrent); 188 | } 189 | } 190 | 191 | void FileEditPage::on_moveUp_clicked() 192 | { 193 | QModelIndexList selected = ui.actionView->selectionModel()->selectedIndexes(); 194 | if (selected.isEmpty()) 195 | return; 196 | int row = selected.at(0).row(); 197 | 198 | row = model->moveUp(row); 199 | ui.actionView->selectionModel()->select(model->index(row, 0), QItemSelectionModel::SelectCurrent); 200 | } 201 | 202 | void FileEditPage::on_moveDown_clicked() 203 | { 204 | QModelIndexList selected = ui.actionView->selectionModel()->selectedIndexes(); 205 | if (selected.isEmpty()) 206 | return; 207 | int row = selected.at(0).row(); 208 | 209 | row = model->moveDown(row); 210 | ui.actionView->selectionModel()->select(model->index(row, 0), QItemSelectionModel::SelectCurrent); 211 | } 212 | 213 | void FileEditPage::changeEvent(QEvent *e) 214 | { 215 | switch(e->type()) { 216 | case QEvent::LanguageChange: 217 | ui.retranslateUi(this); 218 | retranslateUi(); 219 | break; 220 | default: 221 | break; 222 | } 223 | } 224 | 225 | void FileEditPage::setFileModel(QAbstractItemModel *model) 226 | { 227 | ui.currentFile->setModel(model); 228 | ui.currentFile->setCurrentIndex(0); 229 | connect(model, SIGNAL(modelReset()), this, SLOT(updateActionModel())); 230 | } 231 | 232 | void FileEditPage::retranslateUi() 233 | { 234 | QStringList actionTypes; 235 | actionTypes << tr("Find") << tr("Edit") << tr("Inline Find") << tr("Inline Edit"); 236 | 237 | QStringList editTypes; 238 | editTypes << tr("after-add") << tr("before-add") << tr("replace") << tr("operation"); 239 | 240 | ui.actionType->clear(); 241 | ui.actionType->addItems(actionTypes); 242 | 243 | ui.editType->clear(); 244 | ui.inlineEditType->clear(); 245 | 246 | ui.editType->addItems(editTypes); 247 | ui.inlineEditType->addItems(editTypes); 248 | } 249 | 250 | void FileEditPage::clearFields() 251 | { 252 | ui.actionType->setCurrentIndex(Action::Find); 253 | ui.find->setText(""); 254 | 255 | ui.editType->setCurrentIndex(Action::AfterAdd); 256 | ui.edit->setText(""); 257 | 258 | ui.inlineFind->setText(""); 259 | 260 | ui.inlineEditType->setCurrentIndex(Action::AfterAdd); 261 | ui.inlineEdit->setText(""); 262 | } 263 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "mainwindow.h" 22 | 23 | #include "modxapp.h" 24 | #include "modxreader.h" 25 | #include "modxwriter.h" 26 | #include "modxdata.h" 27 | #include "pages/generalpage.h" 28 | #include "pages/authorgrouppage.h" 29 | #include "pages/changelogpage.h" 30 | #include "pages/sqlpage.h" 31 | #include "pages/filepage.h" 32 | #include "pages/editedfilespage.h" 33 | #include "pages/fileeditpage.h" 34 | #include "pages/diypage.h" 35 | #include "widgets/aboutdialog.h" 36 | 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | 47 | MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) 48 | : QMainWindow(parent, flags) 49 | { 50 | data = 0; 51 | 52 | init = true; 53 | ui.setupUi(this); 54 | 55 | 56 | setCurrentFile("Untitled"); 57 | 58 | connect(ui.actionNew, SIGNAL(triggered()), this, SLOT(newFile())); 59 | connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(openFile())); 60 | connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(saveFile())); 61 | connect(ui.actionSaveAs,SIGNAL(triggered()), this, SLOT(saveFileAs())); 62 | connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(close())); 63 | 64 | connect(ui.pageList, SIGNAL(currentRowChanged(int)), this, SLOT(changePage(int))); 65 | 66 | EditedFilesPage *editedFilesPage = new EditedFilesPage(ui.stackedWidget); 67 | FileEditPage *fileEditPage = new FileEditPage(ui.stackedWidget); 68 | 69 | fileEditPage->setFileModel(editedFilesPage->model()); 70 | 71 | 72 | ui.stackedWidget->removeWidget(ui.stackedWidget->currentWidget()); 73 | // ui.stackedWidget->removeTab(ui.stackedWidget->currentIndex()); 74 | addPage(tr("General Info"), new GeneralPage(ui.stackedWidget)); 75 | addPage(tr("Authors"), new AuthorGroupPage(ui.stackedWidget)); 76 | addPage(tr("Changelog"), new ChangelogPage(ui.stackedWidget)); 77 | addPage(tr("SQL"), new SqlPage(ui.stackedWidget)); 78 | addPage(tr("Copy Files"), new FilePage(ui.stackedWidget)); 79 | addPage(tr("Files to Edit"), editedFilesPage); 80 | addPage(tr("File Edits"), fileEditPage); 81 | addPage(tr("Do-It-Yourself"), new DIYPage(ui.stackedWidget)); 82 | 83 | ui.pageList->setCurrentRow(0); 84 | 85 | { 86 | // GAH!!! 87 | QList sizes; 88 | sizes << 100 << 1000; 89 | ui.splitter->setSizes(sizes); 90 | ui.splitter->setCollapsible(1, false); 91 | } 92 | 93 | loadSettings(); 94 | 95 | openFile(ModXApp::currentFile); 96 | 97 | init = false; 98 | } 99 | 100 | MainWindow::~MainWindow() 101 | { 102 | if (data) 103 | delete data; 104 | } 105 | 106 | void MainWindow::newFile() 107 | { 108 | if (!init) 109 | { 110 | if (!askSave()) 111 | { 112 | return; 113 | } 114 | } 115 | setCurrentFile("Untitled"); 116 | if (data) 117 | delete data; 118 | data = new ModXData; 119 | data->authorGroup << Author(); 120 | data->history << ChangelogEntry(); 121 | setData(data); 122 | } 123 | 124 | void MainWindow::openFile() 125 | { 126 | if (!askSave()) 127 | return; 128 | 129 | QString fileName = QFileDialog::getOpenFileName( 130 | this, 131 | tr("Open MODX file..."), 132 | QDesktopServices::storageLocation(QDesktopServices::HomeLocation), 133 | "MODX files (*.xml *.modx)"); 134 | 135 | if (fileName == "") 136 | return; 137 | 138 | openFile(fileName, true); 139 | } 140 | 141 | void MainWindow::openFile(const QString &fileName, bool force) 142 | { 143 | if (!init && !force && !askSave()) 144 | return; 145 | 146 | setCurrentFile(fileName); 147 | 148 | if (fileName == "Untitled") 149 | { 150 | newFile(); 151 | return; 152 | } 153 | 154 | ModXReader reader; 155 | QFile file(fileName); 156 | file.open(QIODevice::ReadOnly); 157 | 158 | if(!reader.read(&file)) 159 | { 160 | qDebug() << "FAIL!!"; 161 | qDebug() << reader.errorString(); 162 | ui.statusBar->showMessage(tr("Failed opening file: %1. Error: %2").arg(file.fileName()).arg(reader.errorString())); 163 | return; 164 | } 165 | qDebug() << "SUCESS!!"; 166 | 167 | if (data) 168 | delete data; 169 | 170 | data = new ModXData; 171 | 172 | data = reader.data(); 173 | setData(data); 174 | 175 | ui.statusBar->showMessage(tr("Opened file: %1").arg(file.fileName())); 176 | } 177 | 178 | bool MainWindow::saveFile() 179 | { 180 | if (ModXApp::currentFile == "Untitled") 181 | { 182 | return saveFileAs(); 183 | } 184 | 185 | for (int i = 0; i < ui.stackedWidget->count(); ++i) 186 | { 187 | qobject_cast(ui.stackedWidget->widget(i))->getData(data); 188 | } 189 | 190 | QFile file(ModXApp::currentFile); 191 | file.open(QIODevice::WriteOnly); 192 | 193 | ModXWriter writer; 194 | writer.setData(data); 195 | 196 | writer.write(&file); 197 | ui.statusBar->showMessage(tr("File Saved")); 198 | return true; 199 | } 200 | 201 | 202 | bool MainWindow::saveFileAs() 203 | { 204 | QString fileName = QFileDialog::getSaveFileName( 205 | this, 206 | tr("Save file as..."), 207 | QDesktopServices::storageLocation(QDesktopServices::HomeLocation), 208 | "MODX files (*.xml *.modx)"); 209 | 210 | if (fileName == "") 211 | return false; 212 | 213 | setCurrentFile(fileName); 214 | return saveFile(); 215 | } 216 | 217 | bool MainWindow::askSave() 218 | { 219 | int ret = QMessageBox::warning( 220 | this, 221 | tr("MODX Editor"), 222 | tr("Save changes to document?"), 223 | QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); 224 | 225 | switch (ret) 226 | { 227 | case QMessageBox::Save: 228 | return saveFile(); 229 | break; 230 | case QMessageBox::Discard: 231 | return true; 232 | break; 233 | case QMessageBox::Cancel: 234 | default: 235 | return false; 236 | break; 237 | } 238 | } 239 | 240 | void MainWindow::closeEvent(QCloseEvent *e) 241 | { 242 | if (askSave()) 243 | { 244 | saveSettings(); 245 | e->accept(); 246 | } 247 | else 248 | { 249 | e->ignore(); 250 | } 251 | } 252 | 253 | void MainWindow::changePage(int i) 254 | { 255 | ui.stackedWidget->setCurrentIndex(i); 256 | } 257 | 258 | void MainWindow::on_actionAbout_triggered() 259 | { 260 | AboutDialog dialog(this); 261 | dialog.exec(); 262 | } 263 | 264 | 265 | void MainWindow::addPage(const QString &title, Page *page) 266 | { 267 | page->show(); 268 | ui.pageList->addItem(title); 269 | ui.stackedWidget->addWidget(page); 270 | // ui.stackedWidget->addTab(page, title); 271 | } 272 | 273 | void MainWindow::setData(const ModXData *data) 274 | { 275 | for (int i = 0; i < ui.stackedWidget->count(); ++i) 276 | { 277 | qobject_cast(ui.stackedWidget->widget(i))->setData(data); 278 | } 279 | } 280 | 281 | void MainWindow::setCurrentFile(const QString &file) 282 | { 283 | ModXApp::currentFile = file; 284 | setWindowTitle(tr("MODX Editor - %1 [*]").arg(file)); 285 | } 286 | 287 | void MainWindow::loadSettings() 288 | { 289 | QSettings settings; 290 | 291 | settings.beginGroup("mainWindow"); 292 | ModXApp::currentFile = settings.value("currentFile", "Untitled").toString(); 293 | if (!QFile(ModXApp::currentFile).exists()) 294 | ModXApp::currentFile = "Untitled"; 295 | 296 | restoreGeometry(settings.value("geometry").toByteArray()); 297 | ui.splitter->restoreGeometry(settings.value("splitterGeometry").toByteArray()); 298 | settings.endGroup(); 299 | } 300 | 301 | void MainWindow::saveSettings() 302 | { 303 | QSettings settings; 304 | 305 | settings.beginGroup("mainWindow"); 306 | settings.setValue("currentFile", ModXApp::currentFile); 307 | settings.setValue("geometry", saveGeometry()); 308 | settings.setValue("splitterGeometry", ui.splitter->saveGeometry()); 309 | settings.endGroup(); 310 | } 311 | -------------------------------------------------------------------------------- /modxwriter.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "modxwriter.h" 22 | 23 | #include "modxdata.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | ModXWriter::ModXWriter() 30 | { 31 | setAutoFormatting(true); 32 | } 33 | 34 | void ModXWriter::setData(const ModXData *data) 35 | { 36 | m_data = data; 37 | } 38 | 39 | 40 | void ModXWriter::write(QIODevice *device) 41 | { 42 | if (m_data == NULL) 43 | return; 44 | 45 | setDevice(device); 46 | 47 | writeProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"");\ 48 | writeProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"modx.prosilver.en.xsl\""); 49 | writeComment( 50 | "For security purposes, please check: " 51 | "http://www.phpbb.com/mods/ for the latest version of this MOD. " 52 | "Although MODs are checked before being allowed in the MODs Database " 53 | "there is no guarantee that there are no security problems within the MOD. " 54 | "No support will be given for MODs not found within the MODs Database " 55 | "which can be found at http://www.phpbb.com/mods/"); 56 | writeStartElement("mod"); 57 | writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); 58 | writeAttribute("xmlns", "http://www.phpbb.com/mods/xml/modx-1.2.1.xsd"); 59 | 60 | writeHeader(); 61 | writeActionGroup(); 62 | writeEndDocument(); 63 | } 64 | 65 | void ModXWriter::writeHeader() 66 | { 67 | writeStartElement("header"); 68 | 69 | for (QMap::ConstIterator i = m_data->title.constBegin(); i != m_data->title.constEnd(); ++i) 70 | { 71 | writeStartElement("title"); 72 | writeAttribute("lang", i.key()); 73 | writeCharacters(i.value()); 74 | writeEndElement(); 75 | } 76 | 77 | for (QMap::ConstIterator i = m_data->description.constBegin(); i != m_data->description.constEnd(); ++i) 78 | { 79 | writeStartElement("description"); 80 | writeAttribute("lang", i.key()); 81 | writeCharacters(i.value()); 82 | writeEndElement(); 83 | } 84 | 85 | for (QMap::ConstIterator i = m_data->authorNotes.constBegin(); i != m_data->authorNotes.constEnd(); ++i) 86 | { 87 | writeStartElement("author-notes"); 88 | writeAttribute("lang", i.key()); 89 | writeCharacters(i.value()); 90 | writeEndElement(); 91 | } 92 | 93 | writeAuthorGroup(); 94 | 95 | writeStartElement("mod-version"); 96 | writeCharacters(m_data->version); 97 | writeEndElement(); 98 | 99 | writeStartElement("installation"); 100 | writeStartElement("level"); 101 | writeCharacters(ModXData::installationLevels.at(int(m_data->installLevel))); 102 | writeEndElement(); 103 | writeStartElement("time"); 104 | writeCharacters(QString::number(m_data->installTime)); 105 | writeEndElement(); 106 | writeStartElement("target-version"); 107 | writeCharacters(m_data->targetVersion); 108 | writeEndElement(); 109 | writeEndElement(); 110 | 111 | writeHistory(); 112 | 113 | writeStartElement("meta"); 114 | writeCharacters("Generated by " + QCoreApplication::applicationName() + " v" + QCoreApplication::applicationVersion()); 115 | writeEndElement(); 116 | 117 | writeStartElement("license"); 118 | writeCharacters(m_data->license); 119 | writeEndElement(); 120 | writeEndElement(); 121 | } 122 | 123 | void ModXWriter::writeAuthorGroup() 124 | { 125 | writeStartElement("author-group"); 126 | foreach (Author author, m_data->authorGroup) 127 | { 128 | writeStartElement("author"); 129 | writeStartElement("realname"); 130 | writeCharacters(author.realName); 131 | writeEndElement(); 132 | writeStartElement("username"); 133 | writeCharacters(author.userName); 134 | writeEndElement(); 135 | writeStartElement("email"); 136 | writeCharacters(author.email); 137 | writeEndElement(); 138 | writeStartElement("homepage"); 139 | writeCharacters(author.homePage); 140 | writeEndElement(); 141 | writeStartElement("contributions"); 142 | writeAttribute("status", author.contributionStatus); 143 | writeAttribute("from", author.contributionFrom.toString(Qt::ISODate)); 144 | writeAttribute("to", author.contributionTo.toString(Qt::ISODate)); 145 | writeEndElement(); 146 | writeEndElement(); 147 | } 148 | writeEndElement(); 149 | } 150 | 151 | void ModXWriter::writeHistory() 152 | { 153 | writeStartElement("history"); 154 | 155 | foreach (ChangelogEntry entry, m_data->history) 156 | { 157 | writeStartElement("entry"); 158 | writeStartElement("date"); 159 | writeCharacters(entry.date.toString(Qt::ISODate)); 160 | writeEndElement(); 161 | writeStartElement("rev-version"); 162 | writeCharacters(entry.version); 163 | writeEndElement(); 164 | for (QMap::ConstIterator i = entry.changes.constBegin(); i != entry.changes.constEnd(); ++i) 165 | { 166 | writeStartElement("changelog"); 167 | writeAttribute("lang", i.key()); 168 | foreach (QString change, i.value()) 169 | { 170 | writeStartElement("change"); 171 | writeCharacters(change); 172 | writeEndElement(); 173 | } 174 | writeEndElement(); 175 | } 176 | writeEndElement(); 177 | } 178 | writeEndElement(); 179 | } 180 | 181 | void ModXWriter::writeActionGroup() 182 | { 183 | writeStartElement("action-group"); 184 | 185 | foreach(QString sql, m_data->sql) 186 | { 187 | writeStartElement("sql"); 188 | writeAttribute("dbms", ModXData::sqlDialects[m_data->sqlDialect]); 189 | writeCharacters(sql); 190 | writeEndElement(); 191 | } 192 | 193 | if (m_data->copyFiles) 194 | { 195 | writeStartElement("copy"); 196 | writeComment("A_Jelly_Donut said this is enough to copy all files from root/ recursively.\n\tEspecially the to=\"*.*\" part!"); 197 | writeStartElement("file"); 198 | writeAttribute("from", "root/*.*"); 199 | writeAttribute("to", "*.*"); 200 | writeEndElement(); 201 | writeEndElement(); 202 | } 203 | 204 | writeOpen(); 205 | 206 | for (QMap::ConstIterator i = m_data->diy.constBegin(); i != m_data->diy.constEnd(); ++i) 207 | { 208 | writeStartElement("diy-instructions"); 209 | writeAttribute("lang", i.key()); 210 | writeCharacters(i.value()); 211 | writeEndElement(); 212 | } 213 | writeEndElement(); 214 | } 215 | 216 | void ModXWriter::writeOpen() 217 | { 218 | for (QMap >::const_iterator i = m_data->actions.constBegin(); i != m_data->actions.constEnd(); ++i) 219 | { 220 | Action::Type prevActionType = Action::Find; 221 | writeStartElement("open"); 222 | writeAttribute("src", i.key()); 223 | 224 | writeStartElement("edit"); 225 | foreach (Action action, i.value()) 226 | { 227 | switch (action.type) 228 | { 229 | case Action::Find: 230 | if (prevActionType == Action::InlineFind || prevActionType == Action::InlineEdit) 231 | { 232 | writeEndElement(); 233 | } 234 | if (prevActionType != Action::Find) 235 | { 236 | writeEndElement(); 237 | writeStartElement("edit"); 238 | } 239 | writeStartElement("find"); 240 | writeCharacters(action.find); 241 | writeEndElement(); 242 | break; 243 | case Action::Edit: 244 | if (prevActionType == Action::InlineFind || prevActionType == Action::InlineEdit) 245 | { 246 | writeEndElement(); 247 | } 248 | writeStartElement("action"); 249 | writeAttribute("type", Action::editTypes[action.editType]); 250 | writeCharacters(action.edit); 251 | writeEndElement(); 252 | break; 253 | case Action::InlineFind: 254 | if (prevActionType != Action::InlineFind && prevActionType != Action::InlineEdit) 255 | { 256 | writeStartElement("inline-edit"); 257 | } 258 | writeStartElement("inline-find"); 259 | writeCharacters(action.find); 260 | writeEndElement(); 261 | break; 262 | case Action::InlineEdit: 263 | if (prevActionType != Action::InlineFind && prevActionType != Action::InlineEdit) 264 | { 265 | writeStartElement("inline-edit"); 266 | } 267 | writeStartElement("inline-action"); 268 | writeAttribute("type", Action::editTypes[action.editType]); 269 | writeCharacters(action.edit); 270 | writeEndElement(); 271 | break; 272 | } 273 | prevActionType = action.type; 274 | } 275 | if (prevActionType == Action::InlineFind || prevActionType == Action::InlineEdit) 276 | { 277 | writeEndElement(); 278 | } 279 | writeEndElement(); 280 | writeEndElement(); 281 | } 282 | } 283 | -------------------------------------------------------------------------------- /modxreader.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by the phpBB Group * 3 | * phpbb.com * 4 | * * 5 | * This file is part of MODX Editor. * 6 | * * 7 | * MODX Editor is free software: you can redistribute it and/or modify * 8 | * it under the terms of the GNU General Public License as published by * 9 | * the Free Software Foundation, either version 3 of the License, or * 10 | * (at your option) any later version. * 11 | * * 12 | * MODX Editor is distributed in the hope that it will be useful, * 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 | * GNU General Public License for more details. * 16 | * * 17 | * You should have received a copy of the GNU General Public License * 18 | * along with MODX Editor. If not, see . * 19 | ***************************************************************************/ 20 | 21 | #include "modxreader.h" 22 | #include "modxdata.h" 23 | 24 | 25 | ModXReader::ModXReader() 26 | { 27 | } 28 | 29 | ModXData *ModXReader::data() const 30 | { 31 | return m_data; 32 | } 33 | 34 | 35 | void ModXReader::readUnknownElement() 36 | { 37 | Q_ASSERT(isStartElement()); 38 | 39 | while (!atEnd()) 40 | { 41 | readNext(); 42 | if (isEndElement()) 43 | { 44 | break; 45 | } 46 | if (isStartElement()) 47 | { 48 | readUnknownElement(); 49 | } 50 | } 51 | } 52 | 53 | bool ModXReader::read(QIODevice *device) 54 | { 55 | m_data = new ModXData; 56 | 57 | setDevice(device); 58 | 59 | while (!atEnd()) 60 | { 61 | readNext(); 62 | if (isStartElement()) 63 | { 64 | if (name() == "mod") 65 | { 66 | readModX(); 67 | } 68 | else 69 | { 70 | raiseError(QObject::tr("The file is not a ModX file.")); 71 | } 72 | } 73 | } 74 | 75 | return !error(); 76 | } 77 | 78 | void ModXReader::readModX() 79 | { 80 | Q_ASSERT(isStartElement() && name() == "mod"); 81 | while (!atEnd()) 82 | { 83 | readNext(); 84 | 85 | if (isEndElement()) 86 | { 87 | break; 88 | } 89 | 90 | if (isStartElement()) 91 | { 92 | if (name() == "header") 93 | { 94 | readHeader(); 95 | } 96 | else if (name() == "action-group") 97 | { 98 | readActionGroup(); 99 | } 100 | else 101 | { 102 | readUnknownElement(); 103 | } 104 | } 105 | } 106 | } 107 | 108 | void ModXReader::readHeader() 109 | { 110 | while (!atEnd()) 111 | { 112 | readNext(); 113 | 114 | if (isEndElement()) 115 | { 116 | break; 117 | } 118 | 119 | if (isStartElement()) 120 | { 121 | QString lang = attributes().value("lang").toString(); 122 | if (name() == "title") 123 | { 124 | m_data->title.insert(lang, readElementText()); 125 | } 126 | else if (name() == "description") 127 | { 128 | m_data->description.insert(lang, readElementText()); 129 | } 130 | else if (name() == "author-notes") 131 | { 132 | m_data->authorNotes.insert(lang, readElementText()); 133 | } 134 | else if (name() == "license") 135 | { 136 | m_data->license = readElementText(); 137 | } 138 | else if (name() == "installation") 139 | { 140 | readInstallation(); 141 | } 142 | else if (name() == "author-group") 143 | { 144 | readAuthorGroup(); 145 | } 146 | else if (name() == "history") 147 | { 148 | readHistory(); 149 | } 150 | else if (name() == "mod-version") 151 | { 152 | m_data->version = readElementText(); 153 | } 154 | else 155 | { 156 | readUnknownElement(); 157 | } 158 | } 159 | } 160 | } 161 | 162 | void ModXReader::readAuthorGroup() 163 | { 164 | while (!atEnd()) 165 | { 166 | readNext(); 167 | 168 | if (isEndElement()) 169 | { 170 | break; 171 | } 172 | 173 | if (isStartElement()) 174 | { 175 | if (name() == "author") 176 | { 177 | m_data->authorGroup << readAuthor(); 178 | } 179 | else 180 | { 181 | readUnknownElement(); 182 | } 183 | } 184 | } 185 | } 186 | 187 | Author ModXReader::readAuthor() 188 | { 189 | Author author; 190 | 191 | while (!atEnd()) 192 | { 193 | readNext(); 194 | 195 | if (isEndElement()) 196 | { 197 | break; 198 | } 199 | 200 | if (isStartElement()) 201 | { 202 | if (name() == "realname") 203 | { 204 | author.realName = readElementText(); 205 | } 206 | else if (name() == "username") 207 | { 208 | author.userName = readElementText(); 209 | } 210 | else if (name() == "email") 211 | { 212 | author.email = readElementText(); 213 | } 214 | else if (name() == "homepage") 215 | { 216 | author.homePage = readElementText(); 217 | } 218 | else if (name() == "contributions") 219 | { 220 | author.contributionStatus = attributes().value("status").toString(); 221 | author.contributionFrom = QDate::fromString(attributes().value("from").toString(), Qt::ISODate); 222 | author.contributionTo = QDate::fromString(attributes().value("to").toString(), Qt::ISODate); 223 | readElementText(); 224 | } 225 | else 226 | { 227 | readUnknownElement(); 228 | } 229 | } 230 | } 231 | 232 | return author; 233 | } 234 | 235 | void ModXReader::readInstallation() 236 | { 237 | while (!atEnd()) 238 | { 239 | readNext(); 240 | 241 | if (isEndElement()) 242 | { 243 | break; 244 | } 245 | 246 | if (isStartElement()) 247 | { 248 | if (name() == "level") 249 | { 250 | QString level = readElementText().toLower(); 251 | if (level == "easy") 252 | { 253 | m_data->installLevel = ModXData::LevelEasy; 254 | } 255 | else if (level == "advanced") 256 | { 257 | m_data->installLevel = ModXData::LevelAdvanced; 258 | } 259 | else 260 | { 261 | m_data->installLevel = ModXData::LevelIntermediate; 262 | } 263 | } 264 | else if (name() == "time") 265 | { 266 | bool ok = false; 267 | quint32 time = readElementText().toUInt(&ok); 268 | m_data->installTime = ok ? time : 60; 269 | } 270 | else if (name() == "target-version") 271 | { 272 | m_data->targetVersion = readElementText(); 273 | } 274 | else 275 | { 276 | readUnknownElement(); 277 | } 278 | } 279 | } 280 | } 281 | 282 | void ModXReader::readHistory() 283 | { 284 | while (!atEnd()) 285 | { 286 | readNext(); 287 | 288 | if (isEndElement()) 289 | { 290 | break; 291 | } 292 | 293 | if (isStartElement()) 294 | { 295 | if (name() == "entry") 296 | { 297 | m_data->history << readEntry(); 298 | } 299 | else 300 | { 301 | readUnknownElement(); 302 | } 303 | } 304 | } 305 | } 306 | 307 | ChangelogEntry ModXReader::readEntry() 308 | { 309 | ChangelogEntry entry; 310 | 311 | while (!atEnd()) 312 | { 313 | readNext(); 314 | 315 | if (isEndElement()) 316 | { 317 | break; 318 | } 319 | 320 | if (isStartElement()) 321 | { 322 | if (name() == "date") 323 | { 324 | entry.date = QDate::fromString(readElementText(), Qt::ISODate); 325 | } 326 | else if (name() == "rev-version") 327 | { 328 | entry.version = readElementText(); 329 | } 330 | else if (name() == "changelog") 331 | { 332 | QString lang = attributes().value("lang").toString(); 333 | entry.changes.insert(lang, readChanges()); 334 | } 335 | else 336 | { 337 | readUnknownElement(); 338 | } 339 | } 340 | } 341 | return entry; 342 | } 343 | 344 | QStringList ModXReader::readChanges() 345 | { 346 | QStringList changes; 347 | while (!atEnd()) 348 | { 349 | readNext(); 350 | 351 | if (isEndElement()) 352 | { 353 | break; 354 | } 355 | 356 | if (isStartElement()) 357 | { 358 | if (name() == "change") 359 | { 360 | changes << readElementText(); 361 | } 362 | else 363 | { 364 | readUnknownElement(); 365 | } 366 | } 367 | } 368 | return changes; 369 | } 370 | 371 | 372 | void ModXReader::readActionGroup() 373 | { 374 | while (!atEnd()) 375 | { 376 | readNext(); 377 | 378 | if (isEndElement()) 379 | { 380 | break; 381 | } 382 | 383 | if (isStartElement()) 384 | { 385 | if (name() == "sql") 386 | { 387 | m_data->sqlDialect = ModXData::sqlDialects.key(attributes().value("dbms").toString(), ModXData::DialectSqlParser); 388 | m_data->sql << readElementText(); 389 | } 390 | else if (name() == "copy") 391 | { 392 | m_data->copyFiles = true; 393 | // Read as unknown elements... 394 | readUnknownElement(); 395 | } 396 | else if (name() == "open") 397 | { 398 | QString file = attributes().value("src").toString(); 399 | m_data->actions[file] = readOpen(); 400 | } 401 | else if (name() == "diy-instructions") 402 | { 403 | QString lang = attributes().value("lang").toString(); 404 | m_data->diy[lang] = readElementText(); 405 | } 406 | else 407 | { 408 | readUnknownElement(); 409 | } 410 | } 411 | } 412 | } 413 | 414 | QList ModXReader::readOpen() 415 | { 416 | QList actions; 417 | 418 | while (!atEnd()) 419 | { 420 | readNext(); 421 | 422 | if (isEndElement()) 423 | { 424 | break; 425 | } 426 | 427 | if (isStartElement()) 428 | { 429 | if (name() == "edit") 430 | { 431 | actions << readEdit(); 432 | } 433 | else 434 | { 435 | readUnknownElement(); 436 | } 437 | } 438 | } 439 | return actions; 440 | } 441 | 442 | QList ModXReader::readEdit() 443 | { 444 | QList actions; 445 | 446 | while (!atEnd()) 447 | { 448 | readNext(); 449 | 450 | if (isEndElement()) 451 | { 452 | break; 453 | } 454 | 455 | if (isStartElement()) 456 | { 457 | if (name() == "find") 458 | { 459 | Action action; 460 | action.type = Action::Find; 461 | action.find = readElementText(); 462 | actions << action; 463 | } 464 | else if (name() == "action") 465 | { 466 | Action action; 467 | action.type = Action::Edit; 468 | action.editType = Action::editTypes.key(attributes().value("type").toString(), Action::BeforeAdd); 469 | action.edit = readElementText(); 470 | actions << action; 471 | } 472 | else if (name() == "inline-edit") 473 | { 474 | actions << readInlineEdit(); 475 | } 476 | else 477 | { 478 | readUnknownElement(); 479 | } 480 | } 481 | } 482 | return actions; 483 | } 484 | 485 | QList ModXReader::readInlineEdit() 486 | { 487 | QList actions; 488 | 489 | while (!atEnd()) 490 | { 491 | readNext(); 492 | 493 | if (isEndElement()) 494 | { 495 | break; 496 | } 497 | 498 | if (isStartElement()) 499 | { 500 | if (name() == "inline-find") 501 | { 502 | Action action; 503 | action.type = Action::InlineFind; 504 | action.find = readElementText(); 505 | actions << action; 506 | } 507 | else if (name() == "inline-action") 508 | { 509 | Action action; 510 | action.type = Action::InlineEdit; 511 | action.editType = Action::editTypes.key(attributes().value("type").toString(), Action::BeforeAdd); 512 | action.edit = readElementText(); 513 | actions << action; 514 | } 515 | else 516 | { 517 | readUnknownElement(); 518 | } 519 | } 520 | } 521 | return actions; 522 | } 523 | 524 | /*void ModXReader::readActionGroup() 525 | { 526 | qDebug() << "readActionGroup();"; 527 | while (!atEnd()) 528 | { 529 | readNext(); 530 | 531 | if (isEndElement()) 532 | { 533 | break; 534 | } 535 | 536 | if (isStartElement()) 537 | { 538 | readUnknownElement(); 539 | } 540 | } 541 | qDebug() << "<-readActionGroup();"; 542 | }*/ 543 | 544 | QDebug operator<<(QDebug dbg, const QXmlStreamAttribute &a) 545 | { 546 | dbg.nospace() << a.namespaceUri().toString() << ":" << a.name().toString() << " = " << a.value().toString(); 547 | 548 | return dbg.space(); 549 | }/**/ 550 | -------------------------------------------------------------------------------- /pages/fileeditpage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | FileEditPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 463 10 | 332 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 22 | 23 | QLayout::SetMaximumSize 24 | 25 | 26 | 27 | 28 | 0 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 0 36 | 37 | 38 | 39 | 40 | 100 41 | 16777215 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 0 50 | 51 | 52 | QLayout::SetFixedSize 53 | 54 | 55 | 56 | 57 | 58 | 20 59 | 20 60 | 61 | 62 | 63 | + 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 20 72 | 20 73 | 74 | 75 | 76 | - 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 20 85 | 20 86 | 87 | 88 | 89 | /\ 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 20 98 | 20 99 | 100 | 101 | 102 | \/ 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | Action Type: 118 | 119 | 120 | actionType 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 0 129 | 0 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 0 140 | 141 | 142 | 143 | 144 | 0 145 | 146 | 147 | 148 | 149 | Find 150 | 151 | 152 | 153 | 154 | 155 | 156 | Courier 157 | 158 | 159 | 160 | QTextEdit::NoWrap 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 0 173 | 174 | 175 | 176 | 177 | Edit 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | Edit type: 186 | 187 | 188 | editType 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 0 197 | 0 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | Courier 209 | 210 | 211 | 212 | QTextEdit::NoWrap 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 0 225 | 226 | 227 | 228 | 229 | Inline Find 230 | 231 | 232 | 233 | QFormLayout::AllNonFixedFieldsGrow 234 | 235 | 236 | 237 | 238 | Find: 239 | 240 | 241 | inlineFind 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | Courier 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 0 263 | 264 | 265 | 266 | 267 | Inline Edit 268 | 269 | 270 | 271 | 272 | 273 | Edit Type: 274 | 275 | 276 | inlineEditType 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | Edit: 287 | 288 | 289 | inlineEdit 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | Courier 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | QLayout::SetMinAndMaxSize 317 | 318 | 319 | 320 | 321 | Current File: 322 | 323 | 324 | currentFile 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 0 333 | 0 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | currentFile 344 | actionView 345 | actionType 346 | find 347 | editType 348 | edit 349 | inlineFind 350 | inlineEditType 351 | inlineEdit 352 | add 353 | remove 354 | moveUp 355 | moveDown 356 | 357 | 358 | 359 | 360 | actionType 361 | currentIndexChanged(int) 362 | stackedWidget 363 | setCurrentIndex(int) 364 | 365 | 366 | 220 367 | 34 368 | 369 | 370 | 379 371 | 61 372 | 373 | 374 | 375 | 376 | 377 | --------------------------------------------------------------------------------