QTfrontend/ui/page/pageplayrecord.cpp
changeset 6616 f77bb02b669f
parent 6060 fdfc01419815
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    29 #include "pageplayrecord.h"
    29 #include "pageplayrecord.h"
    30 
    30 
    31 QLayout * PagePlayDemo::bodyLayoutDefinition()
    31 QLayout * PagePlayDemo::bodyLayoutDefinition()
    32 {
    32 {
    33     QGridLayout * pageLayout = new QGridLayout();
    33     QGridLayout * pageLayout = new QGridLayout();
    34     
    34 
    35     pageLayout->setColumnStretch(0, 1);
    35     pageLayout->setColumnStretch(0, 1);
    36     pageLayout->setColumnStretch(1, 2);
    36     pageLayout->setColumnStretch(1, 2);
    37     pageLayout->setColumnStretch(2, 1);
    37     pageLayout->setColumnStretch(2, 1);
    38     pageLayout->setRowStretch(2, 100);
    38     pageLayout->setRowStretch(2, 100);
    39 
    39 
    79     if (rectype == RT_Demo)
    79     if (rectype == RT_Demo)
    80     {
    80     {
    81         dir.cd("Demos");
    81         dir.cd("Demos");
    82         extension = "hwd";
    82         extension = "hwd";
    83         BtnPlayDemo->setText(QPushButton::tr("Play demo"));
    83         BtnPlayDemo->setText(QPushButton::tr("Play demo"));
    84     } else
    84     }
       
    85     else
    85     {
    86     {
    86         dir.cd("Saves");
    87         dir.cd("Saves");
    87         extension = "hws";
    88         extension = "hws";
    88         BtnPlayDemo->setText(QPushButton::tr("Load"));
    89         BtnPlayDemo->setText(QPushButton::tr("Load"));
    89     }
    90     }
   106 {
   107 {
   107     QListWidgetItem * curritem = DemosList->currentItem();
   108     QListWidgetItem * curritem = DemosList->currentItem();
   108     if (!curritem)
   109     if (!curritem)
   109     {
   110     {
   110         QMessageBox::critical(this,
   111         QMessageBox::critical(this,
   111                 tr("Error"),
   112                               tr("Error"),
   112                 tr("Please select record from the list"),
   113                               tr("Please select record from the list"),
   113                 tr("OK"));
   114                               tr("OK"));
   114         return ;
   115         return ;
   115     }
   116     }
   116     QFile rfile(curritem->data(Qt::UserRole).toString());
   117     QFile rfile(curritem->data(Qt::UserRole).toString());
   117 
   118 
   118     QFileInfo finfo(rfile);
   119     QFileInfo finfo(rfile);
   122     QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
   123     QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok);
   123 
   124 
   124     if(ok && newname.size())
   125     if(ok && newname.size())
   125     {
   126     {
   126         QString newfullname = QString("%1/%2.%3.%4")
   127         QString newfullname = QString("%1/%2.%3.%4")
   127                                       .arg(finfo.absolutePath())
   128                               .arg(finfo.absolutePath())
   128                                       .arg(newname)
   129                               .arg(newname)
   129                                       .arg(*cProtoVer)
   130                               .arg(*cProtoVer)
   130                                       .arg(finfo.suffix());
   131                               .arg(finfo.suffix());
   131 
   132 
   132         ok = rfile.rename(newfullname);
   133         ok = rfile.rename(newfullname);
   133         if(!ok)
   134         if(!ok)
   134             QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname);
   135             QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname);
   135         else
   136         else
   141 {
   142 {
   142     QListWidgetItem * curritem = DemosList->currentItem();
   143     QListWidgetItem * curritem = DemosList->currentItem();
   143     if (!curritem)
   144     if (!curritem)
   144     {
   145     {
   145         QMessageBox::critical(this,
   146         QMessageBox::critical(this,
   146                 tr("Error"),
   147                               tr("Error"),
   147                 tr("Please select record from the list"),
   148                               tr("Please select record from the list"),
   148                 tr("OK"));
   149                               tr("OK"));
   149         return ;
   150         return ;
   150     }
   151     }
   151     QFile rfile(curritem->data(Qt::UserRole).toString());
   152     QFile rfile(curritem->data(Qt::UserRole).toString());
   152 
   153 
   153     bool ok;
   154     bool ok;