![]() |
XML Mill
1.0.0
A GUI based XML editor with a memory.
|
00001 /* Copyright (c) 2012 - 2013 by William Hallatt. 00002 * 00003 * This file forms part of "XML Mill". 00004 * 00005 * The official website for this project is <http://www.goblincoding.com> and, 00006 * although not compulsory, it would be appreciated if all works of whatever 00007 * nature using this source code (in whole or in part) include a reference to 00008 * this site. 00009 * 00010 * Should you wish to contact me for whatever reason, please do so via: 00011 * 00012 * <http://www.goblincoding.com/contact> 00013 * 00014 * This program is free software: you can redistribute it and/or modify it under 00015 * the terms of the GNU General Public License as published by the Free Software 00016 * Foundation, either version 3 of the License, or (at your option) any later 00017 * version. 00018 * 00019 * This program is distributed in the hope that it will be useful, but WITHOUT 00020 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00021 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along with 00024 * this program (GNUGPL.txt). If not, see 00025 * 00026 * <http://www.gnu.org/licenses/> 00027 */ 00028 00029 #ifndef GCMAINWINDOW_H 00030 #define GCMAINWINDOW_H 00031 00032 #include <QMainWindow> 00033 #include <QHash> 00034 #include <QDomElement> 00035 00036 namespace Ui 00037 { 00038 class GCMainWindow; 00039 } 00040 00041 class GCDBSessionManager; 00042 class GCTreeWidgetItem; 00043 class QSignalMapper; 00044 class QTableWidgetItem; 00045 class QComboBox; 00046 class QTimer; 00047 class QLabel; 00048 class QMovie; 00049 00073 00074 00082 class GCMainWindow : public QMainWindow 00083 { 00084 Q_OBJECT 00085 00086 public: 00088 explicit GCMainWindow( QWidget* parent = 0 ); 00089 00091 ~GCMainWindow(); 00092 00093 protected: 00096 void closeEvent( QCloseEvent* event ); 00097 00098 private slots: 00102 void initialise(); 00103 00106 void elementChanged( GCTreeWidgetItem* item, int column ); 00107 00114 void elementSelected( GCTreeWidgetItem* item, int column ); 00115 00125 void attributeChanged( QTableWidgetItem* tableItem ); 00126 00133 void attributeSelected( QTableWidgetItem* tableItem ); 00134 00144 void attributeValueChanged( const QString& value ); 00145 00154 void setCurrentComboBox( QWidget* combo ); 00155 00162 bool openXMLFile(); 00163 00170 void newXMLFile(); 00171 00180 bool saveXMLFile(); 00181 00190 bool saveXMLFileAs(); 00191 00198 void closeXMLFile(); 00199 00203 void saveTempFile(); 00204 00211 void importXMLFromFile(); 00212 00218 void addNewDatabase(); 00219 00225 void addExistingDatabase(); 00226 00232 void removeDatabase(); 00233 00239 void switchActiveDatabase(); 00240 00246 void activeDatabaseChanged( QString dbName ); 00247 00255 void addElementToDocument(); 00256 00262 void addSnippetToDocument(); 00263 00268 void insertSnippet( GCTreeWidgetItem* treeItem, QDomElement element ); 00269 00273 void removeItemsFromDB(); 00274 00278 void addItemsToDB(); 00279 00283 void searchDocument(); 00284 00287 void itemFound( GCTreeWidgetItem* item ); 00288 00292 void commentOut( const QList< int >& indices, const QString& comment ); 00293 00296 void rebuild(); 00297 00300 void updateComment( const QString& comment ); 00301 00304 void collapseOrExpandTreeWidget( bool checked ); 00305 00307 void uncheckExpandAll(); 00308 00311 void forgetMessagePreferences(); 00312 00316 void createSpinner(); 00317 00320 void resetDOM(); 00321 00324 void showEmptyProfileHelp(); 00325 00327 void showElementHelp(); 00328 00330 void showMainHelp(); 00331 00333 void setShowHelpButtons( bool show ); 00334 00336 void setShowTreeItemsVerbose( bool verbose ); 00337 00339 void goToSite(); 00340 00342 void useDarkTheme( bool dark ); 00343 00344 private: 00347 GCDBSessionManager* createDBSessionManager(); 00348 00351 void processDOMDoc(); 00352 00354 void setStatusBarMessage( const QString& message ); 00355 00358 void setTextEditContent( GCTreeWidgetItem* item = 0 ); 00359 00362 void highlightTextElement( GCTreeWidgetItem* item ); 00363 00366 void insertEmptyTableRow(); 00367 00369 void resetTableWidget(); 00370 00372 void startSaveTimer(); 00373 00376 void toggleAddElementWidgets(); 00377 00381 void querySetActiveSession( QString reason ); 00382 00385 void readSettings(); 00386 00389 void saveSettings(); 00390 00394 bool queryResetDOM( const QString& resetReason ); 00395 00398 bool importXMLToDatabase(); 00399 00402 void deleteSpinner(); 00403 00409 void queryRestoreFiles(); 00410 00414 void deleteTempFile(); 00415 00416 Ui::GCMainWindow* ui; 00417 QSignalMapper* m_signalMapper; 00418 QTableWidgetItem* m_activeAttribute; 00419 QWidget* m_currentCombo; 00420 QTimer* m_saveTimer; 00421 QLabel* m_activeProfileLabel; 00422 QLabel* m_progressLabel; 00423 QMovie* m_spinner; 00424 QString m_currentXMLFileName; 00425 QString m_activeAttributeName; 00426 bool m_wasTreeItemActivated; 00427 bool m_newAttributeAdded; 00428 bool m_busyImporting; 00429 bool m_fileContentsChanged; 00430 00431 QHash< QWidget*, int /* table row*/ > m_comboBoxes; 00432 }; 00433 00434 #endif // GCMAINWINDOW_H