Example #1
0
/**
 * SocEditPanel
 */
SocEditPanel::SocEditPanel(SocRef ref, QWidget *parent)
    :QWidget(parent), m_ref(ref)
{
    m_name_group = new QGroupBox("Name", this);
    m_name_edit = new QLineEdit(this);
    m_name_edit->setText(QString::fromStdString(ref.GetSoc().name));
    QVBoxLayout *name_group_layout = new QVBoxLayout;
    name_group_layout->addWidget(m_name_edit);
    m_name_group->setLayout(name_group_layout);

    m_desc_group = new QGroupBox("Description", this);
    QHBoxLayout *group_layout = new QHBoxLayout;
    m_desc_edit = new MyTextEditor(this);
    m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetSoc().desc));
    group_layout->addWidget(m_desc_edit);
    m_desc_group->setLayout(group_layout);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(m_name_group);
    layout->addWidget(m_desc_group);
    layout->addStretch(1);

    connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&)));
    connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnTextEdited()));

    setLayout(layout);
}
void CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
  CXFA_FFField::OnProcessEvent(pEvent);
  switch (pEvent->GetClassID()) {
    case CFWL_EventType::SelectChanged: {
      CFWL_EvtSelectChanged* postEvent =
          static_cast<CFWL_EvtSelectChanged*>(pEvent);
      OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->bLButtonUp);
      break;
    }
    case CFWL_EventType::EditChanged: {
      CFX_WideString wsChanged;
      OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged);
      break;
    }
    case CFWL_EventType::PreDropDown: {
      OnPreOpen(m_pNormalWidget->GetWidget());
      break;
    }
    case CFWL_EventType::PostDropDown: {
      OnPostOpen(m_pNormalWidget->GetWidget());
      break;
    }
    default:
      break;
  }
  m_pOldDelegate->OnProcessEvent(pEvent);
}
Example #3
0
FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
  CXFA_FFField::OnProcessEvent(pEvent);
  FX_DWORD dwEventID = pEvent->GetClassID();
  switch (dwEventID) {
    case FWL_EVTHASH_CMB_SelChanged: {
      CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent;
      OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels,
                      postEvent->bLButtonUp);
      break;
    }
    case FWL_EVTHASH_CMB_EditChanged: {
      CFX_WideString wsChanged;
      OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged);
      break;
    }
    case FWL_EVTHASH_CMB_PreDropDown: {
      OnPreOpen(m_pNormalWidget->GetWidget());
      break;
    }
    case FWL_EVTHASH_CMB_PostDropDown: {
      OnPostOpen(m_pNormalWidget->GetWidget());
      break;
    }
    default: {}
  }
  return m_pOldDelegate->OnProcessEvent(pEvent);
}
Example #4
0
void SSuperSearchBox::OnTextCommitted( const FText& InText, ETextCommit::Type CommitInfo)
{
	if (CommitInfo == ETextCommit::OnEnter)
	{
		if (SelectedSuggestion >= 1)
		{
			// find the category
			FString Category;
			for (int32 i = SelectedSuggestion; i >= 0; --i)
			{
				if (Suggestions[i]->bCategory)
				{
					Category = Suggestions[i]->Title;
					break;
				}
			}

			ActOnSuggestion(Suggestions[SelectedSuggestion], Category);
		}
		else
		{
			OnTextChanged(InText);
		}

	}
}
Example #5
0
FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
  CXFA_FFField::OnProcessEvent(pEvent);
  FX_DWORD dwEventID = pEvent->GetClassID();
  switch (dwEventID) {
    case FWL_EVTHASH_EDT_TextChanged: {
      CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent;
      CFX_WideString wsChange;
      OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText);
      break;
    }
    case FWL_EVTHASH_EDT_AddDoRecord: {
      OnAddDoRecord(m_pNormalWidget->GetWidget());
      break;
    }
    case FWL_EVTHASH_EDT_TextFull: {
      OnTextFull(m_pNormalWidget->GetWidget());
      break;
    }
    case FWL_EVTHASH_EDT_CheckWord: {
      CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged");
      CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent;
      event->bCheckWord = CheckWord(event->bsWord);
      break;
    }
    case FWL_EVTHASH_EDT_GetSuggestWords: {
      CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent;
      event->bSuggestWords =
          GetSuggestWords(event->bsWord, event->bsArraySuggestWords);
      break;
    }
    default: {}
  }
  return m_pOldDelegate->OnProcessEvent(pEvent);
}
Example #6
0
DKDSearchEdit::DKDSearchEdit(QWidget *parent) :
    QLineEdit(parent)
{
    setToolTip("输入IP/昵称/登录名/主机名");
    setFixedHeight(25);

    connect(this,SIGNAL(textChanged(QString)),this,SLOT(OnTextChanged(QString)));
}
Example #7
0
void MyTextEditor::OnInternalTextChanged()
{
    if(m_growing_mode)
    {
        int content_size = m_edit->document()->documentLayout()->documentSize().height();
        content_size = qMax(content_size, m_edit->fontMetrics().height());
        m_edit->setMinimumHeight(content_size + m_edit->contentsMargins().top() + 
            m_edit->contentsMargins().bottom());
    }
    emit OnTextChanged();
}
void TextManipulator::OnTextChanged()
{
	auto& observers = mObservers_[ITextManipulatorObserver::Default];
	for (auto it = observers.begin(); it != observers.end(); /**/){
		auto observer = it->lock();
		if (!observer){
			it = observers.erase(it);
			continue;
		}
		++it;
		observer->OnTextChanged(this);
	}
}
Example #9
0
void MyTextEditor::SetGrowingMode(bool en)
{
    m_growing_mode = en;
    if(en)
    {
        m_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
        m_edit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        OnTextChanged();
    }
    else
    {
        m_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        m_edit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    }
}
Example #10
0
void Label::SetText (const String& content)
{
    if (content == textContent_)
        return;

    if (!isChangeColorCall_)
        drawableText_.setColor (userColor_);
    textContent_ = content;
    drawableText_.setString (content);
    /*drawableText_.setPosition (Vector2 (GetPosition ().x + padding_.left,
    GetPosition ().y + padding_.top));*/

    if (isPosSet_)
    {
        drawableText_.setPosition (
            GetPosition ().x + padding_.left,
            GetPosition ().y + padding_.top);
        isPosSet_ = false;
    }

    OnTextChanged (*this, EventArgsString (content));
}
Example #11
0
void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
  CXFA_FFField::OnProcessEvent(pEvent);
  switch (pEvent->GetClassID()) {
    case CFWL_EventType::TextChanged: {
      CFWL_EvtTextChanged* event = static_cast<CFWL_EvtTextChanged*>(pEvent);
      CFX_WideString wsChange;
      OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText);
      break;
    }
    case CFWL_EventType::TextFull: {
      OnTextFull(m_pNormalWidget->GetWidget());
      break;
    }
    case CFWL_EventType::CheckWord: {
      CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged");
      CFWL_EvtCheckWord* event = static_cast<CFWL_EvtCheckWord*>(pEvent);
      event->bCheckWord = CheckWord(event->bsWord.AsStringC());
      break;
    }
    default:
      break;
  }
  m_pOldDelegate->OnProcessEvent(pEvent);
}
Example #12
0
DialogPacket::DialogPacket(QString type, QByteArray packet, QString scriptPath, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogPacket)
{
    ui->setupUi(this);

    m_packet = NULL;
    m_filename = QString();
    m_textChanged = false;

    m_scriptEditor = new TextEdit(this);
    m_scriptEditor->setGeometry(5, 5, 725, 545);
    m_completer = new QCompleter(this);
    m_completer->setModel(modelFromFile());
    m_completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
    m_completer->setCaseSensitivity(Qt::CaseInsensitive);
    m_completer->setWrapAround(false);
    m_scriptEditor->setCompleter(m_completer);

    QFont font;
    font.setFamily("Myriad");
    font.setStyleHint(QFont::Monospace);
    font.setFixedPitch(true);
    font.setPointSize(10);

    QFontMetrics metrics(font);
    Highlighter* highlighter = new Highlighter(m_scriptEditor->document());

    m_scriptEditor->setFont(font);
    m_scriptEditor->setTabStopWidth(4 * metrics.width(" "));
    ui->tabWidget->removeTab(0);
    ui->tabWidget->insertTab(0, m_scriptEditor, tr("Script Editor"));
    ui->tabWidget->setCurrentIndex(0);
    m_scriptEditor->setFocus();

    if (!packet.isEmpty())
    {
        m_packet = new PacketReader(type, packet);
        m_packet->ReadHeader();

        ui->Opcode->setText(QString::number(m_packet->GetOpcode()));
        ui->Opcode->setDisabled(true);
        ui->Type->setCurrentIndex((m_packet->GetType() == "CMSG") ? 0 : 1);
        ui->Type->setDisabled(true);
        ui->Size->setText(QString::number(m_packet->GetSize()));

        if (m_packet->CompileScript())
            ui->tabWidget->setCurrentIndex(1);

        ui->ParsedPacket->setPlainText(m_packet->GetAnalyzedPacket());
    }

    if (m_packet && !m_packet->GetScript().isEmpty())
        m_scriptEditor->setPlainText(m_packet->GetScript());
    else if (!scriptPath.isEmpty())
        LoadFile(scriptPath);
    else
        m_scriptEditor->setPlainText("function ReadPacket()\n{\n\t// Code\n}\n\nReadPacket();");

    connect(ui->Close, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->Save, SIGNAL(clicked()), this, SLOT(Save()));
    connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int)));
    connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(OnTextChanged()));
}
void TextManipulator::ConsumeInput(IInputInjectorPtr injector, bool mouseIn)
{
	if (!mText)
		return;

	if (unsigned int chr = injector->GetChar())
	{
		auto mainWindowHandle = InputManager::GetInstance().GetMainWindowHandle();
		if (chr == 22) // Synchronous idle - ^V
		{
			injector->PopChar();	
			std::string data = GetClipboardDataAsString(mainWindowHandle);
			if (!data.empty())
			{
				if (IsHighlighting()){
					auto it = mText->begin() + mCursorPos;
					auto end = mText->begin() + mHighlightStart;
					if (mCursorPos > mHighlightStart)
					{
						std::swap(it, end);
					}
					mCursorPos = std::distance(mText->begin(), it);
					// delete selected string
					mText->erase(it, end);
					EndHighlighting();
				}
				std::wstring wclipData = AnsiToWide(data.c_str());
				mText->insert(mText->begin() + mCursorPos, wclipData.begin(), wclipData.end());				
				mCursorPos += data.size();
				OnCursorPosChanged();
				OnTextChanged();
			}
		}
		else if (chr == 3){ // ^C
			if (IsHighlighting()){
				auto it = mText->begin() + mCursorPos;
				auto end = mText->begin() + mHighlightStart;
				if (mCursorPos > mHighlightStart)
				{
					std::swap(it, end);
				}
				std::string data(it, end);
				SetClipboardStringData(mainWindowHandle, data.c_str());
			}
		}
		else{
			switch (chr)
			{
			case VK_BACK:
			{			
				if (IsHighlighting() && !mText->empty())
				{
					auto it = mText->begin() + mCursorPos;
					auto end = mText->begin() + mHighlightStart;
					if (mCursorPos > mHighlightStart)
					{
						std::swap(it, end);
					}
					mCursorPos = std::distance(mText->begin(), it);
					mText->erase(it, end);
					EndHighlighting();
				}
				else if (mCursorPos > 0 && !mText->empty())
				{
					mText->erase(mText->begin() + mCursorPos - 1);
					mCursorPos--;
				}
				OnCursorPosChanged();
				OnTextChanged();
			}
			break;
			default:
			{
				if (IsHighlighting())
				{
					auto it = mText->begin() + mCursorPos;
					auto end = mText->begin() + mHighlightStart;
					if (mCursorPos > mHighlightStart)
					{
						std::swap(it, end);
					}
					mCursorPos = std::distance(mText->begin(), it);
					// delete selected string
					mText->erase(it, end);
					EndHighlighting();
				}

				mText->insert(mText->begin() + mCursorPos, chr);
				mCursorPos++;
				OnCursorPosChanged();
				OnTextChanged();
			}
			}
		}

		injector->PopChar();
	}

	if (injector->IsKeyPressed(VK_HOME))
	{
		Highlighting(injector->IsKeyDown(VK_SHIFT));
		mCursorPos = 0;
		OnCursorPosChanged();
	}
	else if (injector->IsKeyPressed(VK_END))
	{
		Highlighting(injector->IsKeyDown(VK_SHIFT));
		mCursorPos = mText->size();
		OnCursorPosChanged();
	}
	else if (injector->IsKeyPressed(VK_DELETE))
	{
		if (!mText->empty())
		{
			if (IsHighlighting())
			{
				auto it = mText->begin() + mCursorPos;
				auto end = mText->begin() + mHighlightStart;
				if (mCursorPos > mHighlightStart)
				{
					std::swap(it, end);
				}
				mCursorPos = std::distance(mText->begin(), it);
				mText->erase(it, end);
				EndHighlighting();
			}
			else
			{
				mText->erase(mText->begin() + mCursorPos);
			}
		}
		OnCursorPosChanged();
		OnTextChanged();
	}
	else if (injector->IsKeyPressed(VK_LEFT))
	{
		Highlighting(injector->IsKeyDown(VK_SHIFT));
		if (mCursorPos>0)
		{
			mCursorPos--;
		}
		OnCursorPosChanged();
	}
	else if (injector->IsKeyPressed(VK_RIGHT))
	{
		Highlighting(injector->IsKeyDown(VK_SHIFT));
		if (mCursorPos < (int)mText->size())
		{
			mCursorPos++;
		}
		OnCursorPosChanged();
	}
	//Logger::Log(FB_DEFAULT_LOG_ARG, "(info) checking double click");
	if (mouseIn && injector->IsLButtonDoubleClicked()){
		SelectAll();
		OnCursorPosChanged();
	}

	injector->Invalidate(InputDevice::Keyboard);
}
Example #14
0
RegEditPanel::RegEditPanel(SocRegRef ref, QWidget *parent)
    :QWidget(parent), m_ref(ref), m_reg_font(font())
{
    m_reg_font.setWeight(100);
    m_reg_font.setKerning(false);

    m_name_group = new QGroupBox("Name", this);
    m_name_edit = new QLineEdit(this);
    m_name_edit->setText(QString::fromStdString(ref.GetReg().name));
    QVBoxLayout *name_group_layout = new QVBoxLayout;
    name_group_layout->addWidget(m_name_edit);
    m_name_group->setLayout(name_group_layout);

    m_instances_table = new QTableWidget(this);
    m_instances_table->setRowCount(ref.GetReg().addr.size() + 1);
    m_instances_table->setColumnCount(RegInstNrColumns);
    for(size_t row = 0; row < ref.GetReg().addr.size(); row++)
        FillRow(row, ref.GetReg().addr[row]);
    CreateNewAddrRow(ref.GetReg().addr.size());
    m_instances_table->setHorizontalHeaderItem(RegInstIconColumn, new QTableWidgetItem(""));
    m_instances_table->setHorizontalHeaderItem(RegInstNameColumn, new QTableWidgetItem("Name"));
    m_instances_table->setHorizontalHeaderItem(RegInstAddrColumn, new QTableWidgetItem("Address"));
    m_instances_table->verticalHeader()->setVisible(false);
    m_instances_table->resizeColumnsToContents();
    m_instances_table->horizontalHeader()->setStretchLastSection(true);
    m_instances_table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    m_instances_group = new QGroupBox("Instances", this);
    QHBoxLayout *instances_group_layout = new QHBoxLayout;
    instances_group_layout->addWidget(m_instances_table);
    m_instances_group->setLayout(instances_group_layout);

    m_desc_group = new QGroupBox("Description", this);
    QHBoxLayout *group_layout = new QHBoxLayout;
    m_desc_edit = new MyTextEditor(this);
    m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetReg().desc));
    group_layout->addWidget(m_desc_edit);
    m_desc_group->setLayout(group_layout);

    bool has_sct = m_ref.GetReg().flags & REG_HAS_SCT;
    m_sct_check = new QCheckBox("Set/Clear/Toggle", this);
    m_sct_check->setCheckState(has_sct ? Qt::Checked : Qt::Unchecked);
    QHBoxLayout *flags_layout = new QHBoxLayout;
    flags_layout->addWidget(m_sct_check);
    flags_layout->addStretch();
    m_flags_group = new QGroupBox("Flags", this);
    m_flags_group->setLayout(flags_layout);

    m_formula_combo = new QComboBox(this);
    m_formula_combo->addItem("None", QVariant(REG_FORMULA_NONE));
    m_formula_combo->addItem("String", QVariant(REG_FORMULA_STRING));
    m_formula_combo->setCurrentIndex(m_formula_combo->findData(QVariant(m_ref.GetReg().formula.type)));
    m_formula_type_label = new QLabel("Type:", this);
    QHBoxLayout *formula_top_layout = new QHBoxLayout;
    formula_top_layout->addWidget(m_formula_type_label);
    formula_top_layout->addWidget(m_formula_combo);
    m_formula_string_edit = new QLineEdit(QString::fromStdString(ref.GetReg().formula.string), this);
    QVBoxLayout *formula_layout = new QVBoxLayout;
    formula_layout->addLayout(formula_top_layout);
    formula_layout->addWidget(m_formula_string_edit);
    m_formula_string_gen = new QPushButton("Generate", this);
    formula_layout->addWidget(m_formula_string_gen);
    m_formula_group = new QGroupBox("Formula", this);
    m_formula_group->setLayout(formula_layout);

    QVBoxLayout *name_layout = new QVBoxLayout;
    name_layout->addWidget(m_name_group);
    name_layout->addWidget(m_flags_group);
    name_layout->addWidget(m_formula_group);
    name_layout->addStretch();

    QHBoxLayout *top_layout = new QHBoxLayout;
    top_layout->addWidget(m_instances_group);
    top_layout->addLayout(name_layout);
    top_layout->addWidget(m_desc_group, 1);

    m_value_table = new QTableView(this);
    m_value_model = new RegFieldTableModel(m_value_table); // view takes ownership
    m_value_model->SetRegister(m_ref.GetReg());
    m_value_model->SetReadOnly(true);
    m_value_table->setModel(m_value_model);
    m_value_table->verticalHeader()->setVisible(false);
    m_value_table->horizontalHeader()->setStretchLastSection(true);
    m_value_table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    // FIXME we cannot use setAlternatingRowColors() because we override the
    // background color, should it be part of the model ?
    m_table_delegate = new SocFieldCachedItemDelegate(this);
    m_value_table->setItemDelegate(m_table_delegate);
    m_value_table->resizeColumnsToContents();

    m_sexy_display2 = new Unscroll<RegSexyDisplay2>(this);
    m_sexy_display2->setFont(m_reg_font);
    m_sexy_display2->setModel(m_value_model);
    m_sexy_display2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    QHBoxLayout *field_layout = new QHBoxLayout;
    field_layout->addWidget(m_value_table);
    m_field_group = new QGroupBox("Flags", this);
    m_field_group->setLayout(field_layout);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(top_layout, 0);
    layout->addWidget(m_sexy_display2, 0);
    layout->addWidget(m_field_group);

    UpdateFormula();

    setLayout(layout);

    SocFieldItemDelegate *m_table_delegate = new SocFieldItemDelegate(this);
    QItemEditorFactory *m_table_edit_factory = new QItemEditorFactory();
    SocFieldEditorCreator *m_table_edit_creator = new SocFieldEditorCreator();
    m_table_edit_factory->registerEditor(QVariant::UInt, m_table_edit_creator);
    m_table_delegate->setItemEditorFactory(m_table_edit_factory);
    m_instances_table->setItemDelegate(m_table_delegate);

    connect(m_instances_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnInstActivated(int,int)));
    connect(m_instances_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnInstChanged(int,int)));
    connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&)));
    connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited()));
    connect(m_sct_check, SIGNAL(stateChanged(int)), this, SLOT(OnSctEdited(int)));
    connect(m_formula_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormulaChanged(int)));
    connect(m_formula_string_edit, SIGNAL(textChanged(const QString&)), this, 
        SLOT(OnFormulaStringChanged(const QString&)));
    connect(m_formula_string_gen, SIGNAL(clicked(bool)), this, SLOT(OnFormulaGenerate(bool)));
}
Example #15
0
/**
 * DevEditPanel
 */
