Ejemplo n.º 1
0
bool
CategoryModel::insertRows(int row, int count, const QModelIndex& /*parent*/)
{
	if (model_ == nullptr || count != 1) {
		return false;
	}
	if (row < 0 || static_cast<std::size_t>(row) > model_->categoryList().size()) {
		return false;
	}

	if (model_->findCategoryName(NEW_ITEM_NAME)) {
		qWarning("Duplicate category: %s", NEW_ITEM_NAME);
		return false;
	}

	beginInsertRows(QModelIndex(), row, row);
	std::shared_ptr<TRMControlModel::Category> newCategory(new TRMControlModel::Category(NEW_ITEM_NAME));
	model_->categoryList().insert(
				model_->categoryList().begin() + row,
				newCategory);
	endInsertRows();

	emit categoryChanged();

	return true;
}
Ejemplo n.º 2
0
category_t *dataHandling(char *recipe, char *category, category_t *head)
{
  category_t *current = head;
  recipe_t* recipeNode = newRecipe(recipe, category, NULL);

  if(head == NULL)
  {
    head = newCategory(category, recipeNode, NULL); 
  } 
  else if(listContains(category, head) != NULL)
  {
    current = listContains(category, head);
    stackRecipe(recipeNode, current);
  }
  else
  {
    stackCategory(newCategory(category, recipeNode, NULL), head);
  }
  return head;
}
Ejemplo n.º 3
0
eXpenses::eXpenses(QWidget *parent)
    : QMainWindow(parent)
{
	ui.setupUi(this);

	// set current date
	ui.m_deDate->setDate(QDate::currentDate());
	ui.m_deDate->setDisplayFormat(st_dateFormat);

	init();

	connect(qManager, SIGNAL(newCategory(QString)), SLOT(onCategoryAdded(QString)));
	connect(qManager, SIGNAL(newProduct(QString)), SLOT(onProductAdded(QString)));
}
Ejemplo n.º 4
0
void CategoryWidget::checkCategory()
{
   try{
         {
         dbo::Transaction t(session_);
         categoryPointer = session_.find<Category>().where("categoryname = ?").bind(categoryEdit->text().toUTF8());
         t.commit();
         }
         new WText(categoryPointer->categoryname + " already exists",categoryContainer);
      }
   catch(exception& e){
      newCategory();
   }
}
Ejemplo n.º 5
0
PMRuleContains::PMRuleContains( QDomElement& e,
                                QPtrList<PMRuleDefineGroup>& globalGroups,
                                QPtrList<PMRuleDefineGroup>& localGroups )
      : PMRuleCondition( )
{
   m_contains = false;
   QDomNode m = e.firstChild( );
   while( !m.isNull( ) )
   {
      if( m.isElement( ) )
      {
         QDomElement me = m.toElement( );
         if( isCategory( me ) )
            m_categories.append( newCategory( me, globalGroups, localGroups ) );
      }
      m = m.nextSibling( );
   }
}
Ejemplo n.º 6
0
PMRuleCount::PMRuleCount( QDomElement& e,
                          QPtrList<PMRuleDefineGroup>& globalGroups,
                          QPtrList<PMRuleDefineGroup>& localGroups )
      : PMRuleValue( )
{
   m_number = 0;
   QDomNode m = e.firstChild( );
   while( !m.isNull( ) )
   {
      if( m.isElement( ) )
      {
         QDomElement me = m.toElement( );
         if( isCategory( me ) )
            m_categories.append( newCategory( me, globalGroups, localGroups ) );
      }
      m = m.nextSibling( );
   }
}
Ejemplo n.º 7
0
PMRuleDefineGroup::PMRuleDefineGroup( QDomElement& e,
                         QPtrList<PMRuleDefineGroup>& globalGroups,
                         QPtrList<PMRuleDefineGroup>& localGroups )
{
   m_name = e.attribute( "name" );
   if( m_name.isEmpty( ) )
      kdError( PMArea ) << "RuleSystem: Invalid group name" << endl;

   QDomNode m = e.firstChild( );
   while( !m.isNull( ) )
   {
      if( m.isElement( ) )
      {
         QDomElement me = m.toElement( );
         if( isCategory( me ) )
            m_categories.append( newCategory( me, globalGroups, localGroups ) );
      }
      m = m.nextSibling( );
   }
}
Ejemplo n.º 8
0
MainController::MainController(): m_mw(new MainWindow), m_search(m_mw)
{


    connect(m_mw, SIGNAL(s_save(QString)), this, SLOT(save(QString)));
    connect(m_mw, SIGNAL(s_load(QString)), this, SLOT(load(QString)));
    connect(m_mw, SIGNAL(s_newBase()), this, SLOT(newBase()));

    connect(m_mw, SIGNAL(s_addCategory(QString)), this, SLOT(newCategory(QString)));
    connect(m_mw, SIGNAL(s_removeCategory(QString)), this, SLOT(removeCategory(QString)));
    connect(m_mw, SIGNAL(s_seeCategory()), this, SLOT(editCategory()));
    connect(m_mw, SIGNAL(s_showCategory()), this, SLOT(showCategory()));

    connect(m_mw, SIGNAL(s_addMedia(QString)), this, SLOT(newMedia(QString)));
    connect(m_mw, SIGNAL(s_removeMedia(QString,QString)), this, SLOT(removeMedia(QString,QString)));
    connect(m_mw, SIGNAL(s_seeMedia()), this, SLOT(editMedia()));

    connect(m_mw, SIGNAL(s_showUser()), this, SLOT(setUser()));

    connect(m_mw, SIGNAL(s_search()), this, SLOT(search()));

    connect(&m_search, SIGNAL(s_find(QList<MediaSPointer>)), this, SLOT(showSearch(QList<MediaSPointer>)));

    connect(m_mw, SIGNAL(s_settings()), this, SLOT(settings()));

    m_mw->setShortcut(SettingsController::settings());

    SettingsController artemis;
    artemis.newSettings(SettingsController::settings());

    if(UserController::userCount() == 0)
        UserController().exec();
    else
        UserController::connectUser();

}
Ejemplo n.º 9
0
PMRule::PMRule( QDomElement& e,
                QPtrList<PMRuleDefineGroup>& globalGroups,
                QPtrList<PMRuleDefineGroup>& localGroups )
      : PMRuleBase( )
{
   m_pCondition = 0;

   QDomNode m = e.firstChild( );
   while( !m.isNull( ) && !m_pCondition )
   {
      if( m.isElement( ) )
      {
         QDomElement me = m.toElement( );
         if( isCategory( me ) )
            m_categories.append( newCategory( me, globalGroups, localGroups ) );
         else if( isCondition( me ) )
         {
            m_pCondition = newCondition( me, globalGroups, localGroups );
            m_children.append( m_pCondition );
         }
      }
      m = m.nextSibling( );
   }
}
Ejemplo n.º 10
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);

}