Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QtApp.cxx

Go to the documentation of this file.
00001 
00012 #ifdef _MSC_VER
00013 #include "msdevstudio/MSconfig.h"
00014 #endif
00015 
00016 #include "QtApp.h"
00017 
00018 #include "CanvasWindow.h"
00019 #include "QtFileDialog.h"
00020 #include "WindowController.h"
00021 
00022 using std::string;
00023 
00024 QtApp * QtApp::s_instance = 0;
00025 
00026 QtApp::QtApp ( int argc, char** argv)
00027   : QApplication ( argc, argv )
00028 {
00029   CanvasWindow::resetFontSize ();
00030 
00031   s_instance = this;
00032 }
00033 
00034 QtApp::~QtApp ()
00035 {
00036 }
00037 
00038 QtApp * QtApp::instance ()
00039 {
00040   return s_instance;
00041 }
00042 
00045 void QtApp::setFirstWindow ()
00046 {
00047   WindowController * wc = WindowController::instance ();
00048   wc -> setFirstWindow ();
00049 
00050   int count = argc ();
00051   char ** args = argv ();
00052 
00053   for ( int i = 1; i < count; i++ ) {
00054     const string arg ( args[i] );
00055     string::size_type pos = arg.find_last_of ( '.' );
00056     if ( pos == string::npos ) continue;
00057     string suffix = arg.substr ( pos );
00058 
00059     if ( QtFileDialog::isDocSuffix ( suffix ) ) {
00060       CanvasWindow * window = new CanvasWindow ();
00061       try {
00062         window -> initFromFile ( arg );
00063       }
00064       catch ( ... ) {
00065       }
00066     }
00067 
00068     if ( QtFileDialog::isTextSuffix ( suffix ) ) {
00069       CanvasWindow * window = new CanvasWindow ();
00070       QtFileDialog::openTextTuple ( arg );
00071       window->setCaption ();
00072       window->show();
00073     }
00074   }
00075 }
00076 
00077 CanvasWindow * QtApp::currentCanvas ()
00078 {
00079   return WindowController::instance() -> currentCanvas();
00080 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3