DevEditPanel::DevEditPanel(SocDevRef ref, QWidget *parent)
    :QWidget(parent), m_ref(ref)
{
    m_name_group = new QGroupBox("Name", this);
    m_name_edit = new QLineEdit(this);
    m_name_edit->setText(QString::fromStdString(ref.GetDev().name));
    QVBoxLayout *name_group_layout = new QVBoxLayout;
    name_group_layout->addWidget(m_name_edit);
    m_name_group->setLayout(name_group_layout);

    m_long_name_group = new QGroupBox("Long Name", this);
    m_long_name_edit = new QLineEdit(this);
    m_long_name_edit->setText(QString::fromStdString(ref.GetDev().long_name));
    QVBoxLayout *long_name_group_layout = new QVBoxLayout;
    long_name_group_layout->addWidget(m_long_name_edit);
    m_long_name_group->setLayout(long_name_group_layout);

    m_version_group = new QGroupBox("Version", this);
    m_version_edit = new QLineEdit(this);
    m_version_edit->setText(QString::fromStdString(ref.GetDev().version));
    QVBoxLayout *version_group_layout = new QVBoxLayout;
    version_group_layout->addWidget(m_version_edit);
    m_version_group->setLayout(version_group_layout);

    QVBoxLayout *name_ver_layout = new QVBoxLayout;
    name_ver_layout->addWidget(m_name_group);
    name_ver_layout->addWidget(m_long_name_group);
    name_ver_layout->addWidget(m_version_group);
    name_ver_layout->addStretch();

    m_instances_table = new QTableWidget(this);
    m_instances_table->setRowCount(ref.GetDev().addr.size() + 1);
    m_instances_table->setColumnCount(3);
    for(size_t row = 0; row < ref.GetDev().addr.size(); row++)
        FillRow(row, ref.GetDev().addr[row]);
    CreateNewRow(ref.GetDev().addr.size());
    m_instances_table->setHorizontalHeaderItem(0, new QTableWidgetItem(""));
    m_instances_table->setHorizontalHeaderItem(1, new QTableWidgetItem("Name"));
    m_instances_table->setHorizontalHeaderItem(2, new QTableWidgetItem("Address"));
    m_instances_table->verticalHeader()->setVisible(false);
    m_instances_table->resizeColumnsToContents();
    m_instances_table->horizontalHeader()->setStretchLastSection(true);
    m_instances_table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    m_instances_group = new QGroupBox("Instances", this);
    QHBoxLayout *instances_group_layout = new QHBoxLayout;
    instances_group_layout->addWidget(m_instances_table);
    m_instances_group->setLayout(instances_group_layout);

    QHBoxLayout *top_layout = new QHBoxLayout;
    top_layout->addWidget(m_instances_group);
    top_layout->addLayout(name_ver_layout);
    top_layout->addStretch();

    m_desc_group = new QGroupBox("Description", this);
    QHBoxLayout *group_layout = new QHBoxLayout;
    m_desc_edit = new MyTextEditor(this);
    m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetDev().desc));
    group_layout->addWidget(m_desc_edit);
    m_desc_group->setLayout(group_layout);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(top_layout, 0);
    layout->addWidget(m_desc_group, 1);

    setLayout(layout);

    SocFieldItemDelegate *m_table_delegate = new SocFieldItemDelegate(this);
    QItemEditorFactory *m_table_edit_factory = new QItemEditorFactory();
    SocFieldEditorCreator *m_table_edit_creator = new SocFieldEditorCreator();
    m_table_edit_factory->registerEditor(QVariant::UInt, m_table_edit_creator);
    m_table_delegate->setItemEditorFactory(m_table_edit_factory);
    m_instances_table->setItemDelegate(m_table_delegate);

    connect(m_instances_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnInstActivated(int,int)));
    connect(m_instances_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnInstChanged(int,int)));
    connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&)));
    connect(m_long_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnLongNameEdited(const QString&)));
    connect(m_version_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnVersionEdited(const QString&)));
    connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited()));
}
Example #16
0
/**
 * FieldEditPanel
 */
