mainwindow.cpp
author jake
Thu, 03 Jun 2010 15:47:45 +0300
changeset 1 b1c4884ae18f
parent 0 b856a9924bbc
child 2 0c23d71853fe
permissions -rw-r--r--
Missing graphics added
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b856a9924bbc initial contribution
jake
parents:
diff changeset
     1
#include "mainwindow.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     2
#include "ui_mainwindow.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     3
b856a9924bbc initial contribution
jake
parents:
diff changeset
     4
#include "widgetcreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     5
#include "renderercreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     6
#include "publishercreator.h"
b856a9924bbc initial contribution
jake
parents:
diff changeset
     7
b856a9924bbc initial contribution
jake
parents:
diff changeset
     8
#include <QMessageBox>
b856a9924bbc initial contribution
jake
parents:
diff changeset
     9
#include <QDir>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    10
#include <QTextStream>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    11
#include <QTimer>
b856a9924bbc initial contribution
jake
parents:
diff changeset
    12
b856a9924bbc initial contribution
jake
parents:
diff changeset
    13
b856a9924bbc initial contribution
jake
parents:
diff changeset
    14
MainWindow::MainWindow(QWidget *parent) :
b856a9924bbc initial contribution
jake
parents:
diff changeset
    15
    QMainWindow(parent), ui(new Ui::MainWindow), iLayoutIndex( 0 ), iLayoutCount( -1 )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    16
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    17
    ui->setupUi(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    18
    iTimer = new QTimer(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    19
    connect(iTimer, SIGNAL(timeout()), this, SLOT(updateLayout()));
b856a9924bbc initial contribution
jake
parents:
diff changeset
    20
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    21
b856a9924bbc initial contribution
jake
parents:
diff changeset
    22
MainWindow::~MainWindow()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    23
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    24
    delete ui;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    25
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    26
b856a9924bbc initial contribution
jake
parents:
diff changeset
    27
void MainWindow::changeEvent(QEvent *e)
b856a9924bbc initial contribution
jake
parents:
diff changeset
    28
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    29
    QMainWindow::changeEvent(e);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    30
    switch (e->type()) {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    31
    case QEvent::LanguageChange:
b856a9924bbc initial contribution
jake
parents:
diff changeset
    32
        ui->retranslateUi(this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    33
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    34
    default:
b856a9924bbc initial contribution
jake
parents:
diff changeset
    35
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    36
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    37
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    38
b856a9924bbc initial contribution
jake
parents:
diff changeset
    39
QString MainWindow::widgetName()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    40
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    41
    return ui->widgetName->text().toLower();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    42
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    43
b856a9924bbc initial contribution
jake
parents:
diff changeset
    44
QString MainWindow::widgetUid()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    45
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    46
    return ui->widgetUid->text().toLower();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    47
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    48
b856a9924bbc initial contribution
jake
parents:
diff changeset
    49
QCheckBox& MainWindow::rendererCheckBox()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    50
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    51
    return *ui->renderingCheckBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    52
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    53
b856a9924bbc initial contribution
jake
parents:
diff changeset
    54
QString MainWindow::rendererName()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    55
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    56
    return ui->rendererName->text();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    57
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    58
b856a9924bbc initial contribution
jake
parents:
diff changeset
    59
QString MainWindow::rendererUid()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    60
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    61
    return ui->rendererUid->text();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    62
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
    63
b856a9924bbc initial contribution
jake
parents:
diff changeset
    64
void MainWindow::on_pushButton_clicked()
b856a9924bbc initial contribution
jake
parents:
diff changeset
    65
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
    66
    if( widgetName().isEmpty() || widgetUid().isEmpty() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    67
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    68
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    69
        msgBox.setText("Widget name and UID must be given.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    70
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    71
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    72
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    73
b856a9924bbc initial contribution
jake
parents:
diff changeset
    74
    bool ok;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    75
    uint uidVal = widgetUid().toUInt(&ok, 16 );
b856a9924bbc initial contribution
jake
parents:
diff changeset
    76
    if( widgetUid().length() != 10 || !widgetUid().startsWith( "0x",Qt::CaseInsensitive ) || !ok )
b856a9924bbc initial contribution
jake
parents:
diff changeset
    77
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    78
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    79
        msgBox.setText("UID must be in 4 byte hexadecimal format\n 0x11223344.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    80
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    81
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    82
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    83
b856a9924bbc initial contribution
jake
parents:
diff changeset
    84
    if( uidVal >= 2147483648 ) //0x80000000
b856a9924bbc initial contribution
jake
parents:
diff changeset
    85
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
    86
        QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    87
        msgBox.setText("UID must be less than\n 0x80000000.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
    88
        msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    89
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    90
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
    91
b856a9924bbc initial contribution
jake
parents:
diff changeset
    92
    generateMainBuildFile();
b856a9924bbc initial contribution
jake
parents:
diff changeset
    93
b856a9924bbc initial contribution
jake
parents:
diff changeset
    94
    PublisherCreator* publisherCreator = new PublisherCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    95
    delete publisherCreator;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    96
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
    97
    WidgetCreator* widgetCreator = new WidgetCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
    98
    delete widgetCreator;
b856a9924bbc initial contribution
jake
parents:
diff changeset
    99
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
   100
    if( ui->renderingCheckBox->isChecked() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   101
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   102
        if( rendererName().isEmpty() || rendererUid().isEmpty() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   103
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   104
            QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   105
            msgBox.setText("Renderer name and UID must be given.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   106
            msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   107
            return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   108
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   109
        if( rendererUid().length() != 10 || !rendererUid().startsWith( "0x",Qt::CaseInsensitive ))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   110
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   111
            QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   112
            msgBox.setText("UID must be in hexadecimal format\n 0x11223344.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   113
            msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   114
            return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   115
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   116
        RendererCreator * renderer = new RendererCreator(*this);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   117
        delete renderer;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   118
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   119
/*
b856a9924bbc initial contribution
jake
parents:
diff changeset
   120
    QMessageBox msgBox;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   121
    msgBox.setText("Widget created.");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   122
    msgBox.exec();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   123
    return;*/
b856a9924bbc initial contribution
jake
parents:
diff changeset
   124
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   125
b856a9924bbc initial contribution
jake
parents:
diff changeset
   126
void MainWindow::generateMainBuildFile()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   127
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   128
    QDir dir;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   129
    dir.mkpath( widgetName() + "/group");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   130
    dir.setPath( widgetName() + "/group");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   131
    QFile file( dir.filePath("bld.inf"));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   132
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   133
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   134
b856a9924bbc initial contribution
jake
parents:
diff changeset
   135
    QTextStream out(&file);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   136
    generateLicense( out );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   137
    
b856a9924bbc initial contribution
jake
parents:
diff changeset
   138
    //out << "#include \"../publisherif/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   139
    out << "#include \"../testpublisher/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   140
    out << "#include \"../widget/group/bld.inf\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   141
    if( ui->renderingCheckBox->isChecked() )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   142
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   143
        out << "#include \"../renderingplugin/group/bld.inf\"\n\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   144
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   145
    out << "// End of File\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   146
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   147
b856a9924bbc initial contribution
jake
parents:
diff changeset
   148
void MainWindow::generateLicense( QTextStream& aStream )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   149
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   150
    aStream << "/*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   151
    aStream << "* Copyright (c) {Year(s)} {Copyright owner}.\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   152
    aStream << "* All rights reserved.\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   153
    aStream << "* This component and the accompanying materials are made available\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   154
    aStream << "* under the terms of the \"Eclipse Public License v1.0\"\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   155
    aStream << "* which accompanies this distribution, and is available\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   156
    aStream << "* at the URL \"http://www.symbianfoundation.org/legal/sfl-v10.html\".\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   157
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   158
    aStream << "* Initial Contributors:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   159
    aStream << "* {Name} {Company} – Initial contribution\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   160
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   161
    aStream << "* Contributors:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   162
    aStream << "* {Name} {Company} – {{Description of contribution}}\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   163
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   164
    aStream << "* Description:\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   165
    aStream << "* {{Description of the file}}\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   166
    aStream << "*\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   167
    aStream << "*/\n\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   168
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   169
b856a9924bbc initial contribution
jake
parents:
diff changeset
   170
QString MainWindow::widgetUidNoHex()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   171
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   172
    QString uid( widgetUid() );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   173
    if( uid.startsWith( "0x",Qt::CaseInsensitive ))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   174
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   175
        return uid.right(8);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   176
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   177
    else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   178
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   179
        return uid;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   180
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   181
b856a9924bbc initial contribution
jake
parents:
diff changeset
   182
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   183
b856a9924bbc initial contribution
jake
parents:
diff changeset
   184
void MainWindow::replaceData( QString sourceFile, QString destFile, bool noHexUid )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   185
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   186
    QString path = QDir::currentPath();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   187
    QFile infile(sourceFile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   188
    if (!infile.open(QIODevice::ReadWrite | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   189
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   190
b856a9924bbc initial contribution
jake
parents:
diff changeset
   191
    QTextStream in(&infile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   192
b856a9924bbc initial contribution
jake
parents:
diff changeset
   193
    QFile outfile(destFile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   194
    if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
b856a9924bbc initial contribution
jake
parents:
diff changeset
   195
        return;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   196
b856a9924bbc initial contribution
jake
parents:
diff changeset
   197
    QTextStream out(&outfile);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   198
b856a9924bbc initial contribution
jake
parents:
diff changeset
   199
    while (!in.atEnd())
b856a9924bbc initial contribution
jake
parents:
diff changeset
   200
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   201
        QString line = in.readLine();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   202
        line.replace(QString("#replace#"), widgetName());
b856a9924bbc initial contribution
jake
parents:
diff changeset
   203
        if( noHexUid )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   204
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   205
            line.replace(QString("#replaceuid#"), widgetUidNoHex());
b856a9924bbc initial contribution
jake
parents:
diff changeset
   206
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   207
        else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   208
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   209
            line.replace(QString("#replaceuid#"), widgetUid());
b856a9924bbc initial contribution
jake
parents:
diff changeset
   210
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   211
        out << line << "\n";
b856a9924bbc initial contribution
jake
parents:
diff changeset
   212
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   213
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   214
b856a9924bbc initial contribution
jake
parents:
diff changeset
   215
void MainWindow::on_renderingCheckBox_stateChanged(int state )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   216
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   217
    if( state == Qt::Unchecked )
b856a9924bbc initial contribution
jake
parents:
diff changeset
   218
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   219
        ui->rendererName->setEnabled( false );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   220
        ui->rendererUid->setEnabled( false );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   221
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   222
    else if ( state == Qt::Checked)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   223
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   224
        ui->rendererName->setEnabled( true );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   225
        ui->rendererUid->setEnabled( true);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   226
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   227
b856a9924bbc initial contribution
jake
parents:
diff changeset
   228
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   229
b856a9924bbc initial contribution
jake
parents:
diff changeset
   230
QString MainWindow::widgetLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   231
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   232
    switch (iLayoutIndex)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   233
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   234
    case 0:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   235
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   236
            return QString( "feed" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   237
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   238
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   239
    case 1:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   240
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   241
            return QString( "text" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   242
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   243
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   244
    case 2:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   245
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   246
            return QString( "iconstext" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   247
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   248
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   249
    case 3:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   250
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   251
            return QString( "graphictext" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   252
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   253
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   254
    };
b856a9924bbc initial contribution
jake
parents:
diff changeset
   255
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   256
b856a9924bbc initial contribution
jake
parents:
diff changeset
   257
void MainWindow::on_comboBox_currentIndexChanged(int index)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   258
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   259
    iLayoutIndex = index;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   260
    iLayoutCount = 3;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   261
    updateLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   262
b856a9924bbc initial contribution
jake
parents:
diff changeset
   263
b856a9924bbc initial contribution
jake
parents:
diff changeset
   264
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   265
b856a9924bbc initial contribution
jake
parents:
diff changeset
   266
void MainWindow::updateLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   267
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   268
    switch (iLayoutIndex)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   269
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   270
    case 0:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   271
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   272
            iTimer->stop();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   273
            showFeedsLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   274
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   275
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   276
    case 1:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   277
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   278
            showTextLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   279
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   280
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   281
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   282
    case 2:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   283
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   284
            showIconsTextLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   285
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   286
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   287
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   288
    case 3:
b856a9924bbc initial contribution
jake
parents:
diff changeset
   289
        {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   290
            showGraphicTextLayout();
b856a9924bbc initial contribution
jake
parents:
diff changeset
   291
            iTimer->start(2000);
b856a9924bbc initial contribution
jake
parents:
diff changeset
   292
        }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   293
        break;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   294
    };
b856a9924bbc initial contribution
jake
parents:
diff changeset
   295
b856a9924bbc initial contribution
jake
parents:
diff changeset
   296
    if( iLayoutCount > 1)
b856a9924bbc initial contribution
jake
parents:
diff changeset
   297
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   298
        iLayoutCount--;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   299
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   300
    else
b856a9924bbc initial contribution
jake
parents:
diff changeset
   301
    {
b856a9924bbc initial contribution
jake
parents:
diff changeset
   302
        iLayoutCount = 3;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   303
    }
b856a9924bbc initial contribution
jake
parents:
diff changeset
   304
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   305
b856a9924bbc initial contribution
jake
parents:
diff changeset
   306
void MainWindow::showFeedsLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   307
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   308
    ui->layoutGraphics->setPixmap(QPixmap(QString::fromUtf8(":/widgets/images/feeds_layout.jpg")));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   309
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   310
b856a9924bbc initial contribution
jake
parents:
diff changeset
   311
void MainWindow::showTextLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   312
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   313
    QString imagePath(":/widgets/images/text_layout_");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   314
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   315
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   316
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   317
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   318
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   319
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   320
b856a9924bbc initial contribution
jake
parents:
diff changeset
   321
void MainWindow::showIconsTextLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   322
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   323
    QString imagePath(":/widgets/images/iconstext_layout_");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   324
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   325
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   326
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   327
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   328
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   329
}
b856a9924bbc initial contribution
jake
parents:
diff changeset
   330
b856a9924bbc initial contribution
jake
parents:
diff changeset
   331
void MainWindow::showGraphicTextLayout()
b856a9924bbc initial contribution
jake
parents:
diff changeset
   332
{
b856a9924bbc initial contribution
jake
parents:
diff changeset
   333
    QString imagePath(":/widgets/images/graphictext_layout_");
b856a9924bbc initial contribution
jake
parents:
diff changeset
   334
    QString cnt;
b856a9924bbc initial contribution
jake
parents:
diff changeset
   335
    cnt.setNum( iLayoutCount );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   336
    imagePath.append( cnt );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   337
    imagePath.append( ".jpg" );
b856a9924bbc initial contribution
jake
parents:
diff changeset
   338
    ui->layoutGraphics->setPixmap(QPixmap(imagePath));
b856a9924bbc initial contribution
jake
parents:
diff changeset
   339
}