WrapperStr UmlPackage::source_path(const WrapperStr & f) { if (!dir.read) { dir.src = cppSrcDir(); dir.h = cppHDir(); QDir d_root(rootDir(cppLanguage)); if (dir.src.isEmpty()) dir.src = RootDir; else if (QDir::isRelativePath(dir.src)) dir.src = d_root.filePath(dir.src); if (dir.h.isEmpty()) dir.h = RootDir; else if (QDir::isRelativePath(dir.h)) dir.h = d_root.filePath(dir.h); if (dir.src.isEmpty()) { UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory " "must be specified for the package<i> ") + name() + "</i>, edit the <i> generation settings</i> (tab 'directory') " "or edit the package (tab 'C++')</b></font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("UmlPackage::source_path"); } dir.read = TRUE; } QDir d(dir.src); return WrapperStr(d.filePath(f).toLatin1().constData()) + WrapperStr(".") + CppSettings::sourceExtension(); }
WrapperStr UmlPackage::source_path(const WrapperStr & f, WrapperStr relto) { if (!dir.read) { dir.src = cppSrcDir(); dir.h = cppHDir(); dir.src_absolute = dir.h_absolute = FALSE; QDir d_root(rootDir()); if (dir.src.isEmpty()) // considered given relative dir.src = RootDir; else if (QDir::isRelativePath(dir.src)) dir.src = d_root.filePath(dir.src); else dir.src_absolute = TRUE; if (dir.h.isEmpty()) // considered given relative dir.h = RootDir; else if (QDir::isRelativePath(dir.h)) dir.h = d_root.filePath(dir.h); else dir.h_absolute = TRUE; if (dir.src.isEmpty()) { UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory " "must be specified for the package<i> ") + name() + "</i>, edit the <i> generation settings</i> (tab 'directory') " "or edit the package (tab 'C++')</b></font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("UmlPackage::source_path"); } dir.read = TRUE; } if (f.isEmpty()) return dir.src; QDir d(dir.src); if (! d.exists()) create_directory(dir.src); // don't return on error QByteArray temp = d.filePath(f).toLatin1(); WrapperStr df = (dir.src_absolute || relto.isEmpty()) ? WrapperStr(temp.constData()) : relative_path(d, relto) + f; return df + WrapperStr(".") + CppSettings::sourceExtension(); }
bool UmlPackage::set_roundtrip_expected() { if (cppHDir().isEmpty()) package->accept_roundtrip_root(TRUE); if (cppSrcDir().isEmpty()) package->accept_roundtrip_root(FALSE); Progress::tic_it(); const Q3PtrVector<UmlItem> & ch = UmlItem::children(); UmlItem ** v = ch.data(); UmlItem ** const vsup = v + ch.size(); bool result = isWritable(); for (;v != vsup; v += 1) result &= (*v)->set_roundtrip_expected(); return result; }
UmlClassView * UmlPackage::get_classview(const Q3CString & nmsp) { UmlPackage * pack; if (nmsp != cppNamespace()) { if (namespace_fixedp) { if ((pack = findCppNamespace(nmsp)) == 0) { Q3CString s = nmsp; if (s.isEmpty()) s = name(); else { int index = 0; while ((index = s.find("::", index)) != -1) s.replace(index++, 2, " "); } if (((pack = UmlBasePackage::create(this, s)) == 0) && ((pack = UmlBasePackage::create(this, s += "_")) == 0) && ((pack = UmlBasePackage::create(this, s += "_")) == 0) && ((pack = UmlBasePackage::create(this, s += "_")) == 0) && ((pack = UmlBasePackage::create(this, s += "_")) == 0)) { #ifdef REVERSE UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create package <i>") + s + "</i> under package <i>" + name() + "</b></font><br>"); UmlCom::message(""); throw 0; #else QMessageBox::critical(0, "Fatal Error", Q3CString("<font face=helvetica><b>cannot create package <i>") + s + "</i> under package <i>" + Name() + "</b></font><br>"); QApplication::exit(1); #endif } pack->set_CppNamespace(nmsp); pack->set_CppSrcDir(cppSrcDir()); pack->set_CppHDir(cppHDir()); pack->namespace_fixedp = TRUE; } } else { pack = this; pack->set_CppNamespace(nmsp); pack->namespace_fixedp = TRUE; } } else pack = this; if (pack->class_view == 0) { Q3PtrVector<UmlItem> ch = pack->children(); for (unsigned index = 0; index != ch.size(); index += 1) // return the first class view find if (ch[index]->kind() == aClassView) return pack->class_view = (UmlClassView *) ch[index]; if ((pack->class_view = UmlBaseClassView::create(pack, name())) == 0) { #ifdef REVERSE UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create class view <i>") + name() + "</i> under package <i>" + pack->name() + "</b></font><br>"); UmlCom::message(""); throw 0; #else QMessageBox::critical(0, "Fatal Error", Q3CString("<font face=helvetica><b>cannot create class view <i>") + name() + "</i> under package <i>" + pack->name() + "</b></font><br>"); QApplication::exit(1); #endif } } return pack->class_view; }