Ejemplo n.º 1
0
int SubsController::TryToClose(bool allow_cancel) const {
	if (!IsModified())
		return wxYES;

	int flags = wxYES_NO;
	if (allow_cancel)
		flags |= wxCANCEL;
	int result = wxMessageBox(wxString::Format(_("Do you want to save changes to %s?"), Filename().wstring()), _("Unsaved changes"), flags, context->parent);
	if (result == wxYES) {
		cmd::call("subtitle/save", context);
		// If it fails saving, return cancel anyway
		return IsModified() ? wxCANCEL : wxYES;
	}
	return result;
}
Ejemplo n.º 2
0
bool
DialUpView::SaveSettingsToFile()
{
	bool settingsChanged, profileChanged;
	IsModified(&settingsChanged, &profileChanged);
	if(!settingsChanged && !profileChanged)
		return true;
	
	BMessage settings, profile;
	if(!SaveSettings(&settings, &profile, false))
		return false;
	
	BDirectory settingsDirectory;
	BDirectory profileDirectory;
	GetPPPDirectories(&settingsDirectory, &profileDirectory);
	if(settingsDirectory.InitCheck() != B_OK || profileDirectory.InitCheck() != B_OK)
		return false;
	
	BFile file;
	if(settingsChanged) {
		settingsDirectory.CreateFile(fCurrentItem->Label(), &file);
		WriteMessageDriverSettings(file, settings);
	}
	
	if(profileChanged) {
		profileDirectory.CreateFile(fCurrentItem->Label(), &file);
		WriteMessageDriverSettings(file, profile);
	}
	
	return true;
}
Ejemplo n.º 3
0
bool TDocument::AllowClose()
{
	if (IsModified())
	{
		bool save;

		if (!TCommonDialogs::SaveChanges(fTitle, GetMainWindow(), save))
			return false;

		if (save)
		{	
	 		// save the file
	 		if (fFile.IsSpecified())
				Save();
			else
			{
				TFile* file = TCommonDialogs::SaveFile(NULL, GetMainWindow());
				
				if (file)
				{
					SetFile(file);
					Save();
					delete file;
				}
				else
					return false;
			}
		}
	}

	return true;
}
Ejemplo n.º 4
0
void CKaiDoc::OnFileSave()
{
    // TODO: Add your command handler code here
    if (pco_Doc_->b_IsImported())
    {
        OnFileSaveAs();
        return;
    }

    CString cstr_path = GetPathName();
    if (!cstr_path.IsEmpty())
    {
        CString cstr_ext = PathFindExtension (cstr_path);
        SetPathName (CString (cstr_path.Left (cstr_path.GetLength() - 
                                              cstr_ext.GetLength())) + 
                              _T(".kai"));
    }
    else
    {
        SetTitle (pco_Doc_->str_Title_.data());
    }

    CDocument::OnFileSave();

    if (IsModified())
    {
        SetTitle (CString (pco_Doc_->str_Title_.data()) + _T("*"));
    }

}
Ejemplo n.º 5
0
	bool DBUpdateThreadWorker::UpdateItem (const Item_ptr& item, const Item_ptr& ourItem)
	{
		if (!IsModified (ourItem, item))
			return false;

		ourItem->Description_ = item->Description_;
		ourItem->Categories_ = item->Categories_;
		ourItem->NumComments_ = item->NumComments_;
		ourItem->CommentsLink_ = item->CommentsLink_;
		ourItem->CommentsPageLink_ = item->CommentsPageLink_;
		ourItem->Latitude_ = item->Latitude_;
		ourItem->Longitude_ = item->Longitude_;

		for (auto& enc : item->Enclosures_)
		{
			if (!ourItem->Enclosures_.contains (enc))
			{
				enc.ItemID_ = ourItem->ItemID_;
				ourItem->Enclosures_ << enc;
			}
		}

		for (auto& entry : item->MRSSEntries_)
			if (!ourItem->MRSSEntries_.contains (entry))
			{
				entry.ItemID_ = ourItem->ItemID_;
				ourItem->MRSSEntries_ << entry;
			}

		SB_->UpdateItem (ourItem);

		return true;
	}
