// The main() function for the Universal Integration(tm) // [standalone] version of P4QTree. //Please set tabs to 4 spaces. #include <clientapi.h> #include <qapplication.h> #include <qcanvas.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qtooltip.h> #include "qtreeitem.h" #include "changesorter.h" #include "filehead.h" #include "filelogcache.h" #include "clientchangeuser.h" #include "qtreechangenum.h" #include "qtreechangebar.h" #include "clientjobdescuser.h" #include "qtreejobtext.h" #include "qtreejobbar.h" #include "qtreerevtext.h" #include "qtreerevball.h" #include "qtreefiletext.h" #include "qtreefilestripe.h" #include "qtreearrow.h" #include "qtreecanvas.h" #include "qtreetooltip.h" #define QTREEWINDOW_H #include "qtreewindow.h" int qtrcol, barwidth; bool console; bool namesort; int main ( int argc, char* argv[] ) { QApplication myapp( argc, argv ); // Initialize the vars we'll be passing in. StrBuf* pathname = NULL; ClientApi* client = new ClientApi(); Error* error = new Error(); char* cfile = NULL; char* outfile = NULL; namesort = false; console = false; // Skip the app name. argc--; argv++; // Parse arguments. while ( argc > 0 && argv[0][0] == '-' ) { switch ( argv[0][1] ) { // First, cases for global opts. case 'p': if ( argc == 1 ) { error->Set( E_FATAL, "Must specify a port after -p flag!" ); break; } client->SetPort( argv[1] ); argc--; argv++; break; case 'u': if ( argc == 1 ) { error->Set( E_FATAL, "Must specify a user after -u flag!" ); break; } client->SetUser( argv[1] ); argc--; argv++; break; case 'P': if ( argc == 1 ) { error->Set( E_FATAL, "Must specify password after -P flag!" ); break; } client->SetPassword( argv[1] ); argc--; argv++; break; case 'c': if ( argc == 1 ) { error->Set( E_FATAL, "Must specify a client after -c flag!" ); break; } client->SetClient( argv[1] ); argc--; argv++; break; case 'd': if (argc == 1) { error->Set( E_FATAL, "Must specify CWD after -d flag!" ); break; } client->SetCwd( argv[1] ); argc--; argv++; break; case 'H': if (argc == 1) { error->Set( E_FATAL, "Must specify hostname after -H flag!" ); break; } client->SetHost( argv[1] ); argc--; argv++; break; case 'F': //Not a standard Perforce g-opt - this is the cache file. if ( argc == 1 ) { error->Set( E_FATAL, "Specify a local file with the -F flag!" ); break; } cfile = argv[1]; argc--; argv++; break; case 'o': //Another custom option - output to file and quit. console = true; if ( argc == 1 ) { error->Set( E_FATAL, "Specify a filename with the -o flag!" ); break; } outfile = argv[1]; argc--; argv++; break; // Other miscellaneous flags. case 'b': case 'e': case 'j': //nop - leave for backwards compatibility break; //Alphabetical name sort. case 'n': namesort = true; break; // Usage dialog. case 'h': QTreeWindow::UsageDialog( NULL ); //fall through and exit case '!': exit( 0 ); default: // Error message. StrBuf* buf = new StrBuf(); buf->Append( "Invalid option " ); buf->Append( argv[0] ); error->Set( E_FATAL, buf->Text() ); break; } argc--; argv++; } if ( argc == 0 ) error->Set( E_FATAL, "You must specify a file.\n" ); if ( error->IsFatal() && console ) { StrBuf msg; error->Fmt( &msg ); fprintf( stderr, "P4QTree Error:\n%s", msg.Text() ); return 1; } if ( error->IsFatal() && !console ) { StrBuf msg; error->Fmt( &msg ); QMessageBox::critical ( NULL, "P4QTree Error", msg.Text(), QMessageBox::Abort, QMessageBox::NoButton, QMessageBox::NoButton ); return 1; } // Create the window! QTreeWindow* mywindow = new QTreeWindow ( NULL, argv[0], client, error, false, cfile ); if ( mywindow->IsEmpty() && error->IsFatal() ) return mywindow->HandleFatalError(); // If -o was specified, just dump the PNG and exit. if ( outfile && !mywindow->IsEmpty() ) { mywindow->SaveImage( outfile ); return 0; } if ( mywindow->IsEmpty() ) { mywindow->setMaximumSize( 200, 200 ); mywindow->setGeometry( 100, 100, 200, 200 ); mywindow->show(); mywindow->HandleError(); } // All good! Pass control to the window. myapp.setMainWidget( mywindow ); return myapp.exec(); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#7 | 4450 | Sam Stafford |
Slight refactoring of "name sort" code... this was to lead to an implementation of "directory graphing" but it didn't pan out. Will need to kludge more than previously thought to make that happen. |
||
#6 | 4428 | Sam Stafford |
Suppress error dialogs if "-o" option specified - dump to stderr instead. (This was a quick hack - hopefully it works.) |
||
#5 | 4419 | Sam Stafford |
Framework for command line alphabetical sort option. No functional change (still need to implement the sort algorithm). |
||
#4 | 4410 | Sam Stafford |
New feature for Laura: "-o OUTPUT" option. When P4QTree is invoked with this option, it'll attempt to dump a PNG file of the graph and then exit. Along the way I removed the silly SVG format thing and switched it back to PNG - nobody can read SVG anyway. Caveat: to write to PNG format, it needs to load the entire image into memory as an uncompressed pixmap, so a large graph very well might not fit in memory. If that happens, you should get a friendly error message and the operation will fail. I can't imagine anybody outside these walls having a use for this option, so I won't bother documenting it. |
||
#3 | 2947 | Sam Stafford |
Give P4QTree the ability to read filelog data from a supplied text file. The syntax is: P4QTree [g-opts] [-F cachefile] depotfile The data in the supplied file will be read before the server is queried for a given filelog. If a required filelog is not found in the file, the server will be queried instead. The most handy application for this that I can see is quickly graphing integ scenarios based on customer-supplied (or even manually-generated) filelogs, when for whatever reason it's not feasible to access the server directly. |
||
#2 | 2584 | Sam Stafford |
Make minimum canvas width more dynamic - create a dummy CanvasText and use that to guesstimate minimum width. |
||
#1 | 2377 | Sam Stafford | P4QTree. |