コード例 #1
0
ファイル: athaneditor.cpp プロジェクト: ghannami/alQuds
void AthanEditor::initAthanFiles()
{
    ui->fajrBox->clear();
    QFileInfo tFileInfo(mFajrFile);
    ui->fajrBox->addItem(tFileInfo.fileName());

    ui->fajrBox->insertSeparator(1);
    ui->fajrBox->addItem("Select...", PrayerTimes::Fajr);

    ui->dhurBox->clear();
    tFileInfo = QFileInfo(mDuhrFile);
    ui->dhurBox->addItem(tFileInfo.fileName());
    ui->dhurBox->insertSeparator(1);
    ui->dhurBox->addItem("Select...", PrayerTimes::Dhuhr);

    ui->asrBox->clear();
    tFileInfo = QFileInfo(mAsrFile);
    ui->asrBox->addItem(tFileInfo.fileName());
    ui->asrBox->insertSeparator(1);
    ui->asrBox->addItem("Select...", PrayerTimes::Asr);

    ui->maghribBox->clear();
    tFileInfo = QFileInfo(mMaghribFile);
    ui->maghribBox->addItem(tFileInfo.fileName());
    ui->maghribBox->insertSeparator(1);
    ui->maghribBox->addItem("Select...", PrayerTimes::Maghrib);

    ui->ishaBox->clear();
    tFileInfo = QFileInfo(mIshaFile);
    ui->ishaBox->addItem(tFileInfo.fileName());
    ui->ishaBox->insertSeparator(1);
    ui->ishaBox->addItem("Select...", PrayerTimes::Isha);

    ui->saveButton->setEnabled(true);
}
コード例 #2
0
void ProjectSelectionPage::validateData()
{
    KUrl url = ui->locationUrl->url();
    if( !url.isLocalFile() || url.isEmpty() )
    {
        ui->locationValidLabel->setText( i18n("Invalid location") );
        setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
        emit invalid();
        return;
    }

    if( appName().isEmpty() )
    {
        ui->locationValidLabel->setText( i18n("Empty project name") );
        setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
        emit invalid();
        return;
    }

    if( appName() == "." || appName() == "..")
    {
        ui->locationValidLabel->setText( i18n("Invalid project name") );
        setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
        emit invalid();
        return;
    }

    QDir tDir(url.toLocalFile( KUrl::RemoveTrailingSlash ));
    while (!tDir.exists() && !tDir.isRoot())
        tDir.setPath( pathUp( tDir.absolutePath() ));

    if (tDir.exists())
    {
        QFileInfo tFileInfo(tDir.absolutePath());
        if (!tFileInfo.isWritable() || !tFileInfo.isExecutable())
        {
            ui->locationValidLabel->setText( i18n("Unable to create subdirectories, "
                                                  "missing permissions on: %1", tDir.absolutePath()) );
            setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
            emit invalid();
            return;
        }
    }

    QStandardItem* item = m_templatesModel->itemFromIndex( ui->templateView->currentIndex() );
    if( item && !item->hasChildren() )
    {
        ui->locationValidLabel->setText( QString(" ") );
        setForeground(ui->locationValidLabel, KColorScheme::NormalText);
        emit valid();
    } else
    {
        ui->locationValidLabel->setText( i18n("Invalid project template, please choose a leaf item") );
        setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
        emit invalid();
        return;
    }

    // Check for non-empty target directory. Not an error, but need to display a warning.
    url.addPath( encodedAppName() );
    QFileInfo fi( url.toLocalFile( KUrl::RemoveTrailingSlash ) );
    if( fi.exists() && fi.isDir() )
    {
        if( !QDir( fi.absoluteFilePath()).entryList( QDir::NoDotAndDotDot | QDir::AllEntries ).isEmpty() )
        {
            ui->locationValidLabel->setText( i18n("Path already exists and contains files") );
            setForeground(ui->locationValidLabel, KColorScheme::NegativeText);
        }
    }
}