Corregida la validaci?n a los di?logos de crear y a?adir

This commit is contained in:
Luis Ángel San Martín
2013-05-05 15:30:56 +02:00
parent aa088334c3
commit 6d9008d3ff
4 changed files with 84 additions and 11 deletions

View File

@ -17,10 +17,12 @@ void AddLibraryDialog::setupUI()
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)));
accept = new QPushButton(tr("Add"));
accept->setDisabled(true);
@ -72,14 +74,46 @@ void AddLibraryDialog::add()
close();
}
void AddLibraryDialog::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);
}
void AddLibraryDialog::pathSetted(const QString & text)
{
QFileInfo fi(text);
if(fi.isDir())
{
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void AddLibraryDialog::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
path->setText(s);
accept->setEnabled(true);
if(!nameEdit->text().isEmpty())
accept->setEnabled(true);
}
else
accept->setEnabled(false);
}
void AddLibraryDialog::close()

View File

@ -25,6 +25,8 @@
void add();
void findPath();
void close();
void nameSetted(const QString & text);
void pathSetted(const QString & text);
signals:
void addLibrary(QString target, QString name);
};

View File

@ -17,10 +17,12 @@ void CreateLibraryDialog::setupUI()
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)));
accept = new QPushButton(tr("Create"));
accept->setDisabled(true);
@ -108,16 +110,6 @@ void CreateLibraryDialog::create()
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::findPath()
{
QString s = QFileDialog::getExistingDirectory(0,"Comics directory",".");
if(!s.isEmpty())
{
path->setText(s);
accept->setEnabled(true);
}
}
void CreateLibraryDialog::showCurrentFile(QString file)
{
currentFileLabel->setText(tr("Importing : \n") + file);
@ -125,6 +117,49 @@ void CreateLibraryDialog::showCurrentFile(QString file)
//this->adjustSize();
//is->update();
}
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);
}
void CreateLibraryDialog::pathSetted(const QString & text)
{
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);
}
void CreateLibraryDialog::close()
{
progressBar->hide();

View File

@ -31,6 +31,8 @@
void showCurrentFile(QString file);
void close();
void setDataAndStart(QString name, QString paht);
void nameSetted(const QString & text);
void pathSetted(const QString & text);
signals:
void createLibrary(QString source, QString target, QString name);
void cancelCreate();