| 136 | } |
| 137 | |
| 138 | void |
| 139 | DocumentWindow::registerFileType(const QString& documentId, |
| 140 | const QString& fileTypeName, |
| 141 | const QString& fileExtension, |
| 142 | qint32 appIconIndex, |
| 143 | bool registerForDDE, |
| 144 | DdeCommands commands) |
| 145 | { |
| 146 | // first register the type ID of our server |
| 147 | if ( !SetHkcrUserRegKey(documentId, fileTypeName) ) { |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | if ( !SetHkcrUserRegKey( QString::fromUtf8("%1\\DefaultIcon").arg(documentId), |
| 152 | QString::fromUtf8("\"%1\",%2").arg( QDir::toNativeSeparators( qApp->applicationFilePath() ) ).arg(appIconIndex) ) ) { |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | m_registerForDDE = registerForDDE; |
| 157 | |
| 158 | if (commands & DDEOpen) { |
| 159 | registerCommand( QString::fromUtf8("Open"), documentId, QString::fromUtf8(" %1"), QString::fromUtf8("[open(\"%1\")]") ); |
| 160 | } |
| 161 | if (commands & DDENew) { |
| 162 | registerCommand( QString::fromUtf8("New"), documentId, QString::fromUtf8("-new %1"), QString::fromUtf8("[new(\"%1\")]") ); |
| 163 | } |
| 164 | if (commands & DDEPrint) { |
| 165 | registerCommand( QString::fromUtf8("Print"), documentId, QString::fromUtf8("-print %1"), QString::fromUtf8("[print(\"%1\")]") ); |
| 166 | } |
| 167 | |
| 168 | LONG lSize = _MAX_PATH * 2; |
| 169 | wchar_t szTempBuffer[_MAX_PATH * 2]; |
| 170 | LONG lResult = ::RegQueryValueW(HKEY_CLASSES_ROOT, |
| 171 | (const wchar_t*)fileExtension.utf16(), |
| 172 | szTempBuffer, |
| 173 | &lSize); |
| 174 | QString temp = QString::fromUtf16( (unsigned short*)szTempBuffer ); |
| 175 | |
| 176 | if ( (lResult != ERROR_SUCCESS) || temp.isEmpty() || (temp == documentId) ) { |
| 177 | // no association for that suffix |
| 178 | if ( !SetHkcrUserRegKey(fileExtension, documentId) ) { |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | SetHkcrUserRegKey( QString::fromUtf8("%1\\ShellNew").arg(fileExtension), QLatin1String(""), QLatin1String("NullFile") ); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void |
| 187 | DocumentWindow::registerCommand(const QString& command, |
nothing calls this directly
no test coverage detected