third attempt to port to QT4, not working, still a lot to do...

This commit is contained in:
Volker Fischer 2008-01-15 22:54:04 +00:00
parent 221a612427
commit 8b0389c192
5 changed files with 178 additions and 190 deletions

View file

@ -105,6 +105,9 @@
#define TIME_MOV_AV_RESPONSE 30 // seconds #define TIME_MOV_AV_RESPONSE 30 // seconds
#define LEN_MOV_AV_RESPONSE ( TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS ) #define LEN_MOV_AV_RESPONSE ( TIME_MOV_AV_RESPONSE * 1000 / MIN_BLOCK_DURATION_MS )
// GUI definition: width/heigth size of LED pixmaps
#define LED_WIDTH_HEIGHT_SIZE_PIXEL 13
#define _MAXSHORT 32767 #define _MAXSHORT 32767
#define _MAXBYTE 255 // binary: 11111111 #define _MAXBYTE 255 // binary: 11111111

View file

@ -27,40 +27,29 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent ) CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
: pServer ( pNServP ), QDialog ( parent ) : pServer ( pNServP ), QDialog ( parent ),
BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL )
{ {
/* set text for version and application name */ /* set text for version and application name */
TextLabelNameVersion->setText ( QString ( APP_NAME ) + TextLabelNameVersion->setText ( QString ( APP_NAME ) +
tr ( " server " ) + QString ( VERSION ) ); tr ( " server " ) + QString ( VERSION ) );
/* Create bitmaps */ /* Create bitmaps */
/* Define size of the bitmaps */
const int iXSize = 13;
const int iYSize = 13;
BitmCubeGreen.resize ( iXSize, iYSize );
BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) );
BitmCubeRed.resize ( iXSize, iYSize );
BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); BitmCubeRed.fill ( QColor ( 255, 0, 0 ) );
BitmCubeYellow.resize ( iXSize, iYSize );
BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) );
/* set up list view for connected clients (We assume that one column is // set up list view for connected clients
already there) */
ListViewClients->setColumnText ( 0, tr ( "Client IP : Port" ) );
ListViewClients->setColumnWidth ( 0, 170 ); ListViewClients->setColumnWidth ( 0, 170 );
ListViewClients->addColumn ( tr ( "Name" ) ); // ListViewClients->setColumnAlignment ( 1, Qt::AlignLeft );
ListViewClients->setColumnAlignment ( 1, Qt::AlignLeft );
ListViewClients->setColumnWidth ( 1, 150 ); ListViewClients->setColumnWidth ( 1, 150 );
ListViewClients->addColumn ( tr ( "Put" ) ); // ListViewClients->setColumnAlignment ( 2, Qt::AlignCenter );
ListViewClients->setColumnAlignment ( 2, Qt::AlignCenter ); // ListViewClients->setColumnAlignment ( 3, Qt::AlignCenter );
ListViewClients->addColumn ( tr ( "Get" ) ); // ListViewClients->setColumnAlignment ( 4, Qt::AlignRight );
ListViewClients->setColumnAlignment ( 3, Qt::AlignCenter ); // ListViewClients->setColumnAlignment ( 5, Qt::AlignRight );
ListViewClients->addColumn ( tr ( "Jitter buffer size" ) ); // ListViewClients->setColumnAlignment ( 6, Qt::AlignRight );
ListViewClients->setColumnAlignment ( 4, Qt::AlignRight );
ListViewClients->addColumn ( tr ( "Block Size In" ) );
ListViewClients->setColumnAlignment ( 5, Qt::AlignRight );
ListViewClients->addColumn ( tr ( "Block Size Out" ) );
ListViewClients->setColumnAlignment ( 6, Qt::AlignRight );
ListViewClients->clear(); ListViewClients->clear();
/* insert items in reverse order because in Windows all of them are /* insert items in reverse order because in Windows all of them are
@ -74,26 +63,27 @@ CLlconServerDlg::CLlconServerDlg ( CServer* pNServP, QWidget* parent )
#endif #endif
} }
/* Init timing jitter text label */ // Init timing jitter text label
TextLabelResponseTime->setText ( "" ); TextLabelResponseTime->setText ( "" );
/* Main menu bar -------------------------------------------------------- */ /* Main menu bar -------------------------------------------------------- */
pMenu = new QMenuBar ( this ); pMenu = new QMenuBar ( this );
pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) ); // pMenu->insertItem ( tr ( "&?" ), new CLlconHelpMenu ( this ) );
pMenu->setSeparator ( QMenuBar::InWindowsStyle ); pMenu->addMenu ( new CLlconHelpMenu ( this ) );
//pMenu->setSeparator ( QMenuBar::InWindowsStyle );
/* Now tell the layout about the menu */ // Now tell the layout about the menu
CLlconServerDlgBaseLayout->setMenuBar ( pMenu ); layout()->setMenuBar ( pMenu );
/* connections ---------------------------------------------------------- */ /* connections ---------------------------------------------------------- */
/* timers */ // timers
QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) ); QObject::connect ( &Timer, SIGNAL ( timeout() ), this, SLOT ( OnTimer() ) );
/* timers --------------------------------------------------------------- */ /* timers --------------------------------------------------------------- */
/* start timer for GUI controls */ // start timer for GUI controls
Timer.start ( GUI_CONTRL_UPDATE_TIME ); Timer.start ( GUI_CONTRL_UPDATE_TIME );
} }

