Various patches: Better windows support, branch sorting, Freedesktop support
authorinsilmaril
Mon, 22 Oct 2007 09:50:08 +0000
changeset 6086cdc2e7b1937
parent 607 53c66cb9f5bd
child 609 6fdccfe13a54
Various patches: Better windows support, branch sorting, Freedesktop support
demos/vym-projectplan.vym
mainwindow.cpp
mainwindow.h
mapeditor.cpp
mapeditor.h
version.h
vym.pro
     1.1 Binary file demos/vym-projectplan.vym has changed
     2.1 --- a/mainwindow.cpp	Mon Oct 22 09:50:03 2007 +0000
     2.2 +++ b/mainwindow.cpp	Mon Oct 22 09:50:08 2007 +0000
     2.3 @@ -20,6 +20,19 @@
     2.4  #include "texteditor.h"
     2.5  #include "warningdialog.h"
     2.6  
     2.7 +#if defined(Q_OS_WIN32)
     2.8 +// Define only this structure as opposed to
     2.9 +// including full 'windows.h'. FindWindow
    2.10 +// clashes with the one in Win32 API.
    2.11 +typedef struct _PROCESS_INFORMATION
    2.12 +{
    2.13 +  long hProcess;
    2.14 +  long hThread;
    2.15 +  long dwProcessId;
    2.16 +  long dwThreadId;
    2.17 +} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
    2.18 +#endif
    2.19 +
    2.20  extern TextEditor *textEditor;
    2.21  extern Main *mainWindow;
    2.22  extern QString tmpVymDir;
    2.23 @@ -77,7 +90,7 @@
    2.24  
    2.25  	// Create unique temporary directory
    2.26  	bool ok;
    2.27 -	tmpVymDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
    2.28 +	tmpVymDir=makeTmpDir (ok,"vym");
    2.29  	if (!ok)
    2.30  	{
    2.31  		qWarning ("Mainwindow: Could not create temporary directory, failed to start vym");
    2.32 @@ -135,12 +148,20 @@
    2.33  		// application to open URLs
    2.34  		p="/mainwindow/readerURL";
    2.35  		#if defined(Q_OS_LINUX)
    2.36 -			s=settings.value (p,"konqueror").toString();
    2.37 +			s=settings.value (p,"xdg-open").toString();
    2.38  		#else
    2.39  			#if defined(Q_OS_MACX)
    2.40  				s=settings.value (p,"/usr/bin/open").toString();
    2.41 -			#else
    2.42 -				s=settings.value (p,"mozilla");
    2.43 +
    2.44 +            #else
    2.45 +                #if defined(Q_OS_WIN32)
    2.46 +                    // Assume that system has been set up so that
    2.47 +                    // Explorer automagically opens up the URL
    2.48 +                    // in the user's preferred browser.
    2.49 +                    s=settings.value (p,"explorer").toString();
    2.50 +                #else
    2.51 +					s=settings.value (p,"mozilla").toString();
    2.52 +				#endif
    2.53  			#endif
    2.54  		#endif
    2.55  		settings.setValue( p,s);
    2.56 @@ -148,7 +169,7 @@
    2.57  		// application to open PDFs
    2.58  		p="/mainwindow/readerPDF";
    2.59  		#if defined(Q_OS_LINUX)
    2.60 -			s=settings.value (p,"acroread").toString();
    2.61 +			s=settings.value (p,"xdg-open").toString();
    2.62  		#else
    2.63  			#if defined(Q_OS_MACX)
    2.64  				s=settings.value (p,"/usr/bin/open").toString();
    2.65 @@ -582,6 +603,11 @@
    2.66  	editMenu->addAction (a);
    2.67  	actionEditMoveDown=a;
    2.68  	
    2.69 +	a = new QAction( QPixmap(iconPath+"editsort.png" ), tr( "Sort children","Edit menu" ), this );
    2.70 +	connect( a, SIGNAL( activated() ), this, SLOT( editSortChildren() ) );
    2.71 +	a->setEnabled (true);
    2.72 +	a->addTo( tb );
    2.73 +	actionEditSortChildren=a;
    2.74  
    2.75  	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ),this);
    2.76  	a->setShortcut ( Qt::Key_ScrollLock );
    2.77 @@ -1784,7 +1810,7 @@
    2.78  
    2.79  		// Create temporary directory for packing
    2.80  		bool ok;
    2.81 -		QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
    2.82 +		QString tmpMapDir=makeTmpDir (ok,"vym-pack");
    2.83  		if (!ok)
    2.84  		{
    2.85  			QMessageBox::critical( 0, tr( "Critical Load Error" ),
    2.86 @@ -1863,7 +1889,7 @@
    2.87  			{
    2.88  				me->setFilePath (fn);
    2.89  				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
    2.90 -				if (fn.left(9)!="/tmp/vym-")
    2.91 +				if (!isInTmpDir (fn))
    2.92  				{
    2.93  					// Only append to lastMaps if not loaded from a tmpDir
    2.94  					// e.g. imported bookmarks are in a tmpDir
    2.95 @@ -2008,7 +2034,7 @@
    2.96  			{
    2.97  				// Create temporary directory for packing
    2.98  				bool ok;
    2.99 -				QString tmpMapDir=makeUniqueDir (ok,"/tmp/vym-XXXXXX");
   2.100 +				QString tmpMapDir=makeTmpDir (ok,"vym-zip");
   2.101  				if (!ok)
   2.102  				{
   2.103  					QMessageBox::critical( 0, tr( "Critical Load Error" ),
   2.104 @@ -2536,7 +2562,12 @@
   2.105  					tr("Please use Settings->")+tr("Set application to open an URL"));
   2.106  				return;
   2.107  			}
   2.108 +#if defined(Q_OS_WIN32)
   2.109 +            // There's no sleep in VCEE, replace it with Qt's QThread::wait().
   2.110 +            this->thread()->wait(3000);
   2.111 +#else
   2.112  			sleep (3);
   2.113 +#endif
   2.114  		}
   2.115  		if (browser.contains("konqueror"))
   2.116  		{
   2.117 @@ -2546,11 +2577,21 @@
   2.118  				// Try to open new tab in existing konqueror started previously by vym
   2.119  				p=new QProcess (this);
   2.120  				args.clear();
   2.121 -				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
   2.122 -					"konqueror-mainwindow#1"<< 
   2.123 -					"newTab" << 
   2.124 +#if defined(Q_OS_WIN32)
   2.125 +                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
   2.126 +                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
   2.127 +				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
   2.128 +					"konqueror-mainwindow#1"<<
   2.129 +					"newTab" <<
   2.130  					urls.at(i);
   2.131 +#else
   2.132 +				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
   2.133 +					"konqueror-mainwindow#1"<<
   2.134 +					"newTab" <<
   2.135 +					urls.at(i);
   2.136 +#endif
   2.137  				p->start ("dcop",args);
   2.138 +				cout << args.join(" ").ascii()<<endl;
   2.139  				if ( !p->waitForStarted() ) success=false;
   2.140  			}
   2.141  			if (!success)
   2.142 @@ -2819,6 +2860,12 @@
   2.143  		currentMapEditor()->moveBranchDown();
   2.144  }
   2.145  
   2.146 +void Main::editSortChildren()
   2.147 +{
   2.148 +	if (currentMapEditor())
   2.149 +		currentMapEditor()->sortChildren();
   2.150 +}
   2.151 +
   2.152  void Main::editToggleScroll()
   2.153  {
   2.154  	if (currentMapEditor())
   2.155 @@ -3631,6 +3678,9 @@
   2.156  	#if defined(Q_OS_MACX)
   2.157  		searchList << "./vym.app/Contents/Resources/doc";
   2.158  	#else
   2.159 +		#if defined(VYM_DOCDIR)
   2.160 +			searchList << VYM_DOCDIR;
   2.161 +		#endif
   2.162  		// default path in SUSE LINUX
   2.163  		searchList <<"/usr/share/doc/packages/vym";
   2.164  	#endif
   2.165 @@ -3757,3 +3807,31 @@
   2.166  	}	
   2.167  }
   2.168  
   2.169 +
   2.170 +
   2.171 +//////////////////////////////////
   2.172 +/*
   2.173 +@@ -2544,18 +2576,27 @@
   2.174 + 				// Try to open new tab in existing konqueror started previously by vym
   2.175 + 				p=new QProcess (this);
   2.176 + 				args.clear();
   2.177 +-				args<< QString("konqueror-%1").arg(procBrowser->pid())<< 
   2.178 +-					"konqueror-mainwindow#1"<< 
   2.179 +-					"newTab" << 
   2.180 ++#if defined(Q_OS_WIN32)
   2.181 ++                // In Win32, pid is not a longlong, but a pointer to a _PROCESS_INFORMATION structure.
   2.182 ++                // Redundant change in Win32, as there's no konqueror, but I wanted to follow the original logic.
   2.183 ++				args<< QString("konqueror-%1").arg(procBrowser->pid()->dwProcessId)<<
   2.184 ++					"konqueror-mainwindow#1"<<
   2.185 ++					"newTab" <<
   2.186 + 					urls.at(i);
   2.187 ++#else
   2.188 ++				args<< QString("konqueror-%1").arg(procBrowser->pid())<<
   2.189 ++					"konqueror-mainwindow#1"<<
   2.190 ++					"newTab" <<
   2.191 ++					urls.at(i);
   2.192 ++#endif
   2.193 + 				p->start ("dcop",args);
   2.194 + 				if ( !p->waitForStarted() ) success=false;
   2.195 + 			}
   2.196 +*/			
     3.1 --- a/mainwindow.h	Mon Oct 22 09:50:03 2007 +0000
     3.2 +++ b/mainwindow.h	Mon Oct 22 09:50:08 2007 +0000
     3.3 @@ -126,6 +126,7 @@
     3.4  	void editMapInfo();
     3.5      void editMoveUp();	
     3.6      void editMoveDown();	
     3.7 +	void editSortChildren();
     3.8      void editToggleScroll();
     3.9      void editUnscrollChilds();
    3.10      void editNewBranch();
    3.11 @@ -254,6 +255,7 @@
    3.12  	QAction *actionEditPaste;
    3.13  	QAction *actionEditMoveUp;
    3.14  	QAction *actionEditMoveDown;
    3.15 +	QAction *actionEditSortChildren;
    3.16  	QAction *actionEditToggleScroll;
    3.17  	QAction* actionEditOpenURL;
    3.18  	QAction* actionEditOpenURLTab;
     4.1 --- a/mapeditor.cpp	Mon Oct 22 09:50:03 2007 +0000
     4.2 +++ b/mapeditor.cpp	Mon Oct 22 09:50:08 2007 +0000
     4.3 @@ -2174,7 +2174,7 @@
     4.4  void MapEditor::addMapInsertInt (const QString &path, int pos)
     4.5  {
     4.6  	BranchObj *sel=xelection.getBranch();
     4.7 -	if (sel);
     4.8 +	if (sel)
     4.9  	{
    4.10  		QString pathDir=path.left(path.findRev("/"));
    4.11  		QDir d(pathDir);
    4.12 @@ -2330,6 +2330,21 @@
    4.13  	}	
    4.14  }
    4.15  
    4.16 +void MapEditor::sortChildren()
    4.17 +{
    4.18 +	BranchObj* bo=xelection.getBranch();
    4.19 +	if (bo)
    4.20 +	{
    4.21 +		if(bo->countBranches()>1)
    4.22 +		{
    4.23 +			bo->sortChildren();
    4.24 +			saveStateChangingPart(bo,bo, "sortChildren ()",QString("Sort children of %1").arg(getName(bo)));
    4.25 +			mapCenter->reposition();
    4.26 +			ensureSelectionVisible();
    4.27 +		}
    4.28 +	}
    4.29 +}
    4.30 +
    4.31  void MapEditor::linkTo(const QString &dstString)	
    4.32  {
    4.33  	FloatImageObj *fio=xelection.getFloatImage();
     5.1 --- a/mapeditor.h	Mon Oct 22 09:50:03 2007 +0000
     5.2 +++ b/mapeditor.h	Mon Oct 22 09:50:08 2007 +0000
     5.3 @@ -189,6 +189,7 @@
     5.4      void moveRel (const double &x, const double &y);
     5.5      void moveBranchUp();	//!< Move branch up
     5.6      void moveBranchDown();	//!< Move branch down
     5.7 +	void sortChildren();	//!< Sort children lexically
     5.8  private:	
     5.9  	void linkTo(const QString &);
    5.10  public:	
     6.1 --- a/version.h	Mon Oct 22 09:50:03 2007 +0000
     6.2 +++ b/version.h	Mon Oct 22 09:50:08 2007 +0000
     6.3 @@ -4,10 +4,10 @@
     6.4  #include <QString>
     6.5  
     6.6  #define __VYM_NAME "VYM"
     6.7 -#define __VYM_VERSION "1.10.1"
     6.8 +#define __VYM_VERSION "1.11.0"
     6.9  //#define __VYM_CODENAME "Codename: 1.10.0-RC-3"
    6.10  #define __VYM_CODENAME "Codename: development version"
    6.11 -#define __VYM_BUILD_DATE "September 30, 2007"
    6.12 +#define __VYM_BUILD_DATE "2007-10-19"
    6.13  
    6.14  
    6.15  bool checkVersion(const QString &);
     7.1 --- a/vym.pro	Mon Oct 22 09:50:03 2007 +0000
     7.2 +++ b/vym.pro	Mon Oct 22 09:50:08 2007 +0000
     7.3 @@ -3,6 +3,13 @@
     7.4  
     7.5  CONFIG	+= qt warn_on release debug
     7.6  CONFIG += x86 ppc
     7.7 +
     7.8 +# Manifest embedding was suggested by Qt docs somewhere...
     7.9 +win32: CONFIG += embed_manifest_exe
    7.10 +
    7.11 +# Without this, M_PI, and M_PI_2 won't be defined.
    7.12 +win32:DEFINES *= _USE_MATH_DEFINES
    7.13 +
    7.14  ICON =icons/vym.icns
    7.15  
    7.16  QT += qt3support
    7.17 @@ -121,26 +128,43 @@
    7.18  TRANSLATIONS += lang/vym_es.ts
    7.19  TRANSLATIONS += lang/vym_it.ts
    7.20  
    7.21 -count( INSTALLDIR, 0 ) {
    7.22 -	INSTALLDIR = /usr/local
    7.23 +isEmpty( PREFIX ) {
    7.24 +	PREFIX = /usr/local
    7.25 +	count( INSTALLDIR, 1 ) {
    7.26 +		PREFIX = $${INSTALLDIR}
    7.27 +		message( "Please use PREFIX instead of INSTALLDIR" )
    7.28 +	}
    7.29 +}
    7.30 +isEmpty( BINDIR ) {
    7.31 +	BINDIR = $${PREFIX}/bin
    7.32 +}
    7.33 +isEmpty( DATADIR ) {
    7.34 +	DATADIR = $${PREFIX}/share
    7.35 +}
    7.36 +isEmpty( DOCDIR ) {
    7.37 +	DOCDIR = $${DATADIR}/doc/packages/vym
    7.38 +}
    7.39 +isEmpty( DEMODIR ) {
    7.40 +	DEMODIR = $${DOCDIR}
    7.41  }
    7.42  
    7.43  message( "Installation directory" )
    7.44 -message( $$INSTALLDIR )
    7.45 +message( $$PREFIX )
    7.46  
    7.47  
    7.48 -target.path = $${INSTALLDIR}/bin
    7.49 +target.path = $${BINDIR}
    7.50  INSTALLS += target
    7.51  
    7.52  support.files = styles/ scripts/ icons/ flags/ lang/ macros/ exports/
    7.53 -support.path = $${INSTALLDIR}/share/vym
    7.54 +support.path = $${DATADIR}/vym
    7.55  INSTALLS += support 
    7.56  
    7.57 -doc.files = tex/vym.pdf 
    7.58 -doc.path = $${INSTALLDIR}/share/doc/packages/vym
    7.59 +doc.files = tex/vym.pdf
    7.60 +doc.path = $${DOCDIR}
    7.61  INSTALLS += doc
    7.62 +DEFINES += VYM_DOCDIR=\\\"$${DOCDIR}\\\"
    7.63  
    7.64  demo.files = demos/
    7.65 -demo.path = $${INSTALLDIR}/share/doc/packages/vym
    7.66 +demo.path = $${DEMODIR}
    7.67  INSTALLS += demo
    7.68