FieldEditPanel::FieldEditPanel(SocFieldRef ref, QWidget *parent)
    :QWidget(parent), m_ref(ref)
{
    m_name_group = new QGroupBox("Name", this);
    m_name_edit = new QLineEdit(this);
    m_name_edit->setText(QString::fromStdString(ref.GetField().name));
    QVBoxLayout *name_group_layout = new QVBoxLayout;
    name_group_layout->addWidget(m_name_edit);
    m_name_group->setLayout(name_group_layout);

    m_bitrange_group = new QGroupBox("Bit Range", this);
    m_bitrange_edit = new QLineEdit(this);
    const soc_reg_field_t& field = ref.GetField();
    QString bits_str;
    if(field.first_bit == field.last_bit)
        bits_str.sprintf("%d", field.first_bit);
    else
        bits_str.sprintf("%d:%d", field.last_bit, field.first_bit);
    m_bitrange_edit->setText(bits_str);
    m_bitrange_edit->setValidator(new SocBitRangeValidator(m_bitrange_edit));
    QVBoxLayout *bitrange_group_layout = new QVBoxLayout;
    bitrange_group_layout->addWidget(m_bitrange_edit);
    m_bitrange_group->setLayout(bitrange_group_layout);

    m_desc_group = new QGroupBox("Description", this);
    QHBoxLayout *group_layout = new QHBoxLayout;
    m_desc_edit = new MyTextEditor(this);
    m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetField().desc));
    group_layout->addWidget(m_desc_edit);
    m_desc_group->setLayout(group_layout);

    m_value_group = new QGroupBox("Values", this);
    QHBoxLayout *value_layout = new QHBoxLayout;
    m_value_table = new QTableWidget(this);
    m_value_table->setRowCount(ref.GetField().value.size() + 1);
    m_value_table->setColumnCount(FieldValueNrColumns);
    for(size_t row = 0; row < ref.GetField().value.size(); row++)
        FillRow(row, ref.GetField().value[row]);
    CreateNewRow(ref.GetField().value.size());
    m_value_table->setHorizontalHeaderItem(FieldValueIconColumn, new QTableWidgetItem(""));
    m_value_table->setHorizontalHeaderItem(FieldValueNameColumn, new QTableWidgetItem("Name"));
    m_value_table->setHorizontalHeaderItem(FieldValueValueColumn, new QTableWidgetItem("Value"));
    m_value_table->setHorizontalHeaderItem(FieldValueDescColumn, new QTableWidgetItem("Description"));
    m_value_table->verticalHeader()->setVisible(false);
    m_value_table->horizontalHeader()->setStretchLastSection(true);
    value_layout->addWidget(m_value_table);
    m_value_group->setLayout(value_layout);

    QHBoxLayout *line_layout = new QHBoxLayout;
    line_layout->addWidget(m_name_group);
    line_layout->addWidget(m_bitrange_group);
    line_layout->addStretch();

    QVBoxLayout *left_layout = new QVBoxLayout;
    left_layout->addLayout(line_layout);
    left_layout->addWidget(m_desc_group);
    left_layout->addWidget(m_value_group, 1);

    UpdateDelegates();

    connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&)));
    connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited()));
    connect(m_value_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnValueActivated(int,int)));
    connect(m_value_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnValueChanged(int,int)));
    connect(m_bitrange_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnBitRangeEdited(const QString&)));

    setLayout(left_layout);
}
Example #17
0
RegEditPanel::RegEditPanel(SocRegRef ref, QWidget *parent)
    :QWidget(parent), m_ref(ref), m_reg_font(font())
{
    m_reg_font.setWeight(100);
    m_reg_font.setKerning(false);

    m_name_group = new QGroupBox("Name", this);
    m_name_edit = new QLineEdit(this);
    m_name_edit->setText(QString::fromStdString(ref.GetReg().name));
    QVBoxLayout *name_group_layout = new QVBoxLayout;
    name_group_layout->addWidget(m_name_edit);
    m_name_group->setLayout(name_group_layout);

    m_instances_table = new QTableWidget(this);
    m_instances_table->setRowCount(ref.GetReg().addr.size() + 1);
    m_instances_table->setColumnCount(RegInstNrColumns);
    for(size_t row = 0; row < ref.GetReg().addr.size(); row++)
        FillRow(row, ref.GetReg().addr[row]);
    CreateNewAddrRow(ref.GetReg().addr.size());
    m_instances_table->setHorizontalHeaderItem(RegInstIconColumn, new QTableWidgetItem(""));
    m_instances_table->setHorizontalHeaderItem(RegInstNameColumn, new QTableWidgetItem("Name"));
    m_instances_table->setHorizontalHeaderItem(RegInstAddrColumn, new QTableWidgetItem("Address"));
    m_instances_table->verticalHeader()->setVisible(false);
    m_instances_table->resizeColumnsToContents();
    m_instances_table->horizontalHeader()->setStretchLastSection(true);
    m_instances_table->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    m_instances_group = new QGroupBox("Instances", this);
    QHBoxLayout *instances_group_layout = new QHBoxLayout;
    instances_group_layout->addWidget(m_instances_table);
    m_instances_group->setLayout(instances_group_layout);

    m_desc_group = new QGroupBox("Description", this);
    QHBoxLayout *group_layout = new QHBoxLayout;
    m_desc_edit = new MyTextEditor(this);
    m_desc_edit->SetTextHtml(QString::fromStdString(ref.GetReg().desc));
    group_layout->addWidget(m_desc_edit);
    m_desc_group->setLayout(group_layout);

    bool has_sct = m_ref.GetReg().flags & REG_HAS_SCT;
    m_sct_check = new QCheckBox("Set/Clear/Toggle", this);
    m_sct_check->setCheckState(has_sct ? Qt::Checked : Qt::Unchecked);
    QHBoxLayout *flags_layout = new QHBoxLayout;
    flags_layout->addWidget(m_sct_check);
    flags_layout->addStretch();
    m_flags_group = new QGroupBox("Flags", this);
    m_flags_group->setLayout(flags_layout);

    m_formula_combo = new QComboBox(this);
    m_formula_combo->addItem("None", QVariant(REG_FORMULA_NONE));
    m_formula_combo->addItem("String", QVariant(REG_FORMULA_STRING));
    m_formula_combo->setCurrentIndex(m_formula_combo->findData(QVariant(m_ref.GetReg().formula.type)));
    m_formula_type_label = new QLabel("Type:", this);
    QHBoxLayout *formula_top_layout = new QHBoxLayout;
    formula_top_layout->addWidget(m_formula_type_label);
    formula_top_layout->addWidget(m_formula_combo);
    m_formula_string_edit = new QLineEdit(QString::fromStdString(ref.GetReg().formula.string), this);
    QVBoxLayout *formula_layout = new QVBoxLayout;
    formula_layout->addLayout(formula_top_layout);
    formula_layout->addWidget(m_formula_string_edit);
    m_formula_string_gen = new QPushButton("Generate", this);
    formula_layout->addWidget(m_formula_string_gen);
    m_formula_group = new QGroupBox("Formula", this);
    m_formula_group->setLayout(formula_layout);

    QVBoxLayout *name_layout = new QVBoxLayout;
    name_layout->addWidget(m_name_group);
    name_layout->addWidget(m_flags_group);
    name_layout->addWidget(m_formula_group);
    name_layout->addStretch();

    QHBoxLayout *top_layout = new QHBoxLayout;
    top_layout->addWidget(m_instances_group);
    top_layout->addLayout(name_layout);
    top_layout->addWidget(m_desc_group, 1);

    m_sexy_display = new RegSexyDisplay(m_ref, this);
    m_sexy_display->setFont(m_reg_font);

    m_field_table = new QTableWidget;
    m_field_table->setRowCount(m_ref.GetReg().field.size());
    m_field_table->setColumnCount(4);
    for(size_t row = 0; row < m_ref.GetReg().field.size(); row++)
    {
        const soc_reg_field_t& field = m_ref.GetReg().field[row];
        QString bits_str;
        if(field.first_bit == field.last_bit)
            bits_str.sprintf("%d", field.first_bit);
        else
            bits_str.sprintf("%d:%d", field.last_bit, field.first_bit);
        QTableWidgetItem *item = new QTableWidgetItem(bits_str);
        item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        m_field_table->setItem(row, 1, item);
        item = new QTableWidgetItem(QString(field.name.c_str()));
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        m_field_table->setItem(row, 2, item);
        item = new QTableWidgetItem(QString(field.desc.c_str()));
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        m_field_table->setItem(row, 3, item);
        UpdateWarning(row);
    }
    m_field_table->setHorizontalHeaderItem(0, new QTableWidgetItem(""));
    m_field_table->setHorizontalHeaderItem(1, new QTableWidgetItem("Bits"));
    m_field_table->setHorizontalHeaderItem(2, new QTableWidgetItem("Name"));
    m_field_table->setHorizontalHeaderItem(3, new QTableWidgetItem("Description"));
    m_field_table->verticalHeader()->setVisible(false);
    m_field_table->resizeColumnsToContents();
    m_field_table->horizontalHeader()->setStretchLastSection(true);
    QHBoxLayout *field_layout = new QHBoxLayout;
    field_layout->addWidget(m_field_table);
    m_field_group = new QGroupBox("Flags", this);
    m_field_group->setLayout(field_layout);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(top_layout, 0);
    layout->addWidget(m_sexy_display, 0);
    layout->addWidget(m_field_group);

    UpdateFormula();

    setLayout(layout);

    SocFieldItemDelegate *m_table_delegate = new SocFieldItemDelegate(this);
    QItemEditorFactory *m_table_edit_factory = new QItemEditorFactory();
    SocFieldEditorCreator *m_table_edit_creator = new SocFieldEditorCreator();
    m_table_edit_factory->registerEditor(QVariant::UInt, m_table_edit_creator);
    m_table_delegate->setItemEditorFactory(m_table_edit_factory);
    m_instances_table->setItemDelegate(m_table_delegate);

    connect(m_instances_table, SIGNAL(cellActivated(int,int)), this, SLOT(OnInstActivated(int,int)));
    connect(m_instances_table, SIGNAL(cellChanged(int,int)), this, SLOT(OnInstChanged(int,int)));
    connect(m_name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(OnNameEdited(const QString&)));
    connect(m_desc_edit, SIGNAL(OnTextChanged()), this, SLOT(OnDescEdited()));
    connect(m_sct_check, SIGNAL(stateChanged(int)), this, SLOT(OnSctEdited(int)));
    connect(m_formula_combo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnFormulaChanged(int)));
    connect(m_formula_string_edit, SIGNAL(textChanged(const QString&)), this, 
        SLOT(OnFormulaStringChanged(const QString&)));
    connect(m_formula_string_gen, SIGNAL(clicked(bool)), this, SLOT(OnFormulaGenerate(bool)));
}
Example #18
0
MainWindow::MainWindow(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::MainWindow)
{
	ui->setupUi(this);

	ui->fEditor->setAcceptRichText(false);

	fSimpleNote = 0;

	ui->fNoteList->setItemDelegate(new ListDelegate(ui->fNoteList));
	ui->fTagsComboBox->view()->setItemDelegate(new TagListDelegate(ui->fTagsComboBox));


	QList<int> sizes;
	sizes << 200 << 400;

	ui->fSplitter->setSizes(sizes);
	fTimer = new QTimer(this);
	fTimer->setInterval(5000);
	fTimer->start();
	connect(fTimer, SIGNAL(timeout()), this, SLOT(OnTimeout()));


	QAction* quitAction = new QAction(tr("Quit"), this);
	quitAction->setShortcut(QKeySequence("Ctrl+Q"));
	connect(quitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
	addAction(quitAction);


	QAction* addNoteAction = new QAction(tr("New Note"), this);
	addNoteAction->setIcon(QIcon(":/images/images/add2.png"));
	addNoteAction->setShortcut(QKeySequence("Ctrl+N"));
	connect(addNoteAction, SIGNAL(triggered(bool)), this, SLOT(OnAdd()));
	ui->fNoteList->addAction(addNoteAction);

	ui->fAddButton->setDefaultAction(addNoteAction);


	QAction* deleteCurrent = new QAction(tr("Remove"), ui->fNoteList);
	deleteCurrent->setIcon(QIcon(":/images/images/delete2.png"));
	connect(deleteCurrent, SIGNAL(triggered(bool)), this, SLOT(RemoveCurrent()));
	ui->fNoteList->addAction(deleteCurrent);
	ui->fNoteList->setContextMenuPolicy(Qt::ActionsContextMenu);


	QAction* syncCurrentAction = new QAction("Sync Current", this);
	syncCurrentAction->setShortcut(QKeySequence("Ctrl+S"));
	connect(syncCurrentAction, SIGNAL(triggered(bool)), this, SLOT(SaveCurrent()));
	addAction(syncCurrentAction);

	QAction* syncAction = new QAction("Full Sync", this);
	syncAction->setShortcut(QKeySequence("Ctrl+Shift+S"));
	connect(syncAction, SIGNAL(triggered(bool)), this, SLOT(FullSync()));
	addAction(syncAction);

	QAction* tagsAction = new QAction("Edit Tags", this);
	tagsAction->setShortcut(QKeySequence("Ctrl+G"));
	connect(tagsAction, SIGNAL(triggered(bool)), this, SLOT(EditTags()));
	addAction(tagsAction);

	QAction* settingsAction = new QAction("Settings...", this);
	connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(OnSettings()));
	addAction(settingsAction);

	ui->fSettingsButton->addAction(syncCurrentAction);
	ui->fSettingsButton->addAction(syncAction);
	ui->fSettingsButton->addAction(settingsAction);
	ui->fSettingsButton->setPopupMode(QToolButton::InstantPopup);


	connect(ui->fFavouriteButton, SIGNAL(clicked(bool)), this, SLOT(OnFavourite()));


	connect(ui->fEditor, SIGNAL(textChanged()), this, SLOT(OnTextChanged()));
	connect(ui->fSearchEdit, SIGNAL(textChanged(QString)), this, SLOT(OnSearchChanged()));
	connect(ui->fTagsEdit, SIGNAL(textChanged(QString)), this, SLOT(OnTagsChanged()));
	connect(ui->fExportButton, SIGNAL(clicked(bool)), this, SLOT(OnExport()));
	connect(ui->fTagsComboBox, SIGNAL(activated(int)), this, SLOT(OnTagSelected()));
	connect(ui->fEditor, SIGNAL(OpenNote(QString)), this, SLOT(OpenNote(QString)));

	fCurrent = -1;

	fNotes.SetMessageReceiver(this);

	fSnippets.reset(new SnippetCollection);
	ui->fEditor->SetSnippets(fSnippets);

	fNotesModel = new NoteListModel(&fNotes, this);
	fFilterModel = new NoteSortFilterModel(this);
	fFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
	fFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive);
	fFilterModel->setSourceModel(fNotesModel);

	ui->fNoteList->setModel(fFilterModel);

	connect(ui->fNoteList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(OnSelection(QModelIndex)));

	LoadNotes();
	UpdateNoteList();

	ui->fNoteList->setCurrentIndex(fFilterModel->index(0, 0));
	ui->fNoteList->setFocus();

	RestoreSettings();
	SetEditorFont(SettingsDialog::CurrentFont(), SettingsDialog::CurrentTabSize());
}
void TextBoxRenderComponent::OnFontChanged(Variant *pDataObject)
{
	//OPTIMIZE: this is lame, recomputing everything, but whatever
	OnTextChanged(NULL);
}