Ejemplo n.º 1
0
void 
KAMenu::slotHostlistChanged()
{
  /* die Liste der erreichbaren Archiehosts hat sich
   * veraendert. neu einlesen
   */
  //  KConfig *config = KApplication::getKApplication()->getConfig();
  QStrList archiehostlist;
  //  int archiehostlistnumber = 
  KConfigGroupSaver saveGroup( config, "HostConfig" );

  config->readListEntry( "Hosts", archiehostlist );
  //  QString currenthost = config->readEntry( "CurrentHost", "archie.sura.net" );
  QString defaulthost = "archie.sura.net" ;
  if ( archiehostlist.isEmpty() ) {
    archiehostlist.append( defaulthost );
    //    currentHostId = 0;
  }
  
  host->clear();
  char *tmpStr;
  int i = 0;
  for (tmpStr=archiehostlist.first(); tmpStr; tmpStr=archiehostlist.next()) {
    host->insertItem( tmpStr, i, i);
    i++;
  }

  slotConfigChanged();

  emit sigArchieHost(host->text(host_id));
}
Ejemplo n.º 2
0
void 
KASearchSettings::readConfig()
{
  int tmp;
  KConfig *config = KApplication::getKApplication()->getConfig();
  KConfigGroupSaver saveGroup( config, "SearchConfig" );
  
  maxhits->setValue(config->readNumEntry("hits", 95));

  switch (SearchMode::toMode( ((const char *)config->readEntry("Search", "="))[0] )) {
  case SearchMode::exactregexp: tmp=6 ; break;
  case SearchMode::exactsubcase: tmp=5 ; break;
  case SearchMode::exactsubstr: tmp=4 ; break;
  case SearchMode::regexp: tmp=3 ; break;
  case SearchMode::subcase: tmp=2 ; break;
  case SearchMode::substr: tmp=1 ; break;
  case SearchMode::exact: // fall through
  default: tmp=0 ; break;
  }
  searchmode->setCurrentItem(tmp);

  switch(NiceLevel::toLevel(config->readNumEntry("Nice", 0))) {
  case NiceLevel::nice : tmp=1 ; break;
  case NiceLevel::nicer : // fall through
  case NiceLevel::verynice : tmp=2 ; break;
  case NiceLevel::extremlynice : tmp=3 ; break;
  case NiceLevel::nicest : tmp=4 ; break;
  case NiceLevel::norm : // fall through
  default: tmp=0 ; break;
  }
  nicelevel->setCurrentItem(tmp);

}
Ejemplo n.º 3
0
void DocumentScene::saveGroupAsWithoutDoc(BlockGroup *group)
{
    group=getBlockGroup();

    QString fileName = QFileDialog::getSaveFileName((QWidget*)parent());

    if (!fileName.isEmpty()) saveGroup(fileName, group, true);

}
Ejemplo n.º 4
0
KAArchieSettings::KAArchieSettings(const char *title, QWidget *parent, const char *name)
  :QGroupBox( title, parent, name )
{

  //  debug( "set KAArchieSettings Combobox" );
  hostbox = new QGroupBox( this, "hostbox" );
  hostbox->setFrameStyle( QFrame::NoFrame );
  hostname = new QComboBox( hostbox, "hostname" );
  hostnamelabel = new QLabel( hostname, i18n("&Host"), hostbox, "hostnamelabel" );
  
  timeoutbox = new QGroupBox ( this, "timeoutbox" );
  timeoutbox->setFrameStyle( QFrame::NoFrame );
  timeoutline = new KIntegerLine( timeoutbox, "timeoutline" );
  //  timeoutline->hide();
  //  timeoutline->setText("0000");
  // get the size for displaying "0000"
  //  const QSize lineEditSize = timeoutline->sizeHint();
  //  QFontMetrics *fm = &timeoutline->fontMetrics();
  //  int lineEditHeight = fm->boundingRect('8').height();
  //  timeoutline->setFixedHeight( timeoutline->height() );
  //  timeoutline->show();
  timeoutlabel = new QLabel( timeoutline, i18n("&Timeout (seconds)"), timeoutbox, "timeoutlabel" );
  connect(timeoutline, SIGNAL(returnPressed()),
	  this, SLOT(slotRP()) );

  triesbox = new QGroupBox ( this, "triesbox" );
  triesbox->setFrameStyle( QFrame::NoFrame );
  triesline = new KIntegerLine( triesbox, "triesline" );
  //  QString tmp("set KLineEdit height ");
  //  tmp.setNum( lineEditHeight );
  //  debug( tmp );
  //  triesline->setFixedHeight( triesline->height() );
  trieslabel = new QLabel( triesline, i18n("Maximal &retries"), triesbox, "trieslabel" );
  connect(triesline, SIGNAL(returnPressed()),
	  this, SLOT(slotRP()) );

  doLayout();


  // read initial archie server list
  QStrList archiehostlist;
  KConfig *config = KApplication::getKApplication()->getConfig();
  // get the list of hosts
  KConfigGroupSaver saveGroup( config, "HostConfig" );
  //  archiehostlistnumber = 
  config->readListEntry( "Hosts", archiehostlist );
  QString defaulthost = "archie.sura.net" ;
  if ( archiehostlist.isEmpty() ) {
    archiehostlist.append( defaulthost );
    //    currentHostId = 0;
  }
  hostname->insertStrList( &archiehostlist );
  hostname->adjustSize();


  readConfig();
}
Ejemplo n.º 5
0
void DocumentScene::saveGroupAs(BlockGroup *group)
{
    //group=getBlockGroup();

    QString dir = QFileInfo(window->windowFilePath()).absoluteDir().absolutePath();

    QString fileName = QFileDialog::getSaveFileName((QWidget*)parent(), tr("Save file..."),
                                                    dir);

    if (!fileName.isEmpty()) saveGroup(fileName, group);

}
Ejemplo n.º 6
0
void 
KAMenu::slotSettingsHostname(int menu)
{
  //  debug( "Settings hostname selected %i",menu );
  changeCheckMenu(host, host_id, menu);
  host_id = menu;
  // Eintrag in der Config aendern
  KConfigGroupSaver saveGroup( config, "HostConfig" );
  config->writeEntry("CurrentHostId", menu, true, false, false);
  config->sync();
  emit sigArchieHost(host->text(menu));
}
Ejemplo n.º 7
0
void DocumentScene::saveGroupAsWithoutDoc(BlockGroup *group)
{
    if (group == 0)
    {
        if (currentGroup == 0) return;

        group = currentGroup;
    }

    QString fileName = QFileDialog::getSaveFileName((QWidget*)parent());

    if (!fileName.isEmpty()) saveGroup(fileName, group, true);

}
Ejemplo n.º 8
0
void 
KAMenu::slotSettingsNicelevel(int menuitem)
{
  //  debug( "Settings nicelevel selected %i", menuitem );
  changeCheckMenu(nicelevel, nice_id, menuitem);
  nice_id = menuitem;
  NiceLevel nicelevel(menu2nicelevel(menuitem));

  // Eintrag in der Config aendern
  KConfigGroupSaver saveGroup( config, "SearchConfig" );
  config->writeEntry("Nice", nicelevel.toLevel(), true, false, false);
  config->sync();

  emit sigNicelevel(nicelevel.getLevel());
}
Ejemplo n.º 9
0
int NewGroup::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: cancel(); break;
        case 1: saveGroup(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Ejemplo n.º 10
0
void 
KAMenu::slotSettingsShowFile()
{
  //  debug( "Settings showfile selected" );
  const bool itemChecked = !settings->isItemChecked(0);
  // toggle the showfilemenuitem
  settings->setItemChecked( 0, itemChecked);

  // save it
  KConfigGroupSaver saveGroup( config, "WindowConfig" );
  config->writeEntry("FAttr", itemChecked, true, false, false);
  config->sync();
  
  // call it to the world..
  emit sigSettingsShowFileDiscription( itemChecked );
}
Ejemplo n.º 11
0
void 
KAArchieSettings::readConfig()
{
  KConfig *config = KApplication::getKApplication()->getConfig();
  KConfigGroupSaver saveGroup( config, "HostConfig" );
  uint currentHostId = config->readUnsignedNumEntry( "CurrentHostId", 0 );

  if ((uint)hostname->count() < currentHostId-1) {
    currentHostId = 0;
  }    

  hostname->setCurrentItem( currentHostId );

  timeoutline->setText( config->readEntry( "Timeout", "4" ) );
  triesline->setText( config->readEntry( "Retries", "3" ) );

}
Ejemplo n.º 12
0
void 
KAMenu::slotSettingsSearchmode(int mode)
{
  //  debug( "Settings seachtype selected %i", mode );
  changeCheckMenu(searchmode, searchmode_id, mode);
  searchmode_id = mode;
  SearchMode currentmode(menu2searchmode(mode));

  // Eintrag in der Config aendern
  KConfigGroupSaver saveGroup( config, "SearchConfig" );
  char input[2]; //= new char[2];
  input[0] = currentmode.getChar();
  input[1] = '\0';
  config->writeEntry("Search", input, true, false, false);
  config->sync();
  //  delete input;

  emit (currentmode.getMode());
}
Ejemplo n.º 13
0
void 
KAArchieSettings::writeConfig()
{
  KConfig *config = KApplication::getKApplication()->getConfig();
  KConfigGroupSaver saveGroup( config, "HostConfig" );

  //  debug("write hostnum to %i",hostname->currentItem() );
  config->writeEntry( ConfigEntries::CurrentHostNumEntry,
		      hostname->currentItem(), TRUE );
  //  debug("write current host to %s",hostname->currentText() );
  config->writeEntry( ConfigEntries::CurrentHostEntry,
		      hostname->currentText(), TRUE );
  //  debug("write timeout to %i",timeoutline->value() );
  config->writeEntry( "Timeout",
		      timeoutline->value(), TRUE );
  //  debug("write retries to %i",triesline->value() );
  config->writeEntry( "Retries",
		      triesline->value(), TRUE );
  config->sync();
}
Ejemplo n.º 14
0
bool CSVSortList::checkDisplayIndex()
{
    irow it;
    map<int, string, less<int> > lsDis;
    map<int, string, less<int> >::iterator lsDisItem;
    for(it = m_svList.begin(); it != m_svList.end(); it++)
    {
        SVTableCell *pCell = (*it).second.Cell(1);
        if(pCell && pCell->Type() == adLineEdit)
        {
            if(pCell->Value())
            {                
                string szIndex = ((WLineEdit*)pCell->Value())->text();
                int nIndex = 0;
                if(!szIndex.empty())
                    nIndex = atoi(szIndex.c_str());
                lsDisItem = lsDis.find(nIndex);
                while(lsDisItem != lsDis.end())
                {
                    nIndex ++;
                    lsDisItem = lsDis.find(nIndex);
                }
                lsDis[nIndex] = pCell->Property();
            }
        }
    } 
    switch(m_nType)
    {
    case Tree_GROUP:
        saveGroup(lsDis);
        break;
    case Tree_DEVICE:
        saveDevice(lsDis);
        break;
    case Tree_MONITOR:
        saveMonitor(lsDis);
        break;
    }
    return true;
}
Ejemplo n.º 15
0
void 
KASearchSettings::writeConfig()
{
  KConfig *config = KApplication::getKApplication()->getConfig();
  KConfigGroupSaver saveGroup( config, "SearchConfig" );

  config->writeEntry("hits", maxhits->value());

  SearchMode::mode tmpmode;
  switch(searchmode->currentItem()) {
  case 6: tmpmode=SearchMode::exactregexp ; break;
  case 5: tmpmode=SearchMode::exactsubcase ; break;
  case 4: tmpmode=SearchMode::exactsubstr ; break;
  case 3: tmpmode=SearchMode::regexp ; break;
  case 2: tmpmode=SearchMode::subcase ; break;
  case 1: tmpmode=SearchMode::substr ; break;
  case 0: // fall through
  default: tmpmode=SearchMode::exact ; break;
  }
  char input[2];
  input[0] = SearchMode::toChar(tmpmode);
  input[1] = '\0';
  config->writeEntry("Search", input, true, false, false);

  NiceLevel::mode tmpnice;
  switch (nicelevel->currentItem()) {
  case 4: tmpnice=NiceLevel::nicest; break;
  case 3: tmpnice=NiceLevel::extremlynice; break;
  case 2: tmpnice=NiceLevel::verynice; break;
  case 1: tmpnice=NiceLevel::nice; break;
  case 0: // fall through
  default: tmpnice=NiceLevel::norm; break;
  }
  NiceLevel nicelevel(tmpnice);
  config->writeEntry("Nice", nicelevel.toLevel(), true, false, false);

  config->sync();
}
Ejemplo n.º 16
0
bool SvgWriter::save(QIODevice &outputDevice)
{
    if (m_toplevelShapes.isEmpty())
        return false;

    QTextStream svgStream(&outputDevice);

    // standard header:
    svgStream << "<?xml version=\"1.0\" standalone=\"no\"?>" << endl;
    svgStream << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\" ";
    svgStream << "\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">" << endl;

    // add some PR.  one line is more than enough.
    svgStream << "<!-- Created using Karbon, part of Calligra: http://www.calligra.org/karbon -->" << endl;

    svgStream << "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
    svgStream << " width=\"" << m_pageSize.width() << "pt\"";
    svgStream << " height=\"" << m_pageSize.height() << "pt\">" << endl;

    {
        SvgSavingContext savingContext(outputDevice, m_writeInlineImages);

        // top level shapes
        Q_FOREACH (KoShape *shape, m_toplevelShapes) {
            KoShapeLayer *layer = dynamic_cast<KoShapeLayer*>(shape);
            if(layer) {
                saveLayer(layer, savingContext);
            } else {
                KoShapeGroup *group = dynamic_cast<KoShapeGroup*>(shape);
                if (group)
                    saveGroup(group, savingContext);
                else
                    saveShape(shape, savingContext);
            }
        }
    }
Ejemplo n.º 17
0
 void save(XmlNode *parentNode, Matrix3 parentTransform)
 {
     rapidxml::xml_node<> *node = saveGroup(parentNode, "sound-component");
     (void) node;
 }
Ejemplo n.º 18
0
    foreach (BlockGroup *group, groups)
    {
        saveGroup(group->fileName, group);
//        saveGroup("", group); // povodna funkcia
    }
Ejemplo n.º 19
0
bool BulkHeaderGroup::BulkHeaderGroupBody()
{
    // belt and braces
    key.set_data(keymem);
    data.set_data(datamem);

    if (m_cancel)
    {
        emit updateJob(JobList::BulkHeaderGroup, JobList::Cancelled, job->seq);
        return false;
    }

    emit updateJob(JobList::BulkHeaderGroup, JobList::Running, job->seq);

    NewsGroup* ng = job->ng;
    Db* db = ng->getDb();

    MultiPartHeader mph;
    SinglePartHeader sph;
    HeaderBase* hb = 0;
    HeaderGroup* headerGroup = 0;
    HeaderGroup* advancedHeaderGroup = 0;

    // typedef QMap<QString, QString> HeaderGroupIndexes; // subj, headerGroup index
    // typedef QMap<QString, HeaderGroup*> HeaderGroups; //  headerGroup index, headerGroup *

    HeaderGroupIndexes headerGroupIndexes;
    HeaderGroups       headerGroups;

    DBC *dbcp = 0;
    DBT ckey, cdata;

    memset(&ckey, 0, sizeof(ckey));
    memset(&cdata, 0, sizeof(cdata));

    size_t retklen, retdlen;
    void *retkey = 0, *retdata = 0;
    int ret, t_ret;
    void *p = 0;

    quint64 count=0;

    cdata.data = (void *) new char[HEADER_BULK_BUFFER_LENGTH];
    cdata.ulen = HEADER_BULK_BUFFER_LENGTH;
    cdata.flags = DB_DBT_USERMEM;

    ckey.data = (void *) new char[HEADER_BULK_BUFFER_LENGTH];
    ckey.ulen = HEADER_BULK_BUFFER_LENGTH;
    ckey.flags = DB_DBT_USERMEM;

    /* Acquire a cursor for the database. */
    if ((ret = db->get_DB()->cursor(db->get_DB(), NULL, &dbcp, DB_CURSOR_BULK)) != 0)
    {
        db->err(ret, "DB->cursor");
        char* ptr = 0;

        ptr = (char*)(ckey.data);
        Q_DELETE_ARRAY(ptr);
        ptr = (char*)(cdata.data);
        Q_DELETE_ARRAY(ptr);
        return false;
    }

    // To save the group records
    ng->articlesNeedDeleting(false);

    // Store the data in the database - flush first ...

    u_int32_t delCount;

    uchar keymem[KEYMEM_SIZE];
    uchar datamem[DATAMEM_SIZE];
    Dbt key, data;
    char* p2 = 0;
    QByteArray ba;
    const char *k = 0;

    key.set_flags(DB_DBT_USERMEM);
    key.set_data(&keymem);
    key.set_ulen(KEYMEM_SIZE);

    data.set_flags(DB_DBT_USERMEM);
    data.set_ulen(DATAMEM_SIZE);
    data.set_data(&datamem);

    QString subj =  "MDQuban", from = "MDQuban";

    //QString rs1 = "^(.*)(\".*\")";
    //QString rs2 = "^(.*)\\s-\\s(.*)$";
    //QString rs3 = "^(\\S+.*)\\[.*\\].*(\".*\")";

    //QString rs3 = "^(.*)\\s-\\s.*\\s-\\s(.*)$";
    QRegExp rx[3];
    bool    rxPosBack[3];
    bool    noRegexpGrouping;

    QString recKey, storeIndex;
    QString prevSubj = "MDQuban", prevFrom = "MDQuban";

    int pos;
    bool newGroup = false;

    bool mphFound = false;

    quint32 grouped = 0,
            single = 0,
            numGroups = 0;

    qint16 stringDiff = -1;

    bool prevGroup = false;
    bool advancedPlacement = false;
    bool skipAdvanced = false;

    noRegexpGrouping = ng->isThereNoRegexOnGrouping();

    if (noRegexpGrouping == false) // need regex for grouping
    {
        rx[0].setPattern(ng->getGroupRE1());
        rx[1].setPattern(ng->getGroupRE2());
        rx[2].setPattern(ng->getGroupRE3());

        rxPosBack[0] = ng->getGroupRE1Back();
        rxPosBack[1] = ng->getGroupRE2Back();
        rxPosBack[2] = ng->getGroupRE3Back();
    }

    ng->getGroupingDb()->truncate(0, &delCount, 0);
    qDebug() << "Deleted " << delCount << " records from group db";

    QMapIterator<QString, QString> it(headerGroupIndexes);
    QString advancedIndex;

    for (;;)
    {
        /*
         * Acquire the next set of key/data pairs.  This code
         * does not handle single key/data pairs that won't fit
         * in a BUFFER_LENGTH size buffer, instead returning
         * DB_BUFFER_SMALL to our caller.
         */
        if ((ret = dbcp->get(dbcp, &ckey, &cdata, DB_MULTIPLE_KEY | DB_NEXT)) != 0)
        {
            if (ret != DB_NOTFOUND)
                db->err(ret, "DBcursor->get");
            break;
        }

        for (DB_MULTIPLE_INIT(p, &cdata);;)
        {
            DB_MULTIPLE_KEY_NEXT(p, &cdata, retkey, retklen, retdata, retdlen);
            if (p == NULL)
                break;

            if (retdlen){;} // MD TODO compiler .... unused variable

            recKey = QString::fromLocal8Bit((char*)retkey, retklen);

            if (*((char *)retdata) == 'm')
            {
                MultiPartHeader::getMultiPartHeader((unsigned int)retklen, (char *)retkey, (char *)retdata, &mph);
                hb = (HeaderBase*)&mph;
                mphFound = true;
            }
            else if (*((char *)retdata) == 's')
            {
                SinglePartHeader::getSinglePartHeader((unsigned int)retklen, (char *)retkey, (char *)retdata, &sph);
                hb = (HeaderBase*)&sph;
                mphFound = false;
            }
            else
            {
                // What have we found ?????
                qDebug() << "Found unexpected identifier for header : " << (char)*((char *)retdata);
                continue;
            }

            ++count;

            prevSubj = subj;

            prevFrom = from;

            subj = hb->getSubj();
            from = hb->getFrom();

            if (noRegexpGrouping == false) // need regex for grouping
            {
                for (int i=0; i<3; ++i)
                {
                    if (rx[i].isEmpty() == false)
                    {
                        if (rxPosBack[i] == true) // from the back
                        {
                            pos = subj.lastIndexOf(rx[i]);
                            if (pos != -1)
                                subj.truncate(pos);
                        }
                        else // from the front
                        {
                            pos = rx[i].indexIn(subj);
                            if (pos > -1)
                                subj = rx[i].cap(0);
                        }
                    }
                }
            }

            //qDebug() << "Stripped down to: " << subj;

            stringDiff = -1;

            if (prevFrom != from) // change of contributor
            {
                newGroup = true;
            }
            else // same contributor
            {
               if ((stringDiff = levenshteinDistance(prevSubj, subj)) > ng->getMatchDistance()) // no match ...
                   newGroup = true;
               else
                   newGroup = false;

               //qDebug() << "Diff between " << prevSubj << " and " << subj << " is " << stringDiff;
            }

            if (newGroup)
            {
                if (ng->isThereAdvancedGrouping())
                {
                    it.toFront();

                    // decide if we can match to a previous group
                    while (it.hasNext())
                    {
                        it.next();
                        if ((stringDiff = levenshteinDistance(it.key(), subj)) <= ng->getMatchDistance()) // match ...
                        {
                            // The index for this group is in it.value()
                            // See if we have the HeaderGroup in our cache headerGroups)

                            if (headerGroups.contains(it.value()))
                            {
                                advancedHeaderGroup = headerGroups.value(it.value());
                            }
                            else // not in cache
                            {
                                advancedIndex = it.value();
                                advancedHeaderGroup = getGroup(ng, advancedIndex);
                                if (advancedHeaderGroup)
                                {
                                    headerGroups.insert(advancedIndex, advancedHeaderGroup);
                                }
                                else // db read failed ..
                                {
                                    skipAdvanced = true;
                                }
                            }

                            if (skipAdvanced == false)
                            {
                                if (mphFound)
                                    advancedHeaderGroup->addMphKey(recKey);
                                else
                                    advancedHeaderGroup->addSphKey(recKey);

                                advancedPlacement = true;
                                subj = prevSubj; // ignore this header as it's been placed out of sequence
                                from = prevFrom;
                                newGroup = false; // as we managed to relocate to an existing group

                                break; // stop looking at previous groups
                            }
                            else
                                skipAdvanced = false;
                        }
                    }
                }
            }

            if (newGroup)
            {
                if (prevGroup) // save before moving on
                {
                    ba = storeIndex.toLocal8Bit();
                    k= ba.constData();
                    memcpy(keymem, k, storeIndex.length());
                    key.set_size(storeIndex.length());

                    p2=headerGroup->data();
                    data.set_data(p2);
                    data.set_size(headerGroup->getRecordSize());
                    ret=ng->getGroupingDb()->put(NULL, &key, &data, 0);
                    if (ret!=0)
                        qDebug("Error updating record: %d", ret);

                    if (ng->isThereAdvancedGrouping())
                        headerGroupIndexes.insert(storeIndex.section('\n', 0, 0), storeIndex);

                    Q_DELETE_ARRAY(p2);
                    Q_DELETE(headerGroup);
                    numGroups++;
                }

                prevGroup = true;

                storeIndex = subj % "\n" % from;

                headerGroup = new HeaderGroup();

                headerGroup->setDisplayName(subj);
                headerGroup->setPostingDate(hb->getPostingDate());
                headerGroup->setDownloadDate(hb->getDownloadDate());
                headerGroup->setStatus(hb->getStatus());
                headerGroup->setNextDistance(stringDiff);
            }

            // if we've found somewhere else to place this header then don't add again
            if (!advancedPlacement)
            {
                if (mphFound)
                    headerGroup->addMphKey(recKey);
                else
                    headerGroup->addSphKey(recKey);
            }
            else
                advancedPlacement = false;

            if (count % 250 == 0)
            {
                QCoreApplication::processEvents();

                emit updateJob(JobList::BulkHeaderGroup, tr("Header bulk grouping for newsgroup ") + job->ng->getAlias() + ": " +
                    QString::number(count) + " out of " + QString::number(ng->getTotal()) + tr(" grouped"), job->seq);
            }

            if (m_cancel)
            {
                emit updateJob(JobList::BulkHeaderGroup, JobList::Cancelled, job->seq);
                return false;
            }
        }

        if (m_cancel)
        {
            emit updateJob(JobList::BulkHeaderGroup, JobList::Cancelled, job->seq);
            return false;
        }
    }

    if ((t_ret = dbcp->close(dbcp)) != 0)
    {
        db->err(ret, "DBcursor->close");
        if (ret == 0)
            ret = t_ret;
    }

    char* ptr = ((char*)ckey.data);
    Q_DELETE_ARRAY(ptr);
    ptr = ((char*)cdata.data);
    Q_DELETE_ARRAY(ptr);
    if (headerGroups.count())
    {
        qDeleteAll(headerGroups);
        headerGroups.clear();
    }

    qDebug() << "Multi = " << grouped << ", single = " << single;

    ng->setHeadersNeedGrouping(false);
    // Finally update the newsgroup
    emit saveGroup(ng);

    emit updateJob(JobList::BulkHeaderGroup, tr("Header bulk grouping for newsgroup ") + job->ng->getAlias() + ": " +
                  QString::number(count) + " out of " + QString::number(ng->getTotal()) + tr(" grouped"), job->seq);

    if (m_cancel)
    {
        emit updateJob(JobList::BulkHeaderGroup, JobList::Cancelled, job->seq);
        return false;
    }

    emit logEvent(tr("Bulk grouping of ") + ng->getTotal() + tr(" articles completed successfully."));

    emit updateJob(JobList::BulkHeaderGroup, JobList::Finished_Ok, job->seq);

    ng->setTotalGroups(numGroups);

    Q_DELETE(headerGroup);

    return true;
}
Ejemplo n.º 20
0
void fnSaveStateAndRebuildList(HWND hwnd, struct ClcData *dat)
{
	NMCLISTCONTROL nm;
	int i, j;
	ClcGroup *group;
	ClcContact *contact;

	cli.pfnHideInfoTip(hwnd, dat);
	KillTimer(hwnd, TIMERID_INFOTIP);
	KillTimer(hwnd, TIMERID_RENAME);
	cli.pfnEndRename(hwnd, dat, 1);

	OBJLIST<SavedContactState_t> saveContact(10, NumericKeySortT);
	OBJLIST<SavedGroupState_t> saveGroup(100, NumericKeySortT);
	OBJLIST<SavedInfoState_t> saveInfo(10, NumericKeySortT);

	dat->needsResort = 1;
	group = &dat->list;
	group->scanIndex = 0;
	for (;;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			if (group == NULL)
				break;
		}
		else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;

			SavedGroupState_t* p = new SavedGroupState_t;
			p->groupId = group->groupId;
			p->expanded = group->expanded;
			saveGroup.insert(p);
			continue;
		}
		else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) {
			SavedContactState_t* p = new SavedContactState_t;
			p->hContact = group->cl.items[group->scanIndex]->hContact;
			memcpy(p->iExtraImage, group->cl.items[group->scanIndex]->iExtraImage, sizeof(p->iExtraImage));
			p->checked = group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED;
			saveContact.insert(p);
		}
		else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) {
			SavedInfoState_t* p = new SavedInfoState_t;
			p->parentId = (group->parent == NULL) ? -1 : group->groupId;
			p->contact = *group->cl.items[group->scanIndex];
			saveInfo.insert(p);
		}
		group->scanIndex++;
	}

	cli.pfnFreeGroup(&dat->list);
	cli.pfnRebuildEntireList(hwnd, dat);

	group = &dat->list;
	group->scanIndex = 0;
	for (;;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			if (group == NULL)
				break;
		}
		else if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
			group = group->cl.items[group->scanIndex]->group;
			group->scanIndex = 0;

			SavedGroupState_t tmp, *p;
			tmp.groupId = group->groupId;
			if ((p = saveGroup.find(&tmp)) != NULL)
				group->expanded = p->expanded;
			continue;
		}
		else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) {
			SavedContactState_t tmp, *p;
			tmp.hContact = group->cl.items[group->scanIndex]->hContact;
			if ((p = saveContact.find(&tmp)) != NULL) {
				memcpy(group->cl.items[group->scanIndex]->iExtraImage, p->iExtraImage, sizeof(p->iExtraImage));
				if (p->checked)
					group->cl.items[group->scanIndex]->flags |= CONTACTF_CHECKED;
			}
		}

		group->scanIndex++;
	}

	for (i=0; i < saveInfo.getCount(); i++) {
		if (saveInfo[i].parentId == -1)
			group = &dat->list;
		else {
			if (!cli.pfnFindItem(hwnd, dat, saveInfo[i].parentId | HCONTACT_ISGROUP, &contact, NULL, NULL))
				continue;
			group = contact->group;
		}
		j = cli.pfnAddInfoItemToGroup(group, saveInfo[i].contact.flags, _T(""));
		*group->cl.items[j] = saveInfo[i].contact;
	}

	cli.pfnRecalculateGroupCheckboxes(hwnd, dat);

	cli.pfnRecalcScrollBar(hwnd, dat);
	nm.hdr.code = CLN_LISTREBUILT;
	nm.hdr.hwndFrom = hwnd;
	nm.hdr.idFrom = GetDlgCtrlID(hwnd);
	SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM) & nm);
}
Ejemplo n.º 21
0
 foreach (BlockGroup *group, groups)
 {
     saveGroup("", group);
 }