summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-07-10 17:21:47 +0200
committerAndrea Diamantini <adjam7@gmail.com>2011-07-18 11:37:08 +0200
commita656e6c5fd5662a3d990115e2b5851570149d594 (patch)
tree06f85884c8c81b1c1d6db697b2f47d4aef779ae8
parentImproving SSL widget & dialog, step 3 (diff)
downloadrekonq-a656e6c5fd5662a3d990115e2b5851570149d594.tar.xz
WARNING: HISTORY_VERSION upgrade!!
This commit changes rekonq history data struct to manage also the first time you visited a site. This way we can "expose" this new info in the SSL widget. (We can obviously do a lot more with it...)
-rw-r--r--src/history/historymanager.cpp26
-rw-r--r--src/history/historymanager.h13
-rw-r--r--src/history/historymodels.cpp25
-rw-r--r--src/history/historymodels.h3
-rw-r--r--src/urlbar/sslwidget.cpp61
5 files changed, 82 insertions, 46 deletions
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 742e957c..0b5e9e48 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -59,7 +59,7 @@
#include <QtAlgorithms>
-static const unsigned int HISTORY_VERSION = 24;
+static const unsigned int HISTORY_VERSION = 25;
HistoryManager::HistoryManager(QObject *parent)
@@ -123,7 +123,7 @@ void HistoryManager::addHistoryEntry(const QString &url)
m_history.removeOne(item);
emit entryRemoved(item);
- item.dateTime = QDateTime::currentDateTime();
+ item.lastDateTimeVisit = QDateTime::currentDateTime();
item.visitCount++;
}
else
@@ -172,7 +172,7 @@ void HistoryManager::checkForExpired()
while(!m_history.isEmpty())
{
- QDateTime checkForExpired = m_history.last().dateTime;
+ QDateTime checkForExpired = m_history.last().lastDateTimeVisit;
checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit));
if(now.daysTo(checkForExpired) > 7)
{
@@ -352,23 +352,33 @@ void HistoryManager::load()
{
case HISTORY_VERSION: // default case
stream >> item.url;
- stream >> item.dateTime;
+ stream >> item.firstDateTimeVisit;
+ stream >> item.lastDateTimeVisit;
stream >> item.title;
stream >> item.visitCount;
break;
- case 23: // this will be used to upgrade previous structure...
+ case 24: // this was history structure for rekonq < 0.8
stream >> item.url;
- stream >> item.dateTime;
+ stream >> item.lastDateTimeVisit;
+ stream >> item.title;
+ stream >> item.visitCount;
+ item.firstDateTimeVisit = item.lastDateTimeVisit;
+ break;
+
+ case 23: // this will be used to upgrade previous structure...
+ stream >> item.url;
+ stream >> item.lastDateTimeVisit;
stream >> item.title;
item.visitCount = 1;
+ item.firstDateTimeVisit = item.lastDateTimeVisit;
break;
default:
continue;
};
- if(!item.dateTime.isValid())
+ if (!item.lastDateTimeVisit.isValid())
continue;
if(item == lastInsertedItem)
@@ -446,7 +456,7 @@ void HistoryManager::save()
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
HistoryItem item = m_history.at(i);
- stream << HISTORY_VERSION << item.url << item.dateTime << item.title << item.visitCount;
+ stream << HISTORY_VERSION << item.url << item.firstDateTimeVisit << item.lastDateTimeVisit << item.title << item.visitCount;
out << data;
}
tempFile.close();
diff --git a/src/history/historymanager.h b/src/history/historymanager.h
index e22b7042..101bc09d 100644
--- a/src/history/historymanager.h
+++ b/src/history/historymanager.h
@@ -65,7 +65,8 @@ public:
)
: title(t)
, url(u)
- , dateTime(d)
+ , firstDateTimeVisit(d)
+ , lastDateTimeVisit(d)
, visitCount(1)
{}
@@ -73,23 +74,25 @@ public:
{
return other.title == title
&& other.url == url
- && other.dateTime == dateTime;
+ && other.firstDateTimeVisit == firstDateTimeVisit
+ && other.lastDateTimeVisit == lastDateTimeVisit;
}
inline qreal relevance() const
{
- return log(visitCount) - log(dateTime.daysTo(QDateTime::currentDateTime()) + 1);
+ return log(visitCount) - log(lastDateTimeVisit.daysTo(QDateTime::currentDateTime()) + 1);
}
// history is sorted in reverse
inline bool operator <(const HistoryItem &other) const
{
- return dateTime > other.dateTime;
+ return lastDateTimeVisit > other.lastDateTimeVisit;
}
QString title;
QString url;
- QDateTime dateTime;
+ QDateTime firstDateTimeVisit;
+ QDateTime lastDateTimeVisit;
int visitCount;
};
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index e78c3ac1..0315513b 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -115,9 +115,11 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
switch(role)
{
case DateTimeRole:
- return item.dateTime;
+ return item.lastDateTimeVisit;
case DateRole:
- return item.dateTime.date();
+ return item.lastDateTimeVisit.date();
+ case FirstDateTimeVisitRole:
+ return item.firstDateTimeVisit;
case UrlRole:
return QUrl(item.url);
case Qt::UserRole:
@@ -152,7 +154,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
QString tooltip = "";
if(!item.title.isEmpty())
tooltip = item.title + '\n';
- tooltip += item.dateTime.toString(Qt::SystemLocaleShortDate) + '\n' + item.url;
+ tooltip += item.lastDateTimeVisit.toString(Qt::SystemLocaleShortDate) + '\n' + item.url;
return tooltip;
}
return QVariant();
@@ -188,7 +190,7 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)
}
-// -------------------------------------------------------------------------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------------------------------------------
HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent)
@@ -436,7 +438,7 @@ 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)
@@ -456,15 +458,24 @@ QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const
}
}
}
- 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)
+ {
+ int offset = sourceDateRow(index.row());
+ QModelIndex idx = sourceModel()->index(offset, 0);
+ return idx.data(HistoryModel::FirstDateTimeVisitRole);
+ }
+
return QAbstractProxyModel::data(index, role);
}
diff --git a/src/history/historymodels.h b/src/history/historymodels.h
index 8cb1a5dd..7388cef5 100644
--- a/src/history/historymodels.h
+++ b/src/history/historymodels.h
@@ -56,7 +56,8 @@ public:
DateRole = Qt::UserRole + 1,
DateTimeRole = Qt::UserRole + 2,
UrlRole = Qt::UserRole + 3,
- UrlStringRole = Qt::UserRole + 4
+ UrlStringRole = Qt::UserRole + 4,
+ FirstDateTimeVisitRole = Qt::UserRole + 5
};
explicit HistoryModel(HistoryManager *history, QObject *parent = 0);
diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp
index fb0ed493..862bdb3f 100644
--- a/src/urlbar/sslwidget.cpp
+++ b/src/urlbar/sslwidget.cpp
@@ -100,28 +100,37 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)
label->setText( QL1S("<hr /><h4>Encryption</h4>") ); // ----------------------------------------------- //
layout->addRow(label);
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText( i18n("Your connection to %1 is encrypted with %2 encryption\n\n", m_url.host(), m_info.supportedChiperBits()) );
- layout->addRow(label);
-
- QString sslVersion = QL1S("SSLv") + cert.version();
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText( i18n("The connection uses %1\n\n", sslVersion) );
- layout->addRow(label);
-
- const QStringList cipherInfo = m_info.ciphers().split('\n', QString::SkipEmptyParts);
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText( i18n("The connection is encrypted using %1 at %2 bits with %3 for message authentication and %4 as the key exchange mechanism.\n\n",
- cipherInfo[0],
- m_info.usedChiperBits(),
- cipherInfo[3],
- cipherInfo[1])
-
- );
- layout->addRow(label);
+ if (cert.isNull())
+ {
+ label = new QLabel(this);
+ label->setWordWrap(true);
+ label->setText( i18n("Your connection to %1 is NOT encrypted!!\n\n", m_url.host()) );
+ layout->addRow(label);
+ }
+ else
+ {
+ label = new QLabel(this);
+ label->setWordWrap(true);
+ label->setText( i18n("Your connection to %1 is encrypted with %2 encryption\n\n", m_url.host(), m_info.supportedChiperBits()) );
+ layout->addRow(label);
+
+ QString sslVersion = QL1S("SSLv") + cert.version();
+ label = new QLabel(this);
+ label->setWordWrap(true);
+ label->setText( i18n("The connection uses %1\n\n", sslVersion) );
+ layout->addRow(label);
+
+ const QStringList cipherInfo = m_info.ciphers().split('\n', QString::SkipEmptyParts);
+ label = new QLabel(this);
+ label->setWordWrap(true);
+ label->setText(
+ i18n("The connection is encrypted using %1 at %2 bits with %3 for message authentication and %4 as the key exchange mechanism.\n\n",
+ cipherInfo[0],
+ m_info.usedChiperBits(),
+ cipherInfo[3],
+ cipherInfo[1]) );
+ layout->addRow(label);
+ }
// ------------------------------------------------------------------------------------------------------------------
label = new QLabel(this);
@@ -132,13 +141,15 @@ SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)
label = new QLabel(this);
label->setWordWrap(true);
- if (rApp->historyManager()->historyContains(url.toString())) //FIXME change with visit count > 1
+ HistoryItem firstVisit = rApp->historyManager()->find(url.toString()).first();
+
+ if (firstVisit.visitCount == 1)
{
- label->setText( i18n("You just visited this site") );
+ label->setText( i18n("It's your first time visiting this site") );
}
else
{
- label->setText( i18n("It's your first time visiting this site") );
+ label->setText( i18n("You just visited this site!\nYour first visit was on %1", firstVisit.firstDateTimeVisit.toString()) );
}
layout->addRow(label);