Example #1
0
void HistoryModel::removeEntry(quint64 identifier)
{
	HistoryEntryItem *entry(getEntry(identifier));

	if (!entry)
	{
		return;
	}

	const QUrl url(Utils::normalizeUrl(entry->data(UrlRole).toUrl()));

	if (m_urls.contains(url))
	{
		m_urls[url].removeAll(entry);

		if (m_urls[url].isEmpty())
		{
			m_urls.remove(url);
		}
	}

	if (identifier > 0 && m_identifiers.contains(identifier))
	{
		m_identifiers.remove(identifier);
	}

	emit entryRemoved(entry);

	removeRow(entry->row());

	emit modelModified();
}
Example #2
0
HistoryManager::HistoryManager(QObject *parent)
    :
#if defined(QWEBENGINEHISTORYINTERFACE)
      QWebEngineHistoryInterface(parent),
#endif
      m_saveTimer(new AutoSaver(this))
    , m_historyLimit(30)
    , m_historyModel(0)
    , m_historyFilterModel(0)
    , m_historyTreeModel(0)
{
    m_expiredTimer.setSingleShot(true);
    connect(&m_expiredTimer, SIGNAL(timeout()),
            this, SLOT(checkForExpired()));
    connect(this, SIGNAL(entryAdded(HistoryItem)),
            m_saveTimer, SLOT(changeOccurred()));
    connect(this, SIGNAL(entryRemoved(HistoryItem)),
            m_saveTimer, SLOT(changeOccurred()));
    load();

    m_historyModel = new HistoryModel(this, this);
    m_historyFilterModel = new HistoryFilterModel(m_historyModel, this);
    m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);

#if defined(QWEBENGINEHISTORYINTERFACE)
    // QWebEngineHistoryInterface will delete the history manager
    QWebEngineHistoryInterface::setDefaultInterface(this);
