bool ImportOPJ::createProjectTree(const OPJFile &opj) { const tree<projectNode> *projectTree = opj.project(); tree<projectNode>::iterator root = projectTree->begin(projectTree->begin()); if (!root.node) return false; FolderListItem *item = static_cast<FolderListItem *>(mw->folders->firstChild()); item->setText(0, root->name.c_str()); item->folder()->setObjectName(root->name.c_str()); Folder *projectFolder = mw->projectFolder(); QHash<tree<projectNode>::iterator, Folder *> parent; parent[root] = projectFolder; for (tree<projectNode>::iterator sib = projectTree->begin(root); sib != projectTree->end(root); ++sib) { if (sib->type == 1) { parent[sib] = mw->addFolder(sib->name.c_str(), parent.value(projectTree->parent(sib))); parent[sib]->setBirthDate(JulianDateTime2String(sib->creation_date)); parent[sib]->setModificationDate( JulianDateTime2String(sib->modification_date)); } else { MdiSubWindow *w = projectFolder->window(sib->name.c_str()); if (w) { parent.value(projectTree->parent(sib))->addWindow(w); projectFolder->removeWindow(w); } } } mw->changeFolder(projectFolder, true); return true; }
Folder* FolderListView::currentFolder() const { FolderListItem *item = currentFolderItem(); if ( item != NULL ) return item->folder(); return NULL; }
bool FolderListItem::isChildOf(FolderListItem *src) { FolderListItem *parent = (FolderListItem *)this->parent(); while (parent) { if (parent == src) return true; parent = (FolderListItem *)parent->parent(); } return false; }
void ListViews::slotFolderChanged( QListViewItem *i ) { if ( !i ) return; messages->clear(); message->setText( "" ); FolderListItem *item = ( FolderListItem* )i; for ( Message* msg = item->folder()->firstMessage(); msg; msg = item->folder()->nextMessage() ) (void)new MessageListItem( messages, msg ); }
bool FolderListView::setCurrentFolder(const Folder* folder) { QModelIndex index = model()->index( 0, 0 ); for ( ; index.isValid(); index = next( index ) ) { FolderListItem *item = folderItemFromIndex( index ); if ( item->folder() == folder ) { setCurrentItem( item ); return true; } } return false; }
QModelIndex FolderListView::accountFolderIndex(const Folder* account, const QString& mailbox) const { QModelIndex index = model()->index( 0, 0 ); for ( ; index.isValid(); index = next( index ) ) { FolderListItem* item = folderItemFromIndex( index ); Folder* folder = item->folder(); if ( ( mailbox.isNull() && (folder == account) ) || ( (folder->folderType() == FolderTypeMailbox) && (static_cast<Mailbox*>(folder)->pathName() == mailbox) && (itemAccount(item) == account) ) ) { break; } } return index; }