Ejemplo n.º 6
0
  /**
   * Opens cube in qview.
   * @throws Isis::Exception::User "You must enter a cube name to open"
   */
  void GuiCubeParameter::ViewCube() {
    try {
      // Make sure the user entered a value
      if(IsModified()) {
        QString cubeName = Value();

        // Check to make sure the cube can be opened
        Isis::Cube temp;
        temp.open(cubeName);
        temp.close();

        // Open the cube in Qview
        QString command = "$ISISROOT/bin/qview " + cubeName + " &";
        ProgramLauncher::RunSystemCommand(command);
      }
      // Throw an error if no cube name was entered
      else {
        QString msg = "You must enter a cube name to open";
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }
    catch(IException &e) {
      Isis::iApp->GuiReportError(e);
    }
  }
Ejemplo n.º 7
0
void CCoolFormat3Doc::CheckTitle()
{
	if (IsModified() ^ m_bTitleMark)
	{
		SetTitle(GetTitle());
	}
}
Ejemplo n.º 8
0
bool CEditableObject::SaveObject(const char* fname)
{
	if (IsModified()){
        // update transform matrix
        Fmatrix	mTransform,mScale,mTranslate,mRotate;
        if (!fsimilar(t_vRotate.magnitude(),0)||!fsimilar(t_vScale.magnitude(),1.73205f)||!fsimilar(t_vPosition.magnitude(),0)){
            mRotate.setHPB			(t_vRotate.y, t_vRotate.x, t_vRotate.z);
            mScale.scale			(t_vScale);
            mTranslate.translate	(t_vPosition);
            mTransform.mul			(mTranslate,mRotate);
            mTransform.mulB_43		(mScale);
	        TranslateToWorld		(mTransform);
            t_vRotate.set			(0,0,0);
            t_vPosition.set			(0,0,0);
            t_vScale.set			(1,1,1);
        }
    }

    // save object
    IWriter* F			= FS.w_open(fname);
	if (F){
        F->open_chunk	(EOBJ_CHUNK_OBJECT_BODY);
        Save			(*F);
        F->close_chunk	();

        FS.w_close		(F);

        m_LoadName 		= fname;
        m_ObjectVersion = FS.get_file_age(fname); 	VERIFY3(m_ObjectVersion>0,"Invalid file age:",fname);
        return			true;
    }else{
    	return 			false;
    }
}
Ejemplo n.º 9
0
  /**
   * Displays cube label in the GUI log.
   * @throws Isis::Exception::User "You must enter a cube name to open"
   */
  void GuiCubeParameter::ViewLabel() {
    try {
      // Make sure the user entered a value
      if(IsModified()) {
        QString cubeName = Value();

        // Check to make sure the cube can be opened
        Isis::Cube temp;
        temp.open(cubeName);

        // Get the label and write it out to the log
        Isis::Pvl *label = temp.label();
        Isis::Application::GuiLog(*label);

        // Close the cube
        temp.close();

      }
      else {
        QString msg = "You must enter a cube name to open";
        throw IException(IException::User, msg, _FILEINFO_);
      }
    }
    catch(IException &e) {
      Isis::iApp->GuiReportError(e);
    }

  }
Ejemplo n.º 10
0
// DataSize
size_t
ResourceItem::DataSize() const
{
	if (IsModified())
		return BufferLength();
	return fInitialSize;
}
Ejemplo n.º 11
0
void CFREDDoc::OnFileSaveUpdate(CCmdUI* pCmdUI)
{
	if (IsModified())
		pCmdUI->Enable(1);
	else
		pCmdUI->Enable(1);
}
Ejemplo n.º 12
0
// true if error
bool ProjectData::Compile()
{
  if(IsModified()) Save();

  wxString cmd="\""+frame->cmdCompiler+"\" +\""+frame->cmdLibrary+"\" "+GetSourceFile(0)->Name();
  wxString msg="Compiling: "+cmd+"\n\n";
  frame->logWindow->AppendText(msg);

  wxArrayString output;
  long status=wxExecute(cmd, output);

  msg="";
	unsigned int i;
  for(i=0; i<output.GetCount() && i<20; i++) {
    msg+=output[i]+"\n";
  }
  frame->logWindow->AppendText(msg);

  if(output.GetCount()>i) {
    frame->logWindow->AppendText("[Compiler output truncated]\n");
  }

  if(status!=0) {
    frame->logWindow->AppendText("\nCompilation failed\n");
    if(status==-1) frame->logWindow->AppendText("Check Compiler and Library settings in Edit/Preferences\n");
    return true;
  }

  frame->logWindow->AppendText("\nCompilation successful!\n");
  return false;
}
Ejemplo n.º 13
0
bool HexDoc::Read(uint64 nOffset, uint32 nSize, uint8 *target, uint8 *pModified /*= NULL*/)
{
    if (nOffset + nSize > this->size)
        return false;

    if (!Load(nOffset))
        return false;
    Segment *ts = m_curSeg;

    uint32 copySize, dstOffset = 0;
    uint64 srcOffset = nOffset - m_iCurSegOffset;
    uint32 remaining = nSize;
    while (remaining > 0)
    {
        if (ts == NULL)
            return false; //! Help!
        copySize = min(remaining, ts->size - srcOffset);
        if (!ts->Read(srcOffset, copySize, target + dstOffset))
            return false;
        dstOffset += copySize;
        srcOffset = 0;
        remaining -= copySize;
        ts = ts->next;
    }

    if (pModified)
    {
        for (uint32 n = 0; n < nSize; n++)
        {
            pModified[n] = IsModified(nOffset + n); //! much room for improvement here.
        }
    }

    return true;
}
Ejemplo n.º 14
0
void __fastcall TFrmCustomBill::CdsmasterBeforeScroll(TDataSet *DataSet)
{
  int I;
  if ((!IsInternalDelete) && (!IsInternalEdit)&& (IsModified()))
  {
    if ( ShowDlg("数据未保存,是否真放弃?",DLG_CONFIRMATION) == false)
        Abort();
    else
    {
        try
        {
            Cdsmaster->BeforeScroll = NULL;
            for (int i=0;i< FDataSetArr.Length;i++)  
            {
                if (FDataSetArr[i]->Active)
                {
                    FDataSetArr[i]->Cancel();
                    FDataSetArr[i]->CancelUpdates();
                }
            }
        } 
        __finally
        {
           Cdsmaster->BeforeScroll = CdsmasterBeforeScroll;
        }
    }
  }
}
Ejemplo n.º 15
0
void CInputDoc::SetModifiedFlag(BOOL bModified)
{
	if(bModified==IsModified())
		return; // no change

	CDocument::SetModifiedFlag(bModified);
	SetTitle(getFullFileName(GetPathName()));
}
Ejemplo n.º 16
0
IEncConverter*  CAutoConfigDlg::InsureApplyAndInitializeEncConverter()
{
	// in case it wasn't done, update the variables now (i.e. do "OnApply")
	if( IsModified() && !OnApply() )
		return NULL;

	return InitializeEncConverter();
}
Ejemplo n.º 17
0
	UGbool UGDataSourceBaiduMap::SaveInfo()
	{
		if (IsModified())
		{

		}
		SetModifiedFlag(FALSE);
		return TRUE;
	}
Ejemplo n.º 18
0
//----------------------------------------------------------------------------
BOOL CMorphwizardDoc::SaveModified()
{
	CSLFDocument* doc, *doc1;
	CString s;
	if( HasModifiedSlf() ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			if( doc->IsModified() )
				s += doc->GetLemma() + ",\n";
		}
	}

	bool hasModifedSlf = !s.IsEmpty();
	int rn=IDCANCEL;

	if( hasModifedSlf || IsModified() ) 
	{
		CString msg; 
		if( hasModifedSlf )
		{
			s.Delete(s.GetLength()-2,2);
			msg = GetTitle() + "\n\nSave all ";
			if( GetWizard()->is_changed() ) 
				msg += "changes\nincluding ";

			msg += "revised paradigms:\n\n" + s + "?";
		}
		else	// if( IsModified() )
		{
			msg = GetTitle() + "\n\nSave all changes?";
		}

		rn = ::AfxMessageBox(msg, MB_YESNOCANCEL);

		if( rn==IDCANCEL ) 
			return FALSE;
	}

	if( hasModifedSlf && rn==IDYES ) 
	{
		POSITION pos = m_slfDocs.GetStartPosition();
		while( !!pos ) 
		{
			m_slfDocs.GetNextAssoc(pos,doc,doc1);
			doc->DoFileSave();
		}
	}

	if( rn==IDYES ) 
		DoFileSave();

	return TRUE;
}
Ejemplo n.º 19
0
bool SubExpressionTap::GetArgs(SubExpressionBlock &expBlock, Node *node) {
	if(!node)
		return false;
	Values value = node->value();
	if(BinaryOpNode *bNode = dynamic_cast<BinaryOpNode*>(node)){
		if(IdentifierNode *l_id = dynamic_cast<IdentifierNode*>(bNode->left))
				l_id->assignCounter = IsChangedValue(value) ? ++l_id->var->assignCounter : l_id->var->assignCounter;			
		if(IdentifierNode *r_id = dynamic_cast<IdentifierNode*>(bNode->right)){
			r_id->assignCounter = r_id->var->assignCounter;
		}

		if(!((bNode->left->isIdent() || bNode->left->isSimple()) &&	(bNode->right->isIdent() || bNode->right->isSimple()))){
			if(!IsModified(bNode->left) || !IsModified(bNode->right))
				return false;
				
			bool ok1 = GetArgs(expBlock, bNode->left),
				ok2 = GetArgs(expBlock, bNode->right);
			if(!ok1 || !ok2 || !IsModified(node))
				return false;
			expBlock.Add(node);
		} else {
			expBlock.Add(node);
		if(!IsModified(node))
			return false;
		}
	} else
		if(UnaryOpNode *uNode = dynamic_cast<UnaryOpNode*>(node)){
			if(IdentifierNode *id = dynamic_cast<IdentifierNode*>(uNode->operand)){
				if(IsChangedValue(value))
					id->assignCounter = ++id->var->assignCounter;
				else 
					id->assignCounter = id->var->assignCounter;
			}
			if(!(uNode->operand->isSimple() || uNode->operand->isIdent())){
				if(!GetArgs(expBlock, uNode->operand) || !IsModified(node))
					return false;
				expBlock.Add(node);
			}
			else
				expBlock.Add(uNode->value(), uNode->operand);
		}
	return true;
}
Ejemplo n.º 20
0
void TDocument::DoSetupMenu(TMenu* menu)
{
	if (IsModified() || !fFile.IsSpecified())
		menu->EnableCommand(kSaveCommandID);

	menu->EnableCommand(kSaveAsCommandID);
	menu->EnableCommand(kSaveCopyCommandID);

	TWindowContext::DoSetupMenu(menu);
}
Ejemplo n.º 21
0
// Saves the doc
bool ctConfigToolDoc::Save()
{
    if (!IsModified() && m_savedYet) return true;

    bool ret = (m_documentFile == wxT("") || !m_savedYet) ?
                 SaveAs() :
                 OnSaveDocument(m_documentFile);
    if ( ret )
        SetDocumentSaved(true);
    return ret;
}
Ejemplo n.º 22
0
void
Profile::Save()
{
  if (!IsModified())
    return;

  LogFormat("Saving profiles");
  if (StringIsEmpty(startProfileFile))
    SetFiles(_T(""));
  SaveFile(startProfileFile);
}
Ejemplo n.º 23
0
/*=== OnCancel() ====================================================
  Description:  Dismisses window, prompting user if there are unsaved
                changes
  Arguments:  none

  Returns:    nothing

  Modifies:   nothing

  Calls:      nothing

  Called By:  Event Handler

  History:    5/13/99  SRH   Initial implementation
  ===================================================================*/
