Logo Search packages:      
Sourcecode: basket version File versions  Download package

void Container::loadBaskets (  )  [slot]

Firstly load all previously openned baskets (including mirror ones) :

And then load the baskets in the Global::basketsFolder() that weren't loaded (import < 0.5.0 ones)

Definition at line 1572 of file container.cpp.

References BasketFactory::createBasketClips(), listBaskets(), loadBasket(), and ContainerTabWidget::setCurrentPage().

Referenced by Container().

{
      QStringList failed;

/** Firstly load all previously openned baskets (including mirror ones) : */

      // TODO: Also store the last shown basket here ?

      QDomDocument *doc = XMLWork::openFile("container", Global::basketsFolder() + "container.baskets");
      if (doc != 0) {
            QDomElement docElem = doc->documentElement();
            QDomElement baskets = XMLWork::getElement(docElem, "baskets");

            QDomNode n = baskets.firstChild();
            while ( ! n.isNull() ) {
                  QDomElement e = n.toElement();
                  if ( (!e.isNull()) && e.tagName() == "basket" ) {
                        Basket *loaded = loadBasket(e.text(), false);
                        if (loaded == 0L)
                              failed.append(e.text());
                  }
                  n = n.nextSibling();
            }
      }

/** And then load the baskets in the Global::basketsFolder() that weren't loaded (import < 0.5.0 ones) */

      QDir dir(Global::basketsFolder(), QString::null,
               QDir::Name | QDir::IgnoreCase, QDir::Dirs | QDir::NoSymLinks);

      QStringList list = dir.entryList();
      bool wasImported = false;
      if ( list.count() > 2 )                                                     // Pass "." and ".."
            for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) // For each folder
                  if ( *it != "." && *it != ".." )                                    // If it can be a basket folder
                        if (basketForFolderName((*it) + "/") == 0) {                    // And folder not already loaded
                              if ( ! failed.contains((*it) + "/") ) {                     // And we not already tried to load it
                                    loadBasket( (*it) + "/", false );                       // Load it
                                    wasImported = true;                                     // Set the flag to say basket(s) was loaded
                              }
                        }

      if (wasImported)
            save();

      /*if ( ! failed.isEmpty() ) {
            KMessageBox::informationList( this,  / * TODO FIXME i18n* /QString(
                  "<p>The following baskets failed to load.</p>"
                  "<p>Please check if it exists, is readable and if data aren't corrupted.</p>"),
                  failed, / *i18n* /QString("Basket Load Failure") );
      / *   KMessageBox::error( this, / * TODO FIXME i18n* /QString(
                  "<p>The basket <b>%1</b> failed to load.</p>"
                  "<p>Please check if it exists, is readable and if data aren't corrupted.</p>").arg(basket->folderName()),
                  / *i18n* /QString("Basket Load Failure") );
      }*/

      if (listBaskets().count() == 0) // TODO: Create a basket of examples (tutorial) or link to a short help ?
            loadBasket( BasketFactory::createBasketClips() );

      m_tab->setCurrentPage(Settings::lastBasket());
      currentBasket()->setFocus();// At BasKet start, no widget have focus!
}


Generated by  Doxygen 1.6.0   Back to index