Exemple #1
0
void BGDialog::loadWallpaperFilesList()
{

    // Wallpapers
    // the following QMap is lower cased names mapped to cased names and URLs
    // this way we get case insensitive sorting
    QMap<QString, QPair<QString, QString> > papers;

    //search for .desktop files before searching for images without .desktop files
    QStringList lst = m_pDirs->findAllResources("wallpaper", "*desktop", KStandardDirs::NoDuplicates);
    QStringList files;
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        KDesktopFile fileConfig(*it);
        KConfigGroup cg = fileConfig.group("Wallpaper");

        QString imageCaption = cg.readEntry("Name");
        QString fileName = cg.readEntry("File");

        if (imageCaption.isEmpty()) {
            imageCaption = fileName;
            imageCaption.replace('_', ' ');
            imageCaption = KStringHandler::capwords(imageCaption);
        }

        // avoid name collisions
        QString rs = imageCaption;
        QString lrs = rs.toLower();
        for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
            rs = imageCaption + " (" + QString::number(n) + ')';
            lrs = rs.toLower();
        }
        int slash = (*it).lastIndexOf('/') + 1;
        QString directory = (*it).left(slash);
        if (cg.readEntry("ImageType") == QLatin1String("pixmap")) {
            papers[lrs] = qMakePair(rs, QString(directory + fileName));
            files.append(directory + fileName);
        }
    }

    //now find any wallpapers that don't have a .desktop file
    lst = m_pDirs->findAllResources("wallpaper", "*", KStandardDirs::NoDuplicates);
    for (QStringList::ConstIterator it = lst.constBegin(); it != lst.constEnd(); ++it) {
        if (!(*it).endsWith(".desktop") && files.filter(*it).empty()) {
            // First try to see if we have a comment describing the image.  If we do
            // just use the first line of said comment.
            KFileMetaInfo metaInfo(*it);
            QString imageCaption;

            if (metaInfo.isValid() && metaInfo.item("Comment").isValid())
                imageCaption = metaInfo.item("Comment").value().toString().section('\n', 0, 0);

            if (imageCaption.isEmpty()) {
                int slash = (*it).lastIndexOf('/') + 1;
                int endDot = (*it).lastIndexOf('.');

                // strip the extension if it exists
                if (endDot != -1 && endDot > slash)
                    imageCaption = (*it).mid(slash, endDot - slash);
                else
                    imageCaption = (*it).mid(slash);

                imageCaption.replace('_', ' ');
                imageCaption = KStringHandler::capwords(imageCaption);
            }

            // avoid name collisions
            QString rs = imageCaption;
            QString lrs = rs.toLower();
            for (int n = 1; papers.find(lrs) != papers.end(); ++n) {
                rs = imageCaption + " (" + QString::number(n) + ')';
                lrs = rs.toLower();
            }
            papers[lrs] = qMakePair(rs, *it);
        }
    }

    KComboBox *comboWallpaper = m_urlWallpaperBox;
    comboWallpaper->clear();
    m_wallpaper.clear();
    int i = 0;
    for (QMap<QString, QPair<QString, QString> >::Iterator it = papers.begin();
            it != papers.end();
            ++it) {
        comboWallpaper->addItem(it.value().first);
        m_wallpaper[it.value().second] = i;
        i++;
    }
}
void kiptablesgenerator::slotChangedProtocol(int newProtocol)
{
  // 0 = TCP
  // 1 = UDP
  // 2 = TCP+UDP
  // 3 = ICMP
  KComboBox *names = (KComboBox*) namedWidgets["newService_names"];
  names->clear();
  if (newProtocol != 3)
  {
    names->insertItem("SSH");
    names->insertItem("Telnet");
    names->insertItem("HTTP");
    names->insertItem("HTTPS");
    names->insertItem("SMTP");
    names->insertItem("SMTPS");
    names->insertItem("POP3");
    names->insertItem("POP3S");
    names->insertItem("IMAP");
    names->insertItem("IMAPS");
    ((QRadioButton *) namedWidgets["newService_numbered"])->setEnabled(true);
    ((QLineEdit *) namedWidgets["newService_ports"])->setEnabled(true);
    return;
  }
  ((QRadioButton *) namedWidgets["newService_numbered"])->setEnabled(false);
  ((QLineEdit *) namedWidgets["newService_ports"])->setEnabled(false);
  ((QRadioButton *) namedWidgets["newService_named"])->setChecked(true);
  names->insertItem("any");
  names->insertItem("echo-reply");
  names->insertItem("destination-unreachable");
  names->insertItem(" network-unreachable");
  names->insertItem(" host-unreachable");
  names->insertItem(" protocol-unreachable");
  names->insertItem(" port-unreachable");
  names->insertItem(" fragmentation-needed");
  names->insertItem(" source-route-failed");
  names->insertItem(" network-unknown");
  names->insertItem(" host-unknown");
  names->insertItem(" network-prohibited");
  names->insertItem(" host-prohibited");
  names->insertItem(" TOS-network-unreachable");
  names->insertItem(" TOS-host-unreachable");
  names->insertItem(" communication-prohibited");
  names->insertItem(" host-precedence-violation");
  names->insertItem(" precedence-cutoff");
  names->insertItem("source-quench");
  names->insertItem("redirect");
  names->insertItem(" network-redirect");
  names->insertItem(" host-redirect");
  names->insertItem(" TOS-network-redirect");
  names->insertItem(" TOS-host-redirect");
  names->insertItem("echo-request");
  names->insertItem("router-advertisement");
  names->insertItem("router-solicitation");
  names->insertItem("time-exceeded");
  names->insertItem(" ttl-zero-during-transit");
  names->insertItem(" ttl-zero-during-reassembly");
  names->insertItem("parameter-problem");
  names->insertItem(" ip-header-bad");
  names->insertItem(" required-option-missing");
  names->insertItem("timestamp-request");
  names->insertItem("timestamp-reply");
  names->insertItem("address-mask-request");
  names->insertItem("address-mask-reply");
}