void InventoryWindow::CreateActions() { /* itemMenu_ = new QMenu(this); fileTransferMenu_ = new QMenu(this); connect(actionMenu_, SIGNAL(aboutToShow()), this, SLOT(UpdateActions())); */ // File transfer actions InventoryAction *actionUpload= new InventoryAction(tr("&Upload"), treeView_); actionUpload->setObjectName("Upload"); actionUpload->setStatusTip(tr("Upload file to your inventory")); connect(actionUpload, SIGNAL(triggered()), this, SLOT(Upload())); treeView_->addAction(actionUpload); InventoryAction *actionDownload = new InventoryAction(tr("&Download"), treeView_); actionDownload->setObjectName("Download"); actionDownload->setStatusTip(tr("Download assets to your hard drive")); connect(actionDownload, SIGNAL(triggered()), this, SLOT(Download())); treeView_->addAction(actionDownload); // Add separator InventoryAction *actionSeparator = new InventoryAction(treeView_); actionSeparator->setSeparator(true); treeView_->addAction(actionSeparator); // Inventory item actions. InventoryAction *actionDelete = new InventoryAction(tr("&Delete"), treeView_); actionDelete->setObjectName("Delete"); //actionDelete_->setShortcuts(QKeySequence::Delete); actionDelete->setStatusTip(tr("Delete this item")); connect(actionDelete, SIGNAL(triggered()), this, SLOT(DeleteItem())); treeView_->addAction(actionDelete); InventoryAction *actionRename = new InventoryAction(tr("&Rename"), treeView_); actionRename->setObjectName("Rename"); //actionRename_->setShortcuts(); actionRename->setStatusTip(tr("Rename this item")); connect(actionRename, SIGNAL(triggered()), this, SLOT(RenameItem())); treeView_->addAction(actionRename); /* InventoryAction *actionCut_ = new InventoryAction(tr("&Cut"), treeView_); actionDelete_->setShortcuts(QKeySequence::Cut); actionDelete_->setStatusTip(tr("Cut this item")); connect(actionCut_, SIGNAL(triggered()), this, SLOT(Test())); treeView_->addAction(actionCut_); InventoryAction *actionPaste_ = new InventoryAction(tr("&Paste"), treeView_); actionDelete_->setShortcuts(QKeySequence::Paste); actionDelete_->setStatusTip(tr("Paste this item")); connect(actionPaste_, SIGNAL(triggered()), this, SLOT(Test())); treeView_->addAction(actionPaste_); */ InventoryAction *actionNewFolder = new InventoryAction(tr("&New folder"), treeView_); actionNewFolder->setObjectName("NewFolder"); //actionDelete_->setShortcuts(QKeySequence::Delete); actionNewFolder->setStatusTip(tr("Create new folder")); connect(actionNewFolder, SIGNAL(triggered()), this, SLOT(AddFolder())); treeView_->addAction(actionNewFolder); InventoryAction *actionOpen = new InventoryAction(tr("&Open"), treeView_); actionOpen->setObjectName("Open"); //actionDelete_->setShortcuts(QKeySequence::Delete); actionOpen->setStatusTip(tr("Open this item")); connect(actionOpen, SIGNAL(triggered()), this, SLOT(OpenItem())); treeView_->addAction(actionOpen); InventoryAction *actionProperties= new InventoryAction(tr("&Properties"), treeView_); actionProperties->setObjectName("Properties"); //actionProperties_->setShortcuts(QKeySequence::Delete); actionProperties->setStatusTip(tr("View item properties")); connect(actionProperties, SIGNAL(triggered()), this, SLOT(OpenItemProperties())); treeView_->addAction(actionProperties); InventoryAction *actionCopyAssetReference = new InventoryAction(tr("&Copy asset reference"), treeView_); actionCopyAssetReference->setObjectName("CopyAssetReference"); //actionDelete_->setShortcuts(QKeySequence::Delete); actionCopyAssetReference->setStatusTip(tr("Copies asset reference to clipboard")); connect(actionCopyAssetReference, SIGNAL(triggered()), this, SLOT(CopyAssetReference())); treeView_->addAction(actionCopyAssetReference); }
void wxZEditNode::BuildInterface(wxGraphNode *pNode) { mEditingNode = pNode; BeginPanel(); if (mEditingNode) { mNodeName = mEditingNode->GetFunctionName(); AddFolder(_("Node")); AddTextEdit(_("Name"), &mNodeName, 200); #if 0 AddStatic("Comments"); AddScriptEdit(pNode->GetComment(), 2); if (pNode->GetType() == GNT_STATE) { AddFolder("Properties"); } #endif if (pNode->GetType() == GNT_MESSAGE) { AddFolder(_("Source code")); AddScriptEdit(pNode->GetCode(pNode->GetSubItem()), 2); } if (mEditingNode->GetType() == GNT_STATE) { wxString info; info = mNodeName+_(" > "); info += ((wxGraphNodeState*)mEditingNode)->mCurSelectedButton; SetScriptToEdit(info, pNode->GetCode(pNode->GetSubItem())); } } else { // editing tab extern wxNotebook * myNotebook; mNodeName = myNotebook->GetPageText(myNotebook->GetSelection()); AddFolder(_("FSM")); AddTextEdit(_("Name"), &mNodeName, 199); AddCheckBox(_("Add Raknet packet support"), &mScrollV->mbRaknetMessage); AddCheckBox(_("Tick has time parameter"), &mScrollV->mbTickHasTime); AddTextEdit(_("State base"), &mScrollV->mStateEnumBase); AddTextEdit(_("Message base"), &mScrollV->mMessageEnumBase); AddTextEdit(_("Output"), &mScrollV->mOutputFileName); std::vector<wxString> mStateList; mScrollV->FillNodeList(mStateList, GNT_STATE); if (!mStateList.empty()) { wxString mInitialStatesList; for (unsigned int i=0;i<mStateList.size()-1;i++) { mInitialStatesList += mStateList[i]+_("|"); } mInitialStatesList += mStateList[mStateList.size()-1]; if (mScrollV->mInitialState > (mStateList.size()-1) ) mScrollV->mInitialState = 0; AddCombo(_("Initial State"), mInitialStatesList.c_str(), &mScrollV->mInitialState); } AddFolder(_("Code")); AddStatic(_("Includes")); AddScriptEdit(mScrollV->GetIncludes(), 14); AddStatic(_("Member Variables")); AddScriptEdit(mScrollV->GetMemberVariables(), 14); AddStatic(_("Members Init")); AddScriptEdit(mScrollV->GetMembersInit(), 14); extern wxScriptEditPanel *mEditScriptPanel; mEditScriptPanel->SetScriptToEdit(wxT(""), NULL); } EndPanel(); }
int StructureManager::AddFirstEmpty(RNAStructure* structure) { int index; bool added = false; bool found = false; if (!m_structures && folders.empty()) { m_structures = (RNAStructure**)malloc(sizeof(RNAStructure*)); m_structures[0] = structure; m_structureCount = 1; added = true; AddFolder(structure, 0); found = true; return 0; } for (int i = 0; i < m_structureCount; ++i) { if (!m_structures[i]) { m_structures[i] = structure; index = i; added = true; break; } } if(!added) { m_structureCount++; m_structures = (RNAStructure**)realloc(m_structures, sizeof(RNAStructure*) * m_structureCount); m_structures[m_structureCount - 1] = structure; index = m_structureCount - 1; } for(unsigned int ui = 0; ui < folders.size(); ui++) { for(int j = 0; j < folders[ui]->structCount; j++) { if(folders[ui]->folderStructs[j] > -1 && SequenceCompare(m_structures[folders[ui]->folderStructs[j]], structure)) { folders[ui]->structCount++; if(folders[ui]->structCount >=128) folders[ui]->folderStructs = (int*)realloc(folders[ui]->folderStructs, sizeof(int) * folders[ui]->structCount); bool emptySlot = false; for(int i = 0; i < folders[ui]->structCount-1; i++) { if(folders[ui]->folderStructs[i] == -1) { folders[ui]->folderStructs[i] = index; emptySlot = true; break; } } if(!emptySlot) folders[ui]->folderStructs[folders[ui]->structCount - 1] = index; AddNewStructure(ui, index); if (folders[ui]->folderNameFileCount != NULL) sprintf(folders[ui]->folderNameFileCount, "%-.48s (%d)", folders[ui]->folderName, folders[ui]->structCount); found = true; break; } } if(found) break; } if(!found) { AddFolder(structure, index); } return index; }
void GuiResourceFolder::LoadResourceFolderFromXml(DelayLoadingList& delayLoadings, const WString& containingFolder, Ptr<parsing::xml::XmlElement> folderXml, collections::List<WString>& errors) { ClearItems(); ClearFolders(); FOREACH(Ptr<XmlElement>, element, XmlGetElements(folderXml)) { WString name; if(Ptr<XmlAttribute> nameAtt=XmlGetAttribute(element, L"name")) { name=nameAtt->value.value; } if(element->name.value==L"Folder") { if (name == L"") { errors.Add(L"A resource folder should have a name."); errors.Add( L"Format: RESOURCE, Row: " + itow(element->codeRange.start.row + 1) + L", Column: " + itow(element->codeRange.start.column + 1) + L", Message: A resource folder should have a name."); } else { Ptr<GuiResourceFolder> folder=new GuiResourceFolder; if(AddFolder(name, folder)) { WString newContainingFolder=containingFolder; Ptr<XmlElement> newFolderXml=element; if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content")) { if(contentAtt->value.value==L"Link") { folder->SetFileContentPath(XmlGetValue(element)); WString filePath = containingFolder + folder->GetFileContentPath(); WString text; if(LoadTextFile(filePath, text)) { if(auto parser=GetParserManager()->GetParser<XmlDocument>(L"XML")) { if(auto xml=parser->TypedParse(text, errors)) { newContainingFolder=GetFolderPath(filePath); newFolderXml=xml->rootElement; } } } else { errors.Add(L"Failed to load file \"" + filePath + L"\"."); } } } folder->LoadResourceFolderFromXml(delayLoadings, newContainingFolder, newFolderXml, errors); } else { errors.Add(L"Duplicated resource folder name \"" + name + L"\"."); } } } else if(element->name.value.Length() <= 3 || element->name.value.Sub(0, 4) != L"ref.") { WString relativeFilePath; WString filePath; if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content")) { if(contentAtt->value.value==L"File") { relativeFilePath = XmlGetValue(element); filePath = containingFolder + relativeFilePath; if(name==L"") { name=GetFileName(filePath); } } } Ptr<GuiResourceItem> item = new GuiResourceItem; if(AddItem(name, item)) { WString type = element->name.value; IGuiResourceTypeResolver* typeResolver = GetResourceResolverManager()->GetTypeResolver(type); IGuiResourceTypeResolver* preloadResolver = typeResolver; if(typeResolver) { if (!typeResolver->DirectLoadXml()) { WString preloadType = typeResolver->IndirectLoad()->GetPreloadType(); if (preloadType != L"") { preloadResolver = GetResourceResolverManager()->GetTypeResolver(preloadType); if (!preloadResolver) { errors.Add(L"Unknown resource resolver \"" + preloadType + L"\" of resource type \"" + type + L"\"."); } } } } else { errors.Add(L"Unknown resource type \"" + type + L"\"."); } if(typeResolver && preloadResolver) { if (auto directLoad = preloadResolver->DirectLoadXml()) { Ptr<DescriptableObject> resource; WString itemType = preloadResolver->GetType(); if (filePath == L"") { resource = directLoad->ResolveResource(element, errors); } else { item->SetFileContentPath(relativeFilePath); resource = directLoad->ResolveResource(filePath, errors); } if (typeResolver != preloadResolver) { if (auto indirectLoad = typeResolver->IndirectLoad()) { if(indirectLoad->IsDelayLoad()) { DelayLoading delayLoading; delayLoading.type = type; delayLoading.workingDirectory = containingFolder; delayLoading.preloadResource = item; delayLoadings.Add(delayLoading); } else if(resource) { resource = indirectLoad->ResolveResource(resource, 0, errors); itemType = typeResolver->GetType(); } } else { resource = 0; errors.Add(L"Resource type \"" + typeResolver->GetType() + L"\" is not a indirect load resource type."); } } item->SetContent(itemType, resource); } else { errors.Add(L"Resource type \"" + preloadResolver->GetType() + L"\" is not a direct load resource type."); } } if(!item->GetContent()) { RemoveItem(name); } } else { errors.Add(L"Duplicated resource item name \"" + name + L"\"."); } } }
/////////////////////////////////////////////////////////////////////////////// /// \brief /// Returns unmanaged data /// MgByteReader* MgUnmanagedDataManager::EnumerateUnmanagedData(CREFSTRING path, bool recursive, CREFSTRING type, CREFSTRING filter) { Ptr<MgByteReader> byteReader; MG_TRY() ACE_TRACE("MgUnmanagedDataManager::EnumerateUnmanagedData"); Ptr<MgPropertyCollection> unmanagedDataMappings = GetUnmanagedDataMappings(); if (NULL != unmanagedDataMappings.p) { // this XML follows the ResourceList-1.0.0.xsd schema string list = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; list += "<UnmanagedDataList xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"UnmanagedDataList-1.0.0.xsd\">\n"; // check arguments... // pull out the mapping name from the path // path must be in the form of: // "" // "[alias1]" // "[alias1]subfolder1" // "[alias1]subfolder1/" // "[alias1]subfolder1/subfolder2/" STRING mappingName = L"", subfolder = L""; if (!MgUnmanagedDataManager::ParsePath(path, mappingName, subfolder)) { MgStringCollection arguments; arguments.Add(L"1"); arguments.Add(path); throw new MgInvalidArgumentException(L"MgUnmanagedDataManager.EnumerateUnmanagedData", __LINE__, __WFILE__, &arguments, L"", NULL); } // type must be: // "FOLDERS" // "FILES" // "BOTH" bool storeFolders = ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Folders.c_str()) == 0 || ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Both.c_str()) == 0; bool storeFiles = ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Files.c_str()) == 0 || ACE_OS::strcasecmp(type.c_str(), MgResourceUnmanagedDataType::Both.c_str()) == 0; ACE_ASSERT(storeFolders || storeFiles); // filter is ignored if type = "FOLDERS" // filter can be: // "" // ".sdf" // ".sdf;.pdf;.shp" // "sdf" // "sdf;dwf;png" MgStringCollection filters; if (storeFiles) ParseFilter(filter, &filters); // are we looking in a specific path? if (!mappingName.empty()) { Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(unmanagedDataMappings->FindItem(mappingName)); if (stringProp != NULL) { // we have a match! STRING mappingDir = stringProp->GetValue(); // get the files and/or folders from that folder and subfolder (recursive) GetFilesAndFolders(list, mappingName, mappingDir, subfolder, &filters, storeFolders, storeFiles, recursive); } else { MgStringCollection arguments; arguments.Add(L"1"); arguments.Add(path); throw new MgInvalidArgumentException(L"MgUnmanagedDataManager.EnumerateUnmanagedData", __LINE__, __WFILE__, &arguments, L"", NULL); } } else { // getting files starting from virtual root (all mappings) // iterate thru mappings for (int i = 0; i < unmanagedDataMappings->GetCount(); i++) { Ptr<MgStringProperty> stringProp = dynamic_cast<MgStringProperty*>(unmanagedDataMappings->GetItem(i)); STRING mapName = stringProp->GetName(); STRING mapDir = stringProp->GetValue(); if (MgFileUtil::IsDirectory(mapDir)) { if (storeFolders) { MgDateTime createdDate = MgFileUtil::GetFileCreationTime(mapDir); MgDateTime modifiedDate = MgFileUtil::GetFileModificationTime(mapDir); INT32 numFolders = 0; INT32 numFiles = 0; GetNumberOfFilesAndSubfolders(mapDir, numFolders, numFiles); // add top-level mappings AddFolder(list, mapName, L"", L"", numFolders, numFiles, createdDate, modifiedDate); } if (recursive) GetFilesAndFolders(list, mapName, mapDir, L"", &filters, storeFolders, storeFiles, recursive); } } } list += "</UnmanagedDataList>"; Ptr<MgByteSource> byteSource = new MgByteSource( (unsigned char*)list.c_str(), (INT32)list.length()); byteSource->SetMimeType(MgMimeType::Xml); byteReader = byteSource->GetReader(); } MG_CATCH_AND_THROW(L"MgUnmanagedDataManager.EnumerateUnmanagedData") return byteReader.Detach(); }
void CCreateNewDatabase::RunEx() { //SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST); // reset values m_strQueryCreateItem = ""; m_iCreateItem = 0; m_strQueryUpdateItem = ""; m_iUpdateItem = 0; m_strQueryNoUpdateItem = ""; m_iNoUpdateItem = 0; // calculate last run time // Scheduler SallyAPI::Scheduler::CSchedulerManager* schedulerManager = SallyAPI::Scheduler::CSchedulerManager::GetInstance(); SYSTEMTIME lastRun = schedulerManager->GetLastSchedulerRun(m_pWindow, "dbcreator"); //Convert both to FILETIMEs m_ftLastRun.dwHighDateTime = 0; m_ftLastRun.dwLowDateTime = 0; SystemTimeToFileTime(&lastRun, &m_ftLastRun); m_strCreateDate = SallyAPI::Date::DateHelper::GetCurrentDateString(false); // set the database version m_pWindow->SetPropertyInt("databaseVersion", 4); std::string mediaDB = m_strMediaDirectory; mediaDB.append("media.db"); bool bFileExists = SallyAPI::File::FileHelper::FileExistsAndNotEmpty(mediaDB); SallyAPI::Database::CDatabaseConnection* dbconn = SallyAPI::Database::CDatabaseConnection::Open(mediaDB); dbconn->LockDatabase(); if (bFileExists == false) { // Create std::string queryCreate; queryCreate.append("CREATE TABLE media ( \ Filename TEXT UNIQUE, \ Album TEXT, \ Artist TEXT, \ Band TEXT, \ Title TEXT, \ Year TEXT, \ Genre TEXT, \ Track TEXT, \ Type varchar(1) NOT NULL, \ DeleteFlag INTEGER, \ Rating INTEGER, \ PlayTime INTEGER, \ Cover INTEGER, \ DBAddDate varchar(19) NOT NULL, \ FileCreateDate varchar(19) NOT NULL, \ LastPlayDate varchar(19) NOT NULL, \ AlbumArtist TEXT, \ Field1 TEXT, \ Field2 TEXT, \ PRIMARY KEY (Filename));"); try { SallyAPI::Database::CStatement* stmtCreate = dbconn->CreateStatement(); stmtCreate->Execute(queryCreate.c_str()); } catch (SallyAPI::Database::CSQLException* e) { SallyAPI::System::CLogger* logger = SallyAPI::Core::CGame::GetLogger(); logger->Error(e->GetMessage()); } } dbconn->ReleaseDatabase(); // Set Delete Flag std::string querySetDelete = "UPDATE media SET DeleteFlag = 1;"; dbconn->LockDatabase(); try { SallyAPI::Database::CStatement* stmtSetDelete = dbconn->CreateStatement(); stmtSetDelete->Execute(querySetDelete.c_str()); } catch (SallyAPI::Database::CSQLException* e) { SallyAPI::System::CLogger* logger = SallyAPI::Core::CGame::GetLogger(); logger->Error(e->GetMessage()); } dbconn->ReleaseDatabase(); std::vector<std::string>::iterator iter; // Collect Information for (iter = m_vFolders.begin(); iter != m_vFolders.end(); iter++) { std::string folder = *iter; CollectInformation(folder); if (m_bPleaseStop) { SallyAPI::Database::CDatabaseConnection::Close(mediaDB); return; } } m_pProcessbar->SetMaxPosition(m_iFileCount); // Create Database for (iter = m_vFolders.begin(); iter != m_vFolders.end(); iter++) { std::string folder = *iter; AddFolder(dbconn, folder, mediaDB); if (m_bPleaseStop) { SallyAPI::Database::CDatabaseConnection::Close(mediaDB); return; } } // execute rest of the create item statements ExecuteCreateItem(dbconn); ExecuteUpdateItem(dbconn); ExecuteNoUpdateItem(dbconn); // Set Delete Flag std::string queryDelete; queryDelete.append("DELETE FROM media WHERE DeleteFlag = 1;"); dbconn->LockDatabase(); try { SallyAPI::Database::CStatement* stmtDelete = dbconn->CreateStatement(); stmtDelete->Execute(queryDelete.c_str()); } catch (SallyAPI::Database::CSQLException* e) { SallyAPI::System::CLogger* logger = SallyAPI::Core::CGame::GetLogger(); logger->Error(e->GetMessage()); } dbconn->ReleaseDatabase(); SallyAPI::Database::CDatabaseConnection::Close(mediaDB); m_pWindow->SendMessageToParent(0, 0, m_iMessageId); }
void wxZEdit::EditClass(SerializableField *pFields, const char *className, void *ptr, bool bCreateFolder, bool aHandleParentClass) { if (bCreateFolder) { if ( (className[0] == 'P') && (className[1] == 'S') && (className[2] == 'M') && (className[3] == '_')) AddFolder(className+4); else AddFolder(className); } while (pFields->type != SerializableEnd) { if (pFields->type == SerializableBaseClass) { //printf("%s+ %s \n",getTabDepth(depth),pFields->name); if (aHandleParentClass) EditClass((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset)), /*depth, */false, false); } else { // agregated class? if (pFields->type == SerializableAgregat) { if (pFields->count>1) { /* for (unsigned int i= 0;i<pFields->count;i++) { printf("%s%s[%d]\n",getTabDepth(depth),pFields->name,i); DumpObjectValuesFn((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset+(i*gSerializableClasses[pFields->classID].mClassSize))), depth); } */ } else { /* if (pFields->classID == tcolor::mClassID) { AddColorPicker(pFields->name, (tcolor*)((((char*)ptr)+pFields->offset))); } else { } */ //printf("%s%s\n",getTabDepth(depth),pFields->name); //DumpObjectValuesFn((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset)), depth); } } else { /* if (pFields->count>1) { printf("%s%s[%d] = {",getTabDepth(depth),pFields->name,pFields->count); } else printf("%s%s = ",getTabDepth(depth),pFields->name); */ const char *aFieldName = pFields->name; if (aFieldName[0] == 'm') aFieldName++; for (unsigned int i= 0;i<pFields->count;i++) { char *ptrOfset = (((char*)ptr)+pFields->offset+(i*pFields->size_fieldsOffset)); // base switch (pFields->classID) { case SB_UNDEFINED: /*printf("(undefined type)");*/ break; case SB_I8: { if (pFields->mEnumStr) { AddCombo(aFieldName, wxString(pFields->mEnumStr), (unsigned char*)ptrOfset); } else { AddNumEdit<char>(aFieldName, -128, 127, (char*)ptrOfset, 1); } } break; case SB_BOOL: AddCheckBox(aFieldName, (bool*)ptrOfset); break; case SB_UI8: AddNumEdit<unsigned char>(aFieldName, 0, 255, (unsigned char*)ptrOfset, 1); break; case SB_I16: AddNumEdit<short>(aFieldName, -32768, 32767, (short*)ptrOfset, 1); break; case SB_UI16: AddNumEdit<unsigned short>(aFieldName, 0, 65535, (unsigned short*)ptrOfset, 1); break; case SB_I32: AddNumEdit<long>(aFieldName, -2147483647, 2147483647, (long*)ptrOfset, 1); break; case SB_UI32: { if (pFields->mEnumStr) { // bit field unsigned long aBitNb = 0; wxStringTokenizer tkz(pFields->mEnumStr, wxT("|")); while ( tkz.HasMoreTokens() ) { wxString bitFieldName = tkz.GetNextToken(); if (!bitFieldName.IsEmpty()) { AddCheckBoxBitField(bitFieldName, (unsigned long*)ptrOfset, aBitNb); } aBitNb++; } } else { // normal ui32 AddNumEdit<unsigned long>(aFieldName, 0, 4294967295, (unsigned long*)ptrOfset, 1); } } break; case SB_FLOAT: AddNumEdit<float>(aFieldName, -10000000, 10000000, (float*)ptrOfset, 0.1f); break; case SB_DOUBLE: /*printf("%f",*(double*) ptrOfset);*/ break; case SB_STRING: /*printf("%s",(char*) ptrOfset);*/ if (!_stricmp(aFieldName,"name")) AddTextEdit(aFieldName, (tstring*)ptrOfset, 10); else AddTextEdit(aFieldName, (tstring*)ptrOfset); break; case SB_WSTRING: //printf("%s%s = %d \n",getTabDepth(depth),pFields->name,*(int*) (((char*)ptr)+pFields->offset)); break; } //if ((i!=(pFields->count-1))&&(pFields->count>1)) printf(", "); } /* if (pFields->count>1) printf("}\n"); else printf("\n"); */ } } pFields++; } }
void CCreateNewDatabase::AddFolder(SallyAPI::Database::CDatabaseConnection* dbconn, std::string& folder, const std::string& mediaDirectory) { HANDLE hFile; WIN32_FIND_DATA FileInformation; std::string firstFile; folder = SallyAPI::String::PathHelper::CorrectPath(folder); firstFile.append(folder); firstFile.append("*"); hFile = FindFirstFile(firstFile.c_str(), &FileInformation); if(hFile != INVALID_HANDLE_VALUE) { do { if ((strcmp(FileInformation.cFileName, ".") != NULL) && (strcmp(FileInformation.cFileName, "..") != NULL)) { std::string filename; filename.append(folder); filename.append(FileInformation.cFileName); if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { AddFolder(dbconn, filename, mediaDirectory); } else if (CAudioFile::IsAudioFile(filename) || CVideoFile::IsVideoFile(filename)) { // compare the last file write time with the lastRun time FILETIME writeTimeTemp = FileInformation.ftLastWriteTime; FILETIME creationTimeTemp = FileInformation.ftCreationTime; FILETIME writeTime; FILETIME creationTime; FileTimeToLocalFileTime(&writeTimeTemp, &writeTime); FileTimeToLocalFileTime(&creationTimeTemp, &creationTime); // get file Infos std::string sDBFileName = SallyAPI::String::StringHelper::ReplaceString(filename, "'", "#"); if ((CompareFileTime(&m_ftLastRun, &writeTime) <= 0) || (CompareFileTime(&m_ftLastRun, &creationTime) <= 0)) { SYSTEMTIME creationTimeSystem; FileTimeToSystemTime(&creationTime, &creationTimeSystem); std::string sDBFileCreated = SallyAPI::Date::DateHelper::GetDateString(creationTimeSystem, false); // check if it exists in the database std::string queryFind; queryFind.append("SELECT Filename FROM media WHERE UPPER(Filename) = UPPER('"); queryFind.append(sDBFileName); queryFind.append("');"); dbconn->LockDatabase(); SallyAPI::Database::CStatement* stmtFind = dbconn->CreateStatement(); bool found = false; try { SallyAPI::Database::CResultSet* rslt = stmtFind->ExecuteQuery(queryFind.c_str()); found = rslt->Next(); } catch (SallyAPI::Database::CSQLException* e) { SallyAPI::System::CLogger* logger = SallyAPI::Core::CGame::GetLogger(); logger->Error(e->GetMessage()); } dbconn->ReleaseDatabase(); if (found) { UpdateItem(filename, sDBFileName, sDBFileCreated); if (m_iUpdateItem == 15) { ExecuteUpdateItem(dbconn); } } else { CreateItem(filename, sDBFileName, sDBFileCreated); if (m_iCreateItem == 15) { ExecuteCreateItem(dbconn); } } } else { NoItemUpdate(sDBFileName); if (m_iNoUpdateItem == 15) { ExecuteNoUpdateItem(dbconn); } } // update processbar m_pProcessbar->SetPosition(m_pProcessbar->GetPosition() + 1); } } } while ((FindNextFile(hFile, &FileInformation) == TRUE) && (m_bPleaseStop == false)); } FindClose(hFile); return; }
void ProjectWindow::AddFolder(entry_ref folderref) { BDirectory dir; if (dir.SetTo(&folderref) != B_OK) return; if (strcmp(folderref.name,"CVS") == 0 || strcmp(folderref.name,".svn") == 0 || strcmp(folderref.name,".git") == 0 || strcmp(folderref.name,".hg") == 0) return; dir.Rewind(); entry_ref ref; while (dir.GetNextRef(&ref) == B_OK) { if (BEntry(&ref).IsDirectory()) AddFolder(ref); else { // Here is where we actually add the file to the project. The name of the folder // containing the file will be the name of the file's group. If the group doesn't // exist, it will be created at the end of the list, but if it does, we will fake // a drop onto the group item to reuse the code path by finding the group and getting // its position in the list. DPath filepath(ref); if (filepath.GetExtension() && !( strcmp(filepath.GetExtension(),"cpp") == 0 || strcmp(filepath.GetExtension(),"c") == 0 || strcmp(filepath.GetExtension(),"cc") == 0 || strcmp(filepath.GetExtension(),"cxx") == 0 || strcmp(filepath.GetExtension(),"rdef") == 0 || strcmp(filepath.GetExtension(),"rsrc") == 0) ) continue; // Don't bother adding build files from other systems if (strcmp(filepath.GetFileName(), "Jamfile") == 0 || strcmp(filepath.GetFileName(), "Makefile") == 0) continue; DPath parent(filepath.GetFolder()); SourceGroup *group = NULL; SourceGroupItem *groupItem = NULL; fProject->Lock(); group = fProject->FindGroup(parent.GetFileName()); Lock(); if (group) groupItem = fProjectList->ItemForGroup(group); else { group = fProject->AddGroup(parent.GetFileName()); groupItem = new SourceGroupItem(group); fProjectList->AddItem(groupItem); UpdateIfNeeded(); } if (groupItem) { int32 index = fProjectList->IndexOf(groupItem); BPoint pt = fProjectList->ItemFrame(index).LeftTop(); pt.x += 5; pt.y += 5; AddFile(ref,&pt); } Unlock(); fProject->Unlock(); } } }
void SpeedDialSuggestionsModel::AddOpenTabs(BOOL items_under_parent_folder /*= FALSE*/, INT32 num_of_item_to_add /*= -1*/) { if (num_of_item_to_add == 0) return; INT32 open_pages_folder_idx = -1; // Add open tabs folder folder if (items_under_parent_folder) { OpString open_pages; RETURN_VOID_IF_ERROR(g_languageManager->GetString(Str::S_CURRENTLY_OPEN_PAGES, open_pages)); OpStringC8 open_pages_image("Open Pages"); open_pages_folder_idx = AddFolder(open_pages, open_pages_image); if (open_pages_folder_idx == -1) return; } // Get the title and url of last accessed open tabs (only from the active browser window) OpWorkspace* workspace = NULL; if (BrowserDesktopWindow* browser = g_application->GetActiveBrowserDesktopWindow()) workspace = browser->GetWorkspace(); if (!workspace) return; INT32 count = 0; for (INT32 i = 0; i < workspace->GetDesktopWindowCount() && count < num_of_item_to_add; i++) { DesktopWindow* window = workspace->GetDesktopWindowFromStack(i); if (window && window->GetType() == OpTypedObject::WINDOW_TYPE_DOCUMENT) { DocumentDesktopWindow* ddw = (DocumentDesktopWindow*)window; if (ddw->HasDocument() && !ddw->IsLockedByUser()) { OpString title, address; OpStatus::Ignore(title.Set(ddw->GetTitle(FALSE))); OpStatus::Ignore(WindowCommanderProxy::GetMovedToURL(ddw->GetWindowCommander()).GetAttribute(URL::KUniName_Username_Password_NOT_FOR_UI, address)); if (!DocumentView::IsUrlRestrictedForViewFlag(address.CStr(), DocumentView::ALLOW_ADD_TO_SPEED_DIAL)) continue; if (-1 != AddSuggestion(title, address, open_pages_folder_idx)) count ++; } } } if (count == 0 && items_under_parent_folder) { /* Add information on 'no pages currently open' only if 'items_under_parent_folder' is set to TRUE and tab count is 0. */ OpString no_items_label; RETURN_VOID_IF_ERROR(g_languageManager->GetString(Str::S_NO_PAGES_CURRENTLY_OPEN, no_items_label)); RETURN_VOID_IF_ERROR(AddLabel(no_items_label, open_pages_folder_idx)); } }
int COutlook2Ctrl::AddFolderRes(LPCTSTR m_strName, UINT iIcoID, DWORD lParam) { HICON hIco = (HICON) LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(iIcoID),IMAGE_ICON,16,16,0); return AddFolder(m_strName, hIco, lParam); }
BOOL CAlbumFolder::OrganiseFile(CLibraryFile* pFile) { BOOL bResult = FALSE; if ( m_sSchemaURI == CSchema::uriAllFiles ) { AddFile( pFile ); return TRUE; } if ( m_bCollSHA1 && ( m_pCollection != NULL || GetCollection() ) ) { if ( m_pCollSHA1 == pFile->m_pSHA1 || m_pCollection->FindFile( pFile, TRUE ) ) { AddFile( pFile ); return TRUE; } else { return FALSE; } } if ( pFile->m_pMetadata == NULL && m_pParent != NULL ) return FALSE; if ( m_sSchemaURI == CSchema::uriMusicRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriMusicAlbumCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") ); CXMLNode::UniformString( strAlbum ); if ( strAlbum.IsEmpty() ) return FALSE; if ( _tcsicmp( strAlbum, _T("tba") ) == 0 ) return FALSE; if ( _tcsicmp( strAlbum, _T("na") ) == 0 ) return FALSE; if ( _tcsicmp( strAlbum, _T("n/a") ) == 0 ) return FALSE; if ( _tcsicmp( strAlbum, _T("none") ) == 0 ) return FALSE; if ( _tcsicmp( strAlbum, _T("empty") ) == 0 ) return FALSE; if ( _tcsicmp( strAlbum, _T("unknown") ) == 0 ) return FALSE; if ( _tcsistr( strAlbum, _T("uploaded by") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("ripped by") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("downloaded") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("http") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("mp3") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("www.mp3sfinder.com") ) ) return FALSE; if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles"); for ( POSITION pos = GetFolderIterator() ; pos ; ) { CAlbumFolder* pAlbum = GetNextFolder( pos ); if ( pAlbum->m_sName.CompareNoCase( strAlbum ) == 0 ) { bResult = pAlbum->OrganiseFile( pFile ); } else if ( pAlbum->m_bAutoDelete ) { pAlbum->RemoveFile( pFile ); } } if ( bResult ) return TRUE; CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicAlbum, strAlbum, TRUE ); return pAlbum->OrganiseFile( pFile ); } else if ( m_sSchemaURI == CSchema::uriMusicAlbum ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strAlbum = pFile->m_pMetadata->GetAttributeValue( _T("album") ); CXMLNode::UniformString( strAlbum ); if ( _tcsistr( strAlbum, _T("single") ) ) strAlbum = _T("Singles"); if ( strAlbum.CompareNoCase( m_sName ) ) return FALSE; AddFile( pFile ); if ( _tcsistr( m_sName, _T("soundtrack") ) != NULL || _tcsistr( m_sName, _T("ost") ) != NULL ) { // TODO: Scrap artist specific info ! MetaFromFile( pFile ); } else { MetaFromFile( pFile ); } return TRUE; } else if ( m_sSchemaURI == CSchema::uriMusicArtistCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") ); CXMLNode::UniformString( strArtist ); Replace( strArtist, _T(" (www.mp3sfinder.com)"), _T("") ); if ( strArtist.IsEmpty() ) return FALSE; for ( POSITION pos = GetFolderIterator() ; pos ; ) { CAlbumFolder* pAlbum = GetNextFolder( pos ); if ( pAlbum->m_sName.CompareNoCase( strArtist ) == 0 ) { bResult = pAlbum->OrganiseFile( pFile ); } else if ( pAlbum->m_bAutoDelete ) { pAlbum->RemoveFile( pFile ); } } if ( bResult ) return TRUE; CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicArtist, strArtist, TRUE ); return pAlbum->OrganiseFile( pFile ); } else if ( m_sSchemaURI == CSchema::uriMusicArtist ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strArtist = pFile->m_pMetadata->GetAttributeValue( _T("artist") ); CXMLNode::UniformString( strArtist ); if ( strArtist.CompareNoCase( m_sName ) ) return FALSE; AddFile( pFile ); MetaFromFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriMusicGenreCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") ); if ( strGenre.IsEmpty() ) return FALSE; for ( POSITION pos = GetFolderIterator() ; pos ; ) { CAlbumFolder* pAlbum = GetNextFolder( pos ); if ( pAlbum->m_sName.CompareNoCase( strGenre ) == 0 ) { bResult = pAlbum->OrganiseFile( pFile ); } else if ( pAlbum->m_bAutoDelete ) { pAlbum->RemoveFile( pFile ); } } if ( bResult ) return TRUE; CAlbumFolder* pAlbum = AddFolder( CSchema::uriMusicGenre, strGenre, TRUE ); return pAlbum->OrganiseFile( pFile ); } else if ( m_sSchemaURI == CSchema::uriMusicGenre ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; CString strGenre = pFile->m_pMetadata->GetAttributeValue( _T("genre") ); if ( strGenre.CompareNoCase( m_sName ) ) return FALSE; AddFile( pFile ); MetaFromFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriMusicAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriAudio ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriVideoRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriVideoSeriesCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") ); CXMLNode::UniformString( strSeries ); if ( strSeries.IsEmpty() ) return FALSE; for ( POSITION pos = GetFolderIterator() ; pos ; ) { CAlbumFolder* pAlbum = GetNextFolder( pos ); if ( pAlbum->m_sName.CompareNoCase( strSeries ) == 0 ) { bResult = pAlbum->OrganiseFile( pFile ); } else if ( pAlbum->m_bAutoDelete ) { pAlbum->RemoveFile( pFile ); } } if ( bResult ) return TRUE; CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoSeries, strSeries, TRUE ); return pAlbum->OrganiseFile( pFile ); } else if ( m_sSchemaURI == CSchema::uriVideoSeries ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; CString strSeries = pFile->m_pMetadata->GetAttributeValue( _T("series") ); CXMLNode::UniformString( strSeries ); if ( strSeries.CompareNoCase( m_sName ) ) return FALSE; AddFile( pFile ); MetaFromFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriVideoFilmCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") ); if ( strType.CompareNoCase( _T("film") ) ) return FALSE; CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") ); CXMLNode::UniformString( strTitle ); if ( strTitle.IsEmpty() ) return FALSE; for ( POSITION pos = GetFolderIterator() ; pos ; ) { CAlbumFolder* pAlbum = GetNextFolder( pos ); if ( pAlbum->m_sName.CompareNoCase( strTitle ) == 0 ) { bResult = pAlbum->OrganiseFile( pFile ); } else if ( pAlbum->m_bAutoDelete ) { pAlbum->RemoveFile( pFile ); } } if ( bResult ) return TRUE; CAlbumFolder* pAlbum = AddFolder( CSchema::uriVideoFilm, strTitle, TRUE ); return pAlbum->OrganiseFile( pFile ); } else if ( m_sSchemaURI == CSchema::uriVideoFilm ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") ); if ( strType.CompareNoCase( _T("film") ) ) return FALSE; CString strTitle = pFile->m_pMetadata->GetAttributeValue( _T("title") ); CXMLNode::UniformString( strTitle ); if ( strTitle.CompareNoCase( m_sName ) ) return FALSE; AddFile( pFile ); MetaFromFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriVideoMusicCollection ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; CString strType = pFile->m_pMetadata->GetAttributeValue( _T("type") ); if ( strType.CompareNoCase( _T("music video") ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriVideoAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriVideo ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriImageRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriImageAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriImage ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriApplicationRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriApplicationAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriApplication ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriBookRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriBookAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriBook ) ) return FALSE; AddFile( pFile ); return TRUE; } else if ( m_sSchemaURI == CSchema::uriDocumentRoot ) { if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) && ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) && ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE; } else if ( m_sSchemaURI == CSchema::uriDocumentAll ) { if ( ! pFile->IsSchemaURI( CSchema::uriDocument ) && ! pFile->IsSchemaURI( CSchema::uriSpreadsheet ) && ! pFile->IsSchemaURI( CSchema::uriPresentation ) ) return FALSE; AddFile( pFile ); return TRUE; } for ( POSITION pos = GetFolderIterator() ; pos ; ) { bResult |= GetNextFolder( pos )->OrganiseFile( pFile ); } return bResult; }