Format code using clang-format

This commit is contained in:
Luis Ángel San Martín
2019-05-30 19:46:37 +02:00
parent e0eb94e3ae
commit e3ec56aa43
356 changed files with 19824 additions and 21874 deletions

View File

@ -6,201 +6,190 @@
#include <QSizePolicy>
#include <QMessageBox>
CreateLibraryDialog::CreateLibraryDialog(QWidget * parent)
:QDialog(parent)
CreateLibraryDialog::CreateLibraryDialog(QWidget *parent)
: QDialog(parent)
{
setupUI();
setupUI();
}
void CreateLibraryDialog::setupUI()
{
textLabel = new QLabel(tr("Comics folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
connect(path,SIGNAL(textChanged(QString)),this,SLOT(pathSetted(QString)));
textLabel = new QLabel(tr("Comics folder : "));
path = new QLineEdit;
textLabel->setBuddy(path);
connect(path, SIGNAL(textChanged(QString)), this, SLOT(pathSetted(QString)));
nameLabel = new QLabel(tr("Library Name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit,SIGNAL(textChanged(QString)),this,SLOT(nameSetted(QString)));
nameLabel = new QLabel(tr("Library Name : "));
nameEdit = new QLineEdit;
nameLabel->setBuddy(nameEdit);
connect(nameEdit, SIGNAL(textChanged(QString)), this, SLOT(nameSetted(QString)));
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
connect(accept,SIGNAL(clicked()),this,SLOT(create()));
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
connect(accept, SIGNAL(clicked()), this, SLOT(create()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelCreate()));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
cancel = new QPushButton(tr("Cancel"));
connect(cancel, SIGNAL(clicked()), this, SIGNAL(cancelCreate()));
connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
find = new QPushButton(QIcon(":/images/find_folder.png"),"");
connect(find,SIGNAL(clicked()),this,SLOT(findPath()));
find = new QPushButton(QIcon(":/images/find_folder.png"), "");
connect(find, SIGNAL(clicked()), this, SLOT(findPath()));
QGridLayout * content = new QGridLayout;
QGridLayout *content = new QGridLayout;
//QHBoxLayout *nameLayout = new QHBoxLayout;
//QHBoxLayout *nameLayout = new QHBoxLayout;
content->addWidget(nameLabel,0,0);
content->addWidget(nameEdit,0,1);
content->addWidget(nameLabel, 0, 0);
content->addWidget(nameEdit, 0, 1);
//QHBoxLayout *libraryLayout = new QHBoxLayout;
//QHBoxLayout *libraryLayout = new QHBoxLayout;
content->addWidget(textLabel,1,0);
content->addWidget(path,1,1);
content->addWidget(find,1,2);
content->setColumnMinimumWidth(2,0); //TODO
content->addWidget(textLabel, 1, 0);
content->addWidget(path, 1, 1);
content->addWidget(find, 1, 2);
content->setColumnMinimumWidth(2, 0); //TODO
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
message->setWordWrap(true);
//message->hide();
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(message = new QLabel(tr("Create a library could take several minutes. You can stop the process and update the library later for completing the task.")));
message->setWordWrap(true);
//message->hide();
bottomLayout->addStretch();
bottomLayout->addWidget(accept);
bottomLayout->addWidget(cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(content);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(content);
mainLayout->addLayout(bottomLayout);
mainLayout->addLayout(bottomLayout);
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/new.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel *imgLabel = new QLabel(this);
QPixmap p(":/images/new.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setModal(true);
setWindowTitle(tr("Create new library"));
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Create new library"));
}
void CreateLibraryDialog::open(const YACReaderLibraries & libs)
void CreateLibraryDialog::open(const YACReaderLibraries &libs)
{
libraries = libs;
libraries = libs;
QDialog::open();
}
void CreateLibraryDialog::create()
{
QFileInfo f(path->text());
if(f.exists() && f.isDir() && f.isWritable())
{
if(!libraries.contains(nameEdit->text()))
{
emit(createLibrary(QDir::cleanPath(path->text()),QDir::cleanPath(path->text())+"/.yacreaderlibrary",nameEdit->text()));
close();
}
else
emit(libraryExists(nameEdit->text()));
}
else
QMessageBox::critical(NULL,tr("Path not found"),tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
QFileInfo f(path->text());
if (f.exists() && f.isDir() && f.isWritable()) {
if (!libraries.contains(nameEdit->text())) {
emit(createLibrary(QDir::cleanPath(path->text()), QDir::cleanPath(path->text()) + "/.yacreaderlibrary", nameEdit->text()));
close();
} else
emit(libraryExists(nameEdit->text()));
} else
QMessageBox::critical(NULL, tr("Path not found"), tr("The selected path does not exist or is not a valid path. Be sure that you have write access to this folder"));
}
void CreateLibraryDialog::nameSetted(const QString & text)
void CreateLibraryDialog::nameSetted(const QString &text)
{
if(!text.isEmpty())
{
if(!path->text().isEmpty())
{
QFileInfo fi(path->text());
if(fi.isDir())
accept->setEnabled(true);
else
accept->setEnabled(false);
}
}
else
accept->setEnabled(false);
if (!text.isEmpty()) {
if (!path->text().isEmpty()) {
QFileInfo fi(path->text());
if (fi.isDir())
accept->setEnabled(true);
else
accept->setEnabled(false);
}
} else
accept->setEnabled(false);
}
void CreateLibraryDialog::pathSetted(const QString & text)
void CreateLibraryDialog::pathSetted(const QString &text)
{
QFileInfo fi(text);
if(fi.isDir())
{
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
QFileInfo fi(text);
if (fi.isDir()) {
if (!nameEdit->text().isEmpty())
accept->setEnabled(true);
} else
accept->setEnabled(false);
}
void CreateLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
path->setText(s);
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
QString s = QFileDialog::getExistingDirectory(0, "Comics directory", ".");
if (!s.isEmpty()) {
path->setText(s);
if (!nameEdit->text().isEmpty())
accept->setEnabled(true);
} else
accept->setEnabled(false);
}
void CreateLibraryDialog::close()
{
path->clear();
nameEdit->clear();
accept->setEnabled(false);
QDialog::close();
path->clear();
nameEdit->clear();
accept->setEnabled(false);
QDialog::close();
}
void CreateLibraryDialog::setDataAndStart(QString name, QString path)
{
this->path->setText(path);
this->nameEdit->setText(name);
this->path->setText(path);
this->nameEdit->setText(name);
QDialog::open();
create();
create();
}
//-----------------------------------------------------------------------------
// UpdateLibraryDialog
//-----------------------------------------------------------------------------
UpdateLibraryDialog::UpdateLibraryDialog(QWidget * parent)
:QDialog(parent)
UpdateLibraryDialog::UpdateLibraryDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addWidget(message = new QLabel(tr("Updating....")));
mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
currentFileLabel->setWordWrap(true);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(message = new QLabel(tr("Updating....")));
mainLayout->addWidget(currentFileLabel = new QLabel("\n\n\n\n"));
currentFileLabel->setWordWrap(true);
QHBoxLayout * bottom = new QHBoxLayout;
bottom->addStretch();
bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
QHBoxLayout *bottom = new QHBoxLayout;
bottom->addStretch();
bottom->addWidget(cancel = new QPushButton(tr("Cancel")));
connect(cancel,SIGNAL(clicked()),this,SIGNAL(cancelUpdate()));
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
mainLayout->addStretch();
mainLayout->addLayout(bottom);
connect(cancel, SIGNAL(clicked()), this, SIGNAL(cancelUpdate()));
connect(cancel, SIGNAL(clicked()), this, SLOT(close()));
QHBoxLayout * imgMainLayout = new QHBoxLayout;
QLabel * imgLabel = new QLabel(this);
QPixmap p(":/images/updateLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
mainLayout->addStretch();
setModal(true);
setWindowTitle(tr("Update library"));
mainLayout->addLayout(bottom);
QHBoxLayout *imgMainLayout = new QHBoxLayout;
QLabel *imgLabel = new QLabel(this);
QPixmap p(":/images/updateLibrary.png");
imgLabel->setPixmap(p);
imgMainLayout->addWidget(imgLabel);
imgMainLayout->addLayout(mainLayout);
setLayout(imgMainLayout);
setModal(true);
setWindowTitle(tr("Update library"));
}
void UpdateLibraryDialog::showCurrentFile(QString file)
{
currentFileLabel->setText(file);
currentFileLabel->update();
this->update();
currentFileLabel->setText(file);
currentFileLabel->update();
this->update();
}
void UpdateLibraryDialog::close()
{
currentFileLabel->setText("");
this->adjustSize();
QDialog::close();
currentFileLabel->setText("");
this->adjustSize();
QDialog::close();
}