[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3500: Add a BridgeUsageDialog class and .ui that can be used to di (in vidalia/trunk/src/vidalia: . config)
Author: edmanm
Date: 2009-02-01 23:53:05 -0500 (Sun, 01 Feb 2009)
New Revision: 3500
Added:
vidalia/trunk/src/vidalia/config/bridgeusagedialog.cpp
vidalia/trunk/src/vidalia/config/bridgeusagedialog.h
vidalia/trunk/src/vidalia/config/bridgeusagedialog.ui
Modified:
vidalia/trunk/src/vidalia/CMakeLists.txt
Log:
Add a BridgeUsageDialog class and .ui that can be used to display a
summary of the geographic location of Tor clients recently seen by a
bridge.
Modified: vidalia/trunk/src/vidalia/CMakeLists.txt
===================================================================
--- vidalia/trunk/src/vidalia/CMakeLists.txt 2009-02-02 04:50:28 UTC (rev 3499)
+++ vidalia/trunk/src/vidalia/CMakeLists.txt 2009-02-02 04:53:05 UTC (rev 3500)
@@ -72,6 +72,7 @@
config/abstracttorsettings.cpp
config/advancedpage.cpp
config/appearancepage.cpp
+ config/bridgeusagedialog.cpp
config/configdialog.cpp
config/configpagestack.cpp
config/domainvalidator.cpp
@@ -97,6 +98,7 @@
config/abstracttorsettings.h
config/advancedpage.h
config/appearancepage.h
+ config/bridgeusagedialog.h
config/configdialog.h
config/configpage.h
config/configpagestack.h
@@ -243,6 +245,7 @@
bwgraph/bwgraph.ui
config/advancedpage.ui
config/appearancepage.ui
+ config/bridgeusagedialog.ui
config/configdialog.ui
config/generalpage.ui
config/networkpage.ui
Added: vidalia/trunk/src/vidalia/config/bridgeusagedialog.cpp
===================================================================
--- vidalia/trunk/src/vidalia/config/bridgeusagedialog.cpp (rev 0)
+++ vidalia/trunk/src/vidalia/config/bridgeusagedialog.cpp 2009-02-02 04:53:05 UTC (rev 3500)
@@ -0,0 +1,81 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to the
+** terms described in the LICENSE file.
+*/
+
+/*
+** \file bridgeusagedialog.cpp
+** \version $Id$
+** \brief Displays a summary of bridge usage information, including client
+** geographic location history.
+*/
+
+#include <QHeaderView>
+#include <QTreeWidgetItem>
+#include <QPixmap>
+#include <countryinfo.h>
+
+#include "bridgeusagedialog.h"
+
+
+BridgeUsageDialog::BridgeUsageDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+ ui.treeClientSummary->setHeaderLabels(QStringList() << QString("")
+ << tr("Country")
+ << tr("# Clients"));
+}
+
+void
+BridgeUsageDialog::showEvent(QShowEvent *e)
+{
+ QHeaderView *header = ui.treeClientSummary->header();
+ header->setResizeMode(0, QHeaderView::ResizeToContents);
+ header->resizeSection(1, 220);
+ header->setResizeMode(2, QHeaderView::ResizeToContents);
+
+ QDialog::showEvent(e);
+}
+
+void
+BridgeUsageDialog::update(const QDateTime &timeStarted,
+ const QHash<QString,int> &countrySummary)
+{
+ QTreeWidgetItem *item;
+ int minClients, maxClients;
+ QString countryName;
+ QPixmap flag;
+
+ /* Set the header with the TimeStarted value converted to local time */
+ ui.lblClientSummary->setText(tr("Clients from the following countries have "
+ "used your relay since %1")
+ .arg(timeStarted.toLocalTime().toString()));
+
+ /* Populate the table of client country statistics */
+ foreach (QString countryCode, countrySummary.keys()) {
+ maxClients = countrySummary.value(countryCode);
+ minClients = maxClients-7;
+
+ flag = QPixmap(":/images/flags/" + countryCode.toLower() + ".png");
+ if (flag.isNull())
+ flag = QPixmap(":/images/flags/unknown.png");
+
+ countryName = CountryInfo::countryName(countryCode);
+ if (countryName.isEmpty())
+ countryName = countryCode;
+
+ item = new QTreeWidgetItem();
+ item->setIcon(0, QIcon(flag));
+ item->setText(1, countryName);
+ item->setText(2, QString("%1-%2").arg(minClients).arg(maxClients));
+ ui.treeClientSummary->addTopLevelItem(item);
+ }
+ ui.treeClientSummary->sortItems(2, Qt::DescendingOrder);
+}
+
Property changes on: vidalia/trunk/src/vidalia/config/bridgeusagedialog.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: vidalia/trunk/src/vidalia/config/bridgeusagedialog.h
===================================================================
--- vidalia/trunk/src/vidalia/config/bridgeusagedialog.h (rev 0)
+++ vidalia/trunk/src/vidalia/config/bridgeusagedialog.h 2009-02-02 04:53:05 UTC (rev 3500)
@@ -0,0 +1,53 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to the
+** terms described in the LICENSE file.
+*/
+
+/*
+** \file bridgeusagedialog.h
+** \version $Id$
+** \brief Displays a summary of bridge usage information, including client
+** geographic location history.
+*/
+
+#ifndef _BRIDGEUSAGEDIALOG_H
+#define _BRIDGEUSAGEDIALOG_H
+
+#include <QDialog>
+#include <QDateTime>
+#include <QHash>
+
+#include "ui_bridgeusagedialog.h"
+
+
+class BridgeUsageDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ /** Default constructor.
+ */
+ BridgeUsageDialog(QWidget *parent = 0);
+
+ /** Updates the dialog with current bridge usage information.
+ */
+ void update(const QDateTime &timeStarted,
+ const QHash<QString,int> &countrySummary);
+
+protected:
+ /** Called when the dialog is displayed. Adjusts the size of the column
+ * headers.
+ */
+ void showEvent(QShowEvent *e);
+
+private:
+ Ui::BridgeUsageDialog ui;
+};
+
+#endif
+
Property changes on: vidalia/trunk/src/vidalia/config/bridgeusagedialog.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: vidalia/trunk/src/vidalia/config/bridgeusagedialog.ui
===================================================================
--- vidalia/trunk/src/vidalia/config/bridgeusagedialog.ui (rev 0)
+++ vidalia/trunk/src/vidalia/config/bridgeusagedialog.ui 2009-02-02 04:53:05 UTC (rev 3500)
@@ -0,0 +1,110 @@
+<ui version="4.0" >
+ <class>BridgeUsageDialog</class>
+ <widget class="QDialog" name="BridgeUsageDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>444</width>
+ <height>408</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Bridge Usage Summary</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Client Summary</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QLabel" name="lblClientSummary" >
+ <property name="text" >
+ <string></string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="treeClientSummary" >
+ <property name="alternatingRowColors" >
+ <bool>false</bool>
+ </property>
+ <property name="sortingEnabled" >
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string></string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Country</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string># Clients</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>BridgeUsageDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>BridgeUsageDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>