void MainWindow::OpenImage(const QString &fileName)
{
	QScrollArea* area = new QScrollArea();
	ImageWidget* img = new ImageWidget();

	// Nur les- und schreibbare Bildformate werden unterstützt
	if (img->OpenImage(fileName)) {
		QString shortFileName = ParseFileName(fileName);
		shortFileName = shortFileName.mid(0, shortFileName.lastIndexOf('.'));

		// Bild in die ScrollArea laden
		area->setWidget(img);
		area->setStyleSheet("background: qlineargradient(x1: 0, y0: 1, x2:1, y2: 0, stop: 0.96 #383838, stop: 0.99 #2e2e2e);");

		// neuen Tab hinzufügen
		int index = ui->imagetab->addTab(area, shortFileName);
		ui->imagetab->setTabToolTip(index, shortFileName);
		ui->imagetab->setCurrentIndex(index);

		// schließlich Signalhandler setzen
		connect(this, SIGNAL(Arguments(QHash<QString,QString>)), img, SLOT(Arguments(QHash<QString,QString>)));
		connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>)), img, SLOT(Operation(IOperation*,QHash<QString,QString>)));
		connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>,OperationType)), img, SLOT(Operation(IOperation*,QHash<QString,QString>,OperationType)));
		emit Operation(mOperation, GetArgs());
	}
Beispiel #2
0
    FileInfo ParseFileFullPathName(const wchar_t *fileFullPathName)
	{
        FileInfo info;
		//file path & name
		swprintf_s(info.m_FullPathName, MAX_PATH, fileFullPathName);

		//file path
		swprintf_s(info.m_FilePath, MAX_PATH, info.m_FullPathName);
		PathRemoveFileSpecW(info.m_FilePath);
				
		//get video file short name
		wchar_t* _pch2 = wcsrchr(info.m_FullPathName, L'\\');
		if ( _pch2 )
			wcscpy_s(info.m_FileName, MAX_PATH, _pch2+1);
		else
			wmemset(info.m_FileName, L'\0', MAX_PATH);

		// Parse file name into prefix and suffix
		if ( !ParseFileName(info.m_FileName, info.m_FileNameWithoutExt, info.m_FileExt) )
		{
			wmemset(info.m_FileNameWithoutExt, L'\0', MAX_PATH);
			wmemset(info.m_FileExt, L'\0', VIDEOFILE_EXT_LEN);
		}

        return info;
	}