View file

@ -45,66 +45,66 @@ int main ( int argc, char** argv )
bool bUseServerLogging = false; bool bUseServerLogging = false;
std::string strIniFileName = ""; std::string strIniFileName = "";
/* QT docu: argv()[0] is the program name, argv()[1] is the first /* QT docu: argv()[0] is the program name, argv()[1] is the first
argument and argv()[argc()-1] is the last argument. argument and argv()[argc()-1] is the last argument.
Start with first argument, therefore "i = 1" */ Start with first argument, therefore "i = 1" */
for ( int i = 1; i < argc; i++ ) for ( int i = 1; i < argc; i++ )
{ {
/* Server mode flag ------------------------------------------------------- */ /* Server mode flag ------------------------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-s", "--server" ) == TRUE )
{ {
bIsClient = false; bIsClient = false;
cerr << "server "; cerr << "server ";
continue; continue;
} }
/* Use GUI flag ----------------------------------------------------------- */ /* Use GUI flag ----------------------------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-n", "--nogui" ) == TRUE )
{ {
bUseGUI = false; bUseGUI = false;
cerr << "nogui "; cerr << "nogui ";
continue; continue;
} }
/* Use logging flag ------------------------------------------------------- */ /* Use logging flag ------------------------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) == TRUE ) if ( GetFlagArgument ( argc, argv, i, "-l", "--log" ) == TRUE )
{ {
bUseServerLogging = true; bUseServerLogging = true;
cerr << "logging "; cerr << "logging ";
continue; continue;
} }
/* Initialization file ---------------------------------------------------- */ /* Initialization file ---------------------------------------------------- */
if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) == TRUE ) if ( GetStringArgument ( argc, argv, i, "-i", "--inifile", strArgument ) == TRUE )
{ {
strIniFileName = strArgument; strIniFileName = strArgument;
continue; continue;
} }
/* Help (usage) flag ------------------------------------------------------ */ /* Help (usage) flag ------------------------------------------------------ */
if ( ( !strcmp ( argv[i], "--help" ) ) || if ( ( !strcmp ( argv[i], "--help" ) ) ||
( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) ) ( !strcmp ( argv[i], "-h" ) ) || ( !strcmp ( argv[i], "-?" ) ) )
{ {
const std::string strHelp = UsageArguments(argv); const std::string strHelp = UsageArguments(argv);
cerr << strHelp; cerr << strHelp;
exit ( 1 ); exit ( 1 );
} }
/* Unknown option --------------------------------------------------------- */ /* Unknown option --------------------------------------------------------- */
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help" cerr << "Unknown option '" << argv[i] << "' -- use '--help' for help"
<< endl; << endl;
exit ( 1 ); exit ( 1 );
} }
/* Application object */ // Application object
QApplication app ( argc, argv, bUseGUI ); QApplication app ( argc, argv, bUseGUI );
if ( bIsClient ) if ( bIsClient )
@ -118,10 +118,10 @@ cerr << "logging ";
Settings.Load ( strIniFileName ); Settings.Load ( strIniFileName );
// GUI object // GUI object
CLlconClientDlg ClientDlg ( &Client, 0, 0, FALSE, Qt::WStyle_MinMax ); CLlconClientDlg ClientDlg ( &Client, 0 );
// set main window // set main window
app.setMainWidget ( &ClientDlg ); app.setActiveWindow ( &ClientDlg );
pApp = &app; // Needed for post-event routine pApp = &app; // Needed for post-event routine
// show dialog // show dialog
@ -140,11 +140,10 @@ cerr << "logging ";
if ( bUseGUI ) if ( bUseGUI )
{ {
// GUI object for the server // GUI object for the server
CLlconServerDlg ServerDlg ( &Server, 0, 0, FALSE, CLlconServerDlg ServerDlg ( &Server, 0 );
Qt::WStyle_MinMax );
// set main window // set main window
app.setMainWidget ( &ServerDlg ); app.setActiveWindow ( &ServerDlg );
pApp = &app; // needed for post-event routine pApp = &app; // needed for post-event routine
// show dialog // show dialog
@ -154,7 +153,7 @@ cerr << "logging ";
else else
{ {
// only start application without using the GUI // only start application without using the GUI
qDebug ( CAboutDlg::GetVersionAndNameStr ( false ) ); qDebug() << CAboutDlg::GetVersionAndNameStr ( false );
app.exec(); app.exec();
} }
} }
@ -166,86 +165,86 @@ cerr << "logging ";
/******************************************************************************\ /******************************************************************************\
* Command Line Argument Parsing * * Command Line Argument Parsing *
\******************************************************************************/ \******************************************************************************/
std::string UsageArguments ( char **argv ) std::string UsageArguments ( char **argv )
{ {
return return
"Usage: " + std::string ( argv[0] ) + " [option] [argument]\n" "Usage: " + std::string ( argv[0] ) + " [option] [argument]\n"
"Recognized options:\n" "Recognized options:\n"
" -s, --server start server\n" " -s, --server start server\n"
" -n, --nogui disable GUI (only avaiable for server)\n" " -n, --nogui disable GUI (only avaiable for server)\n"
" -l, --log enable logging\n" " -l, --log enable logging\n"
" -i, --inifile initialization file name (only available for client)\n" " -i, --inifile initialization file name (only available for client)\n"
" -h, -?, --help this help text\n" " -h, -?, --help this help text\n"
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
} }
bool GetFlagArgument ( int, char **argv, int &i, bool GetFlagArgument ( int, char **argv, int &i,
std::string strShortOpt, std::string strLongOpt ) std::string strShortOpt, std::string strLongOpt )
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
bool GetStringArgument ( int argc, char **argv, int &i, bool GetStringArgument ( int argc, char **argv, int &i,
std::string strShortOpt, std::string strLongOpt, std::string strShortOpt, std::string strLongOpt,
std::string & strArg ) std::string & strArg )
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
if ( ++i >= argc ) if ( ++i >= argc )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a string argument" << endl; cerr << "'" << strLongOpt << "' needs a string argument" << endl;
exit ( 1 ); exit ( 1 );
} }
strArg = argv[i]; strArg = argv[i];
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
bool GetNumericArgument ( int argc, char **argv, int &i, bool GetNumericArgument ( int argc, char **argv, int &i,
std::string strShortOpt, std::string strLongOpt, std::string strShortOpt, std::string strLongOpt,
double rRangeStart, double rRangeStop, double rRangeStart, double rRangeStop,
double & rValue) double & rValue)
{ {
if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) ) if ( ( !strShortOpt.compare ( argv[i] ) ) || ( !strLongOpt.compare ( argv[i] ) ) )
{ {
if ( ++i >= argc ) if ( ++i >= argc )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a numeric argument between " cerr << "'" << strLongOpt << "' needs a numeric argument between "
<< rRangeStart << " and " << rRangeStop << endl; << rRangeStart << " and " << rRangeStop << endl;
exit ( 1 ); exit ( 1 );
} }
char *p; char *p;
rValue = strtod ( argv[i], &p ); rValue = strtod ( argv[i], &p );
if ( *p || rValue < rRangeStart || rValue > rRangeStop ) if ( *p || rValue < rRangeStart || rValue > rRangeStop )
{ {
cerr << argv[0] << ": "; cerr << argv[0] << ": ";
cerr << "'" << strLongOpt << "' needs a numeric argument between " cerr << "'" << strLongOpt << "' needs a numeric argument between "
<< rRangeStart << " and " << rRangeStop << endl; << rRangeStart << " and " << rRangeStop << endl;
exit ( 1 ); exit ( 1 );
} }
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
@ -262,6 +261,6 @@ void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam,
new CLlconEvent ( MessID, iMessageParam, iChanNum ); new CLlconEvent ( MessID, iMessageParam, iChanNum );
// Qt will delete the event object when done // Qt will delete the event object when done
QThread::postEvent ( pApp->mainWidget(), LlconEv ); // QThread::postEvent ( pApp->mainWidget(), LlconEv );
} }
} }

