summaryrefslogtreecommitdiff
path: root/src/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/history')
-rw-r--r--src/history/autosaver.cpp10
-rw-r--r--src/history/historymanager.cpp82
-rw-r--r--src/history/historymodels.cpp136
-rw-r--r--src/history/historypanel.cpp20
4 files changed, 124 insertions, 124 deletions
diff --git a/src/history/autosaver.cpp b/src/history/autosaver.cpp
index c490ac46..bb2a7683 100644
--- a/src/history/autosaver.cpp
+++ b/src/history/autosaver.cpp
@@ -50,7 +50,7 @@ AutoSaver::AutoSaver(QObject *parent)
AutoSaver::~AutoSaver()
{
- if(m_timer->isActive())
+ if (m_timer->isActive())
kDebug() << "AutoSaver: still active when destroyed, changes not saved.";
delete m_firstChange;
@@ -60,17 +60,17 @@ AutoSaver::~AutoSaver()
void AutoSaver::saveIfNeccessary()
{
- if(m_timer->isActive())
+ if (m_timer->isActive())
save();
}
void AutoSaver::changeOccurred()
{
- if(m_firstChange->isNull())
+ if (m_firstChange->isNull())
m_firstChange->start();
- if(m_firstChange->elapsed() > MAX_TIME_LIMIT)
+ if (m_firstChange->elapsed() > MAX_TIME_LIMIT)
save();
else
m_timer->start(AUTOSAVE_TIME, this);
@@ -79,7 +79,7 @@ void AutoSaver::changeOccurred()
void AutoSaver::timerEvent(QTimerEvent *event)
{
- if(event->timerId() == m_timer->timerId())
+ if (event->timerId() == m_timer->timerId())
save();
else
QObject::timerEvent(event);
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 3b765e7d..0a29950e 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -98,13 +98,13 @@ bool HistoryManager::historyContains(const QString &url) const
void HistoryManager::addHistoryEntry(const QString &url)
{
QWebSettings *globalSettings = QWebSettings::globalSettings();
- if(globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
return;
QUrl cleanUrl(url);
// don't store about: urls (home page related)
- if(cleanUrl.scheme() == QString("about"))
+ if (cleanUrl.scheme() == QString("about"))
return;
cleanUrl.setPassword(QString());
@@ -116,7 +116,7 @@ void HistoryManager::addHistoryEntry(const QString &url)
// NOTE
// check if the url has just been visited.
// if so, remove previous entry from history, update and prepend it
- if(historyContains(checkUrlString))
+ if (historyContains(checkUrlString))
{
int index = m_historyFilterModel->historyLocation(checkUrlString);
item = m_history.at(index);
@@ -134,7 +134,7 @@ void HistoryManager::addHistoryEntry(const QString &url)
m_history.prepend(item);
emit entryAdded(item);
- if(m_history.count() == 1)
+ if (m_history.count() == 1)
checkForExpired();
}
@@ -144,12 +144,12 @@ void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAn
m_history = history;
// verify that it is sorted by date
- if(!loadedAndSorted)
+ if (!loadedAndSorted)
qSort(m_history.begin(), m_history.end());
checkForExpired();
- if(loadedAndSorted)
+ if (loadedAndSorted)
{
m_lastSavedUrl = m_history.value(0).url;
}
@@ -164,17 +164,17 @@ void HistoryManager::setHistory(const QList<HistoryItem> &history, bool loadedAn
void HistoryManager::checkForExpired()
{
- if(m_historyLimit < 0 || m_history.isEmpty())
+ if (m_historyLimit < 0 || m_history.isEmpty())
return;
QDateTime now = QDateTime::currentDateTime();
int nextTimeout = 0;
- while(!m_history.isEmpty())
+ while (!m_history.isEmpty())
{
QDateTime checkForExpired = m_history.last().lastDateTimeVisit;
checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit));
- if(now.daysTo(checkForExpired) > 7)
+ if (now.daysTo(checkForExpired) > 7)
{
// check at most in a week to prevent int overflows on the timer
nextTimeout = 7 * 86400;
@@ -183,7 +183,7 @@ void HistoryManager::checkForExpired()
{
nextTimeout = now.secsTo(checkForExpired);
}
- if(nextTimeout > 0)
+ if (nextTimeout > 0)
break;
HistoryItem item = m_history.takeLast();
// remove from saved file also
@@ -191,7 +191,7 @@ void HistoryManager::checkForExpired()
emit entryRemoved(item);
}
- if(nextTimeout > 0)
+ if (nextTimeout > 0)
QTimer::singleShot(nextTimeout * 1000, this, SLOT(checkForExpired()));
}
@@ -200,22 +200,22 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)
{
QString urlString = url.url();
urlString.remove(QL1S("www."));
- if(urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/')))
+ if (urlString.startsWith(QL1S("http")) && urlString.endsWith(QL1C('/')))
urlString.remove(urlString.length() - 1, 1);
- for(int i = 0; i < m_history.count(); ++i)
+ for (int i = 0; i < m_history.count(); ++i)
{
QString itemUrl = m_history.at(i).url;
itemUrl.remove(QL1S("www."));
- if(itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/')))
+ if (itemUrl.startsWith(QL1S("http")) && itemUrl.endsWith(QL1C('/')))
itemUrl.remove(itemUrl.length() - 1, 1);
- if(urlString == itemUrl)
+ if (urlString == itemUrl)
{
m_history[i].title = title;
m_history[i].url = url.url();
m_saveTimer->changeOccurred();
- if(m_lastSavedUrl.isEmpty())
+ if (m_lastSavedUrl.isEmpty())
m_lastSavedUrl = m_history.at(i).url;
emit entryUpdated(i);
@@ -228,9 +228,9 @@ void HistoryManager::updateHistoryEntry(const KUrl &url, const QString &title)
void HistoryManager::removeHistoryEntry(const KUrl &url, const QString &title)
{
HistoryItem item;
- for(int i = 0; i < m_history.count(); ++i)
+ for (int i = 0; i < m_history.count(); ++i)
{
- if(url == m_history.at(i).url
+ if (url == m_history.at(i).url
&& (title.isEmpty() || title == m_history.at(i).title))
{
item = m_history.at(i);
@@ -257,14 +257,14 @@ QList<HistoryItem> HistoryManager::find(const QString &text)
bool matches = true;
foreach(const QString & word, words)
{
- if(!url.contains(word, Qt::CaseInsensitive)
+ if (!url.contains(word, Qt::CaseInsensitive)
&& !item.title.contains(word, Qt::CaseInsensitive))
{
matches = false;
break;
}
}
- if(matches)
+ if (matches)
list << item;
}
@@ -286,7 +286,7 @@ void HistoryManager::loadSettings()
{
int historyExpire = ReKonfig::expireHistory();
int days;
- switch(historyExpire)
+ switch (historyExpire)
{
case 0:
days = 1;
@@ -320,9 +320,9 @@ void HistoryManager::load()
QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history");
QFile historyFile(historyFilePath);
- if(!historyFile.exists())
+ if (!historyFile.exists())
return;
- if(!historyFile.open(QFile::ReadOnly))
+ if (!historyFile.open(QFile::ReadOnly))
{
kDebug() << "Unable to open history file" << historyFile.fileName();
return;
@@ -337,7 +337,7 @@ void HistoryManager::load()
QDataStream stream;
QBuffer buffer;
stream.setDevice(&buffer);
- while(!historyFile.atEnd())
+ while (!historyFile.atEnd())
{
in >> data;
buffer.close();
@@ -348,7 +348,7 @@ void HistoryManager::load()
HistoryItem item;
- switch(version)
+ switch (version)
{
case HISTORY_VERSION: // default case
stream >> item.url;
@@ -378,29 +378,29 @@ void HistoryManager::load()
continue;
};
- if(!item.lastDateTimeVisit.isValid())
+ if (!item.lastDateTimeVisit.isValid())
continue;
- if(item == lastInsertedItem)
+ if (item == lastInsertedItem)
{
- if(lastInsertedItem.title.isEmpty() && !list.isEmpty())
+ if (lastInsertedItem.title.isEmpty() && !list.isEmpty())
list[0].title = item.title;
continue;
}
- if(!needToSort && !list.isEmpty() && lastInsertedItem < item)
+ if (!needToSort && !list.isEmpty() && lastInsertedItem < item)
needToSort = true;
list.prepend(item);
lastInsertedItem = item;
}
- if(needToSort)
+ if (needToSort)
qSort(list.begin(), list.end());
setHistory(list, true);
// If we had to sort re-write the whole history sorted
- if(needToSort)
+ if (needToSort)
{
m_lastSavedUrl.clear();
m_saveTimer->changeOccurred();
@@ -412,19 +412,19 @@ void HistoryManager::save()
{
bool saveAll = m_lastSavedUrl.isEmpty();
int first = m_history.count() - 1;
- if(!saveAll)
+ if (!saveAll)
{
// find the first one to save
- for(int i = 0; i < m_history.count(); ++i)
+ for (int i = 0; i < m_history.count(); ++i)
{
- if(m_history.at(i).url == m_lastSavedUrl)
+ if (m_history.at(i).url == m_lastSavedUrl)
{
first = i - 1;
break;
}
}
}
- if(first == m_history.count() - 1)
+ if (first == m_history.count() - 1)
saveAll = true;
QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history");
@@ -434,7 +434,7 @@ void HistoryManager::save()
QTemporaryFile tempFile;
tempFile.setAutoRemove(false);
bool open = false;
- if(saveAll)
+ if (saveAll)
{
open = tempFile.open();
}
@@ -443,7 +443,7 @@ void HistoryManager::save()
open = historyFile.open(QFile::Append);
}
- if(!open)
+ if (!open)
{
kDebug() << "Unable to open history file for saving"
<< (saveAll ? tempFile.fileName() : historyFile.fileName());
@@ -451,7 +451,7 @@ void HistoryManager::save()
}
QDataStream out(saveAll ? &tempFile : &historyFile);
- for(int i = first; i >= 0; --i)
+ for (int i = first; i >= 0; --i)
{
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
@@ -461,13 +461,13 @@ void HistoryManager::save()
}
tempFile.close();
- if(saveAll)
+ if (saveAll)
{
- if(historyFile.exists() && !historyFile.remove())
+ if (historyFile.exists() && !historyFile.remove())
{
kDebug() << "History: error removing old history." << historyFile.errorString();
}
- if(!tempFile.rename(historyFile.fileName()))
+ if (!tempFile.rename(historyFile.fileName()))
{
kDebug() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName();
}
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index bddc34be..ed5eee20 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -92,10 +92,10 @@ void HistoryModel::entryUpdated(int offset)
QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if(orientation == Qt::Horizontal
+ if (orientation == Qt::Horizontal
&& role == Qt::DisplayRole)
{
- switch(section)
+ switch (section)
{
case 0: return i18n("Title");
case 1: return i18n("Address");
@@ -108,11 +108,11 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int
QVariant HistoryModel::data(const QModelIndex &index, int role) const
{
QList<HistoryItem> lst = m_historyManager->history();
- if(index.row() < 0 || index.row() >= lst.size())
+ if (index.row() < 0 || index.row() >= lst.size())
return QVariant();
const HistoryItem &item = lst.at(index.row());
- switch(role)
+ switch (role)
{
case DateTimeRole:
return item.lastDateTimeVisit;
@@ -129,14 +129,14 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
case Qt::DisplayRole:
case Qt::EditRole:
{
- switch(index.column())
+ switch (index.column())
{
case 0:
// when there is no title try to generate one from the url
- if(item.title.isEmpty())
+ if (item.title.isEmpty())
{
QString page = QFileInfo(QUrl(item.url).path()).fileName();
- if(!page.isEmpty())
+ if (!page.isEmpty())
return page;
return item.url;
}
@@ -146,13 +146,13 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
}
}
case Qt::DecorationRole:
- if(index.column() == 0)
+ if (index.column() == 0)
{
return rApp->iconManager()->iconForUrl(item.url);
}
case Qt::ToolTipRole:
QString tooltip = "";
- if(!item.title.isEmpty())
+ if (!item.title.isEmpty())
tooltip = item.title + '\n';
tooltip += item.lastDateTimeVisit.toString(Qt::SystemLocaleShortDate) + '\n' + item.url;
return tooltip;
@@ -175,12 +175,12 @@ int HistoryModel::rowCount(const QModelIndex &parent) const
bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)
{
- if(parent.isValid())
+ if (parent.isValid())
return false;
int lastRow = row + count - 1;
beginRemoveRows(parent, row, lastRow);
QList<HistoryItem> lst = m_historyManager->history();
- for(int i = lastRow; i >= row; --i)
+ for (int i = lastRow; i >= row; --i)
lst.removeAt(i);
disconnect(m_historyManager, SIGNAL(historyReset()), this, SLOT(historyReset()));
m_historyManager->setHistory(lst);
@@ -204,7 +204,7 @@ HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject
int HistoryFilterModel::historyLocation(const QString &url) const
{
load();
- if(!m_historyHash.contains(url))
+ if (!m_historyHash.contains(url))
return 0;
return sourceModel()->rowCount() - m_historyHash.value(url);
}
@@ -218,7 +218,7 @@ QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const
void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel)
{
- if(sourceModel())
+ if (sourceModel())
{
disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset()));
disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
@@ -231,7 +231,7 @@ void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel)
QAbstractProxyModel::setSourceModel(newSourceModel);
- if(sourceModel())
+ if (sourceModel())
{
m_loaded = false;
connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset()));
@@ -267,7 +267,7 @@ void HistoryFilterModel::sourceReset()
int HistoryFilterModel::rowCount(const QModelIndex &parent) const
{
load();
- if(parent.isValid())
+ if (parent.isValid())
return 0;
return m_historyHash.count();
}
@@ -291,7 +291,7 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co
{
load();
QString url = sourceIndex.data(HistoryModel::UrlStringRole).toString();
- if(!m_historyHash.contains(url))
+ if (!m_historyHash.contains(url))
return QModelIndex();
// This can be done in a binary search, but we can't use qBinary find
@@ -301,15 +301,15 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co
int realRow = -1;
int sourceModelRow = sourceModel()->rowCount() - sourceIndex.row();
- for(int i = 0; i < m_sourceRow.count(); ++i)
+ for (int i = 0; i < m_sourceRow.count(); ++i)
{
- if(m_sourceRow.at(i) == sourceModelRow)
+ if (m_sourceRow.at(i) == sourceModelRow)
{
realRow = i;
break;
}
}
- if(realRow == -1)
+ if (realRow == -1)
return QModelIndex();
return createIndex(realRow, sourceIndex.column(), sourceModel()->rowCount() - sourceIndex.row());
@@ -319,7 +319,7 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co
QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const
{
load();
- if(row < 0 || row >= rowCount(parent)
+ if (row < 0 || row >= rowCount(parent)
|| column < 0 || column >= columnCount(parent))
return QModelIndex();
@@ -335,16 +335,16 @@ QModelIndex HistoryFilterModel::parent(const QModelIndex &) const
void HistoryFilterModel::load() const
{
- if(m_loaded)
+ if (m_loaded)
return;
m_sourceRow.clear();
m_historyHash.clear();
m_historyHash.reserve(sourceModel()->rowCount());
- for(int i = 0; i < sourceModel()->rowCount(); ++i)
+ for (int i = 0; i < sourceModel()->rowCount(); ++i)
{
QModelIndex idx = sourceModel()->index(i, 0);
QString url = idx.data(HistoryModel::UrlStringRole).toString();
- if(!m_historyHash.contains(url))
+ if (!m_historyHash.contains(url))
{
m_sourceRow.append(sourceModel()->rowCount() - i);
m_historyHash[url] = sourceModel()->rowCount() - i;
@@ -358,18 +358,18 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start
{
Q_UNUSED(end);
- if(start != 0)
+ if (start != 0)
{
kDebug() << "STARTING from a NON zero position...";
return;
}
- if(!m_loaded)
+ if (!m_loaded)
return;
QModelIndex idx = sourceModel()->index(start, 0, parent);
QString url = idx.data(HistoryModel::UrlStringRole).toString();
- if(m_historyHash.contains(url))
+ if (m_historyHash.contains(url))
{
int sourceRow = sourceModel()->rowCount() - m_historyHash[url];
int realRow = mapFromSource(sourceModel()->index(sourceRow, 0)).row();
@@ -399,7 +399,7 @@ void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int e
*/
bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent)
{
- if(row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid())
+ if (row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid())
return false;
int lastRow = row + count - 1;
disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
@@ -413,7 +413,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren
connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int)));
m_loaded = false;
- if(oldCount - count != rowCount())
+ if (oldCount - count != rowCount())
reset();
return true;
}
@@ -437,38 +437,38 @@ QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation,
QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const
{
- if(role == Qt::EditRole || role == Qt::DisplayRole)
+ if (role == Qt::EditRole || role == Qt::DisplayRole)
{
int start = index.internalId();
- if(start == 0)
+ if (start == 0)
{
int offset = sourceDateRow(index.row());
- if(index.column() == 0)
+ if (index.column() == 0)
{
QModelIndex idx = sourceModel()->index(offset, 0);
QDate date = idx.data(HistoryModel::DateRole).toDate();
- if(date == QDate::currentDate())
+ if (date == QDate::currentDate())
return i18n("Earlier Today");
return date.toString(QL1S("dddd, MMMM d, yyyy"));
}
- if(index.column() == 1)
+ if (index.column() == 1)
{
return i18np("1 item", "%1 items", rowCount(index.sibling(index.row(), 0)));
}
}
}
- if(role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid())
+ if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid())
return KIcon("view-history");
- if(role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0)
+ if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0)
{
int offset = sourceDateRow(index.row());
QModelIndex idx = sourceModel()->index(offset, 0);
return idx.data(HistoryModel::DateRole);
}
- if(role == HistoryModel::FirstDateTimeVisitRole && index.column() == 0 && index.internalId() == 0)
+ if (role == HistoryModel::FirstDateTimeVisitRole && index.column() == 0 && index.internalId() == 0)
{
int offset = sourceDateRow(index.row());
QModelIndex idx = sourceModel()->index(offset, 0);
@@ -487,24 +487,24 @@ int HistoryTreeModel::columnCount(const QModelIndex &parent) const
int HistoryTreeModel::rowCount(const QModelIndex &parent) const
{
- if(parent.internalId() != 0
+ if (parent.internalId() != 0
|| parent.column() > 0
|| !sourceModel())
return 0;
// row count OF dates
- if(!parent.isValid())
+ if (!parent.isValid())
{
- if(!m_sourceRowCache.isEmpty())
+ if (!m_sourceRowCache.isEmpty())
return m_sourceRowCache.count();
QDate currentDate;
int rows = 0;
int totalRows = sourceModel()->rowCount();
- for(int i = 0; i < totalRows; ++i)
+ for (int i = 0; i < totalRows; ++i)
{
QDate rowDate = sourceModel()->index(i, 0).data(HistoryModel::DateRole).toDate();
- if(rowDate != currentDate)
+ if (rowDate != currentDate)
{
m_sourceRowCache.append(i);
currentDate = rowDate;
@@ -525,15 +525,15 @@ int HistoryTreeModel::rowCount(const QModelIndex &parent) const
// Translate the top level date row into the offset where that date starts
int HistoryTreeModel::sourceDateRow(int row) const
{
- if(row <= 0)
+ if (row <= 0)
return 0;
- if(m_sourceRowCache.isEmpty())
+ if (m_sourceRowCache.isEmpty())
rowCount(QModelIndex());
- if(row >= m_sourceRowCache.count())
+ if (row >= m_sourceRowCache.count())
{
- if(!sourceModel())
+ if (!sourceModel())
return 0;
return sourceModel()->rowCount();
}
@@ -544,7 +544,7 @@ int HistoryTreeModel::sourceDateRow(int row) const
QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const
{
int offset = proxyIndex.internalId();
- if(offset == 0)
+ if (offset == 0)
return QModelIndex();
int startDateRow = sourceDateRow(offset - 1);
return sourceModel()->index(startDateRow + proxyIndex.row(), proxyIndex.column());
@@ -553,12 +553,12 @@ QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const
QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const
{
- if(row < 0
+ if (row < 0
|| column < 0 || column >= columnCount(parent)
|| parent.column() > 0)
return QModelIndex();
- if(!parent.isValid())
+ if (!parent.isValid())
return createIndex(row, column, 0);
return createIndex(row, column, parent.row() + 1);
}
@@ -567,7 +567,7 @@ QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &pare
QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const
{
int offset = index.internalId();
- if(offset == 0 || !index.isValid())
+ if (offset == 0 || !index.isValid())
return QModelIndex();
return createIndex(offset - 1, 0, 0);
}
@@ -576,7 +576,7 @@ QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const
bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const
{
QModelIndex grandparent = parent.parent();
- if(!grandparent.isValid())
+ if (!grandparent.isValid())
return true;
return false;
}
@@ -584,7 +584,7 @@ bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const
Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const
{
- if(!index.isValid())
+ if (!index.isValid())
return Qt::NoItemFlags;
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled;
}
@@ -592,10 +592,10 @@ Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const
bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent)
{
- if(row < 0 || count <= 0 || row + count > rowCount(parent))
+ if (row < 0 || count <= 0 || row + count > rowCount(parent))
return false;
- if(parent.isValid())
+ if (parent.isValid())
{
// removing pages
int offset = sourceDateRow(parent.row());
@@ -604,11 +604,11 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent)
else
{
// removing whole dates
- for(int i = row + count - 1; i >= row; --i)
+ for (int i = row + count - 1; i >= row; --i)
{
QModelIndex dateParent = index(i, 0);
int offset = sourceDateRow(dateParent.row());
- if(!sourceModel()->removeRows(offset, rowCount(dateParent)))
+ if (!sourceModel()->removeRows(offset, rowCount(dateParent)))
return false;
}
}
@@ -618,7 +618,7 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent)
void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel)
{
- if(sourceModel())
+ if (sourceModel())
{
disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset()));
disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset()));
@@ -630,7 +630,7 @@ void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel)
QAbstractProxyModel::setSourceModel(newSourceModel);
- if(newSourceModel)
+ if (newSourceModel)
{
connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset()));
connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset()));
@@ -655,7 +655,7 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start,
{
Q_UNUSED(parent); // Avoid warnings when compiling release
Q_ASSERT(!parent.isValid());
- if(start != 0 || start != end)
+ if (start != 0 || start != end)
{
m_sourceRowCache.clear();
reset();
@@ -665,7 +665,7 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start,
m_sourceRowCache.clear();
QModelIndex treeIndex = mapFromSource(sourceModel()->index(start, 0));
QModelIndex treeParent = treeIndex.parent();
- if(rowCount(treeParent) == 1)
+ if (rowCount(treeParent) == 1)
{
beginInsertRows(QModelIndex(), 0, 0);
endInsertRows();
@@ -680,15 +680,15 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start,
QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const
{
- if(!sourceIndex.isValid())
+ if (!sourceIndex.isValid())
return QModelIndex();
- if(m_sourceRowCache.isEmpty())
+ if (m_sourceRowCache.isEmpty())
rowCount(QModelIndex());
QList<int>::iterator it;
it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row());
- if(*it != sourceIndex.row())
+ if (*it != sourceIndex.row())
--it;
int dateRow = qMax(0, it - m_sourceRowCache.begin());
@@ -701,28 +701,28 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i
{
Q_UNUSED(parent); // Avoid warnings when compiling release
Q_ASSERT(!parent.isValid());
- if(m_sourceRowCache.isEmpty())
+ if (m_sourceRowCache.isEmpty())
return;
- for(int i = end; i >= start;)
+ for (int i = end; i >= start;)
{
QList<int>::iterator it;
it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i);
// playing it safe
- if(it == m_sourceRowCache.end())
+ if (it == m_sourceRowCache.end())
{
m_sourceRowCache.clear();
reset();
return;
}
- if(*it != i)
+ if (*it != i)
--it;
int row = qMax(0, it - m_sourceRowCache.begin());
int offset = m_sourceRowCache[row];
QModelIndex dateParent = index(row, 0);
// If we can remove all the rows in the date do that and skip over them
int rc = rowCount(dateParent);
- if(i - rc + 1 == offset && start <= i - rc + 1)
+ if (i - rc + 1 == offset && start <= i - rc + 1)
{
beginRemoveRows(QModelIndex(), row, row);
m_sourceRowCache.removeAt(row);
@@ -734,7 +734,7 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i
++row;
--i;
}
- for(int j = row; j < m_sourceRowCache.count(); ++j)
+ for (int j = row; j < m_sourceRowCache.count(); ++j)
--m_sourceRowCache[j];
endRemoveRows();
}
diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp
index e792783c..8ba963e7 100644
--- a/src/history/historypanel.cpp
+++ b/src/history/historypanel.cpp
@@ -108,26 +108,26 @@ void HistoryPanel::contextMenuEmpty(const QPoint& /*pos*/)
void HistoryPanel::openAll()
{
QModelIndex index = panelTreeView()->currentIndex();
- if(!index.isValid())
+ if (!index.isValid())
return;
QList<KUrl> allChild;
- for(int i = 0; i < index.model()->rowCount(index); i++)
+ for (int i = 0; i < index.model()->rowCount(index); i++)
allChild << qVariantValue<KUrl>(index.child(i, 0).data(Qt::UserRole));
- if(allChild.length() > 8)
+ if (allChild.length() > 8)
{
- if(!(KMessageBox::warningContinueCancel(this,
- i18ncp("%1=Number of tabs. Value is always >=8",
- "You are about to open %1 tabs.\nAre you sure?",
- "You are about to open %1 tabs.\nAre you sure?",
- allChild.length())) == KMessageBox::Continue)
- )
+ if (!(KMessageBox::warningContinueCancel(this,
+ i18ncp("%1=Number of tabs. Value is always >=8",
+ "You are about to open %1 tabs.\nAre you sure?",
+ "You are about to open %1 tabs.\nAre you sure?",
+ allChild.length())) == KMessageBox::Continue)
+ )
return;
}
- for(int i = 0; i < allChild.length(); i++)
+ for (int i = 0; i < allChild.length(); i++)
emit openUrl(allChild.at(i).url(), Rekonq::NewTab);
}