Beispiel #3
0
NS_IMETHODIMP
nsBaseURLParser::ParseFilePath(const char *filepath, PRInt32 filepathLen,
                               PRUint32 *directoryPos, PRInt32 *directoryLen,
                               PRUint32 *basenamePos, PRInt32 *basenameLen,
                               PRUint32 *extensionPos, PRInt32 *extensionLen)
{
    NS_PRECONDITION(filepath, "null pointer");

    if (filepathLen < 0)
        filepathLen = strlen(filepath);

    if (filepathLen == 0) {
        SET_RESULT(directory, 0, -1);
        SET_RESULT(basename, 0, 0); // assume a zero length file basename
        SET_RESULT(extension, 0, -1);
        return NS_OK;
    }

    const char *p;
    const char *end = filepath + filepathLen;

    // search backwards for filename
    for (p = end - 1; *p != '/' && p > filepath; --p)
        ;
    if (*p == '/') {
        // catch /.. and /.
        if ((p+1 < end && *(p+1) == '.') &&
                (p+2 == end || (*(p+2) == '.' && p+3 == end)))
            p = end - 1;
        // filepath = <directory><filename>.<extension>
        SET_RESULT(directory, 0, p - filepath + 1);
        ParseFileName(p + 1, end - (p + 1),
                      basenamePos, basenameLen,
                      extensionPos, extensionLen);
        OFFSET_RESULT(basename, p + 1 - filepath);
        OFFSET_RESULT(extension, p + 1 - filepath);
    }
    else {
        // filepath = <filename>.<extension>
        SET_RESULT(directory, 0, -1);
        ParseFileName(filepath, filepathLen,
                      basenamePos, basenameLen,
                      extensionPos, extensionLen);
    }
    return NS_OK;
}
Beispiel #4
0
void SimpleChess::Console::Log(const unsigned short line, const char* file, const char* function, const char* format, ...) {
	va_list args;
	va_start(args, format);
	Log("%11s:%-4d [%s] ", ParseFileName(file).c_str(), line, function);
	vprintf(format, args);
	if (format[strlen(format) - 1] != '\n') {
		putchar('\n');
	}
	va_end(args);
}
Beispiel #5
0
OpenUtility::CTexture::CTextureLoader* OpenUtility::CTexture::GetLoader(const char *file)
{
	OpenUtility::CStream dir,fileName,ext;

	InitTextureLoader();
	ParseFileName(file,dir,fileName,ext);
	for (unsigned int i=0;i<Loaders.GetSize();i++)
	{
		if (Loaders[i]->IsCapable(ext)) return(Loaders[i]);
	}
	return(NULL);
}
Beispiel #6
0
void SimpleChess::Console::Error(const unsigned short line, const char* file, const char* function, const bool leave, const char* format, ...) {
	va_list args;
	va_start(args, format);
	Log("%11s:%-4d [%s] ", ParseFileName(file).c_str(), line, function);
	vfprintf(stderr, format, args);
	if (format[strlen(format) - 1] != '\n') {
		fputc('\n', stderr);
	}

	va_end(args);
	if (leave) {
		exit(1);
	}
}
int main (int argc, char *argv[])
     {
     static ULONG flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU  |
                                 FCF_SIZEBORDER    | FCF_MINMAX   |
                                 FCF_SHELLPOSITION | FCF_TASKLIST |
                                 FCF_MENU ;
     HMQ          hmq ;
     HWND         hwndFrame, hwndClient ;
     QMSG         qmsg ;

               // Check for filename parameter and copy to szFileName

     if (argc > 1)
          ParseFileName (szFileName, argv [1]) ;

               // Continue normally
     
     hab = WinInitialize (0) ;
     hmq = WinCreateMsgQueue (hab, 0) ;

     WinRegisterClass (hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0) ;

     hwndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE,
                                     &flFrameFlags, szClientClass, NULL,
                                     0L, 0, ID_RESOURCE, &hwndClient) ;

     if (hwndFrame != NULLHANDLE)
          {
          while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0))
               WinDispatchMsg (hab, &qmsg) ;

          WinDestroyWindow (hwndFrame) ;
          }

     WinDestroyMsgQueue (hmq) ;
     WinTerminate (hab) ;
     return 0 ;
     }
