new settings classes for client and server, derived from a common base class

This commit is contained in:
Volker Fischer 2020-06-29 20:43:41 +02:00
parent a192acacf9
commit 059d9ef203
7 changed files with 705 additions and 675 deletions

View file

@ -26,14 +26,14 @@
/* Implementation *************************************************************/
CClientDlg::CClientDlg ( CClient* pNCliP,
CSettings* pNSetP,
const QString& strConnOnStartupAddress,
const int iCtrlMIDIChannel,
const bool bNewShowComplRegConnList,
const bool bShowAnalyzerConsole,
QWidget* parent,
Qt::WindowFlags f ) :
CClientDlg::CClientDlg ( CClient* pNCliP,
CClientSettings* pNSetP,
const QString& strConnOnStartupAddress,
const int iCtrlMIDIChannel,
const bool bNewShowComplRegConnList,
const bool bShowAnalyzerConsole,
QWidget* parent,
Qt::WindowFlags f ) :
QDialog ( parent, f ),
pClient ( pNCliP ),
pSettings ( pNSetP ),

View file

@ -72,14 +72,14 @@ class CClientDlg : public QDialog, private Ui_CClientDlgBase
Q_OBJECT
public:
CClientDlg ( CClient* pNCliP,
CSettings* pNSetP,
const QString& strConnOnStartupAddress,
const int iCtrlMIDIChannel,
const bool bNewShowComplRegConnList,
const bool bShowAnalyzerConsole,
QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
CClientDlg ( CClient* pNCliP,
CClientSettings* pNSetP,
const QString& strConnOnStartupAddress,
const int iCtrlMIDIChannel,
const bool bNewShowComplRegConnList,
const bool bShowAnalyzerConsole,
QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
protected:
void SetGUIDesign ( const EGUIDesign eNewDesign );
@ -96,7 +96,7 @@ protected:
void Disconnect();
CClient* pClient;
CSettings* pSettings;
CClientSettings* pSettings;
bool bConnected;
bool bConnectDlgWasShown;

View file

@ -617,7 +617,7 @@ int main ( int argc, char** argv )
strClientName );
// load settings from init-file
CSettings Settings ( &Client, strIniFileName );
CClientSettings Settings ( &Client, strIniFileName );
Settings.Load();
#ifndef HEADLESS
@ -670,7 +670,7 @@ int main ( int argc, char** argv )
if ( bUseGUI )
{
// load settings from init-file
CSettings Settings ( &Server, strIniFileName );
CServerSettings Settings ( &Server, strIniFileName );
Settings.Load();
// update server list AFTER restoring the settings from the

View file

@ -26,11 +26,11 @@
/* Implementation *************************************************************/
CServerDlg::CServerDlg ( CServer* pNServP,
CSettings* pNSetP,
const bool bStartMinimized,
QWidget* parent,
Qt::WindowFlags f )
CServerDlg::CServerDlg ( CServer* pNServP,
CServerSettings* pNSetP,
const bool bStartMinimized,
QWidget* parent,
Qt::WindowFlags f )
: QDialog ( parent, f ),
pServer ( pNServP ),
pSettings ( pNSetP ),

View file

@ -52,11 +52,11 @@ class CServerDlg : public QDialog, private Ui_CServerDlgBase
Q_OBJECT
public:
CServerDlg ( CServer* pNServP,
CSettings* pNSetP,
const bool bStartMinimized,
QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
CServerDlg ( CServer* pNServP,
CServerSettings* pNSetP,
const bool bStartMinimized,
QWidget* parent = nullptr,
Qt::WindowFlags f = nullptr );
protected:
virtual void changeEvent ( QEvent* pEvent );
@ -70,7 +70,7 @@ protected:
QTimer Timer;
CServer* pServer;
CSettings* pSettings;
CServerSettings* pSettings;
CVector<QTreeWidgetItem*> vecpListViewItems;
QMutex ListViewMutex;

File diff suppressed because it is too large Load diff

View file

@ -39,18 +39,15 @@
class CSettings
{
public:
CSettings ( CClient* pNCliP, const QString& sNFiName ) :
pClient ( pNCliP ), bIsClient ( true ), strFileName ( "" )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); }
CSettings ( CServer* pNSerP, const QString& sNFiName ) :
pServer ( pNSerP ), bIsClient ( false ), strFileName ( "" )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER); }
CSettings() : strFileName ( "" ) {}
void Load();
void Save();
protected:
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) = 0;
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) = 0;
void SetFileName ( const QString& sNFiName,
const QString& sDefaultFileName );
@ -106,10 +103,38 @@ protected:
const QString& sKey,
const QString& sValue = "" );
// pointer to the client/server object which stores the various settings
CClient* pClient; // for client
CServer* pServer; // for server
bool bIsClient;
QString strFileName;
QString strFileName;
};
class CClientSettings : public CSettings
{
public:
CClientSettings ( CClient* pNCliP, const QString& sNFiName ) : pClient ( pNCliP )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); }
protected:
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) override;
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) override;
CClient* pClient;
};
class CServerSettings : public CSettings
{
public:
CServerSettings ( CServer* pNSerP, const QString& sNFiName ) : pServer ( pNSerP )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER); }
protected:
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) override;
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) override;
CServer* pServer;
};