コード例 #1
0
void FunctionListModel::setupModelData()
{
 beginResetModel();
  if (rootItem)
    delete rootItem;

  QVector<QVariant> rootData(FUNCTION_LIST_MAX_COLUMN);
  rootData[FUNCTION_LIST_COLUMN_NAME]=tr("Method") ;
  rootData[FUNCTION_LIST_COLUMN_DESCRIPTION]=tr("Prototype") ;
  rootData[FUNCTION_LIST_COLUMN_STATISTIC]=tr("Coverage") ;
  rootData[FUNCTION_LIST_COLUMN_FILE_NAME]=tr("File") ;
  rootData[FUNCTION_LIST_COLUMN_ABSOLUTE_FILE_NAME]=tr("Absolute Path") ;
  rootData[FUNCTION_LIST_COLUMN_POSITION]=tr("Position");
  rootData[FUNCTION_LIST_COLUMN_FILE_NAME_REF]=tr("File (Reference)") ;
  rootData[FUNCTION_LIST_COLUMN_ABSOLUTE_FILE_NAME_REF]=tr("Absolute Path (Reference)") ;
  rootData[FUNCTION_LIST_COLUMN_POSITION_REF]=tr("Position (Reference)");
  rootData[FUNCTION_LIST_COLUMN_DIFFERENCE]=tr("Modifications");
  rootItem = new TreeList(rootData);

  if (csmes_p)
  {
    const SourceFiles sources_all= csmes_p->Sources(CSMes::NON_EMPTY) + csmes_p->SourcesReference(CSMes::NON_EMPTY) ;
    SourceFiles sources;

    for (SourceFiles::const_iterator itsrc=sources_all.begin();itsrc!=sources_all.end();++itsrc)
    {
      if (sources.contains(*itsrc))
        continue;

      sources.append(*itsrc);
      QVector<FunctionInfo> FunctionsInfo = csmes_p->FunctionInfoSource(QString(),*itsrc);
      QVector<FunctionInfo>::const_iterator itfct;
      for (itfct=FunctionsInfo.begin();itfct!=FunctionsInfo.end();++itfct)
      {
        insertFunction(
            (*itfct).getScopedName(),
            (*itfct).getPrototype(),
            *itsrc,
            (*itfct).startLineOrg() ,
            (*itfct).endLineOrg() ,
            (*itfct).startLinePre() ,
            (*itfct).startColumnPre() ,
            (*itfct).endLinePre() ,
            (*itfct).endColumnPre(),
            false
            );
      }

      QVector<FunctionInfo> FunctionsInfoReference = csmes_p->FunctionInfoSourceReference(QString(),*itsrc);
      for (itfct=FunctionsInfoReference.begin();itfct!=FunctionsInfoReference.end();++itfct)
      {
        insertFunction(
            (*itfct).getScopedName(),
            (*itfct).getPrototype(),
            *itsrc,
            (*itfct).startLineOrg() ,
            (*itfct).endLineOrg() ,
            (*itfct).startLinePre() ,
            (*itfct).startColumnPre() ,
            (*itfct).endLinePre() ,
            (*itfct).endColumnPre(),
            true
            );
      }
    }

  }
  rootItem->squeeze();
  endResetModel();
}
コード例 #2
0
ファイル: main.cpp プロジェクト: djdarkbeat/ZTopo
int main(int argc, char **argv)
{
  qRegisterMetaType<Cache::Key>("Key");
  qRegisterMetaType<Tile>("Tile");
  qRegisterMetaType<qkey>("qkey");

  QCoreApplication::setOrganizationName("ZTopo");
  QCoreApplication::setApplicationName("ZTopo");

  QApplication app(argc, argv);

#if defined(Q_WS_MAC)
  QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus);
  // Mac OS specific code to find resources within a bundle
  CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
  CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef,
                                                kCFURLPOSIXPathStyle);
  const char *pathPtr = CFStringGetCStringPtr(macPath,
                                              CFStringGetSystemEncoding());
  if (!pathPtr) {
    qFatal("Could not find Mac application bundle path!");
  }
  QString rootPath = QString(pathPtr) % "/Contents/Resources/";
  QByteArray rootPathArray = QString(rootPath % "proj4").toLatin1();
  //qDebug("proj root '%s'\n", rootPathArray.data());

  const char *path[] = { rootPathArray.data() };
  pj_set_searchpath(1, (const char **)&path);
  CFRelease(appUrlRef);
  CFRelease(macPath);  
#elif defined(Q_WS_WIN)
  /* On Windows, use the proj4 subdirectory of the directory containing the 
     application */
  QString projPath = app.applicationDirPath() % "/proj4";
  //qDebug() << "proj root" << projPath;
  const char *path[] = { QDir::toNativeSeparators(projPath).toLatin1().data() };
  pj_set_searchpath(1, (const char **)&path);
#endif

  // On other operating systems, we assume the proj4 library can find its own datum
  // shift grids.

  QSettings settings;
  QString cachePath = settings.value("cachePath", 
      QDesktopServices::storageLocation(QDesktopServices::CacheLocation)).toString();
  QDir::current().mkpath(cachePath);

  QNetworkAccessManager networkManager;
  QNetworkDiskCache diskCache;
  diskCache.setCacheDirectory(cachePath % "/meta");
  diskCache.setMaximumCacheSize(maxDiskCacheSize);
  networkManager.setCache(&diskCache);
 

  RootData rootData(&networkManager);

  if (rootData.maps().size() == 0) {
    qFatal("No maps in root data file!");
  }
  Map *map = rootData.maps().values()[0];

  int maxMemCache = settings.value(settingMemCache, 64).toInt();
  int maxDiskCache = settings.value(settingDiskCache, 200).toInt();
  Cache::Cache tileCache(map, networkManager, maxMemCache, maxDiskCache, cachePath);
  MapRenderer renderer(map, tileCache);
  MainWindow *window = new MainWindow(rootData, map, &renderer, tileCache, 
                                      networkManager);

  window->show();

  if (rootData.majorVersion() > majorVersion || 
      (rootData.majorVersion() == majorVersion 
       && rootData.minorVersion() > minorVersion)) {
    QMessageBox mbox;
    mbox.setText("A new version of ZTopo is available.");
    mbox.setInformativeText(QString("A new version of ZTopo (%1.%2) is available for download. Would you like to open the ZTopo home page?").arg(rootData.majorVersion()).arg(rootData.minorVersion()));
    mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    mbox.setDefaultButton(QMessageBox::Yes);
    int ret = mbox.exec();
    if (ret == QMessageBox::Yes) {
      QDesktopServices::openUrl(QUrl(rootData.homePageUrl()));
    }
  }

  return app.exec();
}