RioMMSync Class Reference

#include <RioMMSync.h>

Public Member Functions

 RioMMSync (QWidget *parent=0, const char *name=0, WFlags f=0)
bool Initialize (QFileInfo fiSyncFile, int type, int position)

Private Slots

void addNewLine ()
void processInput ()

Private Member Functions

bool readSyncFile (QFileInfo fiSyncFile)
bool writeSyncFile ()

Private Attributes

QLineEdit * leNewLine
QTextEdit * teFileContent
QFile fSyncFile
QTextStream * tsSyncFile
int syncType
int blockNumber

Detailed Description

Definition at line 33 of file RioMMSync.h.


Constructor & Destructor Documentation

RioMMSync::RioMMSync ( QWidget *  parent = 0,
const char *  name = 0,
WFlags  f = 0 
)

Definition at line 33 of file RioMMSync.cpp.

00034               : QDialog( parent, name, true, f )
00035 {
00036     widget = new QWidget( this );
00037 }


Member Function Documentation

void RioMMSync::addNewLine (  )  [private, slot]

Definition at line 244 of file RioMMSync.cpp.

00245 {
00246     teFileContent->append( leNewLine->text() );
00247 }

bool RioMMSync::Initialize ( QFileInfo  fiSyncFile,
int  type,
int  position 
)

Definition at line 39 of file RioMMSync.cpp.

