From 5fe70cdf799cf7063df26fea9036c560cfa20ff4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Mon, 28 Nov 2011 13:33:36 +0200 Subject: [PATCH 01/16] Improved canceling and terminating the worker thread. * The search is now also canceled when the thread is busy reading a large file; * Fixed a deadlock situation where the thread was waiting on the wait condition, but there was nobody to wake it up. --- src/apps/FileFinder/Engine/engine.cpp | 25 ++++++++++++++++++++++--- src/apps/FileFinder/Engine/engine.h | 2 ++ src/apps/FileFinder/Engine/version.h | 4 ++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/apps/FileFinder/Engine/engine.cpp b/src/apps/FileFinder/Engine/engine.cpp index b9fae0e..8ed0f7c 100644 --- a/src/apps/FileFinder/Engine/engine.cpp +++ b/src/apps/FileFinder/Engine/engine.cpp @@ -235,6 +235,13 @@ Internal::Worker::Worker(QObject * parent) , mBusy(false) { setObjectName(QString("%1.Worker").arg(VER_MODULE_NAME_STR)); + + EVAF_INFO("%s created", qPrintable(objectName())); +} + +Internal::Worker::~Worker() +{ + EVAF_INFO("%s destroyed", qPrintable(objectName())); } void Internal::Worker::cancel() @@ -278,6 +285,9 @@ void Internal::Worker::run() forever { QMutexLocker lock(&mLock); + if (mDoTerminate) + break; + mSomethingToDo.wait(&mLock); if (mDoTerminate) @@ -304,8 +314,10 @@ void Internal::Worker::run() lock.relock(); mBusy = false; + bool c = mDoCancel; + lock.unlock(); - emit finished(mDoCancel); + emit finished(c); } } } @@ -325,7 +337,7 @@ void Internal::Worker::recursiveSearch(QString const & path) { QMutexLocker l(&mLock); if (mDoCancel) - break; + return; } // Check for the file name to match the include filter and not the exclude filter @@ -355,6 +367,13 @@ void Internal::Worker::recursiveSearch(QString const & path) QByteArray buf; while (!f.atEnd() && (includeFilterMatched <= 0 || excludeFilterMatched <= 0)) { + // Check for the cancel flag + { + QMutexLocker l(&mLock); + if (mDoCancel) + return; + } + /* We read ReadBufferSize bytes from the file and append to the buffer. * We keep max 2 x ReadBufferSize bytes in the buffer and throw away the oldest * ReadBufferSize bytes of data. Every block is checked twice, but we make sure that @@ -388,7 +407,7 @@ void Internal::Worker::recursiveSearch(QString const & path) { QMutexLocker l(&mLock); if (mDoCancel) - break; + return; } recursiveSearch(l + directory); diff --git a/src/apps/FileFinder/Engine/engine.h b/src/apps/FileFinder/Engine/engine.h index 384fa40..341df0a 100644 --- a/src/apps/FileFinder/Engine/engine.h +++ b/src/apps/FileFinder/Engine/engine.h @@ -181,6 +181,8 @@ public: Worker(QObject * parent = 0); + virtual ~Worker(); + /** * Starts a new search. * @param dir Directory where to search diff --git a/src/apps/FileFinder/Engine/version.h b/src/apps/FileFinder/Engine/version.h index 5e2f8ae..2a39815 100644 --- a/src/apps/FileFinder/Engine/version.h +++ b/src/apps/FileFinder/Engine/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,1 +#define VER_FILE_VERSION 0,1,2,2 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.1\0" +#define VER_FILE_VERSION_STR "0.1.2.2\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 7eca3433b1db8f2bcc61fa8db60bc7546f5cb578 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Mon, 28 Nov 2011 13:36:28 +0200 Subject: [PATCH 02/16] * Added auto-completor to the directory field * Limited the number of history items that are stored * Search fields are disabled while the search is ongoing. --- src/apps/FileFinder/GUI/gui.cpp | 59 +++++++++++++++++++++++++------ src/apps/FileFinder/GUI/gui.h | 8 +++++ src/apps/FileFinder/GUI/version.h | 4 +-- 3 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/apps/FileFinder/GUI/gui.cpp b/src/apps/FileFinder/GUI/gui.cpp index a849da9..29dcd71 100644 --- a/src/apps/FileFinder/GUI/gui.cpp +++ b/src/apps/FileFinder/GUI/gui.cpp @@ -75,6 +75,8 @@ void FileFinder::GUI::Internal::MainWidget::keyPressEvent(QKeyEvent * e) //------------------------------------------------------------------- +int const FileFinder::GUI::Module::MaxHistoryItems = 20; + FileFinder::GUI::Module::Module() : Plugins::iPlugin() , mReady(false) @@ -138,6 +140,8 @@ void FileFinder::GUI::Module::done() { mReady = false; + mFinder = 0; + /* * Widgets are deleted by the SdiWindow module. We use wMain to track calls to done() without * proper init(). @@ -155,27 +159,27 @@ void FileFinder::GUI::Module::saveHistory() QSettings settings(VER_COMPANY_NAME_STR, Common::iApp::instance()->name()); QStringList t; - for (int i = 0; i < wDirectory->count(); ++i) + for (int i = 0; i < wDirectory->count() && i < MaxHistoryItems; ++i) t.append(wDirectory->itemText(i)); settings.setValue("FileFinder/Directories", t); t.clear(); - for (int i = 0; i < wIncludeNames->count(); ++i) + for (int i = 0; i < wIncludeNames->count() && i < MaxHistoryItems; ++i) t.append(wIncludeNames->itemText(i)); settings.setValue("FileFinder/IncludeNames", t); t.clear(); - for (int i = 0; i < wExcludeNames->count(); ++i) + for (int i = 0; i < wExcludeNames->count() && i < MaxHistoryItems; ++i) t.append(wExcludeNames->itemText(i)); settings.setValue("FileFinder/ExcludeNames", t); t.clear(); - for (int i = 0; i < wIncludeContent->count(); ++i) + for (int i = 0; i < wIncludeContent->count() && i < MaxHistoryItems; ++i) t.append(wIncludeContent->itemText(i)); settings.setValue("FileFinder/IncludeContent", t); t.clear(); - for (int i = 0; i < wExcludeContent->count(); ++i) + for (int i = 0; i < wExcludeContent->count() && i < MaxHistoryItems; ++i) t.append(wExcludeContent->itemText(i)); settings.setValue("FileFinder/ExcludeContent", t); @@ -187,6 +191,7 @@ void FileFinder::GUI::Module::loadHistory() wDirectory->addItems(settings.value("FileFinder/Directories").toStringList()); wDirectory->setEditText(QDir::currentPath()); + mDirModel->setRootPath(QDir::currentPath()); wIncludeNames->addItems(settings.value("FileFinder/IncludeNames").toStringList()); wIncludeNames->setEditText(""); @@ -216,12 +221,17 @@ void FileFinder::GUI::Module::createWidgets() wDirectory->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); wDirectory->setEditable(true); wDirectory->setInsertPolicy(QComboBox::InsertAtTop); + QCompleter * completer = new QCompleter(wMain); + mDirModel = new QFileSystemModel(wMain); + mDirModel->setFilter(QDir::AllDirs | QDir::Dirs | QDir::NoDotAndDotDot); + completer->setModel(mDirModel); + wDirectory->setCompleter(completer); l->setBuddy(wDirectory); hbox->addWidget(wDirectory); - QPushButton * btn = new QPushButton(tr("&Browse")); - connect(btn, SIGNAL(clicked()), this, SLOT(browseDirectory())); - hbox->addWidget(btn); + wBrowse = new QPushButton(tr("&Browse")); + connect(wBrowse, SIGNAL(clicked()), this, SLOT(browseDirectory())); + hbox->addWidget(wBrowse); wRecursive = new QCheckBox(tr("&Recursive")); wRecursive->setChecked(true); @@ -286,7 +296,7 @@ void FileFinder::GUI::Module::createWidgets() connect(wFind, SIGNAL(clicked()), this, SLOT(find())); hbox->addWidget(wFind); - btn = new QPushButton(tr("&Close")); + QPushButton * btn = new QPushButton(tr("&Close")); connect(btn, SIGNAL(clicked()), qApp, SLOT(quit())); hbox->addWidget(btn); } @@ -323,7 +333,27 @@ void FileFinder::GUI::Module::find() } else { wResults->clear(); - + + if (wDirectory->findText(wDirectory->currentText()) == -1) + wDirectory->insertItem(0, wDirectory->currentText()); + if (wIncludeNames->findText(wIncludeNames->currentText()) == -1) + wIncludeNames->insertItem(0, wIncludeNames->currentText()); + if (wExcludeNames->findText(wExcludeNames->currentText()) == -1) + wExcludeNames->insertItem(0, wExcludeNames->currentText()); + if (wIncludeContent->findText(wIncludeContent->currentText()) == -1) + wIncludeContent->insertItem(0, wIncludeContent->currentText()); + if (wExcludeContent->findText(wExcludeContent->currentText()) == -1) + wExcludeContent->insertItem(0, wExcludeContent->currentText()); + + // Disable input fields + wDirectory->setEnabled(false); + wBrowse->setEnabled(false); + wRecursive->setEnabled(false); + wIncludeNames->setEnabled(false); + wExcludeNames->setEnabled(false); + wIncludeContent->setEnabled(false); + wExcludeContent->setEnabled(false); + mFinder->search(wDirectory->currentText(), wRecursive->isChecked(), FileFinder::Filter( @@ -351,6 +381,15 @@ void FileFinder::GUI::Module::finished(bool canceled) { Q_UNUSED(canceled) + // Enable input fields + wDirectory->setEnabled(true); + wBrowse->setEnabled(true); + wRecursive->setEnabled(true); + wIncludeNames->setEnabled(true); + wExcludeNames->setEnabled(true); + wIncludeContent->setEnabled(true); + wExcludeContent->setEnabled(true); + wFind->setText(tr("&Search")); } diff --git a/src/apps/FileFinder/GUI/gui.h b/src/apps/FileFinder/GUI/gui.h index 809dab1..e4c0c8e 100644 --- a/src/apps/FileFinder/GUI/gui.h +++ b/src/apps/FileFinder/GUI/gui.h @@ -33,6 +33,7 @@ class QComboBox; class QPushButton; class QListWidget; class QAction; +class QFileSystemModel; namespace eVaf { namespace SdiWindow { @@ -113,6 +114,9 @@ private slots: private: // Members + /// Max number of items in each field that we save + static int const MaxHistoryItems; + /// Flag indicating that the module is ready bool mReady; @@ -126,6 +130,7 @@ private: // Members /// Widgets on the screen Internal::MainWidget * wMain; QComboBox * wDirectory; + QPushButton * wBrowse; QCheckBox * wRecursive; QComboBox * wIncludeNames; QComboBox * wExcludeNames; @@ -134,6 +139,9 @@ private: // Members QListWidget * wResults; QPushButton * wFind; + /// File system auto-completion model for the directory field + QFileSystemModel * mDirModel; + private: // Methods diff --git a/src/apps/FileFinder/GUI/version.h b/src/apps/FileFinder/GUI/version.h index 745d9c7..dd5c198 100644 --- a/src/apps/FileFinder/GUI/version.h +++ b/src/apps/FileFinder/GUI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,1 +#define VER_FILE_VERSION 0,1,2,2 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.1\0" +#define VER_FILE_VERSION_STR "0.1.2.2\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 5748bd7fdfa26ef2dd56735f2b7f77ad02c16ae0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 15:01:36 +0200 Subject: [PATCH 03/16] Added the GuiLib library and the Gui::Window class. The GuiLib library contains common GUI functions and classes. The Gui::Window class is the common ancestor for all the eVaf windows. --- src/libs/CMakeLists.txt | 1 + src/libs/Gui/CMakeLists.txt | 37 +++++++++++++++++++++++ src/libs/Gui/Window | 1 + src/libs/Gui/libgui.h | 30 +++++++++++++++++++ src/libs/Gui/version.h | 60 +++++++++++++++++++++++++++++++++++++ src/libs/Gui/version.rc | 54 +++++++++++++++++++++++++++++++++ src/libs/Gui/window.cpp | 31 +++++++++++++++++++ src/libs/Gui/window.h | 60 +++++++++++++++++++++++++++++++++++++ 8 files changed, 274 insertions(+) create mode 100644 src/libs/Gui/CMakeLists.txt create mode 100644 src/libs/Gui/Window create mode 100644 src/libs/Gui/libgui.h create mode 100644 src/libs/Gui/version.h create mode 100644 src/libs/Gui/version.rc create mode 100644 src/libs/Gui/window.cpp create mode 100644 src/libs/Gui/window.h diff --git a/src/libs/CMakeLists.txt b/src/libs/CMakeLists.txt index 918e3ce..09e2f82 100644 --- a/src/libs/CMakeLists.txt +++ b/src/libs/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(Plugins) add_subdirectory(Common) +add_subdirectory(Gui) diff --git a/src/libs/Gui/CMakeLists.txt b/src/libs/Gui/CMakeLists.txt new file mode 100644 index 0000000..fab0577 --- /dev/null +++ b/src/libs/Gui/CMakeLists.txt @@ -0,0 +1,37 @@ +# Name of the target +set(TARGET GuiLib) + +# Qt modules +include(${QT_USE_FILE}) + +# Needed for exporting/importing symbols +add_definitions(-DGUI_LIBRARY) + +# Include files +include_directories(${eVaf_INCLUDE}) + +# Required eVaf libraries +set(eVaf_LIBRARIES) + +# Source files +set(SRCS + window.cpp +) + +# Header files for the meta-object compiler +set(MOC_HDRS + window.h +) + +# Version info resource file for Windows builds +if(WIN32) + set(SRCS ${SRCS} version.rc) +endif(WIN32) + +qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) + +add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS}) + +target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES}) + +install(TARGETS ${TARGET} DESTINATION bin) diff --git a/src/libs/Gui/Window b/src/libs/Gui/Window new file mode 100644 index 0000000..80b3d1c --- /dev/null +++ b/src/libs/Gui/Window @@ -0,0 +1 @@ +#include "window.h" diff --git a/src/libs/Gui/libgui.h b/src/libs/Gui/libgui.h new file mode 100644 index 0000000..b67d9be --- /dev/null +++ b/src/libs/Gui/libgui.h @@ -0,0 +1,30 @@ +/** + * @file Gui/libgui.h + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __GUI_LIBCOMMON_H +# define __GUI_LIBCOMMON_H + +#include + +#if defined(GUI_LIBRARY) +# define GUI_EXPORT Q_DECL_EXPORT +#else +# define GUI_EXPORT Q_DECL_IMPORT +#endif + +#endif // libgui.h diff --git a/src/libs/Gui/version.h b/src/libs/Gui/version.h new file mode 100644 index 0000000..a298704 --- /dev/null +++ b/src/libs/Gui/version.h @@ -0,0 +1,60 @@ +/** + * @file Gui/version.h + * @brief Version information for eVaf modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __GUI_VERSION_H +# define __GUI_VERSION_H + +#include + +/** + * Module/library version number in the form major,minor,release,build + */ +#define VER_FILE_VERSION 0,1,1,1 + +/** + * Module/library version number in the string format (shall end with \0) + */ +#define VER_FILE_VERSION_STR "0.1.1.1\0" + +/** + * Module/library name (shall end with \0) + */ +#define VER_MODULE_NAME_STR "GuiLib\0" + +/** + * Module type (see version_rc.h for all the types) + */ +#define VER_MODULE_TYPE MT_GENERIC + +/** + * Module type in the string format (see version_rc for all the types) + */ +#define VER_MODULE_TYPE_STR MT_GENERIC + +/** + * Original file name for windows (shall end with \0) + */ +#define VER_ORIGINAL_FILE_NAME_STR "GuiLib.dll\0" + +/** + * Description of the module/library (shall end with \0) + */ +#define VER_FILE_DESCRIPTION_STR "Library for eVaf applications implementing common GUI interfaces, functions and classes.\0" + +#endif // version.h diff --git a/src/libs/Gui/version.rc b/src/libs/Gui/version.rc new file mode 100644 index 0000000..dc65d89 --- /dev/null +++ b/src/libs/Gui/version.rc @@ -0,0 +1,54 @@ +/** + * @file Gui/version.rc + * @brief Windows resource file with module/library version information. + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "version.h" +#include +#include + + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VER_FILE_VERSION + PRODUCTVERSION VER_PRODUCT_VERSION + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0x0L + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", VER_COMPANY_NAME_STR + VALUE "FileDescription", VER_FILE_DESCRIPTION_STR + VALUE "FileVersion", VER_FILE_VERSION_STR + VALUE "LegalCopyright", VER_LEGAL_COPYRIGHT_STR + VALUE "OriginalFilename", VER_ORIGINAL_FILE_NAME_STR + VALUE "ProductName", VER_PRODUCT_NAME_STR + VALUE "ProductVersion", VER_PRODUCT_VERSION_STR + VALUE "Build Date", VER_PRODUCT_DATE_STR + VALUE "Module Name", VER_MODULE_NAME_STR + VALUE "Module Type", VER_MODULE_TYPE_STR + END + END + END diff --git a/src/libs/Gui/window.cpp b/src/libs/Gui/window.cpp new file mode 100644 index 0000000..880e118 --- /dev/null +++ b/src/libs/Gui/window.cpp @@ -0,0 +1,31 @@ +/** + * @file Gui/window.cpp + * @brief Version information for eVaf modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#include "window.h" + +using namespace eVaf; + +//------------------------------------------------------------------- + +Gui::Window::Window(QWidget * parent) + : QWidget(parent) +{} + +Gui::Window::~Window() +{} diff --git a/src/libs/Gui/window.h b/src/libs/Gui/window.h new file mode 100644 index 0000000..07d3bd3 --- /dev/null +++ b/src/libs/Gui/window.h @@ -0,0 +1,60 @@ +/** + * @file Gui/window.h + * @brief Version information for eVaf modules + * @author Enar Vaikene + * + * Copyright (c) 2011 Enar Vaikene + * + * This file is part of the eVaf C++ cross-platform application development framework. + * + * This file can be used under the terms of the GNU General Public License + * version 3.0 as published by the Free Software Foundation and appearing in + * the file LICENSE included in the packaging of this file. Please review the + * the following information to ensure the GNU General Public License version + * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + * + * Alternatively, this file may be used in accordance with the Commercial License + * Agreement provided with the Software. + */ + +#ifndef __GUI_WINDOW_H +# define __GUI_WINDOW_H + +#include "libgui.h" + +#include + +namespace eVaf { + +/** + * Common eVaf GUI library. + * + * This library contains common Graphical User Interface functions and classes for eVaf applications. + * This library is a required dependency for all the eVaf modules that implement elements of the GUI. + */ +namespace Gui { + +/** + * eVaf GUI window class. + * @code#include @endcode + * + * The Gui::Window class is a common ancestor for all the windows in eVaf applications. Objects of Gui::Window class + * can be added to one of the eVaf Window managers. + */ +class GUI_EXPORT Window : public QWidget +{ + Q_OBJECT + +public: + + Window(QWidget * parent = 0); + + virtual ~Window(); + +}; + +} // namespace eVaf::Gui +} // namespace eVaf + + +#endif // window.h -- 2.45.2 From 6e9c71587aab47ea6c2a5913ce28c03109fb8e14 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 15:05:19 +0200 Subject: [PATCH 04/16] Documentation fixes. --- src/libs/Gui/window.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Gui/window.h b/src/libs/Gui/window.h index 07d3bd3..15c426a 100644 --- a/src/libs/Gui/window.h +++ b/src/libs/Gui/window.h @@ -38,8 +38,8 @@ namespace Gui { * eVaf GUI window class. * @code#include @endcode * - * The Gui::Window class is a common ancestor for all the windows in eVaf applications. Objects of Gui::Window class - * can be added to one of the eVaf Window managers. + * The Gui::Window class is a common ancestor for all the eVaf windows. eVaf applications can have different window managers + * that manage Gui::Window objects. */ class GUI_EXPORT Window : public QWidget { -- 2.45.2 From 54f282ee6797c05e60993632218875092362bdf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 15:05:41 +0200 Subject: [PATCH 05/16] Changed the SdiWindow::iSdiWindow interface. The SdiWindow module is now a simple window manager that manages Gui::Window objects. Adding individual widgets and layouts is no more supported. The idea is that the same Gui::Window object could be added to many different window managers, not only the SdiWindow. --- src/plugins/SdiWindow/CMakeLists.txt | 2 +- src/plugins/SdiWindow/isdiwindow.h | 28 ++++++++++++---------------- src/plugins/SdiWindow/sdiwindow.cpp | 24 +++++++++--------------- src/plugins/SdiWindow/sdiwindow.h | 11 +++++------ src/plugins/SdiWindow/version.h | 4 ++-- 5 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/plugins/SdiWindow/CMakeLists.txt b/src/plugins/SdiWindow/CMakeLists.txt index b1a9c79..c87eed6 100644 --- a/src/plugins/SdiWindow/CMakeLists.txt +++ b/src/plugins/SdiWindow/CMakeLists.txt @@ -11,7 +11,7 @@ add_definitions(-DSDIWINDOW_LIBRARY) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib) +set(eVaf_LIBRARIES CommonLib PluginsLib GuiLib) # Source files set(SRCS diff --git a/src/plugins/SdiWindow/isdiwindow.h b/src/plugins/SdiWindow/isdiwindow.h index 28e774d..13b9903 100644 --- a/src/plugins/SdiWindow/isdiwindow.h +++ b/src/plugins/SdiWindow/isdiwindow.h @@ -29,13 +29,17 @@ class QWidget; class QLayout; namespace eVaf { + +namespace Gui { + class Window; +} // namespace eVaf::Gui + namespace SdiWindow { /** - * Main window interface for eVaf applications implementing the Single Document Interface. + * Single Document Interface window manager for eVaf applications. * - * The iSdiWindow interface provides access to the SDI main window. The SDI main window is - * an empty window that the application can fill with widgets. + * The iSdiWindow interface implements an SDI window manager. */ struct SDIWINDOW_EXPORT iSdiWindow { @@ -50,26 +54,18 @@ struct SDIWINDOW_EXPORT iSdiWindow static iSdiWindow * instance(); /** - * Adds the widget to the end of the main window layout - * @param widget The widget - * - * This function adds the widget to the end of the main window layout. - */ - virtual void addWidget(QWidget * widget) = 0; - - /** - * Adds the layout to the end of the main window layout - * @param layout The layout + * Adds the window to the main SDI window + * @param window The window * - * This function adds the new layout to the end of the main window layout. + * This function adds a window to the main SDI layout. */ - virtual void addLayout(QLayout * layout) = 0; + virtual void addWindow(Gui::Window * window) = 0; }; } // namespace eVaf::SdiWindow } // namespace eVaf -Q_DECLARE_INTERFACE(eVaf::SdiWindow::iSdiWindow, "eVaf.SdiWindow.iSdiWindow/1.0") +Q_DECLARE_INTERFACE(eVaf::SdiWindow::iSdiWindow, "eVaf.SdiWindow.iSdiWindow/1.1") #endif // isdiwindow.h diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp index aba9ce2..aa264de 100644 --- a/src/plugins/SdiWindow/sdiwindow.cpp +++ b/src/plugins/SdiWindow/sdiwindow.cpp @@ -106,26 +106,20 @@ void MainWindow::done() close(); - // Delete all the items added to the main window - while (mItemsAdded.count() > 0) { - QWeakPointer item = mItemsAdded.takeAt(0); - if (!item.isNull()) - delete item.data(); - } + // Delete the window + if (mWindow) + delete mWindow.data(); EVAF_INFO("%s finalized", qPrintable(objectName())); } -void MainWindow::addWidget(QWidget * widget) -{ - mLayout->addWidget(widget); - mItemsAdded.append(widget); -} - -void MainWindow::addLayout(QLayout * layout) +void MainWindow::addWindow(Gui::Window * window) { - mLayout->addLayout(layout); - mItemsAdded.append(layout); + // Delete the existing window + if (mWindow) + delete mWindow.data(); + mLayout->addWidget(window); + mWindow = window; } void MainWindow::saveSettings() diff --git a/src/plugins/SdiWindow/sdiwindow.h b/src/plugins/SdiWindow/sdiwindow.h index f0cfe6f..f884255 100644 --- a/src/plugins/SdiWindow/sdiwindow.h +++ b/src/plugins/SdiWindow/sdiwindow.h @@ -23,6 +23,7 @@ #include "isdiwindow.h" #include +#include #include #include @@ -56,9 +57,7 @@ public: virtual bool isReady() { return mReady; } - virtual void addWidget(QWidget * widget); - - virtual void addLayout(QLayout * layout); + virtual void addWindow(Gui::Window * window); private: // Methods @@ -75,11 +74,11 @@ private: // Members /// Ready flag bool mReady; - /// The layout of the window + /// The layout of the main window QVBoxLayout * mLayout; - /// Widgets and layouts added to the main window - QList > mItemsAdded; + /// eVaf GUI window implementing the main window + QWeakPointer mWindow; }; diff --git a/src/plugins/SdiWindow/version.h b/src/plugins/SdiWindow/version.h index 9671900..f3fedec 100644 --- a/src/plugins/SdiWindow/version.h +++ b/src/plugins/SdiWindow/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,4,5 +#define VER_FILE_VERSION 0,3,1,6 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.4.5\0" +#define VER_FILE_VERSION_STR "0.3.1.6\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 25d800db07942aadab4140a4ed05196e7f4dcd12 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 15:08:04 +0200 Subject: [PATCH 06/16] Changed to use the Gui::Window class instead of QWidget. --- src/apps/FileFinder/GUI/CMakeLists.txt | 2 +- src/apps/FileFinder/GUI/gui.cpp | 2 +- src/apps/FileFinder/GUI/gui.h | 5 +++-- src/apps/FileFinder/GUI/version.h | 4 ++-- src/apps/PswGen/GUI/CMakeLists.txt | 2 +- src/apps/PswGen/GUI/gui.cpp | 5 +++-- src/apps/PswGen/GUI/version.h | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/apps/FileFinder/GUI/CMakeLists.txt b/src/apps/FileFinder/GUI/CMakeLists.txt index a29d09f..cdc585f 100644 --- a/src/apps/FileFinder/GUI/CMakeLists.txt +++ b/src/apps/FileFinder/GUI/CMakeLists.txt @@ -8,7 +8,7 @@ include(${QT_USE_FILE}) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib) +set(eVaf_LIBRARIES CommonLib PluginsLib GuiLib) # Source files set(SRCS diff --git a/src/apps/FileFinder/GUI/gui.cpp b/src/apps/FileFinder/GUI/gui.cpp index 29dcd71..260b6c8 100644 --- a/src/apps/FileFinder/GUI/gui.cpp +++ b/src/apps/FileFinder/GUI/gui.cpp @@ -118,7 +118,7 @@ bool FileFinder::GUI::Module::init(QString const & args) // Create the main widget for this window wMain = new Internal::MainWidget; connect(wMain, SIGNAL(quit()), qApp, SLOT(quit())); - win->addWidget(wMain); + win->addWindow(wMain); // Create actions for the window and widgets on it createActions(); diff --git a/src/apps/FileFinder/GUI/gui.h b/src/apps/FileFinder/GUI/gui.h index e4c0c8e..02f4f22 100644 --- a/src/apps/FileFinder/GUI/gui.h +++ b/src/apps/FileFinder/GUI/gui.h @@ -21,6 +21,7 @@ # define __FILEFINDER_GUI_GUI_H #include +#include #include #include @@ -48,14 +49,14 @@ namespace Internal { /** * Main widget for the FileFinder window */ -class MainWidget : public QWidget +class MainWidget : public Gui::Window { Q_OBJECT public: MainWidget(QWidget * parent = 0) - : QWidget(parent) + : Gui::Window(parent) {} virtual void keyPressEvent(QKeyEvent * e); diff --git a/src/apps/FileFinder/GUI/version.h b/src/apps/FileFinder/GUI/version.h index dd5c198..733a6f5 100644 --- a/src/apps/FileFinder/GUI/version.h +++ b/src/apps/FileFinder/GUI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,2,2 +#define VER_FILE_VERSION 0,1,3,3 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.2.2\0" +#define VER_FILE_VERSION_STR "0.1.3.3\0" /** * Module/library name (shall end with \0) diff --git a/src/apps/PswGen/GUI/CMakeLists.txt b/src/apps/PswGen/GUI/CMakeLists.txt index 329cd17..bea3cd6 100644 --- a/src/apps/PswGen/GUI/CMakeLists.txt +++ b/src/apps/PswGen/GUI/CMakeLists.txt @@ -8,7 +8,7 @@ include(${QT_USE_FILE}) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib) +set(eVaf_LIBRARIES CommonLib PluginsLib GuiLib) # Source files set(SRCS diff --git a/src/apps/PswGen/GUI/gui.cpp b/src/apps/PswGen/GUI/gui.cpp index 23a3c88..706522b 100644 --- a/src/apps/PswGen/GUI/gui.cpp +++ b/src/apps/PswGen/GUI/gui.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -74,8 +75,8 @@ bool Module::init(QString const & args) SdiWindow::iSdiWindow * win = evafQueryInterface("iSdiWindow"); EVAF_TEST_X(win, "No iSdiWindow interface"); - QWidget * masterWidget = new QWidget; - win->addWidget(masterWidget); + Gui::Window * masterWidget = new Gui::Window; + win->addWindow(masterWidget); QVBoxLayout * v = new QVBoxLayout; masterWidget->setLayout(v); diff --git a/src/apps/PswGen/GUI/version.h b/src/apps/PswGen/GUI/version.h index c4fbd22..8d9aad3 100644 --- a/src/apps/PswGen/GUI/version.h +++ b/src/apps/PswGen/GUI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,3,4 +#define VER_FILE_VERSION 0,1,4,5 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.3.4\0" +#define VER_FILE_VERSION_STR "0.1.4.5\0" /** * Module/library name (shall end with \0) -- 2.45.2 From b280102618ec2ced838a092ba7673964ab272569 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 16:04:10 +0200 Subject: [PATCH 07/16] Documentation update. --- src/libs/Common/inifile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Common/inifile.h b/src/libs/Common/inifile.h index 5392984..21a1bc4 100644 --- a/src/libs/Common/inifile.h +++ b/src/libs/Common/inifile.h @@ -59,7 +59,7 @@ namespace Internal { * of different data types: * * @li Bool - '0', 'false', 'off', 'no' are equal to false and '1', 'true', 'on', 'yes' are equal to true; - * @li Char - a single character or an ASCII code as '\0NNN' or '\0xNN'; + * @li Char - a single character or an ASCII code as '\0NNN' (oct) or '\0xNN' (hex); * @li Date - date string in the ISO 8601 format YYYY-MM-DD; * @li DateTime - date and time string in the ISO 8601 format YYY-MM-DDTHH:MM:SSTZD; * @li Double - the decimal point is always '.' regardless of the locale; -- 2.45.2 From 926606ce83f3a702d67c5c2c42478b091f78fdc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 17:00:10 +0200 Subject: [PATCH 08/16] Added functions to convert unicode strings to/from escaped 7-bit character arrays. --- src/libs/Common/util.cpp | 84 +++++++++++++++++++++++++++++++++++++++ src/libs/Common/util.h | 21 ++++++++++ src/libs/Common/version.h | 4 +- 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/src/libs/Common/util.cpp b/src/libs/Common/util.cpp index eeedb61..1a07a4a 100644 --- a/src/libs/Common/util.cpp +++ b/src/libs/Common/util.cpp @@ -97,3 +97,87 @@ QVariant eVaf::Common::toVariant(QString const & value, QVariant const & default return QVariant(value); } } + +QByteArray eVaf::Common::toEscapedString(QString const & str) +{ + QByteArray rval; + foreach (QChar c, str) { + if (c.unicode() < 32 || c.unicode() >= 127) + rval.append("&#" + QByteArray::number(c.unicode()) + ";"); + else if (c == '\"') + rval.append("""); + else if (c == '&') + rval.append("&"); + else if (c == '\'') + rval.append("'"); + else if (c == '<') + rval.append("<"); + else if (c == '>') + rval.append(">"); + else + rval.append((char const)c.unicode()); + } + + return rval; +} + +QString eVaf::Common::fromEscapedString(QByteArray const & str) +{ + QString rval; + + bool e = false; + QByteArray ref; + foreach (char c, str) { + if (!e) { + if (c == '&') { + e = true; + ref = "&"; + } + else + rval.append(QChar((ushort)c)); + } + else { + ref.append(c); + if (c == ';') { + e = false; + ref = ref.toLower(); + + if (ref.startsWith("&#x")) { + // Numeric character reference in the HEX format + bool ok; + ushort ucode = ref.mid(3, ref.size() - 4).toUInt(&ok, 16); + if (ok) + rval.append(QChar(ucode)); + else + // Invalid numeric character reference; output as is + rval.append(ref); + } + else if (ref.startsWith("&#")) { + // Numeric character reference in the DEC format + bool ok; + ushort ucode = ref.mid(2, ref.size() - 3).toUInt(&ok, 10); + if (ok) + rval.append(QChar(ucode)); + else + // Invalid numeric character reference; output as is + rval.append(ref); + } + else if (ref == """) + rval.append('\"'); + else if (ref == "&") + rval.append('&'); + else if (ref == "'") + rval.append('\''); + else if (ref == "<") + rval.append('<'); + else if (ref == ">") + rval.append('>'); + else + // Unknown reference, output as is + rval.append(ref); + } + } + } + + return rval; +} diff --git a/src/libs/Common/util.h b/src/libs/Common/util.h index 4b5e4c9..de094b3 100644 --- a/src/libs/Common/util.h +++ b/src/libs/Common/util.h @@ -76,6 +76,27 @@ inline bool isFalse(QString const & str) COMMON_EXPORT QVariant toVariant(QString const & value, QVariant const & defaultValue); +/** + * Converts unicode strings to escaped 7-bit character arrays. + * @param str Unicode string + * @return Escaped 7-bit character array + * + * This function converts a unicode (or any) string to the escaped 7-bit character array. Characters that cannot + * be output directly as a printable 7-bit character are output as numeric character references. The result can be + * directly inserted into XML or HTML documents and later converted back with the eVaf::Common::fromEscapedString() + * function. + */ +COMMON_EXPORT QByteArray toEscapedString(QString const & str); + +/** + * Converts escaped 7-bit character arrays to unicode string. + * @param str Escaped 7-bit character array + * @return Unicode string + * + * This function converts an escaped 7-bit character array to a unicode string. Numeric character references and + * character entity references are expanded to actual unicode characters. + */ +COMMON_EXPORT QString fromEscapedString(QByteArray const & str); } // namespace eVaf::Common } // namespace eVaf diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index 30d4175..dc569f4 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,4,7 +#define VER_FILE_VERSION 0,2,1,8 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.4.7\0" +#define VER_FILE_VERSION_STR "0.2.1.8\0" /** * Module/library name (shall end with \0) -- 2.45.2 From bb631d7ca67c86dd758428fb0e18b905514a16e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Wed, 30 Nov 2011 13:08:46 +0200 Subject: [PATCH 09/16] Added functions to escape binary arrays and renamed string escaping functions. --- src/libs/Common/util.cpp | 90 +++++++++++++++++++++++++++++++++++++-- src/libs/Common/util.h | 30 +++++++++++-- src/libs/Common/version.h | 4 +- 3 files changed, 115 insertions(+), 9 deletions(-) diff --git a/src/libs/Common/util.cpp b/src/libs/Common/util.cpp index 1a07a4a..33f6b4d 100644 --- a/src/libs/Common/util.cpp +++ b/src/libs/Common/util.cpp @@ -98,12 +98,12 @@ QVariant eVaf::Common::toVariant(QString const & value, QVariant const & default } } -QByteArray eVaf::Common::toEscapedString(QString const & str) +QByteArray eVaf::Common::strToEscapedCharArray(QString const & str) { QByteArray rval; foreach (QChar c, str) { if (c.unicode() < 32 || c.unicode() >= 127) - rval.append("&#" + QByteArray::number(c.unicode()) + ";"); + rval.append("&#x" + QByteArray::number(c.unicode(), 16) + ";"); else if (c == '\"') rval.append("""); else if (c == '&') @@ -121,7 +121,7 @@ QByteArray eVaf::Common::toEscapedString(QString const & str) return rval; } -QString eVaf::Common::fromEscapedString(QByteArray const & str) +QString eVaf::Common::strFromEscapedCharArray(QByteArray const & str) { QString rval; @@ -181,3 +181,87 @@ QString eVaf::Common::fromEscapedString(QByteArray const & str) return rval; } + +QByteArray eVaf::Common::binToEscapedCharArray(QByteArray const & src) +{ + QByteArray rval; + foreach (uchar c, src) { + if (c < 32 || c >= 127) + rval.append("&#x" + QByteArray::number(c, 16) + ";"); + else if (c == '\"') + rval.append("""); + else if (c == '&') + rval.append("&"); + else if (c == '\'') + rval.append("'"); + else if (c == '<') + rval.append("<"); + else if (c == '>') + rval.append(">"); + else + rval.append(c); + } + + return rval; +} + +QByteArray eVaf::Common::binFromEscapedCharArray(QByteArray const & str) +{ + QByteArray rval; + + bool e = false; + QByteArray ref; + foreach (char c, str) { + if (!e) { + if (c == '&') { + e = true; + ref = "&"; + } + else + rval.append(c); + } + else { + ref.append(c); + if (c == ';') { + e = false; + ref = ref.toLower(); + + if (ref.startsWith("&#x")) { + // Numeric character reference in the HEX format + bool ok; + uchar ucode = ref.mid(3, ref.size() - 4).toUInt(&ok, 16); + if (ok) + rval.append(ucode); + else + // Invalid numeric character reference; output as is + rval.append(ref); + } + else if (ref.startsWith("&#")) { + // Numeric character reference in the DEC format + bool ok; + uchar ucode = ref.mid(2, ref.size() - 3).toUInt(&ok, 10); + if (ok) + rval.append(ucode); + else + // Invalid numeric character reference; output as is + rval.append(ref); + } + else if (ref == """) + rval.append('\"'); + else if (ref == "&") + rval.append('&'); + else if (ref == "'") + rval.append('\''); + else if (ref == "<") + rval.append('<'); + else if (ref == ">") + rval.append('>'); + else + // Unknown reference, output as is + rval.append(ref); + } + } + } + + return rval; +} diff --git a/src/libs/Common/util.h b/src/libs/Common/util.h index de094b3..8237e7c 100644 --- a/src/libs/Common/util.h +++ b/src/libs/Common/util.h @@ -83,20 +83,42 @@ COMMON_EXPORT QVariant toVariant(QString const & value, QVariant const & default * * This function converts a unicode (or any) string to the escaped 7-bit character array. Characters that cannot * be output directly as a printable 7-bit character are output as numeric character references. The result can be - * directly inserted into XML or HTML documents and later converted back with the eVaf::Common::fromEscapedString() + * directly inserted into XML or HTML documents and later converted back with the eVaf::Common::strFromEscapedCharArray() * function. */ -COMMON_EXPORT QByteArray toEscapedString(QString const & str); +COMMON_EXPORT QByteArray strToEscapedCharArray(QString const & str); /** * Converts escaped 7-bit character arrays to unicode string. * @param str Escaped 7-bit character array * @return Unicode string * - * This function converts an escaped 7-bit character array to a unicode string. Numeric character references and + * This function converts an escaped 7-bit character array to the unicode string. Numeric character references and * character entity references are expanded to actual unicode characters. */ -COMMON_EXPORT QString fromEscapedString(QByteArray const & str); +COMMON_EXPORT QString strFromEscapedCharArray(QByteArray const & str); + +/** + * Converts binary arrays to escaped 7-bit character arrays + * @param src Binary array + * @return Escaped 7-bit character array + * + * This function converts a binary array to the escaped 7-bit character array. Bytes that cannot be output + * directly as printable 7-bit characters are output as numeric character references. The result can be directly + * inserted into XML or HTML documents and later converted back with the eVaf::Common::binFromEscapedCharArray() + * function. + */ +COMMON_EXPORT QByteArray binToEscapedCharArray(QByteArray const & src); + +/** + * Converts escaped 7-bit character arrays to binary arrays + * @param str Escaped 7-bit character array + * @return Binary array + * + * This function converts an escaped 7-bit character array to the binary array. Numeric character references and + * character entoty references are expanded to characters and binary bytes. + */ +COMMON_EXPORT QByteArray binFromEscapedCharArray(QByteArray const & str); } // namespace eVaf::Common } // namespace eVaf diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index dc569f4..e6068b9 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,1,8 +#define VER_FILE_VERSION 0,2,2,9 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.1.8\0" +#define VER_FILE_VERSION_STR "0.2.2.9\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 72ea4a16988f1c28e97064222e722f19bc31b3a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Wed, 30 Nov 2011 14:26:14 +0200 Subject: [PATCH 10/16] Changed the Common::IniFile class to work with 7-bit character INI files only. * Strings and byte arrays are now escaped; * Strings and byte arrays can now be in single or double quotes; makes it possible to have leading and trailing spaces. * When saving string or byte array values with leading or trailing spaces, automatically adds double quotes. --- src/libs/Common/config.cpp | 4 +- src/libs/Common/inifile.cpp | 114 ++++++++++++++++++++++++++---------- src/libs/Common/inifile.h | 6 +- src/libs/Common/inifile_p.h | 23 +++++--- src/libs/Common/version.h | 4 +- 5 files changed, 103 insertions(+), 48 deletions(-) diff --git a/src/libs/Common/config.cpp b/src/libs/Common/config.cpp index 610dd74..c4f0997 100644 --- a/src/libs/Common/config.cpp +++ b/src/libs/Common/config.cpp @@ -123,7 +123,7 @@ QVariant Config::getValue(QString const & paramName, QVariant const & defaultVal } // Read the value - return ini->getValue(name, defaultValue); + return ini->getValue(name.toLocal8Bit(), defaultValue); } bool Config::setValue(QString const & paramName, QVariant const & value, bool commit) @@ -198,7 +198,7 @@ bool Config::writeValue(QString const & paramName, QVariant const & value) } // Write the value - if (!ini->setValue(name, value)) + if (!ini->setValue(name.toLocal8Bit(), value)) return false; return true; diff --git a/src/libs/Common/inifile.cpp b/src/libs/Common/inifile.cpp index 14a47ee..838ff72 100644 --- a/src/libs/Common/inifile.cpp +++ b/src/libs/Common/inifile.cpp @@ -56,12 +56,12 @@ QString IniFile::errorString() const return d->errorString(); } -QVariant IniFile::getValue(QString const & paramName, QVariant const & defaultValue) +QVariant IniFile::getValue(QByteArray const & paramName, QVariant const & defaultValue) { return d->getValue(paramName, defaultValue); } -bool IniFile::setValue(QString const & paramName, QVariant const & value) +bool IniFile::setValue(QByteArray const & paramName, QVariant const & value) { return d->setValue(paramName, value); } @@ -99,7 +99,7 @@ IniFileImpl::~IniFileImpl() void IniFileImpl::updateCache(quint64 pos, qint64 diff) { // Walk through all the sections in the cache - QHash >::const_iterator it; + QHash >::const_iterator it; for (it = mCache.constBegin(); it != mCache.constEnd(); ++it) { QExplicitlySharedDataPointer sectionObject = *it; @@ -108,7 +108,7 @@ void IniFileImpl::updateCache(quint64 pos, qint64 diff) sectionObject->filePos += diff; // Update individual values in the section that come after the current file offset - QHash >::const_iterator it1; + QHash >::const_iterator it1; for (it1 = sectionObject->values.constBegin(); it1 != sectionObject->values.constEnd(); ++it1) { QExplicitlySharedDataPointer valueObject = *it1; if (valueObject->filePos > pos) @@ -117,7 +117,7 @@ void IniFileImpl::updateCache(quint64 pos, qint64 diff) } } -QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & file, QString const & sectionName) +QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & file, QByteArray const & sectionName) { // Check for external modifications QFileInfo fi(file); @@ -128,7 +128,7 @@ QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & fil } // Look for the section in the cache first - QHash >::const_iterator it = mCache.constFind(sectionName.toLower()); + QHash >::const_iterator it = mCache.constFind(sectionName.toLower()); if (it != mCache.constEnd()) { // Found in the cache if (mValid) @@ -138,7 +138,7 @@ QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & fil // Read the INI file and look for the section while (mValid && !file.atEnd()) { - QString line = file.readLine().trimmed(); + QByteArray line = file.readLine().trimmed(); // Ignore the line if it is empty, a comment or not a section name if (line.isEmpty() || line.startsWith(';') || line.startsWith('#') || !line.startsWith('[')) @@ -150,7 +150,7 @@ QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & fil continue; // Is this the section that we are looking for? - if (line.mid(1, idx - 1).compare(sectionName, Qt::CaseInsensitive) == 0) { + if (qstricmp(line.mid(1, idx - 1).constData(), sectionName.constData()) == 0) { // Create the section object and add to the cache QExplicitlySharedDataPointer sectionObject(new IniFileSection(file.pos())); sectionObject->name = sectionName.toLower(); @@ -166,10 +166,10 @@ QExplicitlySharedDataPointer IniFileImpl::getSection(QFile & fil return QExplicitlySharedDataPointer(); } -QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & file, IniFileSection & section, QString const & paramName) +QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & file, IniFileSection & section, QByteArray const & paramName) { // Look for the parameter in the cache first - QHash >::const_iterator it = section.values.constFind(paramName.toLower()); + QHash >::const_iterator it = section.values.constFind(paramName.toLower()); if (it != section.values.constEnd()) { // Found it in the cache if (mValid) @@ -183,7 +183,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil // Current file position quint64 currentPos = file.pos(); - QString line = file.readLine().trimmed(); + QByteArray line = file.readLine().trimmed(); // Ignore the line if it is empty or a comment if (line.isEmpty() || line.startsWith(';') || line.startsWith('#')) @@ -202,8 +202,8 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil if (idx == -1) continue; - QString name = line.mid(0, idx).trimmed().toLower(); - QString value = line.mid(idx + 1).trimmed(); + QByteArray name = line.mid(0, idx).trimmed().toLower(); + QByteArray value = line.mid(idx + 1).trimmed(); // Check for the 'windows:' or 'linux:' prefix in the parameter name bool thisOsOnly = false; @@ -226,7 +226,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil // If the parameter value is not in the cache, add it to the cache QExplicitlySharedDataPointer valueObject; - QHash >::const_iterator it = section.values.constFind(name); + QHash >::const_iterator it = section.values.constFind(name); if (it == section.values.constEnd()) { valueObject = new IniFileValue(currentPos); valueObject->name = name; @@ -243,7 +243,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil } // Is this the parameter vwe are looking for? - if (name.compare(paramName, Qt::CaseInsensitive) == 0) { + if (qstricmp(name.constData(), paramName.constData()) == 0) { // Rewind to the beginning of the line file.seek(currentPos); @@ -256,7 +256,7 @@ QExplicitlySharedDataPointer IniFileImpl::getParameter(QFile & fil return QExplicitlySharedDataPointer(); } -QVariant IniFileImpl::getValue(QString const & paramName, QVariant const & defaultValue) +QVariant IniFileImpl::getValue(QByteArray const & paramName, QVariant const & defaultValue) { // Locate the '/' character that separates section names from key names int idx = paramName.lastIndexOf('/'); @@ -264,8 +264,8 @@ QVariant IniFileImpl::getValue(QString const & paramName, QVariant const & defau return defaultValue; // Separate section and key names - QString section = paramName.left(idx); - QString key = paramName.mid(idx + 1); + QByteArray section = paramName.left(idx); + QByteArray key = paramName.mid(idx + 1); // Open the file QFile f(mFileName); @@ -289,10 +289,38 @@ QVariant IniFileImpl::getValue(QString const & paramName, QVariant const & defau if (f.isOpen()) f.close(); - return toVariant(valueObject->paramValue, defaultValue); + // Return the cached value if it is already set and the type is the same than the default value type + if (valueObject->value.isValid() && (!defaultValue.isValid() || valueObject->value.type() == defaultValue.type())) + return valueObject->value; + + // Convert to the proper type + if (defaultValue.type() == QVariant::ByteArray || defaultValue.type() == QVariant::String) { + // Remove single and double quotes + QByteArray v = valueObject->paramValue; + if (v.startsWith('\"')) { + v.remove(0, 1); + if (v.endsWith('\"')) + v.remove(v.size() - 1, 1); + } + else if (v.startsWith('\'')) { + v.remove(0, 1); + if (v.endsWith('\'')) + v.remove(v.size() - 1, 1); + } + + // Convert from the escaped character array + if (defaultValue.type() == QVariant::String) + valueObject->value = QVariant(strFromEscapedCharArray(v)); + else + valueObject->value = QVariant(binFromEscapedCharArray(v)); + } + else + valueObject->value = toVariant(valueObject->paramValue, defaultValue); + + return valueObject->value; } -bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) +bool IniFileImpl::setValue(QByteArray const & paramName, QVariant const & value) { // Locate the '/' character that separates section names from key names int idx = paramName.lastIndexOf('/', -1); @@ -300,29 +328,49 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) return false; // Separate section and key names - QString section = paramName.left(idx).toLower(); - QString key = paramName.mid(idx + 1).toLower(); + QByteArray section = paramName.left(idx).toLower(); + QByteArray key = paramName.mid(idx + 1).toLower(); // Format the value depending on the type - QString valueString; + QByteArray valueString; switch (value.type()) { case QVariant::UInt: - valueString = "0x" + QString::number(value.toUInt(), 16); + valueString = QByteArray("0x").append(QByteArray::number(value.toUInt(), 16)); break; case QVariant::Int: - valueString = QString::number(value.toInt()); + valueString = QByteArray::number(value.toInt()); break; case QVariant::Double: - valueString = QString::number(value.toDouble(), 'f'); + valueString = QByteArray::number(value.toDouble(), 'f'); break; case QVariant::Bool: valueString = value.toBool() ? "true" : "false"; break; - case QVariant::Char: - valueString = value.toChar(); + case QVariant::Char: { + QChar c = value.toChar(); + printf("c.unicode() = %u\n", c.unicode()); + if (c.unicode() < 32 || c.unicode() >= 127) + valueString = QByteArray("\\0x").append(QByteArray::number(c.unicode(), 16)); + else + valueString = QByteArray(1, (char const)c.unicode()); + break; + } + case QVariant::ByteArray: + valueString = binToEscapedCharArray(value.toByteArray()); + if (valueString.startsWith(' ') || valueString.endsWith(' ')) { + valueString.insert(0, '\"'); + valueString.append('\"'); + } + break; + case QVariant::String: + valueString = strToEscapedCharArray(value.toString()); + if (valueString.startsWith(' ') || valueString.endsWith(' ')) { + valueString.insert(0, '\"'); + valueString.append('\"'); + } break; default: - valueString = value.toString(); + valueString = value.toString().toLatin1(); } // Open the file @@ -343,7 +391,7 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) if (!sectionObject) { // Write the new section to the INI file (the file is already positioned at the end) - if (f.write(QString("[%1]" EOL).arg(section).toLocal8Bit()) == -1) { + if (f.write(QString("[%1]" EOL).arg(section.constData()).toLatin1()) == -1) { mErrorString = f.errorString(); mValid = false; EVAF_ERROR("Failed to write to the INI file %s : %s", qPrintable(mFileName), qPrintable(mErrorString)); @@ -358,7 +406,7 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) mCache.insert(section.toLower(), sectionObject); // Write the parameter value to the INI file - if (f.write(QString("%1 = %2" EOL).arg(key).arg(valueString).toLocal8Bit()) == -1) { + if (f.write(QString("%1 = %2" EOL).arg(key.constData()).arg(valueString.constData()).toLatin1()) == -1) { mErrorString = f.errorString(); mValid = false; EVAF_ERROR("Failed to write to the INI file %s : %s", qPrintable(mFileName), qPrintable(mErrorString)); @@ -369,6 +417,7 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) QExplicitlySharedDataPointer valueObject(new IniFileValue(currentPos)); valueObject->name = key; valueObject->paramValue = valueString; + valueObject->value = value; sectionObject->values.insert(key, valueObject); } @@ -423,7 +472,7 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) // Rewind to the original position and write the new parameter value f.seek(currentPos); - if (f.write(QString("%1%2 = %3" EOL).arg(prefix).arg(key).arg(valueString).toLocal8Bit()) == -1) { + if (f.write(QString("%1%2 = %3" EOL).arg(prefix).arg(key.constData()).arg(valueString.constData()).toLatin1()) == -1) { mErrorString = f.errorString(); mValid = false; EVAF_ERROR("Failed to write to the INI file %s : %s", qPrintable(mFileName), qPrintable(mErrorString)); @@ -459,6 +508,7 @@ bool IniFileImpl::setValue(QString const & paramName, QVariant const & value) // Update the parameter value in the internal cache valueObject->paramValue = valueString; + valueObject->value = value; } diff --git a/src/libs/Common/inifile.h b/src/libs/Common/inifile.h index 21a1bc4..2ebe1c1 100644 --- a/src/libs/Common/inifile.h +++ b/src/libs/Common/inifile.h @@ -59,7 +59,7 @@ namespace Internal { * of different data types: * * @li Bool - '0', 'false', 'off', 'no' are equal to false and '1', 'true', 'on', 'yes' are equal to true; - * @li Char - a single character or an ASCII code as '\0NNN' (oct) or '\0xNN' (hex); + * @li Char - a single character or an UTF-16 code as '\0NNNNNN' (oct) or '\0xNNNN' (hex); * @li Date - date string in the ISO 8601 format YYYY-MM-DD; * @li DateTime - date and time string in the ISO 8601 format YYY-MM-DDTHH:MM:SSTZD; * @li Double - the decimal point is always '.' regardless of the locale; @@ -119,7 +119,7 @@ public: * * @sa eVaf::Common::toVariant() */ - QVariant getValue(QString const & paramName, QVariant const & defaultValue = QVariant::Invalid); + QVariant getValue(QByteArray const & paramName, QVariant const & defaultValue = QVariant::Invalid); /** * Writes a value to the INI file. @@ -134,7 +134,7 @@ public: * The method returns true if the parameter value was written into the INI file and false if not. Use the errorString() method * to get a human-readable error string if writing to the INI file fails. */ - bool setValue(QString const & paramName, QVariant const & value); + bool setValue(QByteArray const & paramName, QVariant const & value); private: diff --git a/src/libs/Common/inifile_p.h b/src/libs/Common/inifile_p.h index b782627..ffb7a1e 100644 --- a/src/libs/Common/inifile_p.h +++ b/src/libs/Common/inifile_p.h @@ -57,12 +57,17 @@ public: /** * Key name of the parameter */ - QString name; + QByteArray name; /** * Value from the INI file */ - QString paramValue; + QByteArray paramValue; + + /** + * Value converted to the final type (defaults to QVariant::Invalid + */ + QVariant value; /** * Flag indicating that this value is valid on this OS only @@ -93,14 +98,14 @@ public: /** * Name of the section */ - QString name; + QByteArray name; /** * List of all the known parameter values in this section * * The key to the hash table is the name of the key for the parameters value. */ - QHash > values; + QHash > values; }; @@ -115,9 +120,9 @@ public: ~IniFileImpl(); - QVariant getValue(QString const & paramName, QVariant const & defaultValue); + QVariant getValue(QByteArray const & paramName, QVariant const & defaultValue); - bool setValue(QString const & paramName, QVariant const & value); + bool setValue(QByteArray const & paramName, QVariant const & value); inline bool isValid() const { return mValid; } @@ -145,7 +150,7 @@ private: // Members * * The key to the hash table is the name of the section. */ - QHash > mCache; + QHash > mCache; /// When was the INI file modified. QDateTime mLastModified; @@ -178,7 +183,7 @@ private: /// Methods * The file object is expected to be opened if the mValid flag is true. If the mValid flag is false, looks * only in the cache. */ - QExplicitlySharedDataPointer getSection(QFile & file, QString const & sectionName); + QExplicitlySharedDataPointer getSection(QFile & file, QByteArray const & sectionName); /** * Looks for a parameter in the INI file @@ -195,7 +200,7 @@ private: /// Methods * The file object is expected to be opened if the mValid flag is true. If the mValid flag is false, looks * only in the cache. */ - QExplicitlySharedDataPointer getParameter(QFile & file, IniFileSection & section, QString const & paramName); + QExplicitlySharedDataPointer getParameter(QFile & file, IniFileSection & section, QByteArray const & paramName); }; diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index e6068b9..fb1c67f 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,2,9 +#define VER_FILE_VERSION 0,2,2,10 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.2.9\0" +#define VER_FILE_VERSION_STR "0.2.2.10\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 77854ea7bd165f8d9afd2cba1490335a67001ab7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Wed, 30 Nov 2011 15:54:27 +0200 Subject: [PATCH 11/16] Numeric character and character entity references are now also supported when converting strings to QVariant values. Documentation fixes and updates. --- src/libs/Common/inifile.h | 14 ++++++++++++-- src/libs/Common/util.cpp | 5 +++++ src/libs/Common/util.h | 10 ++++++++-- src/libs/Common/version.h | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/libs/Common/inifile.h b/src/libs/Common/inifile.h index 2ebe1c1..ecf8737 100644 --- a/src/libs/Common/inifile.h +++ b/src/libs/Common/inifile.h @@ -47,7 +47,10 @@ namespace Internal { * @code * [main] * # The full name of this parameter is 'main/name' - * name = MyApplication + * name = "My Application" + * + * # 4-byte binary version number 1.0.7.10 with the name 'main/version' + * version = � * * [extensions/about] * # The full name of this parameter is 'extensions/about/module' @@ -66,7 +69,14 @@ namespace Internal { * @li Int - only base 10 (decimal) is allowed; * @li Time - 24h time string in the format HH:MM:SS * @li UInt - base 16 (hex) if the string is prefixed with '0x'; base 8 if the string starts with '0'; otherwise - * the value is expected to be base 10 (decimal). + * the value is expected to be base 10 (decimal); + * @li ByteArray - non-printable bytes and special characters are encoded as numeric character or character entity references; + * @li String - non-printable and special characters are encoded as numeric character or character entity references. + * + * Strings and Byte array values can be enclosed in single or double quotes. The IniFile class does this automatically when + * saving String or Byte array values with leading or trailing spaces. Quotes are removed from the parameter value prior + * returning the value to the application. Use character entity references """ and "'" if quotes should be part of + * the parameter value. */ class COMMON_EXPORT IniFile { diff --git a/src/libs/Common/util.cpp b/src/libs/Common/util.cpp index 33f6b4d..30874eb 100644 --- a/src/libs/Common/util.cpp +++ b/src/libs/Common/util.cpp @@ -87,6 +87,11 @@ QVariant eVaf::Common::toVariant(QString const & value, QVariant const & default if (ok) return QVariant(c); } + else if (value.startsWith('&')) { + QString c = strFromEscapedCharArray(value.toLatin1()); + if (c.size() > 0) + return QVariant(c.at(0)); + } else return QVariant(value.at(0)); } diff --git a/src/libs/Common/util.h b/src/libs/Common/util.h index 8237e7c..486da25 100644 --- a/src/libs/Common/util.h +++ b/src/libs/Common/util.h @@ -70,8 +70,10 @@ inline bool isFalse(QString const & str) * @li QVariant::Int - base 10 is used; * @li QVariant::Double - the decimal point is expecte to be '.' regardless which locale is used; * @li QVariant::Bool - tries to use isTrue() and isFalse() methods; otherwise performs a conversion to QVariant::uint; - * @li QVariant::Char - if the string begins with "\0x", expects it to be an ASCII code in hex; if the - * string begins with "\0", expects it to be an ASCII code in oct; otherwise uses the first character in the string; + * @li QVariant::Char - if the string begins with "\0x", expects it to be a UTF-16 code in hex; if the + * string begins with "\0", expects it to be a UTF-16 code in oct; if the string begins with "&", expects it to + * be a numeric character reference ("&#nnnn;" or "&#xhhhh;") or a predefined character entity reference; + * otherwise uses the first character in the string; */ COMMON_EXPORT QVariant toVariant(QString const & value, QVariant const & defaultValue); @@ -85,6 +87,8 @@ COMMON_EXPORT QVariant toVariant(QString const & value, QVariant const & default * be output directly as a printable 7-bit character are output as numeric character references. The result can be * directly inserted into XML or HTML documents and later converted back with the eVaf::Common::strFromEscapedCharArray() * function. + * + * For example, "Groß" becomes "Groß". */ COMMON_EXPORT QByteArray strToEscapedCharArray(QString const & str); @@ -107,6 +111,8 @@ COMMON_EXPORT QString strFromEscapedCharArray(QByteArray const & str); * directly as printable 7-bit characters are output as numeric character references. The result can be directly * inserted into XML or HTML documents and later converted back with the eVaf::Common::binFromEscapedCharArray() * function. + * + * For example, "Hello\r\n" becomes "Hello ". */ COMMON_EXPORT QByteArray binToEscapedCharArray(QByteArray const & src); diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index fb1c67f..b164cb5 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,2,10 +#define VER_FILE_VERSION 0,2,2,11 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.2.10\0" +#define VER_FILE_VERSION_STR "0.2.2.11\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 78ad6c009b334925675998ae2ab02cc1d6d97e18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 1 Dec 2011 16:05:22 +0200 Subject: [PATCH 12/16] Renamed Gui::Window to a more generic Gui::Panel, which can be a window, but also a panel as part of some other user interface layout. --- src/libs/Gui/CMakeLists.txt | 4 ++-- src/libs/Gui/Panel | 1 + src/libs/Gui/Window | 1 - src/libs/Gui/{window.cpp => panel.cpp} | 10 +++++----- src/libs/Gui/{window.h => panel.h} | 27 +++++++++++++++----------- src/libs/Gui/version.h | 4 ++-- 6 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 src/libs/Gui/Panel delete mode 100644 src/libs/Gui/Window rename src/libs/Gui/{window.cpp => panel.cpp} (85%) rename src/libs/Gui/{window.h => panel.h} (62%) diff --git a/src/libs/Gui/CMakeLists.txt b/src/libs/Gui/CMakeLists.txt index fab0577..19fd172 100644 --- a/src/libs/Gui/CMakeLists.txt +++ b/src/libs/Gui/CMakeLists.txt @@ -15,12 +15,12 @@ set(eVaf_LIBRARIES) # Source files set(SRCS - window.cpp + panel.cpp ) # Header files for the meta-object compiler set(MOC_HDRS - window.h + panel.h ) # Version info resource file for Windows builds diff --git a/src/libs/Gui/Panel b/src/libs/Gui/Panel new file mode 100644 index 0000000..896d171 --- /dev/null +++ b/src/libs/Gui/Panel @@ -0,0 +1 @@ +#include "panel.h" diff --git a/src/libs/Gui/Window b/src/libs/Gui/Window deleted file mode 100644 index 80b3d1c..0000000 --- a/src/libs/Gui/Window +++ /dev/null @@ -1 +0,0 @@ -#include "window.h" diff --git a/src/libs/Gui/window.cpp b/src/libs/Gui/panel.cpp similarity index 85% rename from src/libs/Gui/window.cpp rename to src/libs/Gui/panel.cpp index 880e118..f552789 100644 --- a/src/libs/Gui/window.cpp +++ b/src/libs/Gui/panel.cpp @@ -1,5 +1,5 @@ /** - * @file Gui/window.cpp + * @file Gui/panel.cpp * @brief Version information for eVaf modules * @author Enar Vaikene * @@ -17,15 +17,15 @@ * Agreement provided with the Software. */ -#include "window.h" +#include "panel.h" using namespace eVaf; //------------------------------------------------------------------- -Gui::Window::Window(QWidget * parent) - : QWidget(parent) +Gui::Panel::Panel(QWidget * parent, Qt::WindowFlags f) + : QWidget(parent, f) {} -Gui::Window::~Window() +Gui::Panel::~Panel() {} diff --git a/src/libs/Gui/window.h b/src/libs/Gui/panel.h similarity index 62% rename from src/libs/Gui/window.h rename to src/libs/Gui/panel.h index 15c426a..8c70ba6 100644 --- a/src/libs/Gui/window.h +++ b/src/libs/Gui/panel.h @@ -1,5 +1,5 @@ /** - * @file Gui/window.h + * @file Gui/panel.h * @brief Version information for eVaf modules * @author Enar Vaikene * @@ -17,8 +17,8 @@ * Agreement provided with the Software. */ -#ifndef __GUI_WINDOW_H -# define __GUI_WINDOW_H +#ifndef __GUI_PANEL_H +# define __GUI_PANEL_H #include "libgui.h" @@ -35,21 +35,26 @@ namespace eVaf { namespace Gui { /** - * eVaf GUI window class. - * @code#include @endcode + * eVaf GUI panel class. + * @code#include @endcode * - * The Gui::Window class is a common ancestor for all the eVaf windows. eVaf applications can have different window managers - * that manage Gui::Window objects. + * The Gui::Panel class is the generic widget for eVaf GUI applications. It is an empty + * widget that can be filled with actual user interface elements like labels, edit boxes etc. + * Gui::Panel acts like a normal widget, which can be shown as a stand-alone window or added to other + * user interface layouts. + * + * The main purpose of Gui::Panel is that it can be added to one of the eVaf document interface + * managers. */ -class GUI_EXPORT Window : public QWidget +class GUI_EXPORT Panel : public QWidget { Q_OBJECT public: - Window(QWidget * parent = 0); + Panel(QWidget * parent = 0, Qt::WindowFlags f = 0); - virtual ~Window(); + virtual ~Panel(); }; @@ -57,4 +62,4 @@ public: } // namespace eVaf -#endif // window.h +#endif // panel.h diff --git a/src/libs/Gui/version.h b/src/libs/Gui/version.h index a298704..dc36c0a 100644 --- a/src/libs/Gui/version.h +++ b/src/libs/Gui/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,1 +#define VER_FILE_VERSION 0,2,1,3 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.1\0" +#define VER_FILE_VERSION_STR "0.2.1.3\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 5dd5f367dfcecab75077c3cb4ca1f01113fc1561 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 1 Dec 2011 16:08:19 +0200 Subject: [PATCH 13/16] In the process of creating a more generic document interface manager (or window manager) interface. * Now adds panels instead of windows - one becomes part of the main windows; others act as separate windows. * Can manage multiple windows - when the main window is closed, closes all the other managed windows; - when the main window is minimized/restores, does the same for all the other managed windows. * XML file attribute 'mainPanelName' is used to set the main panel; if no attribute is set, uses the first panel. * Panels can be deleted externally; a garbage collector makes sure that the list of managed windows does not grow forever if somebody decides to add/delete millions of panels. --- src/plugins/SdiWindow/isdiwindow.h | 31 ++++- src/plugins/SdiWindow/sdiwindow.cpp | 199 +++++++++++++++++++++++----- src/plugins/SdiWindow/sdiwindow.h | 45 ++++++- src/plugins/SdiWindow/version.h | 4 +- 4 files changed, 238 insertions(+), 41 deletions(-) diff --git a/src/plugins/SdiWindow/isdiwindow.h b/src/plugins/SdiWindow/isdiwindow.h index 13b9903..4e0e43d 100644 --- a/src/plugins/SdiWindow/isdiwindow.h +++ b/src/plugins/SdiWindow/isdiwindow.h @@ -31,7 +31,7 @@ class QLayout; namespace eVaf { namespace Gui { - class Window; + class Panel; } // namespace eVaf::Gui namespace SdiWindow { @@ -54,12 +54,33 @@ struct SDIWINDOW_EXPORT iSdiWindow static iSdiWindow * instance(); /** - * Adds the window to the main SDI window - * @param window The window + * Adds a panel to the SDI window manager + * @param name Name of the panel + * @param panel The panel * - * This function adds a window to the main SDI layout. + * This function adds a panel to the SDI window manager. The ownership of the panel + * is transferred to the window manager and it is the responsibility of the window + * manager to delete it. */ - virtual void addWindow(Gui::Window * window) = 0; + virtual void addPanel(QString const & name, Gui::Panel * panel) = 0; + + /** + * Returns a panel by the name + * @param name Name of the panel + * @return Pointer to the panel or 0 if failed + * + * This function returns a panel identified by the name. + */ + virtual Gui::Panel * panel(QString const & name) const = 0; + + /** + * Shows a panel + * @param name Name of the panel + * @return True if succeeded; false if not + * + * This function shows the panel. + */ + virtual bool showPanel(QString const & name) = 0; }; diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp index aa264de..c0e3587 100644 --- a/src/plugins/SdiWindow/sdiwindow.cpp +++ b/src/plugins/SdiWindow/sdiwindow.cpp @@ -23,8 +23,10 @@ #include #include #include +#include #include +#include namespace eVaf { namespace SdiWindow { @@ -40,28 +42,25 @@ using namespace eVaf; //------------------------------------------------------------------- -using namespace eVaf::SdiWindow; - -iSdiWindow * iSdiWindow::instance() +SdiWindow::iSdiWindow * SdiWindow::iSdiWindow::instance() { - return Internal::mSdiWindow; + return SdiWindow::Internal::mSdiWindow; } //------------------------------------------------------------------- -using namespace eVaf::SdiWindow::Internal; - -MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) +SdiWindow::Internal::MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QWidget(parent, flags) , mReady(false) + , mTimerId(0) { setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__)); // Restore geometry restoreSettings(); - // Apply the size specified in a) properties; or b) on the command line + // Apply the size specified in a) properties; or b) on the command line (overwrites stored geometry) setWindowSize(); // Create the default layout @@ -73,7 +72,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) EVAF_INFO("%s created", qPrintable(objectName())); } -MainWindow::~MainWindow() +SdiWindow::Internal::MainWindow::~MainWindow() { mSdiWindow = 0; @@ -83,14 +82,30 @@ MainWindow::~MainWindow() EVAF_INFO("%s destroyed", qPrintable(objectName())); } -bool MainWindow::init(QString const & args) +QString SdiWindow::Internal::MainWindow::getMainPanelName(QString const & args) const +{ + QXmlStreamReader xml(args); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "attributes") { + if (xml.attributes().hasAttribute("mainPanelName")) + return xml.attributes().value("mainPanelName").toString(); + } + } + return QString(); +} + +bool SdiWindow::Internal::MainWindow::init(QString const & args) { - Q_UNUSED(args); + mMainPanelName = getMainPanelName(args); Common::iRegistry::instance()->registerInterface("iSdiWindow", this); setWindowTitle(Common::iApp::instance()->name()); + // Start the garbage collector timer + mTimerId = startTimer(60 * 1000); + show(); mReady = true; @@ -100,29 +115,73 @@ bool MainWindow::init(QString const & args) return true; } -void MainWindow::done() +void SdiWindow::Internal::MainWindow::done() { mReady = false; close(); - // Delete the window - if (mWindow) - delete mWindow.data(); + if (mTimerId) { + killTimer(mTimerId); + mTimerId = 0; + } + + // Delete all the panels + for (int i = mPanels.size() - 1; i >= 0; --i) { + QWeakPointer p = mPanels.at(i); + if (p) + delete p.data(); + } + mPanels.clear(); + mMinimizedPanels.clear(); + mPanelNames.clear(); + mMainPanel.clear(); + mMainPanelName.clear(); EVAF_INFO("%s finalized", qPrintable(objectName())); } -void MainWindow::addWindow(Gui::Window * window) +void SdiWindow::Internal::MainWindow::addPanel(QString const & name, Gui::Panel * panel) +{ + mPanels.append(panel); + mPanelNames.insert(name, panel); + + // If this is the predefined main panel, add it to this window + if (!mMainPanelName.isEmpty()) { + if (name == mMainPanelName) { + mMainPanel = panel; + mLayout->addWidget(panel); + } + } + + // If the predefined main panel name is not set, use the first panel + else { + if (!mMainPanel) { + mMainPanel = panel; + mLayout->addWidget(panel); + } + } +} + +Gui::Panel * SdiWindow::Internal::MainWindow::panel(QString const & name) const +{ + QHash >::const_iterator it = mPanelNames.constFind(name); + if (it != mPanelNames.constEnd()) + return it.value().data(); + return 0; +} + +bool SdiWindow::Internal::MainWindow::showPanel(QString const & name) { - // Delete the existing window - if (mWindow) - delete mWindow.data(); - mLayout->addWidget(window); - mWindow = window; + Gui::Panel * p = panel(name); + if (p) { + p->show(); + return true; + } + return false; } -void MainWindow::saveSettings() +void SdiWindow::Internal::MainWindow::saveSettings() { static int ver[4] = {VER_FILE_VERSION}; QSettings settings(VER_COMPANY_NAME_STR, Common::iApp::instance()->name()); @@ -131,7 +190,7 @@ void MainWindow::saveSettings() settings.setValue(QString("%1/geometry").arg(objectName()), saveGeometry()); } -void MainWindow::restoreSettings() +void SdiWindow::Internal::MainWindow::restoreSettings() { static int ver[4] = {VER_FILE_VERSION}; QSettings settings(VER_COMPANY_NAME_STR, Common::iApp::instance()->name()); @@ -149,11 +208,11 @@ void MainWindow::restoreSettings() restoreGeometry(settings.value(QString("%1/geometry").arg(objectName())).toByteArray()); } -void MainWindow::setWindowSize() +void SdiWindow::Internal::MainWindow::setWindowSize() { // a) Get window size from properties - int w = 0; - int h = 0; + int w = Common::iProp::instance()->getValue("windowWidth", 0).toInt(); + int h = Common::iProp::instance()->getValue("windowHeight", 0).toInt(); // b) Use command line arguments QStringList args = QApplication::arguments(); @@ -184,10 +243,90 @@ void MainWindow::setWindowSize() } } +void SdiWindow::Internal::MainWindow::closeEvent(QCloseEvent * e) +{ + // Try to close all the managed panels; ignore the event if one of the managed panels refuses to close + foreach (QWeakPointer p, mPanels) { + if (p) { + if (!p.data()->close()) { + e->ignore(); + return; + } + } + } + + QWidget::closeEvent(e); +} + +void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e) +{ + if (e->type() == QEvent::WindowStateChange) { + QWindowStateChangeEvent * wse = static_cast(e); + + if (windowState() == Qt::WindowNoState && wse->oldState() == Qt::WindowMinimized) { + + // Restore all the managed panels that were previously minimized + foreach (QWeakPointer p, mMinimizedPanels) { + if (p && p.data()->isVisible()) + p.data()->showNormal(); + } + mMinimizedPanels.clear(); + } + + else if (windowState() == Qt::WindowMinimized && wse->oldState() != Qt::WindowMinimized) { + + // Minimize all the managed panels that are not minimized yet + mMinimizedPanels.clear(); + foreach (QWeakPointer p, mPanels) { + if (!p) + continue; + + if (p.data()->windowState() != Qt::WindowMinimized && p.data()->isVisible()) { + mMinimizedPanels.append(p); + p.data()->showMinimized(); + } + } + } + } + QWidget::changeEvent(e); +} + +void SdiWindow::Internal::MainWindow::timerEvent(QTimerEvent * e) +{ + if (e->timerId() == mTimerId) { + + // Remove panels that are deleted + { + QList >::iterator it = mPanels.begin(); + while (it != mPanels.end()) { + QWeakPointer p = *it; + if (!p) + it = mPanels.erase(it); + else + ++it; + } + } + + // Do the same with panel names + { + QHash >::iterator it = mPanelNames.begin(); + while (it != mPanelNames.end()) { + QWeakPointer p = it.value(); + if (!p) + it = mPanelNames.erase(it); + else + ++it; + } + } + } + else + QWidget::timerEvent(e); +} + //------------------------------------------------------------------- -SdiWindowPlugin::SdiWindowPlugin() +SdiWindow::Internal::SdiWindowPlugin::SdiWindowPlugin() : Plugins::iPlugin() { setObjectName(VER_MODULE_NAME_STR); @@ -197,14 +336,14 @@ SdiWindowPlugin::SdiWindowPlugin() EVAF_INFO("%s created", qPrintable(objectName())); } -SdiWindowPlugin::~SdiWindowPlugin() +SdiWindow::Internal::SdiWindowPlugin::~SdiWindowPlugin() { delete mWindow; EVAF_INFO("%s destroyed", qPrintable(objectName())); } -bool SdiWindowPlugin::init(const QString & args) +bool SdiWindow::Internal::SdiWindowPlugin::init(const QString & args) { if (!mWindow->init(args)) return false; @@ -214,7 +353,7 @@ bool SdiWindowPlugin::init(const QString & args) return true; } -void SdiWindowPlugin::done() +void SdiWindow::Internal::SdiWindowPlugin::done() { mWindow->done(); diff --git a/src/plugins/SdiWindow/sdiwindow.h b/src/plugins/SdiWindow/sdiwindow.h index f884255..757ed28 100644 --- a/src/plugins/SdiWindow/sdiwindow.h +++ b/src/plugins/SdiWindow/sdiwindow.h @@ -23,12 +23,14 @@ #include "isdiwindow.h" #include -#include +#include #include #include #include #include +#include +#include #include class QVBoxLayout; @@ -57,7 +59,21 @@ public: virtual bool isReady() { return mReady; } - virtual void addWindow(Gui::Window * window); + virtual void addPanel(QString const & name, Gui::Panel * panel); + + virtual Gui::Panel * panel(QString const & name) const; + + virtual bool showPanel(QString const & name); + + virtual void changeEvent(QEvent * e); + + virtual void closeEvent(QCloseEvent * e); + + +protected: // Methods + + /// Garbage collector timer + virtual void timerEvent(QTimerEvent * e); private: // Methods @@ -77,8 +93,29 @@ private: // Members /// The layout of the main window QVBoxLayout * mLayout; - /// eVaf GUI window implementing the main window - QWeakPointer mWindow; + /// Name of the main panel that becomes part of this window + QString mMainPanelName; + + /// List of GUI::Panel objects added to the manager + QList > mPanels; + + /// List of minimized GUI::Panel objects + QVector > mMinimizedPanels; + + /// Hash with panel names + QHash > mPanelNames; + + /// Current main panel added to this window + QWeakPointer mMainPanel; + + /// Garbage collector timer ID + int mTimerId; + + +private: // Methods + + /// Gets the main panel name from module attributes + QString getMainPanelName(QString const & args) const; }; diff --git a/src/plugins/SdiWindow/version.h b/src/plugins/SdiWindow/version.h index f3fedec..c47549d 100644 --- a/src/plugins/SdiWindow/version.h +++ b/src/plugins/SdiWindow/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,3,1,6 +#define VER_FILE_VERSION 0,4,1,7 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.3.1.6\0" +#define VER_FILE_VERSION_STR "0.4.1.7\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 0433bb7cef1ffca603bbcc61fa229d62467a8ea2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 1 Dec 2011 16:14:13 +0200 Subject: [PATCH 14/16] Moved iProp interface registration to the constructor to fix a SEGFAULT in the iProp::instance() function. --- src/libs/Common/prop.cpp | 6 +++--- src/libs/Common/version.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/Common/prop.cpp b/src/libs/Common/prop.cpp index b3ccb6f..86d3b1e 100644 --- a/src/libs/Common/prop.cpp +++ b/src/libs/Common/prop.cpp @@ -47,6 +47,9 @@ Prop::Prop() , mPersistentProps(0) { setObjectName(QString("%1.iProp").arg(VER_MODULE_NAME_STR)); + + // Register the iProp interface + iRegistry::instance()->registerInterface("iProp", this); } Prop::~Prop() @@ -61,9 +64,6 @@ iProp * Prop::interface() const bool Prop::init() { - // Register the iProp interface - iRegistry::instance()->registerInterface("iProp", this); - // Set application name and language properties setValue("applicationName", iApp::instance()->name()); setValue("applicationLanguage", iApp::instance()->language()); diff --git a/src/libs/Common/version.h b/src/libs/Common/version.h index b164cb5..0a5f465 100644 --- a/src/libs/Common/version.h +++ b/src/libs/Common/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,2,11 +#define VER_FILE_VERSION 0,2,3,12 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.2.11\0" +#define VER_FILE_VERSION_STR "0.2.3.12\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 7a8ba1ead6dbe609ecc6eeae5ddde607f0b5bd5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 1 Dec 2011 16:17:44 +0200 Subject: [PATCH 15/16] The LogView widget is now subclassed from Gui::Panel and adds itself to the document interface manager. * Is currently hardcoded to use the SdiWindow::iSdiWindow * The name of the panel defaults to "LogView", but can be changed in the XML file attribute "panelName". --- src/plugins/LogView/CMakeLists.txt | 2 +- src/plugins/LogView/logview.cpp | 33 +++++++++++++++++++++++++----- src/plugins/LogView/logview.h | 7 +++++-- src/plugins/LogView/version.h | 4 ++-- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/plugins/LogView/CMakeLists.txt b/src/plugins/LogView/CMakeLists.txt index 557cacc..8f68dd1 100644 --- a/src/plugins/LogView/CMakeLists.txt +++ b/src/plugins/LogView/CMakeLists.txt @@ -11,7 +11,7 @@ add_definitions(-DLOGVIEW_LIBRARY) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib) +set(eVaf_LIBRARIES CommonLib PluginsLib GuiLib) # Source files set(SRCS diff --git a/src/plugins/LogView/logview.cpp b/src/plugins/LogView/logview.cpp index 2eaae97..1f75c58 100644 --- a/src/plugins/LogView/logview.cpp +++ b/src/plugins/LogView/logview.cpp @@ -23,8 +23,11 @@ #include #include #include +#include +#include #include +#include using namespace eVaf; @@ -243,11 +246,14 @@ void Widget::saveToFile() //------------------------------------------------------------------- -Window::Window(QWidget * parent, Qt::WindowFlags flags) - : QWidget(parent, flags) +Window::Window(QString const & args, QWidget * parent, Qt::WindowFlags flags) + : Gui::Panel(parent, flags) { setObjectName(QString("%1-Window").arg(VER_MODULE_NAME_STR)); + SdiWindow::iSdiWindow * win = evafQueryInterface("iSdiWindow"); + win->addPanel(getPanelName(args), this); + setWindowTitle(tr("Messages")); Common::iLogger * logger = Common::iLogger::instance(); @@ -295,6 +301,25 @@ Window::~Window() EVAF_INFO("%s destroyed", qPrintable(objectName())); } +QString Window::getPanelName(QString const & args) const +{ + QString panelName = "LogView"; + + QXmlStreamReader xml(args); + while (!xml.atEnd()) { + xml.readNext(); + if (xml.isStartElement() && xml.name() == "attributes") { + if (xml.attributes().hasAttribute("panelName")) { + QString s = xml.attributes().value("panelName").toString(); + if (!s.isEmpty()) + panelName = s; + } + } + } + + return panelName; +} + bool Window::event(QEvent * e) { if (e->type() == QEvent::StatusTip) { @@ -371,9 +396,7 @@ Module::~Module() bool Module::init(QString const & args) { - Q_UNUSED(args); - - wWindow = new Window(); + wWindow = new Window(args); EVAF_INFO("%s initialized", qPrintable(objectName())); diff --git a/src/plugins/LogView/logview.h b/src/plugins/LogView/logview.h index 1bfe6a8..dd76858 100644 --- a/src/plugins/LogView/logview.h +++ b/src/plugins/LogView/logview.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -171,13 +172,13 @@ private: /** * The log view window */ -class Window : public QWidget +class Window : public Gui::Panel { Q_OBJECT public: - Window(QWidget * parent = 0, Qt::WindowFlags flags = 0); + Window(QString const & args, QWidget * parent = 0, Qt::WindowFlags flags = 0); virtual ~Window(); @@ -195,6 +196,8 @@ private: // Methods void restoreSettings(); + QString getPanelName(QString const & args) const; + private: // Members diff --git a/src/plugins/LogView/version.h b/src/plugins/LogView/version.h index d8d3133..b1893b1 100644 --- a/src/plugins/LogView/version.h +++ b/src/plugins/LogView/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,1,2 +#define VER_FILE_VERSION 0,2,1,3 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.1.2\0" +#define VER_FILE_VERSION_STR "0.2.1.3\0" /** * Module/library name (shall end with \0) -- 2.45.2 From 388264abc0442ea0e4c6dca6812cb755053c79d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Thu, 1 Dec 2011 16:20:49 +0200 Subject: [PATCH 16/16] Changed to use Gui::Panel instead of Gui::Window. --- src/apps/FileFinder/GUI/gui.cpp | 2 +- src/apps/FileFinder/GUI/gui.h | 6 +++--- src/apps/FileFinder/GUI/version.h | 4 ++-- src/apps/PswGen/GUI/gui.cpp | 18 +++++++++--------- src/apps/PswGen/GUI/version.h | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/apps/FileFinder/GUI/gui.cpp b/src/apps/FileFinder/GUI/gui.cpp index 260b6c8..d1f1c4b 100644 --- a/src/apps/FileFinder/GUI/gui.cpp +++ b/src/apps/FileFinder/GUI/gui.cpp @@ -118,7 +118,7 @@ bool FileFinder::GUI::Module::init(QString const & args) // Create the main widget for this window wMain = new Internal::MainWidget; connect(wMain, SIGNAL(quit()), qApp, SLOT(quit())); - win->addWindow(wMain); + win->addPanel("FileFinder", wMain); // Create actions for the window and widgets on it createActions(); diff --git a/src/apps/FileFinder/GUI/gui.h b/src/apps/FileFinder/GUI/gui.h index 02f4f22..c8d3633 100644 --- a/src/apps/FileFinder/GUI/gui.h +++ b/src/apps/FileFinder/GUI/gui.h @@ -21,7 +21,7 @@ # define __FILEFINDER_GUI_GUI_H #include -#include +#include #include #include @@ -49,14 +49,14 @@ namespace Internal { /** * Main widget for the FileFinder window */ -class MainWidget : public Gui::Window +class MainWidget : public Gui::Panel { Q_OBJECT public: MainWidget(QWidget * parent = 0) - : Gui::Window(parent) + : Gui::Panel(parent) {} virtual void keyPressEvent(QKeyEvent * e); diff --git a/src/apps/FileFinder/GUI/version.h b/src/apps/FileFinder/GUI/version.h index 733a6f5..481c3f1 100644 --- a/src/apps/FileFinder/GUI/version.h +++ b/src/apps/FileFinder/GUI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,3,3 +#define VER_FILE_VERSION 0,1,4,4 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.3.3\0" +#define VER_FILE_VERSION_STR "0.1.4.4\0" /** * Module/library name (shall end with \0) diff --git a/src/apps/PswGen/GUI/gui.cpp b/src/apps/PswGen/GUI/gui.cpp index 706522b..1ced109 100644 --- a/src/apps/PswGen/GUI/gui.cpp +++ b/src/apps/PswGen/GUI/gui.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include @@ -75,11 +75,11 @@ bool Module::init(QString const & args) SdiWindow::iSdiWindow * win = evafQueryInterface("iSdiWindow"); EVAF_TEST_X(win, "No iSdiWindow interface"); - Gui::Window * masterWidget = new Gui::Window; - win->addWindow(masterWidget); + Gui::Panel * panel = new Gui::Panel; + win->addPanel("PswGen", panel); QVBoxLayout * v = new QVBoxLayout; - masterWidget->setLayout(v); + panel->setLayout(v); QGridLayout * g = new QGridLayout; v->addLayout(g); @@ -109,7 +109,7 @@ bool Module::init(QString const & args) } connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); g->addWidget(wName, 1, 1, 1, 2); - masterWidget->setFocusProxy(wName); + panel->setFocusProxy(wName); l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR)); l->setAlignment(Qt::AlignRight); @@ -147,15 +147,15 @@ bool Module::init(QString const & args) connect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked())); h->addWidget(wCopy); - QAction * a = new QAction(masterWidget); + QAction * a = new QAction(panel); a->setShortcut(Qt::Key_Return); connect(a, SIGNAL(triggered()), this, SLOT(generateClicked())); - masterWidget->addAction(a); + panel->addAction(a); - a = new QAction(masterWidget); + a = new QAction(panel); a->setShortcut(Qt::Key_Escape); connect(a, SIGNAL(triggered()), qApp, SLOT(quit())); - masterWidget->addAction(a); + panel->addAction(a); mReady = true; diff --git a/src/apps/PswGen/GUI/version.h b/src/apps/PswGen/GUI/version.h index 8d9aad3..8f3e970 100644 --- a/src/apps/PswGen/GUI/version.h +++ b/src/apps/PswGen/GUI/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,1,4,5 +#define VER_FILE_VERSION 0,1,5,6 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.1.4.5\0" +#define VER_FILE_VERSION_STR "0.1.5.6\0" /** * Module/library name (shall end with \0) -- 2.45.2