View file

@ -30,20 +30,16 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CMultiColorLEDbase::CMultiColorLEDbase() CMultiColorLEDbase::CMultiColorLEDbase() :
BitmCubeGreen ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeRed ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeGrey ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL ),
BitmCubeYellow ( LED_WIDTH_HEIGHT_SIZE_PIXEL, LED_WIDTH_HEIGHT_SIZE_PIXEL )
{ {
/* Define size of the bitmaps */
const int iXSize = 13;
const int iYSize = 13;
/* Create bitmaps */ /* Create bitmaps */
BitmCubeGreen.resize ( iXSize, iYSize );
BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) ); BitmCubeGreen.fill ( QColor ( 0, 255, 0 ) );
BitmCubeRed.resize ( iXSize, iYSize );
BitmCubeRed.fill ( QColor ( 255, 0, 0 ) ); BitmCubeRed.fill ( QColor ( 255, 0, 0 ) );
BitmCubeGrey.resize ( iXSize, iYSize );
BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) ); BitmCubeGrey.fill ( QColor ( 192, 192, 192 ) );
BitmCubeYellow.resize ( iXSize, iYSize );
BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) ); BitmCubeYellow.fill ( QColor ( 255, 255, 0 ) );
/* Init color flags */ /* Init color flags */
@ -141,21 +137,21 @@ void CMultiColorLEDbase::SetLight ( int iNewStatus )
switch ( iNewStatus ) switch ( iNewStatus )
{ {
case MUL_COL_LED_GREEN: case MUL_COL_LED_GREEN:
/* Green light */ // Green light
bFlagGreenLi = true; bFlagGreenLi = true;
TimerGreenLight.changeInterval ( iUpdateTime ); TimerGreenLight.setInterval ( iUpdateTime );
break; break;
case MUL_COL_LED_YELLOW: case MUL_COL_LED_YELLOW:
/* Yellow light */ // Yellow light
bFlagYellowLi = true; bFlagYellowLi = true;
TimerYellowLight.changeInterval ( iUpdateTime ); TimerYellowLight.setInterval ( iUpdateTime );
break; break;
case MUL_COL_LED_RED: case MUL_COL_LED_RED:
/* Red light */ // Red light
bFlagRedLi = true; bFlagRedLi = true;
TimerRedLight.changeInterval ( iUpdateTime ); TimerRedLight.setInterval ( iUpdateTime );
break; break;
} }

View file

@ -89,7 +89,7 @@ void CServer::Stop()
// logging // logging
QString strLogStr = CLogTimeDate::toString() + "Server stopped"; QString strLogStr = CLogTimeDate::toString() + "Server stopped";
qDebug ( strLogStr ); // on console qDebug() << strLogStr; // on console
Logging << strLogStr; // in log file Logging << strLogStr; // in log file
} }