00040 {
00041     /* Class Objects */
00042     leNewLine = new QLineEdit( this, "leNewLine" );
00043     leNewLine->setFixedWidth( 400 );
00044 
00045     teFileContent = new QTextEdit( this, "teFileContent" );
00046     teFileContent->setTextFormat( PlainText );
00047     teFileContent->setFixedWidth( 460 );
00048     teFileContent->setFixedHeight( 480 );
00049 
00050     blockNumber = position;
00051     syncType    = type;
00052 
00053     /* Buttons */
00054     QPushButton *pbAddNewLine  = new QPushButton( "Add", this );
00055     pbAddNewLine->setFixedWidth( 50 );
00056     pbAddNewLine->setDefault( true );
00057     QPushButton *pbOK          = new QPushButton( "OK", this );
00058     pbOK->setFixedWidth( 60 );
00059     QPushButton *pbCancel      = new QPushButton( "Cancel", this );
00060     pbCancel->setFixedWidth( 60 );
00061 
00062     /* Set this widget's caption */
00063     setCaption( "Editing sync file" );
00064 
00065     /* Grid Layouts */
00066     QGridLayout *fileContentLayout = new QGridLayout( 2 , 1 );
00067     fileContentLayout->setSpacing( 10 );
00068     fileContentLayout->setMargin( 0 );
00069 
00070     QGridLayout *newLineLayout = new QGridLayout( 1 , 2 );
00071     newLineLayout->setSpacing( 10 );
00072     newLineLayout->setMargin( 0 );
00073 
00074     /* HBoxLayouts */
00075     QHBoxLayout *buttonLayout = new QHBoxLayout();
00076 
00077     /* VBoxLayout (Main Layout) */
00078     QVBoxLayout *mainLayout = new QVBoxLayout( widget );
00079     mainLayout->setMargin( 10 );
00080     mainLayout->setSpacing( 0 );
00081 
00082     /* Organizing Widgets and Layouts */
00083     fileContentLayout->addWidget( new QLabel( "File content:", this ), 0, 0 );
00084     fileContentLayout->addWidget( teFileContent, 1, 0 );
00085 
00086     newLineLayout->addWidget( leNewLine, 0, 0 );
00087     newLineLayout->addWidget( pbAddNewLine, 0, 1 );
00088 
00089     buttonLayout->addWidget( pbOK, 0 );
00090     buttonLayout->addWidget( pbCancel,  0 );
00091 
00092     mainLayout->addLayout( fileContentLayout );
00093     mainLayout->addLayout( newLineLayout );
00094     mainLayout->addLayout( buttonLayout );
00095 
00096     /* The widget must be as small as possible */
00097     widget->setFixedSize( widget->minimumSizeHint() );
00098     setFixedSize( widget->minimumSizeHint() );
00099 
00100     /* Setting Tab Order */
00101     setTabOrder( teFileContent, leNewLine );
00102     setTabOrder( leNewLine, pbAddNewLine );
00103     setTabOrder( pbAddNewLine, pbOK );
00104     setTabOrder( pbOK, pbCancel );
00105 
00106     /* Connecting button signals to slots */
00107     connect( pbAddNewLine, SIGNAL( clicked() ),
00108              this, SLOT( addNewLine() ) );
00109     connect( pbOK, SIGNAL( clicked() ), this, SLOT( processInput() ) );
00110     connect( pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
00111 
00112     if( readSyncFile( fiSyncFile ) )
00113         return true;
00114     else
00115         return false;
00116 }

void RioMMSync::processInput (  )  [private, slot]

Definition at line 238 of file RioMMSync.cpp.

00239 {
00240     if( writeSyncFile( ) )
00241         accept();
00242 }

bool RioMMSync::readSyncFile ( QFileInfo  fiSyncFile  )  [private]

Definition at line 118 of file RioMMSync.cpp.

00119 {
00120     QString sBlock;
00121     int return_value = false;
00122 
00123     /* Create block id */
00124     sBlock.setNum( blockNumber );
00125     sBlock = "    [" + sBlock + "] ";
00126     fSyncFile.setName( fiSyncFile.filePath() );
00127     switch( syncType )
00128     {
00129         case SYNC_NONE:
00130             if( ! fSyncFile.exists() )
00131             {
00132                 teFileContent->append( "Version(1,0);\n" );
00133                 return_value = true;
00134             }
00135             else
00136             {
00137                 if( fSyncFile.open( IO_ReadOnly ) )
00138                 {
00139                     tsSyncFile = new QTextStream( &fSyncFile );
00140                     while( ! tsSyncFile->atEnd() )
00141                         teFileContent->append( tsSyncFile->readLine() );
00142                     fSyncFile.close();
00143                     return_value = true;
00144                 }
00145                 else
00146                     QMessageBox::critical( 0, "riommclient",
00147                                            "Could not open file:"
00148                                            + fiSyncFile.fileName() );
00149             }
00150             leNewLine->setText( sBlock );
00151 
00152             break;
00153 
00154         case SYNC_BROWSER:
00155             if( ! fSyncFile.exists() )
00156             {
00157                 teFileContent->append( "Version(1,0);\n" );
00158                 teFileContent->append( "Archive(\"" + fiSyncFile.baseName()
00159                                        + ".zip\");\n" );
00160                 return_value = true;
00161             }
00162             else
00163             {
00164                 if( fSyncFile.open( IO_ReadOnly ) )
00165                 {
00166                     tsSyncFile = new QTextStream( &fSyncFile );
00167                     while( ! tsSyncFile->atEnd() )
00168                         teFileContent->append( tsSyncFile->readLine() );
00169                     fSyncFile.close();
00170                     return_value = true;
00171                 }
00172                 else
00173                     QMessageBox::critical( 0, "riommclient",
00174                                            "Could not open file:"
00175                                            + fiSyncFile.fileName() );
00176             }
00177             leNewLine->setText( sBlock + "OpenURL(\"LOCAL:imgN.html\");" );
00178 
00179             break;
00180 
00181         case SYNC_TGIF:
00182             if( ! fSyncFile.exists() )
00183             {
00184                 teFileContent->append( "Version(1,0);\n" );
00185                 teFileContent->append( "Archive(\"" + fiSyncFile.baseName()
00186                                        + ".zip\");\n" );
00187                 teFileContent->append( "[0] File(\"" + fiSyncFile.baseName()
00188                                        + ".obj\")\n{" );
00189                 return_value = true;
00190             }
00191             else
00192             {
00193                 if( fSyncFile.open( IO_ReadOnly ) )
00194                 {
00195                     tsSyncFile = new QTextStream( &fSyncFile );
00196                     while( ! tsSyncFile->atEnd() )
00197                         teFileContent->append( tsSyncFile->readLine() );
00198                     fSyncFile.close();
00199                     return_value = true;
00200                 }
00201                 else
00202                     QMessageBox::critical( 0, "riommclient",
00203                                            "Could not open file:"
00204                                            + fiSyncFile.fileName() );
00205             }
00206             leNewLine->setText( sBlock + "Slide(N);" );
00207 
00208             break;
00209     }
00210 
00211     return return_value;
00212 }

bool RioMMSync::writeSyncFile (  )  [private]

Definition at line 214 of file RioMMSync.cpp.

00215 {
00216     bool return_value = false;
00217 
00218     if( fSyncFile.exists() )
00219         if( ! fSyncFile.remove() )
00220             QMessageBox::critical( 0, "riommclient",
00221                                "Could not create file:"
00222                                + fSyncFile.name() );
00223 
00224     if( fSyncFile.open( IO_WriteOnly ) )
00225     {
00226         tsSyncFile = new QTextStream( &fSyncFile );
00227         ( *tsSyncFile ) << teFileContent->text() << endl;
00228         fSyncFile.close();
00229         return_value = true;
00230     }
00231     else
00232         QMessageBox::critical( 0, "riommclient",
00233                                "Could not create file:"
00234                                + fSyncFile.name() );
00235     return return_value;
00236 }


Field Documentation

int RioMMSync::blockNumber [private]

Definition at line 47 of file RioMMSync.h.

QFile RioMMSync::fSyncFile [private]

Definition at line 42 of file RioMMSync.h.

QLineEdit* RioMMSync::leNewLine [private]

Definition at line 38 of file RioMMSync.h.

int RioMMSync::syncType [private]

Definition at line 46 of file RioMMSync.h.

QTextEdit* RioMMSync::teFileContent [private]

Definition at line 40 of file RioMMSync.h.

QTextStream* RioMMSync::tsSyncFile [private]

Definition at line 44 of file RioMMSync.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:36 2012 for RIO by  doxygen 1.6.3