mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 16:09:35 -05:00
Merge branch 'master' into AddHTML_TextOptimization_0.6
This commit is contained in:
commit
b1fd29033b
@ -587,7 +587,8 @@ RsGRouterAbstractMsgItem *GRouterDataInfo::addDataChunk(RsGRouterTransactionChun
|
|||||||
std::cerr << " ERROR: chunk numbering is wrong. Dropping." << std::endl;
|
std::cerr << " ERROR: chunk numbering is wrong. Dropping." << std::endl;
|
||||||
delete chunk ;
|
delete chunk ;
|
||||||
delete incoming_data_buffer ;
|
delete incoming_data_buffer ;
|
||||||
return NULL;
|
incoming_data_buffer = NULL ;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
incoming_data_buffer->chunk_data = (uint8_t*)realloc((uint8_t*)incoming_data_buffer->chunk_data,incoming_data_buffer->chunk_size + chunk->chunk_size) ;
|
incoming_data_buffer->chunk_data = (uint8_t*)realloc((uint8_t*)incoming_data_buffer->chunk_data,incoming_data_buffer->chunk_size + chunk->chunk_size) ;
|
||||||
memcpy(&incoming_data_buffer->chunk_data[incoming_data_buffer->chunk_size],chunk->chunk_data,chunk->chunk_size) ;
|
memcpy(&incoming_data_buffer->chunk_data[incoming_data_buffer->chunk_size],chunk->chunk_data,chunk->chunk_size) ;
|
||||||
|
@ -570,7 +570,7 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
|||||||
std::map<RsNxsMsg*, RsGxsMsgMetaData* >::iterator mit = msg.begin();
|
std::map<RsNxsMsg*, RsGxsMsgMetaData* >::iterator mit = msg.begin();
|
||||||
|
|
||||||
// start a transaction
|
// start a transaction
|
||||||
mDb->execSQL("BEGIN;");
|
mDb->beginTransaction();
|
||||||
|
|
||||||
for(; mit != msg.end(); ++mit){
|
for(; mit != msg.end(); ++mit){
|
||||||
|
|
||||||
@ -654,7 +654,7 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finish transaction
|
// finish transaction
|
||||||
bool ret = mDb->execSQL("COMMIT;");
|
bool ret = mDb->commitTransaction();
|
||||||
|
|
||||||
for(mit = msg.begin(); mit != msg.end(); ++mit)
|
for(mit = msg.begin(); mit != msg.end(); ++mit)
|
||||||
{
|
{
|
||||||
@ -685,7 +685,7 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
std::map<RsNxsGrp*, RsGxsGrpMetaData* >::iterator sit = grp.begin();
|
std::map<RsNxsGrp*, RsGxsGrpMetaData* >::iterator sit = grp.begin();
|
||||||
|
|
||||||
// begin transaction
|
// begin transaction
|
||||||
mDb->execSQL("BEGIN;");
|
mDb->beginTransaction();
|
||||||
|
|
||||||
for(; sit != grp.end(); ++sit)
|
for(; sit != grp.end(); ++sit)
|
||||||
{
|
{
|
||||||
@ -769,7 +769,7 @@ int RsDataService::storeGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// finish transaction
|
// finish transaction
|
||||||
bool ret = mDb->execSQL("COMMIT;");
|
bool ret = mDb->commitTransaction();
|
||||||
|
|
||||||
for(sit = grp.begin(); sit != grp.end(); ++sit)
|
for(sit = grp.begin(); sit != grp.end(); ++sit)
|
||||||
{
|
{
|
||||||
@ -791,7 +791,7 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
std::map<RsNxsGrp*, RsGxsGrpMetaData* >::iterator sit = grp.begin();
|
std::map<RsNxsGrp*, RsGxsGrpMetaData* >::iterator sit = grp.begin();
|
||||||
|
|
||||||
// begin transaction
|
// begin transaction
|
||||||
mDb->execSQL("BEGIN;");
|
mDb->beginTransaction();
|
||||||
|
|
||||||
for(; sit != grp.end(); ++sit)
|
for(; sit != grp.end(); ++sit)
|
||||||
{
|
{
|
||||||
@ -858,7 +858,7 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpPtr->grpId.toStdString() + "'", cv);
|
||||||
}
|
}
|
||||||
// finish transaction
|
// finish transaction
|
||||||
bool ret = mDb->execSQL("COMMIT;");
|
bool ret = mDb->commitTransaction();
|
||||||
|
|
||||||
for(sit = grp.begin(); sit != grp.end(); ++sit)
|
for(sit = grp.begin(); sit != grp.end(); ++sit)
|
||||||
{
|
{
|
||||||
@ -877,7 +877,7 @@ int RsDataService::updateGroupKeys(const RsGxsGroupId& grpId,const RsTlvSecurity
|
|||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
|
|
||||||
// begin transaction
|
// begin transaction
|
||||||
mDb->execSQL("BEGIN;");
|
mDb->beginTransaction();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* STORE key set
|
* STORE key set
|
||||||
@ -895,7 +895,7 @@ int RsDataService::updateGroupKeys(const RsGxsGroupId& grpId,const RsTlvSecurity
|
|||||||
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpId.toStdString() + "'", cv);
|
mDb->sqlUpdate(GRP_TABLE_NAME, "grpId='" + grpId.toStdString() + "'", cv);
|
||||||
|
|
||||||
// finish transaction
|
// finish transaction
|
||||||
return mDb->execSQL("COMMIT;");
|
return mDb->commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsDataService::validSize(RsNxsGrp* grp) const
|
bool RsDataService::validSize(RsNxsGrp* grp) const
|
||||||
@ -1608,7 +1608,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std
|
|||||||
bool RsDataService::locked_updateMessageEntries(const MsgUpdates& updates)
|
bool RsDataService::locked_updateMessageEntries(const MsgUpdates& updates)
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
bool ret = mDb->execSQL("BEGIN;");
|
bool ret = mDb->beginTransaction();
|
||||||
|
|
||||||
MsgUpdates::const_iterator mit = updates.begin();
|
MsgUpdates::const_iterator mit = updates.begin();
|
||||||
|
|
||||||
@ -1627,7 +1627,7 @@ bool RsDataService::locked_updateMessageEntries(const MsgUpdates& updates)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret &= mDb->execSQL("COMMIT;");
|
ret &= mDb->commitTransaction();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1635,7 +1635,7 @@ bool RsDataService::locked_updateMessageEntries(const MsgUpdates& updates)
|
|||||||
bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
bool ret = mDb->execSQL("BEGIN;");
|
bool ret = mDb->beginTransaction();
|
||||||
|
|
||||||
GxsMsgReq::const_iterator mit = msgIds.begin();
|
GxsMsgReq::const_iterator mit = msgIds.begin();
|
||||||
|
|
||||||
@ -1653,7 +1653,7 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret &= mDb->execSQL("COMMIT;");
|
ret &= mDb->commitTransaction();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1661,7 +1661,7 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds)
|
|||||||
bool RsDataService::locked_removeGroupEntries(const std::vector<RsGxsGroupId>& grpIds)
|
bool RsDataService::locked_removeGroupEntries(const std::vector<RsGxsGroupId>& grpIds)
|
||||||
{
|
{
|
||||||
// start a transaction
|
// start a transaction
|
||||||
bool ret = mDb->execSQL("BEGIN;");
|
bool ret = mDb->beginTransaction();
|
||||||
|
|
||||||
std::vector<RsGxsGroupId>::const_iterator vit = grpIds.begin();
|
std::vector<RsGxsGroupId>::const_iterator vit = grpIds.begin();
|
||||||
|
|
||||||
@ -1672,7 +1672,7 @@ bool RsDataService::locked_removeGroupEntries(const std::vector<RsGxsGroupId>& g
|
|||||||
mDb->sqlDelete(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
mDb->sqlDelete(GRP_TABLE_NAME, KEY_GRP_ID+ "='" + grpId.toStdString() + "'", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
ret &= mDb->execSQL("COMMIT;");
|
ret &= mDb->commitTransaction();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -908,7 +908,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp)
|
|||||||
PrivacyBitPos pos = GRP_OPTION_BITS;
|
PrivacyBitPos pos = GRP_OPTION_BITS;
|
||||||
|
|
||||||
// Check required permissions, and allow them to sign it - if they want too - as well!
|
// Check required permissions, and allow them to sign it - if they want too - as well!
|
||||||
if (!(metaData.mAuthorId.isNull()) || checkAuthenFlag(pos, author_flag))
|
if ((!metaData.mAuthorId.isNull()) || checkAuthenFlag(pos, author_flag))
|
||||||
{
|
{
|
||||||
needIdentitySign = true;
|
needIdentitySign = true;
|
||||||
std::cerr << "Needs Identity sign! (Service Flags)";
|
std::cerr << "Needs Identity sign! (Service Flags)";
|
||||||
|
@ -1897,7 +1897,7 @@ bool pqissl::cansend(uint32_t usec)
|
|||||||
|
|
||||||
if(sockfd == -1)
|
if(sockfd == -1)
|
||||||
{
|
{
|
||||||
std::cerr << "pqissl::moretoread(): socket is invalid or closed." << std::endl;
|
std::cerr << "pqissl::cansend(): socket is invalid or closed." << std::endl;
|
||||||
return 0 ;
|
return 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,32 @@ std::string RetroDb::getKey() const
|
|||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RetroDb::beginTransaction()
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return execSQL("BEGIN;");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RetroDb::commitTransaction()
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return execSQL("COMMIT;");
|
||||||
|
}
|
||||||
|
bool RetroDb::rollbackTransaction()
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return execSQL("ROLLBACK;");
|
||||||
|
}
|
||||||
|
|
||||||
bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶mBindings){
|
bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶mBindings){
|
||||||
|
|
||||||
// prepare statement
|
// prepare statement
|
||||||
@ -531,6 +557,43 @@ bool RetroDb::sqlUpdate(const std::string &tableName, std::string whereClause, c
|
|||||||
return execSQL_bind(sqlQuery, paramBindings);
|
return execSQL_bind(sqlQuery, paramBindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RetroDb::tableExists(const std::string &tableName)
|
||||||
|
{
|
||||||
|
if (!isOpen()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string sqlQuery = "PRAGMA table_info(" + tableName + ");";
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
sqlite3_stmt* stmt = NULL;
|
||||||
|
|
||||||
|
int rc = sqlite3_prepare_v2(mDb, sqlQuery.c_str(), sqlQuery.length(), &stmt, NULL);
|
||||||
|
if (rc == SQLITE_OK) {
|
||||||
|
rc = sqlite3_step(stmt);
|
||||||
|
switch (rc) {
|
||||||
|
case SQLITE_ROW:
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
case SQLITE_DONE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "RetroDb::tableExists(): Error executing statement (code: " << rc << ")"
|
||||||
|
<< std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "RetroDb::tableExists(): Error preparing statement\n";
|
||||||
|
std::cerr << "Error code: " << sqlite3_errmsg(mDb)
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stmt) {
|
||||||
|
sqlite3_finalize(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/********************** RetroCursor ************************/
|
/********************** RetroCursor ************************/
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
|
|
||||||
#include "contentvalue.h"
|
#include "contentvalue.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RetroCursor;
|
class RetroCursor;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -90,7 +88,23 @@ public:
|
|||||||
/* modifying db */
|
/* modifying db */
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Start transaction
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
bool beginTransaction();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Commit transaction
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
bool commitTransaction();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Rollback transaction
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
bool rollbackTransaction();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* To a make query which do not return a result \n
|
* To a make query which do not return a result \n
|
||||||
@ -153,22 +167,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void vacuum();
|
void vacuum();
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Build the "VALUE" part of an insertiong sql query
|
* Check if table exist in database
|
||||||
* @param parameter contains place holder query
|
* @param tableName table to check
|
||||||
* @param paramBindings
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
void buildInsertQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
bool tableExists(const std::string& tableName);
|
||||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Build the "VALUE" part of an insertiong sql query
|
|
||||||
* @param parameter contains place holder query
|
|
||||||
* @param paramBindings
|
|
||||||
*/
|
|
||||||
void buildUpdateQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
|
||||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const int OPEN_READONLY;
|
static const int OPEN_READONLY;
|
||||||
@ -179,6 +184,22 @@ private:
|
|||||||
|
|
||||||
bool execSQL_bind(const std::string &query, std::list<RetroBind*>& blobs);
|
bool execSQL_bind(const std::string &query, std::list<RetroBind*>& blobs);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Build the "VALUE" part of an insertiong sql query
|
||||||
|
* @param parameter contains place holder query
|
||||||
|
* @param paramBindings
|
||||||
|
*/
|
||||||
|
void buildInsertQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||||
|
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Build the "VALUE" part of an insertiong sql query
|
||||||
|
* @param parameter contains place holder query
|
||||||
|
* @param paramBindings
|
||||||
|
*/
|
||||||
|
void buildUpdateQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||||
|
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sqlite3* mDb;
|
sqlite3* mDb;
|
||||||
|
@ -79,7 +79,6 @@
|
|||||||
#define IMAGE_GROUP24 ":/images/user/group24.png"
|
#define IMAGE_GROUP24 ":/images/user/group24.png"
|
||||||
|
|
||||||
#define COLUMN_DATA 0 // column for storing the userdata id
|
#define COLUMN_DATA 0 // column for storing the userdata id
|
||||||
#define COLUMN_SORT COLUMN_NAME // column for sorting
|
|
||||||
|
|
||||||
#define ROLE_ID Qt::UserRole
|
#define ROLE_ID Qt::UserRole
|
||||||
#define ROLE_STANDARD Qt::UserRole + 1
|
#define ROLE_STANDARD Qt::UserRole + 1
|
||||||
@ -130,16 +129,19 @@ FriendList::FriendList(QWidget *parent) :
|
|||||||
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->actionSortByName, SIGNAL(triggered()), this, SLOT(setSortByName()));
|
|
||||||
connect(ui->actionSortByState, SIGNAL(triggered()), this, SLOT(setSortByState()));
|
|
||||||
|
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
|
|
||||||
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
ui->filterLineEdit->setPlaceholderText(tr("Search")) ;
|
||||||
ui->filterLineEdit->showFilterIcon();
|
ui->filterLineEdit->showFilterIcon();
|
||||||
|
|
||||||
|
mActionSortByState = new QAction(tr("Sort by state"), this);
|
||||||
|
mActionSortByState->setCheckable(true);
|
||||||
|
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool)));
|
||||||
|
ui->peerTreeWidget->addHeaderContextMenuAction(mActionSortByState);
|
||||||
|
|
||||||
/* Set sort */
|
/* Set sort */
|
||||||
setSortMode(SORT_MODE_NAME);
|
sortByColumn(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
|
sortByState(false);
|
||||||
|
|
||||||
// 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
|
||||||
@ -191,7 +193,7 @@ void FriendList::addToolButton(QToolButton *toolButton)
|
|||||||
void FriendList::processSettings(bool load)
|
void FriendList::processSettings(bool load)
|
||||||
{
|
{
|
||||||
// state of peer tree
|
// state of peer tree
|
||||||
ui->peerTreeWidget->setSettingsVersion(1);
|
ui->peerTreeWidget->setSettingsVersion(2);
|
||||||
ui->peerTreeWidget->processSettings(load);
|
ui->peerTreeWidget->processSettings(load);
|
||||||
|
|
||||||
if (load) {
|
if (load) {
|
||||||
@ -206,7 +208,7 @@ void FriendList::processSettings(bool load)
|
|||||||
setShowGroups(Settings->value("showGroups", mShowGroups).toBool());
|
setShowGroups(Settings->value("showGroups", mShowGroups).toBool());
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
setSortMode((SortMode) Settings->value("sortMode", SORT_MODE_NAME).toInt());
|
sortByState(Settings->value("sortByState", isSortByState()).toBool());
|
||||||
|
|
||||||
// open groups
|
// open groups
|
||||||
int arrayIndex = Settings->beginReadArray("Groups");
|
int arrayIndex = Settings->beginReadArray("Groups");
|
||||||
@ -224,7 +226,7 @@ void FriendList::processSettings(bool load)
|
|||||||
Settings->setValue("showGroups", mShowGroups);
|
Settings->setValue("showGroups", mShowGroups);
|
||||||
|
|
||||||
// sort
|
// sort
|
||||||
Settings->setValue("sortMode", sortMode());
|
Settings->setValue("sortByState", isSortByState());
|
||||||
|
|
||||||
// open groups
|
// open groups
|
||||||
Settings->beginWriteArray("Groups");
|
Settings->beginWriteArray("Groups");
|
||||||
@ -687,9 +689,11 @@ void FriendList::insertPeers()
|
|||||||
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
|
groupItem->setData(COLUMN_DATA, ROLE_STANDARD, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? true : false);
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 1);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? 0 : 1);
|
groupItem->setData(i, ROLE_SORT_GROUP, 1);
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_STATE, 0);
|
groupItem->setData(i, ROLE_SORT_STANDARD_GROUP, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? 0 : 1);
|
||||||
|
groupItem->setData(i, ROLE_SORT_STATE, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// remove all gpg items that are not more assigned
|
// remove all gpg items that are not more assigned
|
||||||
int childCount = groupItem->childCount();
|
int childCount = groupItem->childCount();
|
||||||
@ -786,9 +790,10 @@ void FriendList::insertPeers()
|
|||||||
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 2);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
// show first the standard groups, than the user groups
|
gpgItem->setData(i, ROLE_SORT_GROUP, 2);
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, 1);
|
gpgItem->setData(i, ROLE_SORT_STANDARD_GROUP, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++availableCount;
|
++availableCount;
|
||||||
@ -860,8 +865,10 @@ void FriendList::insertPeers()
|
|||||||
gpgItem->addChild(sslItem);
|
gpgItem->addChild(sslItem);
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_GROUP, 2);
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP, 1);
|
sslItem->setData(i, ROLE_SORT_GROUP, 2);
|
||||||
|
sslItem->setData(i, ROLE_SORT_STANDARD_GROUP, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not displayed, used to find back the item */
|
/* not displayed, used to find back the item */
|
||||||
@ -879,6 +886,7 @@ void FriendList::insertPeers()
|
|||||||
/* last contact */
|
/* last contact */
|
||||||
QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect);
|
QDateTime sslLastContact = QDateTime::fromTime_t(sslDetail.lastConnect);
|
||||||
sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact));
|
sslItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, QVariant(sslLastContact));
|
||||||
|
sslItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, QVariant(sslLastContact));
|
||||||
if (sslLastContact > bestLastContact) {
|
if (sslLastContact > bestLastContact) {
|
||||||
bestLastContact = sslLastContact;
|
bestLastContact = sslLastContact;
|
||||||
}
|
}
|
||||||
@ -886,6 +894,7 @@ void FriendList::insertPeers()
|
|||||||
/* IP */
|
/* IP */
|
||||||
QString sslIP = (sslDetail.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(sslDetail) : QString("---");
|
QString sslIP = (sslDetail.state & RS_PEER_STATE_CONNECTED) ? StatusDefs::connectStateIpString(sslDetail) : QString("---");
|
||||||
sslItem->setText(COLUMN_IP, sslIP);
|
sslItem->setText(COLUMN_IP, sslIP);
|
||||||
|
sslItem->setData(COLUMN_IP, ROLE_SORT_NAME, sslIP);
|
||||||
|
|
||||||
/* change color and icon */
|
/* change color and icon */
|
||||||
QPixmap sslOverlayIcon;
|
QPixmap sslOverlayIcon;
|
||||||
@ -1044,10 +1053,11 @@ void FriendList::insertPeers()
|
|||||||
sslItem->setIcon(COLUMN_NAME, createAvatar(sslAvatar, sslOverlayIcon));
|
sslItem->setIcon(COLUMN_NAME, createAvatar(sslAvatar, sslOverlayIcon));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_NAME, sslName);
|
sslItem->setData(COLUMN_NAME, ROLE_SORT_NAME, sslName);
|
||||||
sslItem->setData(COLUMN_SORT, ROLE_SORT_STATE, peerState);
|
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
sslItem->setData(i, ROLE_SORT_STATE, peerState);
|
||||||
|
|
||||||
sslItem->setTextColor(i, sslColor);
|
sslItem->setTextColor(i, sslColor);
|
||||||
sslItem->setFont(i, sslFont);
|
sslItem->setFont(i, sslFont);
|
||||||
}
|
}
|
||||||
@ -1147,13 +1157,16 @@ void FriendList::insertPeers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
gpgItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
gpgItem->setData(COLUMN_LAST_CONTACT, Qt::DisplayRole, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
||||||
|
gpgItem->setData(COLUMN_LAST_CONTACT, ROLE_SORT_NAME, showInfoAtGpgItem ? QVariant(bestLastContact) : "");
|
||||||
gpgItem->setText(COLUMN_IP, showInfoAtGpgItem ? bestIP : "");
|
gpgItem->setText(COLUMN_IP, showInfoAtGpgItem ? bestIP : "");
|
||||||
|
gpgItem->setData(COLUMN_IP, ROLE_SORT_NAME, showInfoAtGpgItem ? bestIP : "");
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_NAME, gpgName);
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, gpgName);
|
||||||
gpgItem->setData(COLUMN_SORT, ROLE_SORT_STATE, bestPeerState);
|
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; ++i) {
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
gpgItem->setData(i, ROLE_SORT_STATE, bestPeerState);
|
||||||
|
|
||||||
gpgItem->setTextColor(i, gpgColor);
|
gpgItem->setTextColor(i, gpgColor);
|
||||||
gpgItem->setFont(i, gpgFont);
|
gpgItem->setFont(i, gpgFont);
|
||||||
}
|
}
|
||||||
@ -1173,7 +1186,7 @@ void FriendList::insertPeers()
|
|||||||
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount));
|
groupItem->setText(COLUMN_NAME, QString("%1 (%2/%3)").arg(groupName).arg(onlineCount).arg(availableCount));
|
||||||
|
|
||||||
/* Sort data */
|
/* Sort data */
|
||||||
groupItem->setData(COLUMN_SORT, ROLE_SORT_NAME, groupName);
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_NAME, groupName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1199,7 +1212,7 @@ void FriendList::insertPeers()
|
|||||||
openPeers = NULL;
|
openPeers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->peerTreeWidget->sortItems(COLUMN_SORT, Qt::AscendingOrder);
|
ui->peerTreeWidget->resort();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1745,6 +1758,11 @@ void FriendList::setColumnVisible(Column column, bool visible)
|
|||||||
peerTreeColumnVisibleChanged(column, visible);
|
peerTreeColumnVisibleChanged(column, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendList::sortByColumn(Column column, Qt::SortOrder sortOrder)
|
||||||
|
{
|
||||||
|
ui->peerTreeWidget->sortByColumn(column, sortOrder);
|
||||||
|
}
|
||||||
|
|
||||||
void FriendList::peerTreeColumnVisibleChanged(int /*column*/, bool visible)
|
void FriendList::peerTreeColumnVisibleChanged(int /*column*/, bool visible)
|
||||||
{
|
{
|
||||||
if (visible) {
|
if (visible) {
|
||||||
@ -1771,49 +1789,30 @@ void FriendList::setShowState(bool show)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendList::setSortByName()
|
void FriendList::sortByState(bool sort)
|
||||||
{
|
{
|
||||||
setSortMode(SORT_MODE_NAME);
|
int columnCount = ui->peerTreeWidget->columnCount();
|
||||||
}
|
for (int i = 0; i < columnCount; ++i) {
|
||||||
|
mCompareRole->setRole(i, ROLE_SORT_GROUP);
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_STANDARD_GROUP);
|
||||||
|
|
||||||
void FriendList::setSortByState()
|
if (sort) {
|
||||||
{
|
mCompareRole->addRole(i, ROLE_SORT_STATE);
|
||||||
setSortMode(SORT_MODE_STATE);
|
mCompareRole->addRole(i, ROLE_SORT_NAME);
|
||||||
}
|
} else {
|
||||||
|
mCompareRole->addRole(i, ROLE_SORT_NAME);
|
||||||
void FriendList::setSortMode(SortMode sortMode)
|
mCompareRole->addRole(i, ROLE_SORT_STATE);
|
||||||
{
|
|
||||||
// Add changes also in FriendList::sortMode
|
|
||||||
mCompareRole->setRole(COLUMN_SORT, ROLE_SORT_GROUP);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STANDARD_GROUP);
|
|
||||||
|
|
||||||
switch (sortMode) {
|
|
||||||
case SORT_MODE_STATE:
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STATE);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_NAME);
|
|
||||||
break;
|
|
||||||
default: // SORT_MODE_NAME
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_NAME);
|
|
||||||
mCompareRole->addRole(COLUMN_SORT, ROLE_SORT_STATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->peerTreeWidget->sortItems(COLUMN_SORT, Qt::AscendingOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
FriendList::SortMode FriendList::sortMode()
|
|
||||||
{
|
|
||||||
QList<int> roles;
|
|
||||||
mCompareRole->findRoles(COLUMN_SORT, roles);
|
|
||||||
if (roles.count() == 4) {
|
|
||||||
switch (roles.at(2)) {
|
|
||||||
case ROLE_SORT_NAME:
|
|
||||||
return SORT_MODE_NAME;
|
|
||||||
case ROLE_SORT_STATE:
|
|
||||||
return SORT_MODE_STATE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SORT_MODE_NAME;
|
mActionSortByState->setChecked(sort);
|
||||||
|
|
||||||
|
ui->peerTreeWidget->resort();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FriendList::isSortByState()
|
||||||
|
{
|
||||||
|
return mActionSortByState->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendList::setShowGroups(bool show)
|
void FriendList::setShowGroups(bool show)
|
||||||
@ -1876,14 +1875,6 @@ void FriendList::createDisplayMenu()
|
|||||||
QMenu *displayMenu = new QMenu(this);
|
QMenu *displayMenu = new QMenu(this);
|
||||||
connect(displayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
connect(displayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||||
|
|
||||||
QActionGroup *actionGroup = new QActionGroup(displayMenu);
|
|
||||||
|
|
||||||
QMenu *menu = displayMenu->addMenu(tr("Sort by"));
|
|
||||||
menu->addAction(ui->actionSortByName);
|
|
||||||
ui->actionSortByName->setActionGroup(actionGroup);
|
|
||||||
menu->addAction(ui->actionSortByState);
|
|
||||||
ui->actionSortByState->setActionGroup(actionGroup);
|
|
||||||
|
|
||||||
displayMenu->addAction(ui->actionHideOfflineFriends);
|
displayMenu->addAction(ui->actionHideOfflineFriends);
|
||||||
displayMenu->addAction(ui->actionShowState);
|
displayMenu->addAction(ui->actionShowState);
|
||||||
displayMenu->addAction(ui->actionShowGroups);
|
displayMenu->addAction(ui->actionShowGroups);
|
||||||
@ -1896,14 +1887,4 @@ void FriendList::updateMenu()
|
|||||||
ui->actionHideOfflineFriends->setChecked(mHideUnconnected);
|
ui->actionHideOfflineFriends->setChecked(mHideUnconnected);
|
||||||
ui->actionShowState->setChecked(mShowState);
|
ui->actionShowState->setChecked(mShowState);
|
||||||
ui->actionShowGroups->setChecked(mShowGroups);
|
ui->actionShowGroups->setChecked(mShowGroups);
|
||||||
ui->actionSortByName->setChecked(true);
|
|
||||||
|
|
||||||
switch (sortMode()) {
|
|
||||||
case SORT_MODE_NAME:
|
|
||||||
ui->actionSortByName->setChecked(true);
|
|
||||||
break;
|
|
||||||
case SORT_MODE_STATE:
|
|
||||||
ui->actionSortByState->setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,6 @@ public:
|
|||||||
COLUMN_IP = 2
|
COLUMN_IP = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SortMode
|
|
||||||
{
|
|
||||||
SORT_MODE_NAME = 1,
|
|
||||||
SORT_MODE_STATE = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FriendList(QWidget *parent = 0);
|
explicit FriendList(QWidget *parent = 0);
|
||||||
~FriendList();
|
~FriendList();
|
||||||
@ -79,8 +73,8 @@ public:
|
|||||||
virtual void updateDisplay();
|
virtual void updateDisplay();
|
||||||
void setColumnVisible(Column column, bool visible);
|
void setColumnVisible(Column column, bool visible);
|
||||||
|
|
||||||
void setSortMode(SortMode sortMode);
|
void sortByColumn(Column column, Qt::SortOrder sortOrder);
|
||||||
SortMode sortMode();
|
bool isSortByState();
|
||||||
|
|
||||||
QColor textColorGroup() const { return mTextColorGroup; }
|
QColor textColorGroup() const { return mTextColorGroup; }
|
||||||
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
|
QColor textColorStatusOffline() const { return mTextColorStatus[RS_STATUS_OFFLINE]; }
|
||||||
@ -98,8 +92,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void filterItems(const QString &text);
|
void filterItems(const QString &text);
|
||||||
void setSortByName();
|
void sortByState(bool sort);
|
||||||
void setSortByState();
|
|
||||||
|
|
||||||
void setShowGroups(bool show);
|
void setShowGroups(bool show);
|
||||||
void setHideUnconnected(bool hidden);
|
void setHideUnconnected(bool hidden);
|
||||||
@ -116,6 +109,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Ui::FriendList *ui;
|
Ui::FriendList *ui;
|
||||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||||
|
QAction *mActionSortByState;
|
||||||
|
|
||||||
// Settings for peer list display
|
// Settings for peer list display
|
||||||
bool mShowGroups;
|
bool mShowGroups;
|
||||||
|
@ -75,6 +75,9 @@
|
|||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="allColumnsShowFocus">
|
<property name="allColumnsShowFocus">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -116,28 +119,6 @@
|
|||||||
<string>Hide Offline Friends</string>
|
<string>Hide Offline Friends</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSortByName">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Sort by Name</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSortByState">
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>State</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Sort by State</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionShowState">
|
<action name="actionShowState">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QMenu>
|
||||||
#include "FriendSelectionWidget.h"
|
#include "FriendSelectionWidget.h"
|
||||||
#include "ui_FriendSelectionWidget.h"
|
#include "ui_FriendSelectionWidget.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
@ -44,8 +45,11 @@
|
|||||||
|
|
||||||
#define IDDIALOG_IDLIST 1
|
#define IDDIALOG_IDLIST 1
|
||||||
|
|
||||||
#define ROLE_ID Qt::UserRole
|
#define ROLE_ID Qt::UserRole
|
||||||
#define ROLE_SORT Qt::UserRole + 1
|
#define ROLE_SORT_GROUP Qt::UserRole + 1
|
||||||
|
#define ROLE_SORT_STANDARD_GROUP Qt::UserRole + 2
|
||||||
|
#define ROLE_SORT_NAME Qt::UserRole + 3
|
||||||
|
#define ROLE_SORT_STATE Qt::UserRole + 4
|
||||||
|
|
||||||
#define IMAGE_GROUP16 ":/images/user/group16.png"
|
#define IMAGE_GROUP16 ":/images/user/group16.png"
|
||||||
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
|
#define IMAGE_FRIENDINFO ":/images/peerdetails_16x16.png"
|
||||||
@ -94,15 +98,17 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
|||||||
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
connect(ui->friendList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));
|
||||||
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
connect(ui->friendList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||||
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
connect(ui->friendList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(itemChanged(QTreeWidgetItem*,int)));
|
||||||
connect(ui->selectAll_PB, SIGNAL(clicked()), this, SLOT(selectAll()));
|
connect(ui->friendList, SIGNAL(itemSelectionChanged()), this, SIGNAL(itemSelectionChanged()));
|
||||||
connect(ui->deselectAll_PB, SIGNAL(clicked()), this, SLOT(deselectAll()));
|
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int)));
|
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged(int)));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
||||||
|
|
||||||
mCompareRole = new RSTreeWidgetItemCompareRole;
|
mCompareRole = new RSTreeWidgetItemCompareRole;
|
||||||
mCompareRole->setRole(COLUMN_NAME, ROLE_SORT);
|
mActionSortByState = new QAction(tr("Sort by state"), this);
|
||||||
|
mActionSortByState->setCheckable(true);
|
||||||
|
connect(mActionSortByState, SIGNAL(toggled(bool)), this, SLOT(sortByState(bool)));
|
||||||
|
ui->friendList->addHeaderContextMenuAction(mActionSortByState);
|
||||||
|
|
||||||
/* initialize list */
|
/* initialize list */
|
||||||
ui->friendList->setColumnCount(COLUMN_COUNT);
|
ui->friendList->setColumnCount(COLUMN_COUNT);
|
||||||
@ -110,6 +116,7 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
|
|||||||
|
|
||||||
/* sort list by name ascending */
|
/* sort list by name ascending */
|
||||||
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
ui->friendList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
|
sortByState(false);
|
||||||
|
|
||||||
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
ui->filterLineEdit->setPlaceholderText(tr("Search Friends"));
|
||||||
ui->filterLineEdit->showFilterIcon();
|
ui->filterLineEdit->showFilterIcon();
|
||||||
@ -156,17 +163,6 @@ void FriendSelectionWidget::setModus(Modus modus)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modus == MODUS_CHECK)
|
|
||||||
{
|
|
||||||
ui->selectAll_PB->setHidden(false) ;
|
|
||||||
ui->deselectAll_PB->setHidden(false) ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->selectAll_PB->setHidden(true) ;
|
|
||||||
ui->deselectAll_PB->setHidden(true) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
fillList();
|
fillList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +212,12 @@ static void initSslItem(QTreeWidgetItem *item, const RsPeerDetails &detail, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||||
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString()));
|
item->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.id.toStdString()));
|
||||||
item->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_STATE, (state != (int) RS_STATUS_OFFLINE) ? 0 : 1);
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::fillList()
|
void FriendSelectionWidget::fillList()
|
||||||
@ -349,7 +349,11 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
|
|
||||||
QString groupName = GroupDefs::name(*groupInfo);
|
QString groupName = GroupDefs::name(*groupInfo);
|
||||||
groupItem->setText(COLUMN_NAME, groupName);
|
groupItem->setText(COLUMN_NAME, groupName);
|
||||||
groupItem->setData(COLUMN_DATA, ROLE_SORT, ((groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? "0 " : "1 ") + groupName);
|
|
||||||
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 0);
|
||||||
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, (groupInfo->flag & RS_GROUP_FLAG_STANDARD) ? 0 : 1);
|
||||||
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_STATE, 0);
|
||||||
|
groupItem->setData(COLUMN_NAME, ROLE_SORT_NAME, groupName);
|
||||||
|
|
||||||
if (mListModus == MODUS_CHECK) {
|
if (mListModus == MODUS_CHECK) {
|
||||||
groupItem->setCheckState(0, Qt::Unchecked);
|
groupItem->setCheckState(0, Qt::Unchecked);
|
||||||
@ -411,8 +415,12 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
|
|
||||||
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
gpgItem->setFlags(Qt::ItemIsUserCheckable | gpgItem->flags());
|
||||||
gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
gpgItem->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(state)));
|
||||||
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
gpgItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.gpg_id.toStdString()));
|
||||||
gpgItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
|
||||||
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
|
||||||
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
|
||||||
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_STATE, (state != (int) RS_STATUS_OFFLINE) ? 0 : 1);
|
||||||
|
gpgItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
|
||||||
|
|
||||||
if (mListModus == MODUS_CHECK) {
|
if (mListModus == MODUS_CHECK) {
|
||||||
gpgItem->setCheckState(0, Qt::Unchecked);
|
gpgItem->setCheckState(0, Qt::Unchecked);
|
||||||
@ -542,7 +550,12 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
|
||||||
gxsItem->setIcon(COLUMN_NAME, identicon);
|
gxsItem->setIcon(COLUMN_NAME, identicon);
|
||||||
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
|
||||||
gxsItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);
|
|
||||||
|
gxsItem->setData(COLUMN_NAME, ROLE_SORT_GROUP, 1);
|
||||||
|
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP, 0);
|
||||||
|
//TODO: online state for gxs items
|
||||||
|
gxsItem->setData(COLUMN_NAME, ROLE_SORT_STATE, 1);
|
||||||
|
gxsItem->setData(COLUMN_NAME, ROLE_SORT_NAME, name);
|
||||||
|
|
||||||
if (mListModus == MODUS_CHECK)
|
if (mListModus == MODUS_CHECK)
|
||||||
gxsItem->setCheckState(0, Qt::Unchecked);
|
gxsItem->setCheckState(0, Qt::Unchecked);
|
||||||
@ -573,6 +586,8 @@ void FriendSelectionWidget::secured_fillList()
|
|||||||
|
|
||||||
mInFillList = false;
|
mInFillList = false;
|
||||||
|
|
||||||
|
ui->friendList->resort();
|
||||||
|
|
||||||
emit contentChanged();
|
emit contentChanged();
|
||||||
}
|
}
|
||||||
void FriendSelectionWidget::updateDisplay(bool)
|
void FriendSelectionWidget::updateDisplay(bool)
|
||||||
@ -658,6 +673,7 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
switch (idTypeFromItem(item)) {
|
switch (idTypeFromItem(item)) {
|
||||||
case IDTYPE_NONE:
|
case IDTYPE_NONE:
|
||||||
case IDTYPE_GROUP:
|
case IDTYPE_GROUP:
|
||||||
|
case IDTYPE_GXS:
|
||||||
break;
|
break;
|
||||||
case IDTYPE_GPG:
|
case IDTYPE_GPG:
|
||||||
{
|
{
|
||||||
@ -672,6 +688,8 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
item->setTextColor(COLUMN_NAME, color);
|
item->setTextColor(COLUMN_NAME, color);
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(gpgStatus)));
|
||||||
|
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_STATE, (gpgStatus != (int) RS_STATUS_OFFLINE) ? 0 : 1);
|
||||||
|
|
||||||
bFoundGPG = true;
|
bFoundGPG = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,6 +707,8 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
item->setTextColor(COLUMN_NAME, color);
|
item->setTextColor(COLUMN_NAME, color);
|
||||||
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
item->setIcon(COLUMN_NAME, QIcon(StatusDefs::imageUser(status)));
|
||||||
|
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT_STATE, (status != (int) RS_STATUS_OFFLINE) ? 0 : 1);
|
||||||
|
|
||||||
bFoundSSL = true;
|
bFoundSSL = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -714,11 +734,48 @@ void FriendSelectionWidget::peerStatusChanged(const QString& peerId, int status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->friendList->resort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::contextMenuRequested(const QPoint &pos)
|
void FriendSelectionWidget::addContextMenuAction(QAction *action)
|
||||||
{
|
{
|
||||||
emit customContextMenuRequested(pos);
|
mContextMenuActions.push_back(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FriendSelectionWidget::contextMenuRequested(const QPoint &/*pos*/)
|
||||||
|
{
|
||||||
|
QMenu contextMenu(this);
|
||||||
|
|
||||||
|
if (mListModus == MODUS_CHECK) {
|
||||||
|
contextMenu.addAction(QIcon(), tr("Mark all"), this, SLOT(selectAll()));
|
||||||
|
contextMenu.addAction(QIcon(), tr("Mark none"), this, SLOT(deselectAll()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mContextMenuActions.isEmpty()) {
|
||||||
|
bool addSeparator = false;
|
||||||
|
if (!contextMenu.isEmpty()) {
|
||||||
|
// Check for visible action
|
||||||
|
foreach (QAction *action, mContextMenuActions) {
|
||||||
|
if (action->isVisible()) {
|
||||||
|
addSeparator = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addSeparator) {
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu.addActions(mContextMenuActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contextMenu.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendSelectionWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
void FriendSelectionWidget::itemDoubleClicked(QTreeWidgetItem *item, int /*column*/)
|
||||||
@ -1030,3 +1087,25 @@ std::string FriendSelectionWidget::idFromItem(QTreeWidgetItem *item)
|
|||||||
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
return item->data(COLUMN_DATA, ROLE_ID).toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendSelectionWidget::sortByState(bool sort)
|
||||||
|
{
|
||||||
|
mCompareRole->setRole(COLUMN_NAME, ROLE_SORT_GROUP);
|
||||||
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STANDARD_GROUP);
|
||||||
|
|
||||||
|
if (sort) {
|
||||||
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
||||||
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
||||||
|
} else {
|
||||||
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_NAME);
|
||||||
|
mCompareRole->addRole(COLUMN_NAME, ROLE_SORT_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
mActionSortByState->setChecked(sort);
|
||||||
|
|
||||||
|
ui->friendList->resort();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FriendSelectionWidget::isSortByState()
|
||||||
|
{
|
||||||
|
return mActionSortByState->isChecked();
|
||||||
|
}
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
int addColumn(const QString &title);
|
int addColumn(const QString &title);
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
bool isSortByState();
|
||||||
|
|
||||||
int selectedItemCount();
|
int selectedItemCount();
|
||||||
std::string selectedId(IdType &idType);
|
std::string selectedId(IdType &idType);
|
||||||
|
|
||||||
@ -109,6 +111,9 @@ public:
|
|||||||
|
|
||||||
void setTextColorOnline(QColor color) { mTextColorOnline = color; }
|
void setTextColorOnline(QColor color) { mTextColorOnline = color; }
|
||||||
|
|
||||||
|
// Add QAction to context menu (action won't be deleted)
|
||||||
|
void addContextMenuAction(QAction *action);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
@ -118,9 +123,12 @@ protected:
|
|||||||
signals:
|
signals:
|
||||||
void itemAdded(int idType, const QString &id, QTreeWidgetItem *item);
|
void itemAdded(int idType, const QString &id, QTreeWidgetItem *item);
|
||||||
void contentChanged();
|
void contentChanged();
|
||||||
void customContextMenuRequested(const QPoint &pos);
|
|
||||||
void doubleClicked(int idType, const QString &id);
|
void doubleClicked(int idType, const QString &id);
|
||||||
void itemChanged(int idType, const QString &id, QTreeWidgetItem *item, int column);
|
void itemChanged(int idType, const QString &id, QTreeWidgetItem *item, int column);
|
||||||
|
void itemSelectionChanged();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void sortByState(bool sort);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void groupsChanged(int type);
|
void groupsChanged(int type);
|
||||||
@ -142,6 +150,7 @@ private:
|
|||||||
|
|
||||||
void requestGXSIdList() ;
|
void requestGXSIdList() ;
|
||||||
|
|
||||||
|
private:
|
||||||
bool mStarted;
|
bool mStarted;
|
||||||
RSTreeWidgetItemCompareRole *mCompareRole;
|
RSTreeWidgetItemCompareRole *mCompareRole;
|
||||||
Modus mListModus;
|
Modus mListModus;
|
||||||
@ -150,6 +159,7 @@ private:
|
|||||||
bool mInGpgItemChanged;
|
bool mInGpgItemChanged;
|
||||||
bool mInSslItemChanged;
|
bool mInSslItemChanged;
|
||||||
bool mInFillList;
|
bool mInFillList;
|
||||||
|
QAction *mActionSortByState;
|
||||||
|
|
||||||
/* Color definitions (for standard see qss.default) */
|
/* Color definitions (for standard see qss.default) */
|
||||||
QColor mTextColorOnline;
|
QColor mTextColorOnline;
|
||||||
@ -160,6 +170,7 @@ private:
|
|||||||
|
|
||||||
std::vector<RsGxsGroupId> gxsIds ;
|
std::vector<RsGxsGroupId> gxsIds ;
|
||||||
TokenQueue *mIdQueue ;
|
TokenQueue *mIdQueue ;
|
||||||
|
QList<QAction*> mContextMenuActions;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)
|
||||||
|
@ -26,24 +26,10 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="LineEditClear" name="filterLineEdit"/>
|
<widget class="LineEditClear" name="filterLineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="selectAll_PB">
|
|
||||||
<property name="text">
|
|
||||||
<string>All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="deselectAll_PB">
|
|
||||||
<property name="text">
|
|
||||||
<string>None</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="friendList">
|
<widget class="RSTreeWidget" name="friendList">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>20</width>
|
||||||
@ -80,6 +66,11 @@
|
|||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
<header location="global">gui/common/LineEditClear.h</header>
|
<header location="global">gui/common/LineEditClear.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>RSTreeWidget</class>
|
||||||
|
<extends>QTreeWidget</extends>
|
||||||
|
<header>gui/common/RSTreeWidget.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -31,6 +31,10 @@ RSTreeWidget::RSTreeWidget(QWidget *parent) : QTreeWidget(parent)
|
|||||||
{
|
{
|
||||||
mEnableColumnCustomize = false;
|
mEnableColumnCustomize = false;
|
||||||
mSettingsVersion = 0; // disabled
|
mSettingsVersion = 0; // disabled
|
||||||
|
|
||||||
|
QHeaderView *h = header();
|
||||||
|
h->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSTreeWidget::setPlaceholderText(const QString &text)
|
void RSTreeWidget::setPlaceholderText(const QString &text)
|
||||||
@ -153,16 +157,6 @@ void RSTreeWidget::enableColumnCustomize(bool customizable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mEnableColumnCustomize = customizable;
|
mEnableColumnCustomize = customizable;
|
||||||
|
|
||||||
QHeaderView *h = header();
|
|
||||||
|
|
||||||
if (mEnableColumnCustomize) {
|
|
||||||
h->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
|
|
||||||
} else {
|
|
||||||
h->setContextMenuPolicy(Qt::DefaultContextMenu);
|
|
||||||
disconnect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSTreeWidget::setColumnCustomizable(int column, bool customizable)
|
void RSTreeWidget::setColumnCustomizable(int column, bool customizable)
|
||||||
@ -170,25 +164,51 @@ void RSTreeWidget::setColumnCustomizable(int column, bool customizable)
|
|||||||
mColumnCustomizable[column] = customizable;
|
mColumnCustomizable[column] = customizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSTreeWidget::addHeaderContextMenuAction(QAction *action)
|
||||||
|
{
|
||||||
|
mHeaderContextMenuActions.push_back(action);
|
||||||
|
}
|
||||||
|
|
||||||
void RSTreeWidget::headerContextMenuRequested(const QPoint &pos)
|
void RSTreeWidget::headerContextMenuRequested(const QPoint &pos)
|
||||||
{
|
{
|
||||||
if (!mEnableColumnCustomize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenu contextMenu(this);
|
QMenu contextMenu(this);
|
||||||
|
|
||||||
QTreeWidgetItem *item = headerItem();
|
if (mEnableColumnCustomize) {
|
||||||
int columnCount = item->columnCount();
|
QTreeWidgetItem *item = headerItem();
|
||||||
for (int column = 0; column < columnCount; ++column) {
|
int columnCount = item->columnCount();
|
||||||
QMap<int, bool>::const_iterator it = mColumnCustomizable.find(column);
|
for (int column = 0; column < columnCount; ++column) {
|
||||||
if (it != mColumnCustomizable.end() && *it == false) {
|
QMap<int, bool>::const_iterator it = mColumnCustomizable.find(column);
|
||||||
continue;
|
if (it != mColumnCustomizable.end() && *it == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QAction *action = contextMenu.addAction(QIcon(), item->text(column), this, SLOT(columnVisible()));
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setData(column);
|
||||||
|
action->setChecked(!isColumnHidden(column));
|
||||||
}
|
}
|
||||||
QAction *action = contextMenu.addAction(QIcon(), item->text(column), this, SLOT(columnVisible()));
|
}
|
||||||
action->setCheckable(true);
|
|
||||||
action->setData(column);
|
if (!mHeaderContextMenuActions.isEmpty()) {
|
||||||
action->setChecked(!isColumnHidden(column));
|
bool addSeparator = false;
|
||||||
|
if (!contextMenu.isEmpty()) {
|
||||||
|
// Check for visible action
|
||||||
|
foreach (QAction *action, mHeaderContextMenuActions) {
|
||||||
|
if (action->isVisible()) {
|
||||||
|
addSeparator = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addSeparator) {
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu.addActions(mHeaderContextMenuActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contextMenu.isEmpty()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
contextMenu.exec(mapToGlobal(pos));
|
contextMenu.exec(mapToGlobal(pos));
|
||||||
@ -207,3 +227,10 @@ void RSTreeWidget::columnVisible()
|
|||||||
|
|
||||||
emit columnVisibleChanged(column, visible);
|
emit columnVisibleChanged(column, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSTreeWidget::resort()
|
||||||
|
{
|
||||||
|
if (isSortingEnabled()) {
|
||||||
|
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -43,6 +43,11 @@ public:
|
|||||||
void enableColumnCustomize(bool customizable);
|
void enableColumnCustomize(bool customizable);
|
||||||
void setColumnCustomizable(int column, bool customizable);
|
void setColumnCustomizable(int column, bool customizable);
|
||||||
|
|
||||||
|
void resort();
|
||||||
|
|
||||||
|
// Add QAction to context menu (action won't be deleted)
|
||||||
|
void addHeaderContextMenuAction(QAction *action);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalMouseMiddleButtonClicked(QTreeWidgetItem *item);
|
void signalMouseMiddleButtonClicked(QTreeWidgetItem *item);
|
||||||
void columnVisibleChanged(int column, bool visible);
|
void columnVisibleChanged(int column, bool visible);
|
||||||
@ -63,6 +68,7 @@ private:
|
|||||||
bool mEnableColumnCustomize;
|
bool mEnableColumnCustomize;
|
||||||
quint32 mSettingsVersion;
|
quint32 mSettingsVersion;
|
||||||
QMap<int, bool> mColumnCustomizable;
|
QMap<int, bool> mColumnCustomizable;
|
||||||
|
QList<QAction*> mHeaderContextMenuActions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -128,6 +128,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
|||||||
setupEditActions();
|
setupEditActions();
|
||||||
setupViewActions();
|
setupViewActions();
|
||||||
setupInsertActions();
|
setupInsertActions();
|
||||||
|
setupContactActions();
|
||||||
|
|
||||||
m_compareRole = new RSTreeWidgetItemCompareRole;
|
m_compareRole = new RSTreeWidgetItemCompareRole;
|
||||||
m_compareRole->setRole(COLUMN_CONTACT_NAME, ROLE_CONTACT_SORT);
|
m_compareRole->setRole(COLUMN_CONTACT_NAME, ROLE_CONTACT_SORT);
|
||||||
@ -210,8 +211,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
|
|||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&,int)), this, SLOT(peerStatusChanged(const QString&,int)));
|
||||||
connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter()));
|
connect(ui.friendSelectionWidget, SIGNAL(contentChanged()), this, SLOT(buildCompleter()));
|
||||||
connect(ui.friendSelectionWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuMsgSendList(QPoint)));
|
|
||||||
connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo()));
|
connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo()));
|
||||||
|
connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged()));
|
||||||
|
|
||||||
/* hide the Tree +/- */
|
/* hide the Tree +/- */
|
||||||
ui.msgFileList -> setRootIsDecorated( false );
|
ui.msgFileList -> setRootIsDecorated( false );
|
||||||
@ -698,35 +699,6 @@ void MessageComposer::contextMenuFileList(QPoint)
|
|||||||
contextMnu.exec(QCursor::pos());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageComposer::contextMenuMsgSendList(QPoint)
|
|
||||||
{
|
|
||||||
QMenu contextMnu(this);
|
|
||||||
|
|
||||||
int selectedCount = ui.friendSelectionWidget->selectedItemCount();
|
|
||||||
|
|
||||||
FriendSelectionWidget::IdType idType;
|
|
||||||
ui.friendSelectionWidget->selectedId(idType);
|
|
||||||
|
|
||||||
QAction *action = contextMnu.addAction(QIcon(), tr("Add to \"To\""), this, SLOT(addTo()));
|
|
||||||
action->setEnabled(selectedCount);
|
|
||||||
action = contextMnu.addAction(QIcon(), tr("Add to \"CC\""), this, SLOT(addCc()));
|
|
||||||
action->setEnabled(selectedCount);
|
|
||||||
action = contextMnu.addAction(QIcon(), tr("Add to \"BCC\""), this, SLOT(addBcc()));
|
|
||||||
action->setEnabled(selectedCount);
|
|
||||||
action = contextMnu.addAction(QIcon(), tr("Add as Recommend"), this, SLOT(addRecommend()));
|
|
||||||
action->setEnabled(selectedCount);
|
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
|
||||||
|
|
||||||
action = contextMnu.addAction(QIcon(IMAGE_FRIENDINFO), tr("Friend Details"), this, SLOT(friendDetails()));
|
|
||||||
action->setEnabled(selectedCount == 1 && idType == FriendSelectionWidget::IDTYPE_SSL);
|
|
||||||
|
|
||||||
action = contextMnu.addAction(QIcon(), tr("Person Details"), this, SLOT(identityDetails()));
|
|
||||||
action->setEnabled(selectedCount == 1 && idType == FriendSelectionWidget::IDTYPE_GXS);
|
|
||||||
|
|
||||||
contextMnu.exec(QCursor::pos());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessageComposer::pasteRecommended()
|
void MessageComposer::pasteRecommended()
|
||||||
{
|
{
|
||||||
QList<RetroShareLink> links;
|
QList<RetroShareLink> links;
|
||||||
@ -2009,6 +1981,31 @@ void MessageComposer::setupFormatActions()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageComposer::setupContactActions()
|
||||||
|
{
|
||||||
|
mActionAddTo = new QAction(tr("Add to \"To\""), this);
|
||||||
|
connect(mActionAddTo, SIGNAL(triggered(bool)), this, SLOT(addTo()));
|
||||||
|
mActionAddCC = new QAction(tr("Add to \"CC\""), this);
|
||||||
|
connect(mActionAddCC, SIGNAL(triggered(bool)), this, SLOT(addCc()));
|
||||||
|
mActionAddBCC = new QAction(tr("Add to \"BCC\""), this);
|
||||||
|
connect(mActionAddBCC, SIGNAL(triggered(bool)), this, SLOT(addBcc()));
|
||||||
|
mActionAddRecommend = new QAction(tr("Add as Recommend"), this);
|
||||||
|
connect(mActionAddRecommend, SIGNAL(triggered(bool)), this, SLOT(addRecommend()));
|
||||||
|
mActionContactDetails = new QAction(QIcon(IMAGE_FRIENDINFO), tr("Details"), this);
|
||||||
|
connect(mActionContactDetails, SIGNAL(triggered(bool)), this, SLOT(contactDetails()));
|
||||||
|
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(mActionAddTo);
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(mActionAddCC);
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(mActionAddBCC);
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(mActionAddRecommend);
|
||||||
|
|
||||||
|
QAction *action = new QAction(this);
|
||||||
|
action->setSeparator(true);
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(action);
|
||||||
|
|
||||||
|
ui.friendSelectionWidget->addContextMenuAction(mActionContactDetails);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageComposer::textBold()
|
void MessageComposer::textBold()
|
||||||
{
|
{
|
||||||
QTextCharFormat fmt;
|
QTextCharFormat fmt;
|
||||||
@ -2577,6 +2574,27 @@ void MessageComposer::filterComboBoxChanged(int i)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageComposer::friendSelectionChanged()
|
||||||
|
{
|
||||||
|
std::set<RsPeerId> peerIds;
|
||||||
|
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(peerIds, false);
|
||||||
|
|
||||||
|
std::set<RsGxsId> gxsIds;
|
||||||
|
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(gxsIds, false);
|
||||||
|
|
||||||
|
int selectedCount = peerIds.size() + gxsIds.size();
|
||||||
|
|
||||||
|
mActionAddTo->setEnabled(selectedCount);
|
||||||
|
mActionAddCC->setEnabled(selectedCount);
|
||||||
|
mActionAddBCC->setEnabled(selectedCount);
|
||||||
|
mActionAddRecommend->setEnabled(selectedCount);
|
||||||
|
|
||||||
|
FriendSelectionWidget::IdType idType;
|
||||||
|
ui.friendSelectionWidget->selectedId(idType);
|
||||||
|
|
||||||
|
mActionContactDetails->setEnabled(selectedCount == 1 && (idType == FriendSelectionWidget::IDTYPE_SSL || idType == FriendSelectionWidget::IDTYPE_GXS));
|
||||||
|
}
|
||||||
|
|
||||||
void MessageComposer::addTo()
|
void MessageComposer::addTo()
|
||||||
{
|
{
|
||||||
addContact(TO);
|
addContact(TO);
|
||||||
@ -2613,35 +2631,37 @@ void MessageComposer::addRecommend()
|
|||||||
ui.msgText->setFocus(Qt::OtherFocusReason);
|
ui.msgText->setFocus(Qt::OtherFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageComposer::friendDetails()
|
void MessageComposer::contactDetails()
|
||||||
{
|
{
|
||||||
FriendSelectionWidget::IdType idType;
|
FriendSelectionWidget::IdType idType;
|
||||||
std::string id = ui.friendSelectionWidget->selectedId(idType);
|
std::string id = ui.friendSelectionWidget->selectedId(idType);
|
||||||
|
|
||||||
if (id.empty() || idType != FriendSelectionWidget::IDTYPE_SSL) {
|
if (id.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfCertDialog::showIt(RsPeerId(id), ConfCertDialog::PageDetails);
|
switch (idType) {
|
||||||
}
|
case FriendSelectionWidget::IDTYPE_NONE:
|
||||||
|
case FriendSelectionWidget::IDTYPE_GROUP:
|
||||||
|
case FriendSelectionWidget::IDTYPE_GPG:
|
||||||
|
break;
|
||||||
|
case FriendSelectionWidget::IDTYPE_SSL:
|
||||||
|
ConfCertDialog::showIt(RsPeerId(id), ConfCertDialog::PageDetails);
|
||||||
|
break;
|
||||||
|
case FriendSelectionWidget::IDTYPE_GXS:
|
||||||
|
{
|
||||||
|
if (RsGxsGroupId(id).isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void MessageComposer::identityDetails()
|
IdDetailsDialog *dialog = new IdDetailsDialog(RsGxsGroupId(id));
|
||||||
{
|
dialog->show();
|
||||||
FriendSelectionWidget::IdType idType;
|
|
||||||
std::string id = ui.friendSelectionWidget->selectedId(idType);
|
|
||||||
|
|
||||||
if (id.empty() || idType != FriendSelectionWidget::IDTYPE_GXS) {
|
/* Dialog will destroy itself */
|
||||||
return;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RsGxsGroupId(id).isNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdDetailsDialog *dialog = new IdDetailsDialog(RsGxsGroupId(id));
|
|
||||||
dialog->show();
|
|
||||||
|
|
||||||
/* Dialog will destroy itself */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageComposer::tagAboutToShow()
|
void MessageComposer::tagAboutToShow()
|
||||||
|
@ -97,7 +97,6 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
/* toggle Contacts DockWidget */
|
/* toggle Contacts DockWidget */
|
||||||
void contextMenuFileList(QPoint);
|
void contextMenuFileList(QPoint);
|
||||||
void contextMenuMsgSendList(QPoint);
|
|
||||||
void pasteRecommended();
|
void pasteRecommended();
|
||||||
void on_contactsdockWidget_visibilityChanged(bool visible);
|
void on_contactsdockWidget_visibilityChanged(bool visible);
|
||||||
void toggleContacts();
|
void toggleContacts();
|
||||||
@ -153,10 +152,10 @@ private slots:
|
|||||||
void addBcc();
|
void addBcc();
|
||||||
void addRecommend();
|
void addRecommend();
|
||||||
void editingRecipientFinished();
|
void editingRecipientFinished();
|
||||||
void friendDetails();
|
void contactDetails();
|
||||||
void identityDetails();
|
|
||||||
|
|
||||||
void peerStatusChanged(const QString& peer_id, int status);
|
void peerStatusChanged(const QString& peer_id, int status);
|
||||||
|
void friendSelectionChanged();
|
||||||
|
|
||||||
void tagAboutToShow();
|
void tagAboutToShow();
|
||||||
void tagSet(int tagId, bool set);
|
void tagSet(int tagId, bool set);
|
||||||
@ -179,6 +178,7 @@ private:
|
|||||||
void setupViewActions();
|
void setupViewActions();
|
||||||
void setupInsertActions();
|
void setupInsertActions();
|
||||||
void setupFormatActions();
|
void setupFormatActions();
|
||||||
|
void setupContactActions();
|
||||||
|
|
||||||
bool load(const QString &f);
|
bool load(const QString &f);
|
||||||
bool maybeSave();
|
bool maybeSave();
|
||||||
@ -222,6 +222,11 @@ private:
|
|||||||
*actionUpperRoman;
|
*actionUpperRoman;
|
||||||
|
|
||||||
QAction *contactSidebarAction;
|
QAction *contactSidebarAction;
|
||||||
|
QAction *mActionAddTo;
|
||||||
|
QAction *mActionAddCC;
|
||||||
|
QAction *mActionAddBCC;
|
||||||
|
QAction *mActionAddRecommend;
|
||||||
|
QAction *mActionContactDetails;
|
||||||
|
|
||||||
QTreeView *channelstreeView;
|
QTreeView *channelstreeView;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user