Beispiel #8
0
int ReadNextLineScript( TASK *pTask, FILE* fd )
{
    int i=0, bytes = 0;
    char buf[2048]= {0}, *p;
    p = buf;

    while ( !feof( fd) )
    {
        pTask->script_line++;
        bytes = 0;
        memset( buf, 0x0, sizeof(buf) );
        //read a line
        while ( !feof( fd ) && bytes<sizeof(buf)-1 )
        {
            if ( fread( buf+bytes, 1, 1, fd ) == 0 ) break;
            if ( buf[bytes] == '\n' ) break;
            bytes++;
        }
        if ( feof( fd ) && bytes == 0 ) 	return 0;
        buf[bytes] = 0x0;
        //skip white space
        while ( i < bytes && buf[i] && ( buf[i]==' ' || buf[i]=='\t' || buf[i] =='\a' ) ) i++;

        //skip a blank or comment line
        if ( buf[i] == 0x0 || buf[i] == '#' )  continue;

        if ( ( p = strstr( buf+i, "task" ) )!= NULL )
        {
            pTask->task = ParseTaskArg( p+5 );
        } else if ( ( p = strstr( buf+i, "output_format" ) )!= NULL )
        {
            pTask->output_format = ParseArgOption( p+14 );
        } else if ( ( p = strstr( buf+i, "output_file" ) )!= NULL )
        {
            ParseFileName( ( p+12 ), pTask->output_file, sizeof(pTask->output_file) );
        } else if ( ( p = strstr( buf+i, "input_file" ) )!= NULL )
        {
            int len = ParseFileName( p+11, pTask->input_file, sizeof(pTask->input_file) );
            p += 11+len;
            while ( p < buf+sizeof(buf)-1 && *p && (*p==' '||*p== '\t' )) p++;
            if ( *p )
                strncpy( pTask->channel_desc, p, sizeof( pTask->channel_desc ));
            else
                pTask->channel_desc[0] =0x0;
            if ( len )
                return 1;
        } else if (  strstr( buf+i, "=" ) == NULL )
        {
            int len;
            p = buf+i;
            len = ParseFileName( p, pTask->input_file, sizeof(pTask->input_file) );
            p += len;
            while ( p < buf+sizeof(buf)-1 && *p && (*p==' '||*p== '\t' ) ) p++;
            if ( *p )
                strncpy( pTask->channel_desc, p, sizeof( pTask->channel_desc ));
            else
                pTask->channel_desc[0] =0x0;
            if ( len )
                return 1;
        }


    }
    return 0;
}
MRESULT EXPENTRY OpenDlgProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static CHAR szCurrentPath [CCHMAXPATH], szBuffer [CCHMAXPATH] ;
     INT         iSelect ;

     switch (msg)
          {
          case WM_INITDLG:
               FillDirListBox (hwnd, szCurrentPath) ;
               FillFileListBox (hwnd) ;

               WinSendDlgItemMsg (hwnd, IDD_FILEEDIT, EM_SETTEXTLIMIT,
                                        MPFROM2SHORT (CCHMAXPATH, 0), NULL) ;
               return 0 ;

          case WM_CONTROL:
               if (SHORT1FROMMP (mp1) == IDD_DIRLIST ||
                   SHORT1FROMMP (mp1) == IDD_FILELIST)
                    {
                    iSelect = (USHORT) WinSendDlgItemMsg (hwnd,
                                                  SHORT1FROMMP (mp1),
                                                  LM_QUERYSELECTION, 0L, 0L) ;

                    WinSendDlgItemMsg (hwnd, SHORT1FROMMP (mp1),
                                       LM_QUERYITEMTEXT,
                                       MPFROM2SHORT (iSelect, sizeof szBuffer),
                                       MPFROMP (szBuffer)) ;
                    }

               switch (SHORT1FROMMP (mp1))             // Control ID
                    {
                    case IDD_DIRLIST:
                         switch (SHORT2FROMMP (mp1))   // notification code
                              {
                              case LN_ENTER:
                                   if (szBuffer [0] == ' ')
                                        DosSetDefaultDisk (szBuffer [1] - '@');
                                   else
                                        DosSetCurrentDir (szBuffer) ;

                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;

                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT, "") ;
                                   return 0 ;
                              }
                         break ;

                    case IDD_FILELIST:
                         switch (SHORT2FROMMP (mp1))   // notification code
                              {
                              case LN_SELECT:
                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT,
                                                      szBuffer) ;
                                   return 0 ;

                              case LN_ENTER:
                                   ParseFileName (szFileName, szBuffer) ;
                                   WinDismissDlg (hwnd, TRUE) ;
                                   return 0 ;
                              }
                         break ;
                    }
               break ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case DID_OK:
                         WinQueryDlgItemText (hwnd, IDD_FILEEDIT,
                                              sizeof szBuffer, szBuffer) ;

                         switch (ParseFileName (szCurrentPath, szBuffer))
                              {
                              case 0:
                                   WinAlarm (HWND_DESKTOP, WA_ERROR) ;
                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;
                                   return 0 ;

                              case 1:
                                   FillDirListBox (hwnd, szCurrentPath) ;
                                   FillFileListBox (hwnd) ;
                                   WinSetDlgItemText (hwnd, IDD_FILEEDIT, "") ;
                                   return 0 ;

                              case 2:
                                   strcpy (szFileName, szCurrentPath) ;
                                   WinDismissDlg (hwnd, TRUE) ;
                                   return 0 ;
                              }
                         break ;

                    case DID_CANCEL:
                         WinDismissDlg (hwnd, FALSE) ;
                         return 0 ;
                    }
               break ;
          }
     return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
     }