author | unc0rr |
Mon, 22 Feb 2016 23:49:54 +0300 | |
changeset 11563 | 7e5d6ce6fe14 |
parent 11046 | 47a8c19ecb60 |
child 11819 | 7642955690bc |
permissions | -rw-r--r-- |
579 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
579 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
579 | 17 |
*/ |
18 |
||
7000 | 19 |
#include "pageplayrecord.h" |
20 |
||
579 | 21 |
#include <QFont> |
22 |
#include <QGridLayout> |
|
23 |
#include <QPushButton> |
|
24 |
#include <QListWidget> |
|
627 | 25 |
#include <QListWidgetItem> |
26 |
#include <QFileInfo> |
|
27 |
#include <QMessageBox> |
|
28 |
#include <QInputDialog> |
|
579 | 29 |
|
30 |
#include "hwconsts.h" |
|
7000 | 31 |
|
32 |
#include "DataManager.h" |
|
579 | 33 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
34 |
QLayout * PagePlayDemo::bodyLayoutDefinition() |
579 | 35 |
{ |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
36 |
QGridLayout * pageLayout = new QGridLayout(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
37 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
38 |
pageLayout->setColumnStretch(0, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
39 |
pageLayout->setColumnStretch(1, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
40 |
pageLayout->setColumnStretch(2, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
41 |
pageLayout->setRowStretch(2, 100); |
579 | 42 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
43 |
BtnPlayDemo = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
44 |
BtnPlayDemo->setFont(*font14); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
45 |
BtnPlayDemo->setText(QPushButton::tr("Play demo")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
46 |
pageLayout->addWidget(BtnPlayDemo, 3, 2); |
579 | 47 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
48 |
BtnRenameRecord = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
49 |
BtnRenameRecord->setText(QPushButton::tr("Rename")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
50 |
pageLayout->addWidget(BtnRenameRecord, 0, 2); |
627 | 51 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
52 |
BtnRemoveRecord = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
53 |
BtnRemoveRecord->setText(QPushButton::tr("Delete")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
54 |
pageLayout->addWidget(BtnRemoveRecord, 1, 2); |
720 | 55 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
56 |
DemosList = new QListWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
57 |
DemosList->setGeometry(QRect(170, 10, 311, 311)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
58 |
pageLayout->addWidget(DemosList, 0, 1, 3, 1); |
627 | 59 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
60 |
return pageLayout; |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
61 |
} |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
62 |
|
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
63 |
void PagePlayDemo::connectSignals() |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
64 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
65 |
connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
66 |
connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord())); |
7000 | 67 |
connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(refresh())); |
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
68 |
} |
6009 | 69 |
|
6042
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
70 |
PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent) |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
71 |
{ |
8b5345758f62
some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents:
6009
diff
changeset
|
72 |
initPage(); |
579 | 73 |
} |
74 |
||
581 | 75 |
void PagePlayDemo::FillFromDir(RecordType rectype) |
579 | 76 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
77 |
QDir dir; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
78 |
QString extension; |
581 | 79 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
80 |
recType = rectype; |
627 | 81 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
82 |
dir.cd(cfgdir->absolutePath()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
83 |
if (rectype == RT_Demo) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
84 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
85 |
dir.cd("Demos"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
86 |
extension = "hwd"; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
87 |
BtnPlayDemo->setText(QPushButton::tr("Play demo")); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
88 |
} |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
89 |
else |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
90 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
91 |
dir.cd("Saves"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
92 |
extension = "hws"; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
93 |
BtnPlayDemo->setText(QPushButton::tr("Load")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
94 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
95 |
dir.setFilter(QDir::Files); |
580 | 96 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
97 |
QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
98 |
sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1"); |
580 | 99 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
100 |
DemosList->clear(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
101 |
DemosList->addItems(sl); |
579 | 102 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
103 |
for (int i = 0; i < DemosList->count(); ++i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
104 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
105 |
DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
106 |
DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png")); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
107 |
} |
579 | 108 |
} |
109 |
||
7000 | 110 |
|
111 |
void PagePlayDemo::refresh() |
|
112 |
{ |
|
7130 | 113 |
if (this->isVisible()) |
7000 | 114 |
FillFromDir(recType); |
115 |
} |
|
116 |
||
117 |
||
627 | 118 |
void PagePlayDemo::renameRecord() |
119 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
120 |
QListWidgetItem * curritem = DemosList->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
121 |
if (!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
122 |
{ |
7794
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
123 |
QMessageBox recordMsg(this); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
124 |
recordMsg.setIcon(QMessageBox::Warning); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
125 |
recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
126 |
recordMsg.setText(QMessageBox::tr("Please select record from the list")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
127 |
recordMsg.setWindowModality(Qt::WindowModal); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
128 |
recordMsg.exec(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
129 |
return ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
130 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
131 |
QFile rfile(curritem->data(Qt::UserRole).toString()); |
627 | 132 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
133 |
QFileInfo finfo(rfile); |
627 | 134 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
135 |
bool ok; |
627 | 136 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
137 |
QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok); |
627 | 138 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
139 |
if(ok && newname.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
140 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
141 |
QString newfullname = QString("%1/%2.%3.%4") |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
142 |
.arg(finfo.absolutePath()) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
143 |
.arg(newname) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
144 |
.arg(*cProtoVer) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6060
diff
changeset
|
145 |
.arg(finfo.suffix()); |
627 | 146 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
147 |
ok = rfile.rename(newfullname); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
148 |
if(!ok) |
7794
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
149 |
{ |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
150 |
QMessageBox renameMsg(this); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
151 |
renameMsg.setIcon(QMessageBox::Warning); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
152 |
renameMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
153 |
renameMsg.setText(QMessageBox::tr("Cannot rename to ") + newfullname); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
154 |
renameMsg.setWindowModality(Qt::WindowModal); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
155 |
renameMsg.exec(); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
156 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
157 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
158 |
FillFromDir(recType); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
159 |
} |
627 | 160 |
} |
720 | 161 |
|
162 |
void PagePlayDemo::removeRecord() |
|
163 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
164 |
QListWidgetItem * curritem = DemosList->currentItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
165 |
if (!curritem) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
166 |
{ |
7794
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
167 |
QMessageBox recordMsg(this); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
168 |
recordMsg.setIcon(QMessageBox::Warning); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
169 |
recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
170 |
recordMsg.setText(QMessageBox::tr("Please select record from the list")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
171 |
recordMsg.setWindowModality(Qt::WindowModal); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
172 |
recordMsg.exec(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
173 |
return ; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
174 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
175 |
QFile rfile(curritem->data(Qt::UserRole).toString()); |
720 | 176 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
177 |
bool ok; |
720 | 178 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
179 |
ok = rfile.remove(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
180 |
if(!ok) |
7794
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
181 |
{ |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
182 |
QMessageBox removeMsg(this); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
183 |
removeMsg.setIcon(QMessageBox::Warning); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
184 |
removeMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
185 |
removeMsg.setText(QMessageBox::tr("Cannot delete file ") + rfile.fileName()); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
186 |
removeMsg.setWindowModality(Qt::WindowModal); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
187 |
removeMsg.exec(); |
ab7b94c03bc9
QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents:
7382
diff
changeset
|
188 |
} |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2742
diff
changeset
|
189 |
else |
7382
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
190 |
{ |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
191 |
int i = DemosList->row(curritem); |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
192 |
delete curritem; |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
193 |
DemosList->setCurrentRow(i < DemosList->count() ? i : DemosList->count() - 1); |
b158940f83e2
When removing a record, set selection on the next item in the list
unc0rr
parents:
7130
diff
changeset
|
194 |
} |
720 | 195 |
} |
5865 | 196 |
|
197 |
bool PagePlayDemo::isSave() |
|
198 |
{ |
|
199 |
return recType == RT_Save; |
|
200 |
} |