#endif
}
Example #3
0
void HistoryManager::checkForExpired()
{
    if (m_historyLimit < 0 || m_history.isEmpty())
        return;

    QDateTime now = QDateTime::currentDateTime();
    int nextTimeout = 0;

    while (!m_history.isEmpty()) {
        QDateTime checkForExpired = m_history.last().dateTime;
        checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit));
        if (now.daysTo(checkForExpired) > 7) {
            // check at most in a week to prevent int overflows on the timer
            nextTimeout = 7 * 86400;
        } else {
            nextTimeout = now.secsTo(checkForExpired);
        }
        if (nextTimeout > 0)
            break;
        HistoryItem item = m_history.takeLast();
        // remove from saved file also
        m_lastSavedUrl = QString();
        emit entryRemoved(item);
    }

    if (nextTimeout > 0)
        m_expiredTimer.start(nextTimeout * 1000);
}
Example #4
0
void DvbEpgTableModel::setEpgModel(DvbEpgModel *epgModel_)
{
	if (epgModel != NULL) {
		Log("DvbEpgTableModel::setEpgModel: epg model already set");
		return;
	}

	epgModel = epgModel_;
	connect(epgModel, SIGNAL(entryAdded(DvbSharedEpgEntry)),
		this, SLOT(entryAdded(DvbSharedEpgEntry)));
	connect(epgModel, SIGNAL(entryAboutToBeUpdated(DvbSharedEpgEntry)),
		this, SLOT(entryAboutToBeUpdated(DvbSharedEpgEntry)));
	connect(epgModel, SIGNAL(entryUpdated(DvbSharedEpgEntry)),
		this, SLOT(entryUpdated(DvbSharedEpgEntry)));
	connect(epgModel, SIGNAL(entryRemoved(DvbSharedEpgEntry)),
		this, SLOT(entryRemoved(DvbSharedEpgEntry)));
}
Example #5
0
bool
XClientCache::handle_medialib_info_error (const std::string &error, uint32_t id)
{
    /* we probably couldn't find that entry, let's remove it */
    m_info.remove (id);
    emit entryRemoved (id);
    return true;
}
Example #6
0
bool NetworkCache::remove(const QUrl &url)
{
	const bool result(QNetworkDiskCache::remove(url));

	if (result)
	{
		emit entryRemoved(url);
	}

	return result;
}
Example #7
0
HistoryModel::HistoryModel(HistoryManager *history, QObject *parent)
    : QAbstractTableModel(parent)
    , m_history(history)
{
    Q_ASSERT(m_history);
    connect(m_history, SIGNAL(historyReset()),
            this, SLOT(historyReset()));
    connect(m_history, SIGNAL(entryRemoved(HistoryItem)),
            this, SLOT(historyReset()));

    connect(m_history, SIGNAL(entryAdded(HistoryItem)),
            this, SLOT(entryAdded()));
    connect(m_history, SIGNAL(entryUpdated(int)),
            this, SLOT(entryUpdated(int)));
}
Example #8
0
void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
{
    HistoryItem item;
    for (int i = 0; i < m_history.count(); ++i)
    {
        if (url == m_history.at(i).url
                && (title.isEmpty() || title == m_history.at(i).title))
        {
            item = m_history.at(i);
            m_lastSavedUrl.clear();
            m_history.removeOne(item);
            emit entryRemoved(item);
            break;
        }
    }
}
Example #9
0
EntryInfo::EntryInfo (QWidget *parent, XClientCache *cache, uint32_t id)
                      : QDialog (parent)
{
	setupUi (this);
	setAttribute (Qt::WA_DeleteOnClose);

	m_cache = cache;
	m_id = id;

	connect (cache, SIGNAL (entryChanged (uint32_t)),
	         this, SLOT (mlib_entry_changed (uint32_t)));

	connect (cache, SIGNAL (entryRemoved (uint32_t)),
	         this, SLOT (mlib_entry_removed (uint32_t)));

	getInfo ();
}
Example #10
0
void HistoryManager::addHistoryEntry(const QString &url)
{
    QWebSettings *globalSettings = QWebSettings::globalSettings();
    if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
        return;

    QUrl cleanUrl(url);

    // don't store about: urls (home page related)
    if (cleanUrl.scheme() == QString("about"))
        return;

    cleanUrl.setPassword(QString());
    cleanUrl.setHost(cleanUrl.host().toLower());
    QString checkUrlString = cleanUrl.toString();

    HistoryItem item;
    
    // NOTE
    // check if the url has just been visited.
    // if so, remove previous entry from history, update and prepend it
    if(historyContains(checkUrlString))
    {
        int index = m_historyFilterModel->historyLocation(checkUrlString);
        item = m_history.at(index);
        m_history.removeOne(item);
        emit entryRemoved(item);
        
        item.dateTime = QDateTime::currentDateTime();
        item.visitCount++;
    }
    else
    {
        item = HistoryItem(checkUrlString, QDateTime::currentDateTime());
    }
    
    m_history.prepend(item);
    emit entryAdded(item);
    
    if (m_history.count() == 1)
        checkForExpired();
}
Example #11
0
HistoryManager::HistoryManager(QObject *parent)
    : QObject(parent)
    , m_saveTimer(new AutoSaver(this))
    , m_historyLimit(30)
    , m_historyModel(0)
    , m_historyFilterModel(0)
    , m_historyTreeModel(0)
{
    m_expiredTimer.setSingleShot(true);
    connect(&m_expiredTimer, SIGNAL(timeout()),
            this, SLOT(checkForExpired()));
    connect(this, SIGNAL(entryAdded(HistoryItem)),
            m_saveTimer, SLOT(changeOccurred()));
    connect(this, SIGNAL(entryRemoved(HistoryItem)),
            m_saveTimer, SLOT(changeOccurred()));
    load();

    m_historyModel = new HistoryModel(this, this);
    m_historyFilterModel = new HistoryFilterModel(m_historyModel, this);
    m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this);
}
HistoryContentsWidget::HistoryContentsWidget(Window *window) : ContentsWidget(window),
	m_model(new QStandardItemModel(this)),
	m_isLoading(true),
	m_ui(new Ui::HistoryContentsWidget)
{
	m_ui->setupUi(this);

	QStringList groups;
	groups << tr("Today") << tr("Yesterday") << tr("Earlier This Week") << tr("Previous Week") << tr("Earlier This Month") << tr("Earlier This Year") << tr("Older");

	for (int i = 0; i < groups.count(); ++i)
	{
		m_model->appendRow(new QStandardItem(Utils::getIcon(QLatin1String("inode-directory")), groups.at(i)));
	}

	QStringList labels;
	labels << tr("Address") << tr("Title") << tr("Date");

	m_model->setHorizontalHeaderLabels(labels);
	m_model->setSortRole(Qt::DisplayRole);

	m_ui->historyView->setModel(m_model);
	m_ui->historyView->setItemDelegate(new ItemDelegate(this));
	m_ui->historyView->header()->setTextElideMode(Qt::ElideRight);
	m_ui->historyView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
	m_ui->historyView->expand(m_model->index(0, 0));

	QTimer::singleShot(100, this, SLOT(populateEntries()));

	connect(HistoryManager::getInstance(), SIGNAL(cleared()), this, SLOT(populateEntries()));
	connect(HistoryManager::getInstance(), SIGNAL(entryAdded(qint64)), this, SLOT(addEntry(qint64)));
	connect(HistoryManager::getInstance(), SIGNAL(entryUpdated(qint64)), this, SLOT(updateEntry(qint64)));
	connect(HistoryManager::getInstance(), SIGNAL(entryRemoved(qint64)), this, SLOT(removeEntry(qint64)));
	connect(HistoryManager::getInstance(), SIGNAL(dayChanged()), this, SLOT(populateEntries()));
	connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterHistory(QString)));
	connect(m_ui->historyView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openEntry(QModelIndex)));
	connect(m_ui->historyView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
}
Example #13
0
File: jobs.cpp Project: aelog/ark
void Job::onEntryRemoved(const QString & path)
{
    emit entryRemoved(path);
}
Example #14
0
void HistoryManager::removeHistoryEntry(const HistoryEntry &item)
{
    m_lastSavedUrl.clear();
    m_history.removeOne(item);
    emit entryRemoved(item);
}