示例#1
0
void EvolutionCalendar::loadCalendar(const QString &filename)
{
    //Read gconf file
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly)) {
        qCDebug(IMPORTWIZARD_LOG) << " We can't open file" << filename;
        return;
    }
    QDomDocument doc;
    if (!EvolutionUtil::loadInDomDocument(&file, doc)) {
        return;
    }
    QDomElement config = doc.documentElement();

    if (config.isNull()) {
        qCDebug(IMPORTWIZARD_LOG) << "No config found";
        return;
    }
    mCalendarPath = QDir::homePath() + QLatin1String("/.local/share/evolution/calendar/");
    for (QDomElement e = config.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
        const QString tag = e.tagName();
        if (tag == QLatin1String("entry")) {
            if (e.hasAttribute("name")) {
                const QString attr = e.attribute("name");
                if (attr == QLatin1String("sources")) {
                    readCalendar(e);
                } else {
                    qCDebug(IMPORTWIZARD_LOG) << " attr unknown " << attr;
                }
            }
        }
    }
}
示例#2
0
void Agenda::cerca(int posizione)
{
    /** Avendo la posizione scorre il file bst trovando tutti eventi di un giorno*/
    albero bst;
    ifstream readBst("bst.txt");
    ifstream readCalendar("calendar.txt");
    bool trovato = false;
    readBst.seekg((posizione*(sizeAlbero)),ios_base::beg); // va sulla riga dove punta SX o DX
    readBst.read((char*)&bst,sizeAlbero);
    if(!readBst.eof())
    {
        if(!bst.cancellato)
        {
            if(bst.anno == y)
            {
                if(bst.mese == m)
                {
                    if(bst.giorno == d)
                    {
                        readCalendar.seekg((bst.pos*sizeRecord),ios_base::beg);
                        readCalendar.read((char*)&rec,sizeRecord);
                        ui->listWidget->addItem(rec.descrizone);
                        vetPosizioni->posizione = posizione;
                        vetPosizioni->next = new struct vet;
                        trovato = true;
                        if(bst.dx != -1)
                        {
                            cerca(bst.dx);
                        }
                        if(bst.sx != -1)
                        {
                            cerca(bst.sx);
                        }
                    }
                }
            }
            if(!trovato)
            {   // controllo se la data che ha selezionato, e' > di data sul file;
                if(confronto(bst) > 0) // se 1 a destra , se -1 a sinistra
                { // se e' > va a destra
                    if(bst.dx != -1)
                    {
                        cerca(bst.dx);
                    }
                }
                else
                { // se e' < vado a sinistra;
                    if(bst.sx != -1)
                    {
                        cerca(bst.sx);
                    }
                }
            }
        }
    }
}