[developerteam getadooble] SF.net SVN: dooble:[2525] trunk/browser
Brought to you by:
textfield
From: <tex...@us...> - 2011-07-28 18:06:27
|
Revision: 2525 http://dooble.svn.sourceforge.net/dooble/?rev=2525&view=rev Author: textfield Date: 2011-07-28 18:06:19 +0000 (Thu, 28 Jul 2011) Log Message: ----------- List five most visited sites. Probably incomplete, like the Schmidt. As for centering the icons, don't delete layouts. Things break. Let the professionals do it. You wouldn't clean your toilet with a toothbrush, would you? Modified Paths: -------------- trunk/browser/Include/dwebhistoryitem.h trunk/browser/Source/dooble.cc trunk/browser/Source/dwebhistoryitem.cc trunk/browser/UI/statusBar.ui Modified: trunk/browser/Include/dwebhistoryitem.h =================================================================== --- trunk/browser/Include/dwebhistoryitem.h 2011-07-28 16:41:50 UTC (rev 2524) +++ trunk/browser/Include/dwebhistoryitem.h 2011-07-28 18:06:19 UTC (rev 2525) @@ -1,7 +1,7 @@ /**************************************************************************** ** Dooble - The Secure Internet Web Browser ** -** Copyright (c) 2008, 2009, 2010 Alexis Megas, +** Copyright (c) 2008, 2009, 2010, 2011 Alexis Megas, ** Gunther van Dooble, and the Dooble Team. ** All rights reserved. ** @@ -67,6 +67,7 @@ ~dwebhistoryitem(); bool isValid(void) const; bool operator==(const dwebhistoryitem &other) const; + void setUrl(const QUrl &url); void setIcon(const QIcon &icon); void setTitle(const QString &title); QUrl url(void) const; Modified: trunk/browser/Source/dooble.cc =================================================================== --- trunk/browser/Source/dooble.cc 2011-07-28 16:41:50 UTC (rev 2524) +++ trunk/browser/Source/dooble.cc 2011-07-28 18:06:19 UTC (rev 2525) @@ -3602,6 +3602,11 @@ ** to have a history. The entries will be date-ordered. */ + /* + ** Also retrieve the five (+/- something) most-visited + ** hosts. + */ + if(dooble::s_settings.value("settingsWindow/rememberHistory", true).toBool()) { @@ -3617,11 +3622,13 @@ (dooble::s_settings.value("settingsWindow/hashType"). toString()); QSqlQuery query(db); + QMap<QString, int> counts; QMap<QDateTime, QAction *> actions; + QMap<QString, dwebhistoryitem> hosts; query.exec (QString("SELECT url, title, icon, " - "last_visited " + "last_visited, host, visits " "FROM history WHERE " "passphrase_hash = '%1'"). arg(dmisc::passphraseHash(hashType))); @@ -3678,7 +3685,6 @@ QAction *action = 0; QString title(""); - QString fullTitle(""); title = dmisc::decodedString (QByteArray::fromBase64 @@ -3687,8 +3693,6 @@ if(title.isEmpty()) title = url.toString(QUrl::StripTrailingSlash); - fullTitle = title; - if(title.length() > MAX_NUMBER_OF_MENU_TITLE_CHARACTERS) title = title.mid (0, @@ -3700,7 +3704,6 @@ action = new QAction(icon, title, this); action->setData(url.toString(QUrl::StripTrailingSlash)); - action->setProperty("title", fullTitle); connect(action, SIGNAL(triggered(void)), this, SLOT(slotLinkActionTriggered(void))); @@ -3712,6 +3715,35 @@ Qt::ISODate)); actions[dateTime] = action; + + QString host + (dmisc::decodedString + (QByteArray::fromBase64 + (query.value(4).toString().toAscii())).data()); + QString visits + (dmisc::decodedString + (QByteArray::fromBase64 + (query.value(5).toString().toAscii())).data()); + + if(!host.isEmpty() && + !hosts.contains(host)) + { + dwebhistoryitem item; + + item.setUrl(QUrl(host)); + item.setIcon(action->icon()); + + /* + ** We have to set the title to the URL since the + ** history table does not store the host's title. + */ + + item.setTitle(item.url().toString(QUrl::StripTrailingSlash)); + hosts[host] = item; + counts[host] += visits.toInt(); + } + else if(!host.isEmpty() && hosts.contains(host)) + counts[host] += visits.toInt(); } /* @@ -3729,27 +3761,42 @@ ui.historyMenu->addAction(actions.values().at(i)); } - int i = actions.size() - 1; + actions.clear(); - foreach(QToolButton *toolButton, - ui.statusBar->findChildren<QToolButton *> ()) + QList<int> list(counts.values()); + QList<QToolButton *> toolButtons + (ui.statusBar->findChildren<QToolButton *> ()); + + qSort(list.begin(), list.end()); + + for(int i = 0; i < toolButtons.size(); i++) + toolButtons.at(i)->setVisible(false); + + for(int i = list.size(), j = 0; i >= 0; i--) { - if(i >= 0) - { - toolButton->setVisible(true); - toolButton->setIcon(actions.values().at(i)->icon()); - toolButton->setToolTip(actions.values().at(i)-> - property("title").toString()); - toolButton->setProperty("url", - actions.values().at(i)->data()); - } - else - toolButton->setVisible(false); + QList<QString> keys(counts.keys(list.at(i))); - i -= 1; + for(int k = 0; k < keys.size(); k++) + if(j < 5) + { + toolButtons.at(j)->setVisible(true); + toolButtons.at(j)->setIcon(hosts[keys.at(k)].icon()); + toolButtons.at(j)->setToolTip(hosts[keys.at(k)].title()); + toolButtons.at(j)->setProperty + ("url", hosts[keys.at(k)].url()); + j += 1; + } + else + break; + + if(j > 4) + break; } - actions.clear(); + list.clear(); + hosts.clear(); + counts.clear(); + toolButtons.clear(); } db.close(); Modified: trunk/browser/Source/dwebhistoryitem.cc =================================================================== --- trunk/browser/Source/dwebhistoryitem.cc 2011-07-28 16:41:50 UTC (rev 2524) +++ trunk/browser/Source/dwebhistoryitem.cc 2011-07-28 18:06:19 UTC (rev 2525) @@ -1,7 +1,7 @@ /**************************************************************************** ** Dooble - The Secure Internet Web Browser ** -** Copyright (c) 2008, 2009, 2010 Alexis Megas, +** Copyright (c) 2008, 2009, 2010, 2011 Alexis Megas, ** Gunther van Dooble, and the Dooble Team. ** All rights reserved. ** @@ -89,6 +89,11 @@ return m_url == other.m_url; } +void dwebhistoryitem::setUrl(const QUrl &url) +{ + m_url = url; +} + void dwebhistoryitem::setIcon(const QIcon &icon) { m_icon = icon; Modified: trunk/browser/UI/statusBar.ui =================================================================== --- trunk/browser/UI/statusBar.ui 2011-07-28 16:41:50 UTC (rev 2524) +++ trunk/browser/UI/statusBar.ui 2011-07-28 18:06:19 UTC (rev 2525) @@ -6,125 +6,119 @@ <rect> <x>0</x> <y>0</y> - <width>494</width> - <height>24</height> + <width>231</width> + <height>30</height> </rect> </property> <property name="minimumSize"> <size> <width>0</width> - <height>24</height> + <height>30</height> </size> </property> - <widget class="QProgressBar" name="progressBar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>5</y> - <width>87</width> - <height>16</height> - </rect> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <property name="leftMargin"> + <number>0</number> </property> - <property name="textVisible"> - <bool>false</bool> + <property name="topMargin"> + <number>5</number> </property> - </widget> - <widget class="QWidget" name="horizontalLayoutWidget"> - <property name="geometry"> - <rect> - <x>130</x> - <y>0</y> - <width>161</width> - <height>24</height> - </rect> + <property name="rightMargin"> + <number>0</number> </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QToolButton" name="toolButton_2"> - <property name="minimumSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="toolButton_4"> - <property name="minimumSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="toolButton_3"> - <property name="minimumSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="toolButton_5"> - <property name="minimumSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="toolButton"> - <property name="minimumSize"> - <size> - <width>16</width> - <height>16</height> - </size> - </property> - <property name="autoRaise"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QLabel" name="statusLabel"> - <property name="geometry"> - <rect> - <x>310</x> - <y>0</y> - <width>181</width> - <height>22</height> - </rect> + <property name="bottomMargin"> + <number>5</number> </property> - </widget> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="textVisible"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_1"> + <property name="minimumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_2"> + <property name="minimumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_3"> + <property name="minimumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_4"> + <property name="minimumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="toolButton_5"> + <property name="minimumSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="statusLabel"/> + </item> + </layout> </widget> <tabstops> + <tabstop>toolButton_1</tabstop> <tabstop>toolButton_2</tabstop> + <tabstop>toolButton_3</tabstop> <tabstop>toolButton_4</tabstop> <tabstop>toolButton_5</tabstop> </tabstops> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |