コード例 #1
0
ファイル: clearprivatedata.cpp プロジェクト: Haommin/qupzilla
void ClearPrivateData::dialogAccepted()
{
    QApplication::setOverrideCursor(Qt::WaitCursor);

    if (ui->history->isChecked()) {
        qint64 start = QDateTime::currentMSecsSinceEpoch();
        qint64 end = 0;

        const QDate &today = QDate::currentDate();
        const QDate &week = today.addDays(1 - today.dayOfWeek());
        const QDate &month = QDate(today.year(), today.month(), 1);

        switch (ui->historyLength->currentIndex()) {
        case 0: //Later Today
            end = QDateTime(today).toMSecsSinceEpoch();
            break;
        case 1: //Week
            end = QDateTime(week).toMSecsSinceEpoch();
            break;
        case 2: //Month
            end = QDateTime(month).toMSecsSinceEpoch();
            break;
        case 3: //All
            break;
        }

        if (end == 0) {
            mApp->history()->clearHistory();
        }
        else {
            const QList<int> &indexes = mApp->history()->indexesFromTimeRange(start, end);
            mApp->history()->deleteHistoryEntry(indexes);
        }
    }

    if (ui->cookies->isChecked()) {
        mApp->cookieJar()->setAllCookies(QList<QNetworkCookie>());
    }

    if (ui->cache->isChecked()) {
        clearCache();
    }

    if (ui->databases->isChecked()) {
        clearWebDatabases();
    }

    if (ui->localStorage->isChecked()) {
        clearLocalStorage();
    }

    if (ui->icons->isChecked()) {
        clearIcons();
    }

    QApplication::restoreOverrideCursor();

    close();
}
コード例 #2
0
void gstIconManager::SetPath(IconReference::Type ctype,
                             const std::string& path) {
  icon_path_[ctype].resize(0);

  clearIcons(ctype);

  // empty path de-activates directory searches
  if (path.length() == 0)
    return;

  // validate directory
  if (!khDirExists(path)) {
    if (!khMakeDir(path)) {
      notify(NFY_WARN, "Unable to create icon directory: %s", path.c_str());
      return;
    }
    // the icon dir needs wide open permissions for now
    khChmod(path, 0777);
  }

  DIR* icondir = opendir(path.c_str());
  if (icondir == NULL) {
    notify(NFY_WARN, "Unable to open directory: %s", path.c_str());
    return;
  }

  // find all icons in directory
  // This list does not need to be sorted.
  struct dirent *d;
  while ((d = readdir(icondir)) != NULL) {
    // ignore special directory names
    if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
      continue;

    const std::string& name = d->d_name;
    if (Validate(khComposePath(path, name)) == true) {
      collection_[ctype].push_back(gstIcon(name, ctype));
    }
  }

  closedir(icondir);

  icon_path_[ctype] = path;
}
コード例 #3
0
gstIconManager::~gstIconManager() {
  clearIcons(IconReference::Internal);
  clearIcons(IconReference::External);
}