|
|
@ -12,6 +12,7 @@
|
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
|
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <tqdir.h>
|
|
|
|
#include <tqdir.h>
|
|
|
@ -74,6 +75,10 @@ bool KNGroupInfo::operator< (const KNGroupInfo &gi2)
|
|
|
|
return (name < gi2.name);
|
|
|
|
return (name < gi2.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool KNGroupInfo::PtrCompFn(KNGroupInfo *a, KNGroupInfo *b)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return *a < *b;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//===============================================================================
|
|
|
|
//===============================================================================
|
|
|
|
|
|
|
|
|
|
|
@ -81,16 +86,25 @@ bool KNGroupInfo::operator< (const KNGroupInfo &gi2)
|
|
|
|
KNGroupListData::KNGroupListData()
|
|
|
|
KNGroupListData::KNGroupListData()
|
|
|
|
: codecForDescriptions(0)
|
|
|
|
: codecForDescriptions(0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
groups = new TQPtrList<KNGroupInfo>;
|
|
|
|
groups = new std::list<KNGroupInfo*>();
|
|
|
|
groups->setAutoDelete(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KNGroupListData::~KNGroupListData()
|
|
|
|
KNGroupListData::~KNGroupListData()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (groups)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (KNGroupInfo *g : *groups)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
delete g;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
delete groups;
|
|
|
|
delete groups;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -145,7 +159,7 @@ bool KNGroupListData::readIn(KNProtocolClient *client)
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
sub = false;
|
|
|
|
sub = false;
|
|
|
|
|
|
|
|
|
|
|
|
groups->append(new KNGroupInfo(name,description,false,sub,status));
|
|
|
|
groups->push_back(new KNGroupInfo(name,description,false,sub,status));
|
|
|
|
|
|
|
|
|
|
|
|
if (timer.elapsed() > 200) { // don't flicker
|
|
|
|
if (timer.elapsed() > 200) { // don't flicker
|
|
|
|
timer.restart();
|
|
|
|
timer.restart();
|
|
|
@ -169,7 +183,8 @@ bool KNGroupListData::writeOut()
|
|
|
|
TQCString temp;
|
|
|
|
TQCString temp;
|
|
|
|
|
|
|
|
|
|
|
|
if(f.open(IO_WriteOnly)) {
|
|
|
|
if(f.open(IO_WriteOnly)) {
|
|
|
|
for (KNGroupInfo *i=groups->first(); i; i=groups->next()) {
|
|
|
|
for (KNGroupInfo *i : *groups)
|
|
|
|
|
|
|
|
{
|
|
|
|
temp = i->name.utf8();
|
|
|
|
temp = i->name.utf8();
|
|
|
|
switch (i->status) {
|
|
|
|
switch (i->status) {
|
|
|
|
case KNGroup::unknown: temp += " u ";
|
|
|
|
case KNGroup::unknown: temp += " u ";
|
|
|
@ -196,27 +211,33 @@ bool KNGroupListData::writeOut()
|
|
|
|
|
|
|
|
|
|
|
|
// merge in new groups, we want to preserve the "subscribed"-flag
|
|
|
|
// merge in new groups, we want to preserve the "subscribed"-flag
|
|
|
|
// of the loaded groups and the "new"-flag of the new groups.
|
|
|
|
// of the loaded groups and the "new"-flag of the new groups.
|
|
|
|
void KNGroupListData::merge(TQPtrList<KNGroupInfo>* newGroups)
|
|
|
|
void KNGroupListData::merge(std::list<KNGroupInfo*> *newGroups)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool subscribed;
|
|
|
|
bool subscribed;
|
|
|
|
|
|
|
|
|
|
|
|
for (KNGroupInfo *i=newGroups->first(); i; i=newGroups->next()) {
|
|
|
|
for (KNGroupInfo *i : *newGroups)
|
|
|
|
if (groups->find(i)>=0) {
|
|
|
|
{
|
|
|
|
subscribed = groups->current()->subscribed;
|
|
|
|
std::list<KNGroupInfo*>::iterator ngIt = std::find(groups->begin(), groups->end(), i);
|
|
|
|
groups->remove(); // avoid duplicates
|
|
|
|
|
|
|
|
|
|
|
|
if (ngIt != std::end(*groups))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
KNGroupInfo *newGr = *ngIt;
|
|
|
|
|
|
|
|
subscribed = newGr->subscribed;
|
|
|
|
|
|
|
|
groups->erase(ngIt); // avoid duplicates
|
|
|
|
|
|
|
|
delete newGr;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
subscribed = false;
|
|
|
|
subscribed = false;
|
|
|
|
groups->append(new KNGroupInfo(i->name,i->description,true,subscribed,i->status));
|
|
|
|
groups->push_back(new KNGroupInfo(i->name,i->description,true,subscribed,i->status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
groups->sort();
|
|
|
|
groups->sort(KNGroupInfo::PtrCompFn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQPtrList<KNGroupInfo>* KNGroupListData::extractList()
|
|
|
|
std::list<KNGroupInfo*>* KNGroupListData::extractList()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQPtrList<KNGroupInfo>* temp = groups;
|
|
|
|
std::list<KNGroupInfo*>* temp = groups;
|
|
|
|
groups = 0;
|
|
|
|
groups = nullptr;
|
|
|
|
return temp;
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -417,10 +438,12 @@ void KNGroupManager::showGroupDialog(KNNntpAccount *a, TQWidget *parent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQPtrList<KNGroupInfo> lst2;
|
|
|
|
std::list<KNGroupInfo*> lst2;
|
|
|
|
gDialog->toSubscribe(&lst2);
|
|
|
|
gDialog->toSubscribe(&lst2);
|
|
|
|
for(KNGroupInfo *var=lst2.first(); var; var=lst2.next()) {
|
|
|
|
for (KNGroupInfo *var : lst2)
|
|
|
|
|
|
|
|
{
|
|
|
|
subscribeGroup(var, a);
|
|
|
|
subscribeGroup(var, a);
|
|
|
|
|
|
|
|
delete var;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -593,7 +616,8 @@ void KNGroupManager::processJob(KNJobData *j)
|
|
|
|
// update the descriptions of the subscribed groups
|
|
|
|
// update the descriptions of the subscribed groups
|
|
|
|
for ( TQValueList<KNGroup*>::Iterator it = mGroupList.begin(); it != mGroupList.end(); ++it ) {
|
|
|
|
for ( TQValueList<KNGroup*>::Iterator it = mGroupList.begin(); it != mGroupList.end(); ++it ) {
|
|
|
|
if ( (*it)->account() == j->account() ) {
|
|
|
|
if ( (*it)->account() == j->account() ) {
|
|
|
|
for ( KNGroupInfo* inf = d->groups->first(); inf; inf = d->groups->next() )
|
|
|
|
for (KNGroupInfo *inf : *d->groups)
|
|
|
|
|
|
|
|
{
|
|
|
|
if ( inf->name == (*it)->groupname() ) {
|
|
|
|
if ( inf->name == (*it)->groupname() ) {
|
|
|
|
(*it)->setDescription( inf->description );
|
|
|
|
(*it)->setDescription( inf->description );
|
|
|
|
(*it)->setStatus( inf->status );
|
|
|
|
(*it)->setStatus( inf->status );
|
|
|
@ -602,6 +626,7 @@ void KNGroupManager::processJob(KNJobData *j)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
emit(newListReady(d));
|
|
|
|
emit(newListReady(d));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
KMessageBox::error(knGlobals.topWidget, j->errorString());
|
|
|
|
KMessageBox::error(knGlobals.topWidget, j->errorString());
|
|
|
|