mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
added update every 5 mins to account for changes when sleeping
This commit is contained in:
parent
6a62227dba
commit
a75a4945ec
@ -46,6 +46,7 @@
|
|||||||
std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
|
||||||
|
|
||||||
const QString RsFriendListModel::FilterString("filtered");
|
const QString RsFriendListModel::FilterString("filtered");
|
||||||
|
const uint32_t MAX_INTERNAL_DATA_UPDATE_DELAY = 300 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes.
|
||||||
|
|
||||||
static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs.
|
static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs.
|
||||||
|
|
||||||
@ -694,8 +695,19 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function makes sure that the internal data gets updated. They are situations where the otification system cannot
|
||||||
|
// send the information about changes, such as when the computer is put on sleep.
|
||||||
|
|
||||||
|
void RsFriendListModel::checkInternalData()
|
||||||
|
{
|
||||||
|
if(mLastInternalDataUpdate + MAX_INTERNAL_DATA_UPDATE_DELAY < time(NULL))
|
||||||
|
updateInternalData();
|
||||||
|
}
|
||||||
|
|
||||||
const RsFriendListModel::HierarchicalGroupInformation *RsFriendListModel::getGroupInfo(const EntryIndex& e) const
|
const RsFriendListModel::HierarchicalGroupInformation *RsFriendListModel::getGroupInfo(const EntryIndex& e) const
|
||||||
{
|
{
|
||||||
|
const_cast<RsFriendListModel*>(this)->checkInternalData();
|
||||||
|
|
||||||
if(e.group_index >= mGroups.size())
|
if(e.group_index >= mGroups.size())
|
||||||
return NULL ;
|
return NULL ;
|
||||||
else
|
else
|
||||||
@ -704,6 +716,8 @@ const RsFriendListModel::HierarchicalGroupInformation *RsFriendListModel::getGro
|
|||||||
|
|
||||||
const RsFriendListModel::HierarchicalProfileInformation *RsFriendListModel::getProfileInfo(const EntryIndex& e) const
|
const RsFriendListModel::HierarchicalProfileInformation *RsFriendListModel::getProfileInfo(const EntryIndex& e) const
|
||||||
{
|
{
|
||||||
|
const_cast<RsFriendListModel*>(this)->checkInternalData();
|
||||||
|
|
||||||
// First look into the relevant group, then for the correct profile in this group.
|
// First look into the relevant group, then for the correct profile in this group.
|
||||||
|
|
||||||
if(e.type != ENTRY_TYPE_PROFILE)
|
if(e.type != ENTRY_TYPE_PROFILE)
|
||||||
@ -724,6 +738,8 @@ const RsFriendListModel::HierarchicalProfileInformation *RsFriendListModel::getP
|
|||||||
|
|
||||||
const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNodeInfo(const EntryIndex& e) const
|
const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNodeInfo(const EntryIndex& e) const
|
||||||
{
|
{
|
||||||
|
const_cast<RsFriendListModel*>(this)->checkInternalData();
|
||||||
|
|
||||||
if(e.type != ENTRY_TYPE_NODE)
|
if(e.type != ENTRY_TYPE_NODE)
|
||||||
return NULL ;
|
return NULL ;
|
||||||
|
|
||||||
@ -771,19 +787,6 @@ bool RsFriendListModel::getPeerOnlineStatus(const EntryIndex& e) const
|
|||||||
return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED));
|
return (noded && (noded->node_info.state & RS_PEER_STATE_CONNECTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant RsFriendListModel::userRole(const EntryIndex& fmpe,int col) const
|
|
||||||
{
|
|
||||||
// switch(col)
|
|
||||||
// {
|
|
||||||
// case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.srcId.toStdString()));
|
|
||||||
// case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
|
|
||||||
// default:
|
|
||||||
// return QVariant();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) const
|
QVariant RsFriendListModel::decorationRole(const EntryIndex& entry,int col) const
|
||||||
{
|
{
|
||||||
if(col > 0)
|
if(col > 0)
|
||||||
@ -1084,6 +1087,8 @@ void RsFriendListModel::updateInternalData()
|
|||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
postMods();
|
postMods();
|
||||||
|
|
||||||
|
mLastInternalDataUpdate = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const;
|
const HierarchicalGroupInformation *getGroupInfo (const EntryIndex&) const;
|
||||||
const HierarchicalProfileInformation *getProfileInfo(const EntryIndex&) const;
|
const HierarchicalProfileInformation *getProfileInfo(const EntryIndex&)const;
|
||||||
const HierarchicalNodeInformation *getNodeInfo(const EntryIndex&) const;
|
const HierarchicalNodeInformation *getNodeInfo(const EntryIndex&) const;
|
||||||
|
|
||||||
bool getPeerOnlineStatus(const EntryIndex& e) const;
|
bool getPeerOnlineStatus(const EntryIndex& e) const;
|
||||||
@ -162,7 +162,6 @@ private:
|
|||||||
QVariant displayRole (const EntryIndex& e, int col) const;
|
QVariant displayRole (const EntryIndex& e, int col) const;
|
||||||
QVariant decorationRole(const EntryIndex& e, int col) const;
|
QVariant decorationRole(const EntryIndex& e, int col) const;
|
||||||
QVariant toolTipRole (const EntryIndex& e, int col) const;
|
QVariant toolTipRole (const EntryIndex& e, int col) const;
|
||||||
QVariant userRole (const EntryIndex& e, int col) const;
|
|
||||||
QVariant statusRole (const EntryIndex& e, int col) const;
|
QVariant statusRole (const EntryIndex& e, int col) const;
|
||||||
QVariant sortRole (const EntryIndex& e, int col) const;
|
QVariant sortRole (const EntryIndex& e, int col) const;
|
||||||
QVariant fontRole (const EntryIndex& e, int col) const;
|
QVariant fontRole (const EntryIndex& e, int col) const;
|
||||||
@ -186,6 +185,7 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool passesFilter(const EntryIndex &e, int column) const;
|
bool passesFilter(const EntryIndex &e, int column) const;
|
||||||
|
void checkInternalData();
|
||||||
|
|
||||||
void preMods() ;
|
void preMods() ;
|
||||||
void postMods() ;
|
void postMods() ;
|
||||||
@ -204,6 +204,7 @@ private:
|
|||||||
|
|
||||||
bool mDisplayGroups ;
|
bool mDisplayGroups ;
|
||||||
bool mDisplayStatusString ;
|
bool mDisplayStatusString ;
|
||||||
|
rstime_t mLastInternalDataUpdate;
|
||||||
|
|
||||||
// The 3 vectors below store thehierarchical information for groups, profiles and locations,
|
// The 3 vectors below store thehierarchical information for groups, profiles and locations,
|
||||||
// meaning which is the child/parent of which. The actual group/profile/node data are also stored in the
|
// meaning which is the child/parent of which. The actual group/profile/node data are also stored in the
|
||||||
|
@ -178,7 +178,7 @@ NewFriendList::NewFriendList(QWidget *parent) : QWidget(parent), ui(new Ui::NewF
|
|||||||
ui->filterLineEdit->addFilter(QIcon(), headerText, RsFriendListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), headerText));
|
ui->filterLineEdit->addFilter(QIcon(), headerText, RsFriendListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), headerText));
|
||||||
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsFriendListModel::COLUMN_THREAD_ID, tr("Search ID"));
|
ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsFriendListModel::COLUMN_THREAD_ID, tr("Search ID"));
|
||||||
|
|
||||||
mActionSortByState = new QAction(tr("Display online friends on top"), this);
|
mActionSortByState = new QAction(tr("Online friends on top"), this);
|
||||||
mActionSortByState->setCheckable(true);
|
mActionSortByState->setCheckable(true);
|
||||||
|
|
||||||
//setting default filter by column as subject
|
//setting default filter by column as subject
|
||||||
@ -191,10 +191,7 @@ NewFriendList::NewFriendList(QWidget *parent) : QWidget(parent), ui(new Ui::NewF
|
|||||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||||
QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut);
|
QShortcut *Shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), ui->peerTreeWidget, 0, 0, Qt::WidgetShortcut);
|
||||||
|
connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend()));
|
||||||
/* Initialize tree */
|
|
||||||
// ui->peerTreeWidget->enableColumnCustomize(true);
|
|
||||||
// ui->peerTreeWidget->setColumnCustomizable(COLUMN_NAME, false);
|
|
||||||
|
|
||||||
QFontMetricsF fontMetrics(ui->peerTreeWidget->font());
|
QFontMetricsF fontMetrics(ui->peerTreeWidget->font());
|
||||||
|
|
||||||
@ -216,7 +213,6 @@ NewFriendList::NewFriendList(QWidget *parent) : QWidget(parent), ui(new Ui::NewF
|
|||||||
QHeaderView *h = ui->peerTreeWidget->header();
|
QHeaderView *h = ui->peerTreeWidget->header();
|
||||||
h->setContextMenuPolicy(Qt::CustomContextMenu);
|
h->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
connect(Shortcut, SIGNAL(activated()), this, SLOT(removefriend()));
|
|
||||||
connect(ui->peerTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder)));
|
connect(ui->peerTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder)));
|
||||||
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool)));
|
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(toggleSortByState(bool)));
|
||||||
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
|
connect(ui->peerTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(peerTreeWidgetCustomPopupMenu()));
|
||||||
@ -227,7 +223,6 @@ NewFriendList::NewFriendList(QWidget *parent) : QWidget(parent), ui(new Ui::NewF
|
|||||||
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
connect(ui->actionShowOfflineFriends, SIGNAL(triggered(bool)), this, SLOT(setShowUnconnected(bool)));
|
||||||
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)));
|
connect(ui->actionShowState, SIGNAL(triggered(bool)), this, SLOT(setShowState(bool)));
|
||||||
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)));
|
connect(ui->actionShowGroups, SIGNAL(triggered(bool)), this, SLOT(setShowGroups(bool)));
|
||||||
|
|
||||||
connect(ui->actionExportFriendlist, SIGNAL(triggered()), this, SLOT(exportFriendlistClicked()));
|
connect(ui->actionExportFriendlist, SIGNAL(triggered()), this, SLOT(exportFriendlistClicked()));
|
||||||
connect(ui->actionImportFriendlist, SIGNAL(triggered()), this, SLOT(importFriendlistClicked()));
|
connect(ui->actionImportFriendlist, SIGNAL(triggered()), this, SLOT(importFriendlistClicked()));
|
||||||
|
|
||||||
@ -317,9 +312,8 @@ void NewFriendList::headerContextMenuRequested(QPoint p)
|
|||||||
|
|
||||||
void NewFriendList::addToolButton(QToolButton *toolButton)
|
void NewFriendList::addToolButton(QToolButton *toolButton)
|
||||||
{
|
{
|
||||||
if (!toolButton) {
|
if (!toolButton)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize button */
|
/* Initialize button */
|
||||||
toolButton->setAutoRaise(true);
|
toolButton->setAutoRaise(true);
|
||||||
@ -334,9 +328,8 @@ void NewFriendList::processSettings(bool load)
|
|||||||
{
|
{
|
||||||
// state of peer tree
|
// state of peer tree
|
||||||
|
|
||||||
if (load) {
|
if (load) // load settings
|
||||||
// load settings
|
{
|
||||||
|
|
||||||
// states
|
// states
|
||||||
setShowUnconnected(!Settings->value("hideUnconnected", mProxyModel->showOfflineNodes()).toBool());
|
setShowUnconnected(!Settings->value("hideUnconnected", mProxyModel->showOfflineNodes()).toBool());
|
||||||
setShowState(Settings->value("showState", mModel->getDisplayStatusString()).toBool());
|
setShowState(Settings->value("showState", mModel->getDisplayStatusString()).toBool());
|
||||||
@ -366,7 +359,9 @@ void NewFriendList::processSettings(bool load)
|
|||||||
std::cerr << "(EE) Cannot find group info for openned group \"" << gids << "\"" << std::endl;
|
std::cerr << "(EE) Cannot find group info for openned group \"" << gids << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
Settings->endArray();
|
Settings->endArray();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// save settings
|
// save settings
|
||||||
|
|
||||||
// states
|
// states
|
||||||
|
Loading…
x
Reference in New Issue
Block a user