QElectroTech  0.70
renamedialog.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech 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, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "renamedialog.h"
19 
20 #include <utility>
21 #include "ui_renamedialog.h"
22 
23 RenameDialog::RenameDialog(QString path, QWidget *parent) :
24  QDialog(parent),
25  ui(new Ui::RenameDialog),
26  m_path(std::move(path))
27 {
28  ui->setupUi(this);
29  m_name = m_path.split("/").last();
30  if (m_name.endsWith(".elmt")) m_name.remove(".elmt");
31  ui->m_label->setText(tr("L'élément « %1 » existe déjà. Que souhaitez-vous faire ?").arg(m_path));
32  ui->lineEdit->setText(m_name + QDate::currentDate().toString("dd-MM-yy"));
33 }
34 
36 {
37  delete ui;
38 }
39 
40 void RenameDialog::on_lineEdit_textEdited(const QString &arg1)
41 {
42  if (arg1.isEmpty() || (arg1 == m_name))
43  ui->m_rename_pb->setDisabled(true);
44  else
45  ui->m_rename_pb->setEnabled(true);
46 }
47 
49 {
51  accept();
52 }
53 
55 {
57  m_new_name = ui->lineEdit->text();
58  if (m_path.endsWith(".elmt")) m_new_name.append(".elmt");
59  accept();
60 }
61 
63 {
65  reject();
66 }
abort the whole operation, ignoring the curent item
Definition: qet.h:129
void on_m_rename_pb_clicked()
QET::Action m_action
Definition: renamedialog.h:50
void on_lineEdit_textEdited(const QString &arg1)
QString m_path
Definition: renamedialog.h:47
QString m_new_name
Definition: renamedialog.h:49
void on_m_cancel_pb_clicked()
QString m_name
Definition: renamedialog.h:48
the target has to be renamed
Definition: qet.h:131
Erase the target content.
Definition: qet.h:128
RenameDialog(QString path, QWidget *parent=nullptr)
QIcon tr
Definition: qeticons.cpp:204
void on_m_erase_pb_clicked()
~RenameDialog() override
Ui::RenameDialog * ui
Definition: renamedialog.h:46