Esempio n. 1
0
static void
LOOP_END(State &state, const ControlFlowInst &cf)
{
   // TODO: LOOP_END has different behaviour depending on which LOOP_START
   // instruction started the loop, currently we only handle LOOP_START_DX10
   auto &loopState = state.loopStack.top();
   auto loopIndex = state.loopStack.size() - 1;

   // Sanity check to ensure we are at the cfPC
   decaf_check(state.cfPC == loopState.endPC);
   decaf_check((cf.word0.ADDR - 1) == loopState.startPC);

   state.loopStack.pop();

   // If breakMask is set, lets break from the while
   insertLineStart(state);
   state.out << "if (activeMask == InactiveBreak) {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   state.out << "break;";
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << "}";
   insertLineEnd(state);

   // If ContinueMask is set, lets break from the while
   insertLineStart(state);
   state.out << "if (activeMask == InactiveContinue) {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   state.out << "activeMask = Active;";
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << "}";
   insertLineEnd(state);

   // Check the while condition but without checking loop masks
   decreaseIndent(state);
   insertLineStart(state);
   state.out << "} while (";
   insertCond(state, cf.word1.COND());
   state.out << ");";
   insertLineEnd(state);

   insertPop(state);
   condEnd(state);
}
void
disassembleVtxClause(State &state, const latte::ControlFlowInst &inst)
{
   auto addr = inst.word0.ADDR;
   auto count = (inst.word1.COUNT() + 1) | (inst.word1.COUNT_3() << 3);
   auto clause = reinterpret_cast<const VertexFetchInst *>(state.binary.data() + 8 * addr);

   increaseIndent(state);

   for (auto i = 0u; i < count; ++i) {
      const auto &vtx = clause[i];

      state.out
         << '\n'
         << state.indent
         << fmt::pad(state.groupPC, 3, ' ')
         << "    ";

      disassembleVtxInstruction(state.out, inst, vtx, 15);
      state.out << "\n";
      state.groupPC++;
   }

   decreaseIndent(state);
}
Esempio n. 3
0
void Context::beginBlock(const Text &s, bool indent)
{
    if (!s.empty())
        addLine(s);
    addLine("{");
    if (indent)
        increaseIndent();
}
Esempio n. 4
0
static void
binaryCompareKill(State &state,
                  const ControlFlowInst &cf,
                  const AluInst &alu,
                  const char *op)
{
   // if (src0 op src1) { discard; } else { dst = 0.0f; }
   auto flags = getInstructionFlags(alu.op2.ALU_INST());

   insertLineStart(state);
   state.out << "if (";
   insertSource0(state, state.out, cf, alu);
   state.out << op;
   insertSource1(state, state.out, cf, alu);
   state.out << ") {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   state.out << "discard;";
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << "} else {";
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   insertDestBegin(state, cf, alu, state.unit);

   if ((flags & SQ_ALU_FLAG_INT_OUT) || (flags & SQ_ALU_FLAG_UINT_OUT)) {
      state.out << "0";
   } else {
      state.out << "0.0f";
   }

   insertDestEnd(state, cf, alu);
   state.out << ';';
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   state.out << '}';
   insertLineEnd(state);
}
Esempio n. 5
0
void
condElse(State &state)
{
   decreaseIndent(state);
   insertLineStart(state);
   fmt::format_to(state.out, "}} else {{");
   insertLineEnd(state);
   increaseIndent(state);
}
Esempio n. 6
0
void XmlOutput::newTagOpen(const QString &tag)
{
    Q_ASSERT_X(tag.count(), "XmlOutput", "Cannot open an empty tag");
    closeOpen();

    if (format == NewLine)
        xmlFile << endl << currentIndent;
    xmlFile << '<' << doConversion(tag);
    currentState = Attribute;
    tagStack.append(tag);
    increaseIndent(); // ---> indent
}
void
disassembleControlFlowALU(State &state, const ControlFlowInst &inst)
{
   auto addr = inst.alu.word0.ADDR();
   auto count = inst.alu.word1.COUNT() + 1;

   state.out.write("{}{:02} ", state.indent, state.cfPC);
   disassembleCfALUInstruction(state.out, inst);

   increaseIndent(state);
   disassembleAluClause(state, inst, addr, count);
   decreaseIndent(state);
}
Esempio n. 8
0
void
condStart(State &state,
          SQ_CF_COND cond)
{
   insertLineStart(state);

   fmt::format_to(state.out, "if (");
   insertCond(state, cond);
   fmt::format_to(state.out, ") {{");

   insertLineEnd(state);
   increaseIndent(state);
}
Esempio n. 9
0
static void
LOOP_START_DX10(State &state, const ControlFlowInst &cf)
{
   LoopState loop;
   loop.startPC = state.cfPC;
   loop.endPC = cf.word0.ADDR - 1;
   state.loopStack.emplace(loop);

   condStart(state, cf.word1.COND());
   insertPush(state);

   insertLineStart(state);
   state.out << "do {";
   insertLineEnd(state);
   increaseIndent(state);
}
Esempio n. 10
0
void
insertElse(State &state)
{
   insertLineStart(state);
   fmt::format_to(state.out, "if (stack[stackIndex - 1] == Active) {{");
   insertLineEnd(state);

   increaseIndent(state);
   insertLineStart(state);
   fmt::format_to(state.out, "activeMask = (activeMask == Active) ? InactiveBranch : Active;");
   insertLineEnd(state);
   decreaseIndent(state);

   insertLineStart(state);
   fmt::format_to(state.out, "}}");
   insertLineEnd(state);
}
Esempio n. 11
0
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
	if (event->type() == QEvent::FocusOut)
	{
		if (object == ui->textNote)
		{
			saveNoteText();
		}
	}
	else if (event->type() == QEvent::KeyPress)
	{
		if(object == ui->textNote)
		{
			QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
			// trap tab key
			if (keyEvent->key() == Qt::Key_Tab) {
				// increase indent in lists
				if (ui->textNote->textCursor().currentList())
					increaseIndent();
				// add two spaces in non-lists
				else {
					ui->textNote->insertPlainText("\t");
				}
				return true;
			}
			// trap backtab key
			else if(keyEvent->key() == Qt::Key_Backtab)
			{
				// decrease indent if list
				if (ui->textNote->textCursor().currentList()) {
					decreaseIndent();
				}
				return true;
			}
		}
	}
	return false;
}
bool
disassembleVTX(State &state, shadir::CfInstruction *inst)
{
   state.out
      << " ADDR(" << inst->addr << ")"
      << " CNT(" << inst->clause.size() << ")";

   if (!inst->barrier) {
      state.out << " NO_BARRIER";
   }

   disassembleCondition(state, inst);

   state.out << '\n';
   increaseIndent(state);

   for (auto &child : inst->clause) {
      // TODO: Disassemble VTX clauses
   }

   decreaseIndent(state);
   return true;
}
Esempio n. 13
0
static void
disassembleNormal(State &state, const ControlFlowInst &inst)
{
   auto id = inst.word1.CF_INST();
   auto name = getInstructionName(id);

   switch (id) {
   case SQ_CF_INST_WAIT_ACK:
   case SQ_CF_INST_TEX_ACK:
   case SQ_CF_INST_VTX_ACK:
   case SQ_CF_INST_VTX_TC_ACK:
      decaf_abort(fmt::format("Unable to decode instruction {} {}", id, name));
   }

   // Decode instruction clause
   state.out.write("{}{:02} ", state.indent, state.cfPC);
   disassembleCF(state.out, inst);
   state.out << "\n";

   switch (id) {
   case SQ_CF_INST_LOOP_START:
   case SQ_CF_INST_LOOP_START_DX10:
   case SQ_CF_INST_LOOP_START_NO_AL:
      increaseIndent(state);
      break;
   case SQ_CF_INST_LOOP_END:
      decreaseIndent(state);
      break;
   case SQ_CF_INST_TEX:
      disassembleTEXClause(state, inst);
      break;
   case SQ_CF_INST_VTX:
   case SQ_CF_INST_VTX_TC:
      disassembleVtxClause(state, inst);
      break;
   }
}
Esempio n. 14
0
static bool
disassembleLoop(State &state, shadir::CfInstruction *inst)
{
   switch (inst->id) {
   case SQ_CF_INST_LOOP_START:
   case SQ_CF_INST_LOOP_START_DX10:
   case SQ_CF_INST_LOOP_START_NO_AL:
      state.out << " FAIL_JUMP_ADDR(" << inst->addr << ")";
      increaseIndent(state);
      break;
   case SQ_CF_INST_LOOP_CONTINUE:
   case SQ_CF_INST_LOOP_BREAK:
      state.out << " ADDR(" << inst->addr << ")";
      break;
   case SQ_CF_INST_LOOP_END:
      state.out << " PASS_JUMP_ADDR(" << inst->addr << ")";
      decreaseIndent(state);
      break;
   default:
      state.out << " UNKNOWN_LOOP_CF_INST";
   }

   if (inst->popCount) {
      state.out << " POP_COUNT(" << inst->popCount << ")";
   }

   if (inst->validPixelMode) {
      state.out << " VALID_PIX";
   }

   if (!inst->barrier) {
      state.out << " NO_BARRIER";
   }

   state.out << '\n';
   return true;
}
Esempio n. 15
0
bool Disassembler::cfNormal(fmt::MemoryWriter &out, latte::cf::inst id, latte::cf::Instruction &cf)
{
   auto name = latte::cf::name[id];

   switch (id) {
   case latte::cf::NOP:
      return true;
   case latte::cf::TEX:
      return cfTEX(out, id, cf);
   case latte::cf::VTX:
   case latte::cf::VTX_TC:
      // Vtx
      break;
   case latte::cf::LOOP_START:
   case latte::cf::LOOP_START_DX10:
   case latte::cf::LOOP_START_NO_AL:
      out
         << name
         << " FAIL_JUMP_ADDR(" << cf.word0.addr << ")"
         << "\n";
      increaseIndent();
      break;
   case latte::cf::LOOP_END:
      out
         << name
         << " PASS_JUMP_ADDR(" << cf.word0.addr << ")"
         << "\n";
      decreaseIndent();
      break;
   case latte::cf::JUMP:
      out
         << name
         << " POP_CNT(" << cf.word1.popCount << ")"
         << " ADDR(" << cf.word0.addr << ")"
         << "\n";
      break;
   case latte::cf::END_PROGRAM:
      out
         << name
         << "\n";
      break;
   case latte::cf::CALL_FS:
      out
         << name
         << "\n";
      break;
   case latte::cf::LOOP_CONTINUE:
   case latte::cf::POP_JUMP:
   case latte::cf::ELSE:
   case latte::cf::CALL:
   case latte::cf::RETURN:
   case latte::cf::EMIT_VERTEX:
   case latte::cf::EMIT_CUT_VERTEX:
   case latte::cf::CUT_VERTEX:
   case latte::cf::KILL:
   case latte::cf::PUSH:
   case latte::cf::PUSH_ELSE:
   case latte::cf::POP:
   case latte::cf::POP_PUSH:
   case latte::cf::POP_PUSH_ELSE:
   case latte::cf::WAIT_ACK:
   case latte::cf::TEX_ACK:
   case latte::cf::VTX_ACK:
   case latte::cf::VTX_TC_ACK:
   default:
      assert(false);
      break;
   }

   return true;
}
Esempio n. 16
0
bool Disassembler::cfTEX(fmt::MemoryWriter &out, latte::cf::inst cfID, latte::cf::Instruction &cf)
{
   uint32_t *ptr = mWords + (wordsPerCF * cf.word0.addr);

   out
      << latte::cf::name[cfID] << ": "
      << "ADDR(" << cf.word0.addr << ") CNT(" << (cf.word1.count + 1) << ")\n";

   increaseIndent();

   for (auto slot = 0u; slot <= cf.word1.count; ) {
      auto tex = *reinterpret_cast<latte::tex::Instruction*>(ptr);
      auto name = latte::tex::name[tex.word0.inst];
      auto id = tex.word0.inst;

      if (id == latte::tex::VTX_FETCH || id == latte::tex::VTX_SEMANTIC || id == latte::tex::GET_BUFFER_RESINFO) {
         assert(false);
         ptr += wordsPerVTX;
      } else if (id == latte::tex::MEM) {
         assert(false);
         ptr += wordsPerMEM;
      } else {
         out
            << mIndent.c_str()
            << fmt::pad(mGroupCounter, groupCounterSize, '0')
            << ' '
            << name
            << ' ';

         // Write dst
         if (tex.word1.dstRel != 0) {
            // TODO: relative address
            out << "__UNK_REL(" << tex.word1.dstRel << ")__";
         }

         writeRegisterName(out, tex.word1.dstReg);
         out << '.';
         writeSelectName(out, tex.word1.dstSelX);
         writeSelectName(out, tex.word1.dstSelY);
         writeSelectName(out, tex.word1.dstSelZ);
         writeSelectName(out, tex.word1.dstSelW);

         // Write src
         out << ", ";

         if (tex.word0.srcRel != 0) {
            // TODO: relative address
            out << "__UNK_REL(" << tex.word0.srcRel << ")__";
         }

         writeRegisterName(out, tex.word0.srcReg);
         out << '.';
         writeSelectName(out, tex.word2.srcSelX);
         writeSelectName(out, tex.word2.srcSelY);
         writeSelectName(out, tex.word2.srcSelZ);
         writeSelectName(out, tex.word2.srcSelW);

         out
            << ", t" << tex.word0.resourceID
            << ", s" << tex.word2.samplerID;

         if (tex.word2.offsetX || tex.word2.offsetY || tex.word2.offsetZ) {
            out
               << " OFFSET("
               << tex.word2.offsetX
               << ", "
               << tex.word2.offsetY
               << ", "
               << tex.word2.offsetZ
               << ")";
         }

         if (tex.word1.lodBias) {
            out << " LOD_BIAS(" << tex.word1.lodBias << ")";
         }

         if (!tex.word1.coordTypeX) {
            out << " CTX_UNORM";
         }

         if (!tex.word1.coordTypeY) {
            out << " CTY_UNORM";
         }

         if (!tex.word1.coordTypeZ) {
            out << " CTZ_UNORM";
         }

         if (!tex.word1.coordTypeW) {
            out << " CTW_UNORM";
         }

         if (tex.word0.bcFracMode) {
            out << " BFM";
         }

         if (tex.word0.fetchWholeQuad) {
            out << " FWQ";
         }

         out << '\n';
         ptr += wordsPerTEX;
      }

      mGroupCounter++;
      slot++;
   }

   decreaseIndent();
   return true;
}
Esempio n. 17
0
bool Disassembler::cfALU(fmt::MemoryWriter &out, latte::cf::inst id, latte::cf::Instruction &cf)
{
   uint64_t *slots = reinterpret_cast<uint64_t *>(mWords + (wordsPerCF * cf.aluWord0.addr));

   out
      << latte::alu::name[cf.aluWord1.inst] << ": "
      << "ADDR(" << cf.aluWord0.addr << ") CNT(" << (cf.aluWord1.count + 1) << ")";

   increaseIndent();

   for (auto slot = 0u; slot <= cf.aluWord1.count; ) {
      static char unitName[] = { 'x', 'y', 'z', 'w', 't' };
      bool units[5] = { false, false, false, false, false };
      bool last = false;
      uint32_t *literalPtr = reinterpret_cast<uint32_t*>(slots + slot);
      uint32_t literals = 0;

      out << "\n";

      for (auto i = 0u; i < 5 && !last; ++i) {
         auto alu = *reinterpret_cast<latte::alu::Instruction*>(slots + slot + i);
         literalPtr += 2;
         last = !!alu.word0.last;
      }

      last = false;

      for (auto i = 0u; i < 5 && !last; ++i) {
         auto alu = *reinterpret_cast<latte::alu::Instruction*>(slots + slot);
         auto unit = getUnit(units, alu);
         const char *name = nullptr;
         bool abs0 = false, abs1 = false;
         auto &opcode = latte::alu::op2[alu.op2.inst];

         if (alu.word1.encoding == latte::alu::Encoding::OP2) {
            opcode = latte::alu::op2[alu.op2.inst];
            name = opcode.name;
            abs0 = !!alu.op2.src0Abs;
            abs1 = !!alu.op2.src1Abs;
         } else {
            opcode = latte::alu::op3[alu.op3.inst];
            name = opcode.name;
         }

         out << mIndent.c_str();

         if (i == 0) {
            out << fmt::pad(mGroupCounter, groupCounterSize, '0');
         } else {
            out << std::string(groupCounterSize, ' ').c_str();
         }
         
         out
            << ' '
            << unitName[unit] << ": "
            << fmt::pad(name, instrNamePad, ' ');

         if (alu.word1.encoding == latte::alu::Encoding::OP2 && alu.op2.writeMask == 0) {
            out << "____";
         } else {
            writeAluSource(out, literalPtr, mGroupCounter, alu.word1.dstGpr, alu.word1.dstRel, alu.word1.dstChan, 0, false);
         }

         if (opcode.srcs > 0) {
            out << ", ";
            writeAluSource(out, literalPtr, mGroupCounter, alu.word0.src0Sel, alu.word0.src0Rel, alu.word0.src0Chan, alu.word0.src0Neg, abs0);
         }

         if (opcode.srcs > 1) {
            out << ", ";
            writeAluSource(out, literalPtr, mGroupCounter, alu.word0.src1Sel, alu.word0.src1Rel, alu.word0.src1Chan, alu.word0.src1Neg, abs1);
         }

         if (alu.word1.encoding == latte::alu::Encoding::OP2) {
            if (alu.op2.updateExecuteMask) {
               out << " UPDATE_EXECUTE_MASK";
            }

            if (alu.op2.updatePred) {
               out << " UPDATE_PRED";
            }

            switch (alu.op2.omod) {
            case latte::alu::OutputModifier::Divide2:
               out << " OMOD_D2";
               break;
            case latte::alu::OutputModifier::Multiply2:
               out << " OMOD_M2";
               break;
            case latte::alu::OutputModifier::Multiply4:
               out << " OMOD_M4";
               break;
            }
         } else {
            if (opcode.srcs > 2) {
               out << ", ";
               writeAluSource(out, literalPtr, mGroupCounter, alu.op3.src2Sel, alu.op3.src2Rel, alu.op3.src2Chan, alu.op3.src2Neg, false);
            }
         }

         switch (alu.word1.bankSwizzle) {
         case latte::alu::BankSwizzle::Vec021:
            out << " VEC_021";
            break;
         case latte::alu::BankSwizzle::Vec120:
            out << " VEC_120";
            break;
         case latte::alu::BankSwizzle::Vec102:
            out << " VEC_102";
            break;
         case latte::alu::BankSwizzle::Vec201:
            out << " VEC_201";
            break;
         case latte::alu::BankSwizzle::Vec210:
            out << " VEC_210";
            break;
         }

         if (alu.word1.clamp) {
            out << " CLAMP";
         }

         out << '\n';

         // Count number of literal used
         literals += (alu.word0.src0Sel == latte::alu::Source::SrcLiteral) ? 1 : 0;
         literals += (alu.word0.src1Sel == latte::alu::Source::SrcLiteral) ? 1 : 0;
         literals += ((alu.word1.encoding != latte::alu::Encoding::OP2) && (alu.op3.src2Sel == latte::alu::Source::SrcLiteral)) ? 1 : 0;

         // Increase slot id
         slot += 1;
         last = !!alu.word0.last;
      }

      if (literals) {
         slot += (literals + 1) >> 1;
      }
      mGroupCounter++;
   }

   decreaseIndent();
   return true;
}
Esempio n. 18
0
bool disassembleNormal(DisassembleState &state, latte::cf::inst id, latte::cf::Instruction &cf)
{
   auto name = latte::cf::name[id];

   switch (id) {
   case latte::cf::TEX:
      return disassembleTEX(state, id, cf);
   case latte::cf::LOOP_START:
   case latte::cf::LOOP_START_DX10:
   case latte::cf::LOOP_START_NO_AL:
      state.out
         << name
         << " FAIL_JUMP_ADDR(" << cf.word0.addr << ")";
      endLine(state);
      increaseIndent(state);
      break;
   case latte::cf::LOOP_END:
      state.out
         << name
         << " PASS_JUMP_ADDR(" << cf.word0.addr << ")";
      endLine(state);
      decreaseIndent(state);
      break;
   case latte::cf::ELSE:
   case latte::cf::JUMP:
      state.out
         << name
         << " POP_CNT(" << cf.word1.popCount << ")"
         << " ADDR(" << cf.word0.addr << ")";
      endLine(state);
      break;
   case latte::cf::NOP:
   case latte::cf::CALL_FS:
   case latte::cf::END_PROGRAM:
      state.out
         << name;
      endLine(state);
      break;
   case latte::cf::VTX:
   case latte::cf::VTX_TC:
   case latte::cf::LOOP_CONTINUE:
   case latte::cf::LOOP_BREAK:
   case latte::cf::POP_JUMP:
   case latte::cf::CALL:
   case latte::cf::RETURN:
   case latte::cf::EMIT_VERTEX:
   case latte::cf::EMIT_CUT_VERTEX:
   case latte::cf::CUT_VERTEX:
   case latte::cf::KILL:
   case latte::cf::PUSH:
   case latte::cf::PUSH_ELSE:
   case latte::cf::POP:
   case latte::cf::POP_PUSH:
   case latte::cf::POP_PUSH_ELSE:
   case latte::cf::WAIT_ACK:
   case latte::cf::TEX_ACK:
   case latte::cf::VTX_ACK:
   case latte::cf::VTX_TC_ACK:
   default:
      assert(false);
      break;
   }

   return true;
}
Esempio n. 19
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	// open database connection
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite");
	if(!db.open())
	{
		qDebug() << db.lastError();
		qFatal("Failed to connect.");
	}

	// setup UI
    ui->setupUi(this);
	ui->toolBar->addWidget(ui->comboFonts);
	ui->toolBar->addWidget(ui->comboFontSizes);
	ui->toolBar->addWidget(ui->comboColors);

	// set text editor defaults
	ui->textNote->document()->setIndentWidth(20);
	ui->textNote->setTabStopWidth(20);
	ui->textNote->setTabChangesFocus(false);
	ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab);
	ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab);

	// setup comboColors
	QPixmap pix(16, 16);
	pix.fill(Qt::white);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::black);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::red);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::blue);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::darkGreen);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::gray);
	ui->comboColors->addItem(pix, "");


	// create system tray icon
	createActions();
	createTrayIcon();

	// create models
    categoriesModel = new QSqlTableModel();
	categoriesModel->setTable("categories");
	categoriesModel->setSort(1, Qt::AscendingOrder);
	categoriesModel->select();
	ui->listCategories->setModel(categoriesModel);
	ui->listCategories->setModelColumn(1);

    notesModel = new QSqlTableModel();
	notesModel->setTable("notes");
	ui->listNotes->setModel(notesModel);
	ui->listNotes->setModelColumn(2);

    // set splitter size
    QList<int> sizes;
    sizes << 230 << 150;
    ui->splitterLists->setSizes(sizes);
    sizes.clear();
    sizes << 230 << 600;
    ui->splitterNote->setSizes(sizes);

    // connect File menu slots
    connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory()));
    connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory()));
    connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote()));
    connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote()));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    // connect Edit menu slots	
    connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace()));
    // connect Format menu slots
    connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold()));
    connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic()));
    connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline()));
    connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough()));
    connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList()));
    connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList()));
    connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent()));
    connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent()));
    connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors()));
    connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts()));
    connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont()));
    connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont()));
    connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont()));
    connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft()));
    connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter()));
    connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight()));
    connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify()));
    // connect View menu slots
    connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide()));
    connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory()));
    connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory()));
    connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote()));
    connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote()));
    // connect Help menu slots
    connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
	// connect application slots
	connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus()));
	connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus()));
    connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString)));
    connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString)));
    connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int)));
	// connect category list slots
	connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex)));
	// connect note list slots
	connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex)));
	// connect text slots
	ui->textNote->installEventFilter((this));
	// connect system tray icon
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

	// initialize default data
	ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent);

}