void CPrepaymentAdd::OnCancel() 
{
  if (m_Mode != View && IsModified())
  {
		if(CGuiMsg::GuiQuery(GUIMSG_UNSAVED_DATA_CONFIRM) == IDNO)
    {
			return;
    }
	}

	CDialog::OnCancel();
}
Ejemplo n.º 24
0
void CDialogEditAllele::OnChange(wxCommandEvent &)
{
  bool bModified = IsModified();
  if(m_pButtonBar != NULL)
  {
    m_pButtonBar->EnableApply(bModified);
  }
  else
  {
    m_pButtonUser->Enable(bModified);
  }
}
Ejemplo n.º 25
0
void CDIPDemoDoc::OnFileReopen()
{
    // 重新打开图像,放弃所有修改

    // 判断当前图像是否已经被改动
    if ( IsModified() )
    {
        // 提示用户该操作将丢失所有当前的修改
        if ( MessageBox ( NULL,
                          L"重新打开图像将丢失所有改动!是否继续?",
                          L"系统提示", MB_ICONQUESTION | MB_YESNO ) == IDNO )
        {
            // 用户取消操作,直接返回
            return;
        }
    }

    CString strPathName;
    // 获取当前文件路径
    strPathName = GetPathName();
    // 更改光标形状
    BeginWaitCursor();

    if ( !m_Image.AttachFromFile ( strPathName ) )
    {
        EndWaitCursor();
        AfxMessageBox ( L"打开文件时出错!请确保正确的位图(*.bmp)文件类型。" );
        return;
    }

    // 判断读取成功否
    if ( !m_Image.m_lpData )
    {
        // 失败,可能非BMP格式
        CString strMsg;
        strMsg = L"读取图像时出错!可能是不支持该类型的图像文件!";
        // 提示出错
        MessageBox ( NULL, strMsg, L"系统提示",
                     MB_ICONINFORMATION | MB_OK );
        // 返回
        return;
    }

    Init(); //对图像的尺寸和调色板信息进行初始化
    // 初始化脏标记为FALSE
    SetModifiedFlag ( FALSE );
    // 刷新
    UpdateAllViews ( NULL );
    // 恢复光标形状
    EndWaitCursor();
    // 返回
    return;
}
Ejemplo n.º 26
0
void COptionSheet::OnApply()
{
	if(TRUE == IsModified()) {
		for(int i = 0; i < GetPageCount(); i++) {
			BOOL result = GetPage(i)->OnApply();
			if(FALSE == result) {
				return;
			}
		}
		SetModified(FALSE);
	}
}
Ejemplo n.º 27
0
BOOL CCoolFormat3Doc::SaveModified()
{
	if (!IsModified())
		return TRUE;        // ok to continue

	// get name/title of document
	CString name;
	if (m_strPathName.IsEmpty())
	{
		// get name based on caption
		name = GetTitle();
		if (name.IsEmpty())
			ENSURE(name.LoadString(AFX_IDS_UNTITLED));
		if (m_bTitleMark)
		{
			name = name.Left(name.GetLength() - 2);
		}
	}
	else
	{
		// get name based on file title of path name
		name = m_strPathName;
		GetFileTitle(m_strPathName, name.GetBuffer(_MAX_PATH), _MAX_PATH);
		name.ReleaseBuffer();
	}	

	CString prompt;
	BOOL bNameVaild = prompt.LoadString(IDS_IS_WANTSAVE);
	ASSERT(bNameVaild);
	CString strMsg;
	strMsg.Format(prompt, name);	
	
	switch (CFMessageBox(strMsg, MB_YESNOCANCEL| MB_ICONINFORMATION))
	{
	case IDCANCEL:
		return FALSE;       // don't continue

	case IDYES:
		// If so, either Save or Update, as appropriate
		if (!DoFileSave())
			return FALSE;       // don't continue
		break;

	case IDNO:
		// If not saving changes, revert the document
		break;

	default:
		ASSERT(FALSE);
		break;
	}
	return TRUE;    // keep going
}
Ejemplo n.º 28
0
void CLangModelsDoc::SetModifiedFlag(BOOL bModified)
{
	if(bModified==IsModified())
		return; // no change

	CDocument::SetModifiedFlag(bModified);
	SetTitle(NULL);

	// modifying a language doc means, effectiving, modifying the project.
	// remember that we are saved only when the project is saved.
	if(bModified)
		this->getProject()->SetModifiedFlag(bModified);
}
Ejemplo n.º 29
0
/** \fn ActionSet::SetModifiedFlag(const ActionID&, bool)
 *  \brief Mark an action as modified or unmodified by its identifier.
 *  \return true if the action was modified, and is set to unmodified.
 */
bool ActionSet::SetModifiedFlag(const ActionID &id, bool modified)
{
    if (!modified)
        return m_modified.removeAll(id);

    if (!IsModified(id))
    {
        m_modified.push_back(id);
        return true;
    }

    return false;
}
Ejemplo n.º 30
0
bool CDialogEditAllele::CheckCancel()
{
  bool bRtn = true;
  if(IsModified())
  {
    bRtn = mainApp::ConfirmModificationsLost(this);
  }
  if(bRtn)
  {
    EndModal(wxID_CANCEL);
  }
  return bRtn;
}