/*******************************************************************/
FamilyShoppingManagerMainWindow::FamilyShoppingManagerMainWindow(QWidget *parent)
- : QMainWindow(parent), activityView(NULL), showCheckedItemsAction(NULL),
- endShoppingAction(NULL), goShoppingAction(NULL), editMenu(NULL)
+ : QMainWindow(parent), activityView(NULL), editMenu(NULL),
+ showCheckedItemsAction(NULL), goShoppingAction(NULL), endShoppingAction(NULL)
{
aboutAction = new QAction(tr("&About"), this);
connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAbout()));
setCentralWidget(activityView);
editMenu = new QMenu(tr("&Edit"), this);
- editMenu->addAction(tr("Add category"));
- editMenu->addAction(tr("Remove category"));
- editMenu->addAction(tr("Add item"));
- editMenu->addAction(tr("Remove item"));
+ addCategoryAction = new QAction(tr("Add category"), this);
+ connect(addCategoryAction, SIGNAL(triggered()),
+ this, SLOT(insertRow()));
+ editMenu->addAction(addCategoryAction);
+ removeCategoryAction = new QAction(tr("Remove category"), this);
+ connect(removeCategoryAction, SIGNAL(triggered()),
+ this, SLOT(removeRow()));
+ editMenu->addAction(removeCategoryAction);
+ addItemAction = new QAction(tr("Add item"), this);
+ connect(addItemAction, SIGNAL(triggered()),
+ this, SLOT(insertRow()));
+ editMenu->addAction(addItemAction);
+ removeItemAction = new QAction(tr("Remove item"), this);
+ connect(removeItemAction, SIGNAL(triggered()),
+ this, SLOT(removeRow()));
+ editMenu->addAction(removeItemAction);
menuBar()->addMenu(editMenu);
goShoppingAction = new QAction(tr("Go shopping!"), this);
text += "Licence: GPL";
QMessageBox::about(this,tr("About"), text);
}
+
+/*******************************************************************/
+void FamilyShoppingManagerMainWindow::insertChild()
+{
+ QModelIndex index = ((ListManagerView*) activityView)->
+ selectionModel()->currentIndex();
+ QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
+
+ if (model->columnCount(index) == 0) {
+ if (!model->insertColumn(0, index))
+ return;
+ }
+
+ if (!model->insertRow(0, index))
+ return;
+
+ for (int column = 0; column < model->columnCount(index); ++column)
+ {
+ QModelIndex child = model->index(0, column, index);
+ model->setData(child, QVariant("[No data]"), Qt::EditRole);
+ if (!model->headerData(column, Qt::Horizontal).isValid())
+ model->setHeaderData(column, Qt::Horizontal,
+ QVariant("[No header]"), Qt::EditRole);
+ }
+
+ ((ListManagerView*) activityView)->selectionModel()->
+ setCurrentIndex(model->index(0, 0, index),
+ QItemSelectionModel::ClearAndSelect);
+ ((ListManagerView*) activityView)->updateActions();
+ }
+
+/*******************************************************************/
+/*
+bool FamilyShoppingManagerMainWindow::insertColumn(const QModelIndex &parent)
+{
+ QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
+ int column = ((ListManagerView*) activityView)->selectionModel()->
+ currentIndex().column();
+
+ // Insert a column in the parent item.
+ bool changed = model->insertColumn(column + 1, parent);
+ if (changed)
+ model->setHeaderData(column + 1, Qt::Horizontal,
+ QVariant("[No header]"), Qt::EditRole);
+
+ ((ListManagerView*) activityView)->updateActions();
+
+ return changed;
+}
+*/
+
+/*******************************************************************/
+void FamilyShoppingManagerMainWindow::insertRow()
+{
+ QModelIndex index = ((ListManagerView*) activityView)->
+ selectionModel()->currentIndex();
+ QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
+
+ if (!model->insertRow(index.row()+1, index.parent()))
+ return;
+
+ ((ListManagerView*) activityView)->updateActions();
+
+ for(int column = 0; column < model->columnCount(index.parent()); ++column)
+ {
+ QModelIndex child = model->index(index.row()+1, column, index.parent());
+ model->setData(child, QVariant("New Item"), Qt::EditRole);
+ }
+}
+
+/*******************************************************************/
+/*
+bool FamilyShoppingManagerMainWindow::removeColumn(const QModelIndex &parent)
+{
+ QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
+ int column = ((ListManagerView*) activityView)->selectionModel()->
+ currentIndex().column();
+
+ // Insert columns in each child of the parent item.
+ bool changed = model->removeColumn(column, parent);
+
+ if (!parent.isValid() && changed)
+ ((ListManagerView*) activityView)->updateActions();
+
+ return changed;
+}
+ */
+
+/*******************************************************************/
+void FamilyShoppingManagerMainWindow::removeRow()
+{
+ QModelIndex index = ((ListManagerView*) activityView)->
+ selectionModel()->currentIndex();
+ QAbstractItemModel *model = ((ListManagerView*) activityView)->model();
+ if (model->removeRow(index.row(), index.parent()))
+ ((ListManagerView*) activityView)->updateActions();
+}
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
- <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-GJlGaxlG0v,guid=0c8e1c6e41d3e6f2d1af89c24b6fc5bb</value>
+ <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ftBEZLbXAE,guid=e2c8517a9ef4dda368a3470a4b96c3aa</value>
<value type="QString">DESKTOP_SESSION=default</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">DM_CONTROL=/var/run/xdmctl</value>
- <value type="QString">GPG_AGENT_INFO=/tmp/gpg-pfjgMn/S.gpg-agent:1953:1</value>
+ <value type="QString">GPG_AGENT_INFO=/tmp/gpg-aqBEsG/S.gpg-agent:1905:1</value>
<value type="QString">GS_LIB=/home/onil/.fonts</value>
<value type="QString">GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/onil/.gtkrc-2.0:/home/onil/.gtkrc-2.0-kde4:/home/onil/.kde/share/config/gtkrc-2.0</value>
<value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc</value>
<value type="QString">PWD=/home/onil/Documents</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value>
- <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2044,unix/onil-netbook:/tmp/.ICE-unix/2044</value>
+ <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/1998,unix/onil-netbook:/tmp/.ICE-unix/1998</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=0</value>
- <value type="QString">SSH_AGENT_PID=1952</value>
- <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-pIQBwR1902/agent.1902</value>
+ <value type="QString">SSH_AGENT_PID=1904</value>
+ <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gckQrI1854/agent.1854</value>
<value type="QString">USER=onil</value>
<value type="QString">WINDOWPATH=7</value>
<value type="QString">XCURSOR_THEME=oxy-white</value>
<value type="QString">XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share</value>
- <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1265616314.877010-1127570423</value>
+ <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1268171689.363286-1127686922</value>
<value type="QString">XDM_MANAGED=method=classic</value>
</valuelist>
<valuelist key="abstractProcess.arguments" type="QVariantList">
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
- <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-GJlGaxlG0v,guid=0c8e1c6e41d3e6f2d1af89c24b6fc5bb</value>
+ <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-ftBEZLbXAE,guid=e2c8517a9ef4dda368a3470a4b96c3aa</value>
<value type="QString">DESKTOP_SESSION=default</value>
<value type="QString">DISPLAY=:0.0</value>
<value type="QString">DM_CONTROL=/var/run/xdmctl</value>
- <value type="QString">GPG_AGENT_INFO=/tmp/gpg-pfjgMn/S.gpg-agent:1953:1</value>
+ <value type="QString">GPG_AGENT_INFO=/tmp/gpg-aqBEsG/S.gpg-agent:1905:1</value>
<value type="QString">GS_LIB=/home/onil/.fonts</value>
<value type="QString">GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/onil/.gtkrc-2.0:/home/onil/.gtkrc-2.0-kde4:/home/onil/.kde/share/config/gtkrc-2.0</value>
<value type="QString">GTK_RC_FILES=/etc/gtk/gtkrc:/home/onil/.gtkrc::/home/onil/.kde/share/config/gtkrc</value>
<value type="QString">PWD=/home/onil/Documents</value>
<value type="QString">QTDIR=/usr/share/qt4</value>
<value type="QString">QT_PLUGIN_PATH=/home/onil/.kde/lib/kde4/plugins/:/usr/lib/kde4/plugins/</value>
- <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/2044,unix/onil-netbook:/tmp/.ICE-unix/2044</value>
+ <value type="QString">SESSION_MANAGER=local/onil-netbook:@/tmp/.ICE-unix/1998,unix/onil-netbook:/tmp/.ICE-unix/1998</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SHLVL=0</value>
- <value type="QString">SSH_AGENT_PID=1952</value>
- <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-pIQBwR1902/agent.1902</value>
+ <value type="QString">SSH_AGENT_PID=1904</value>
+ <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gckQrI1854/agent.1854</value>
<value type="QString">USER=onil</value>
<value type="QString">WINDOWPATH=7</value>
<value type="QString">XCURSOR_THEME=oxy-white</value>
<value type="QString">XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share</value>
- <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1265616314.877010-1127570423</value>
+ <value type="QString">XDG_SESSION_COOKIE=67465ad3dd74e5003d0b02474b126985-1268171689.363286-1127686922</value>
<value type="QString">XDM_MANAGED=method=classic</value>
</valuelist>
<value key="abstractProcess.IgnoreReturnValue" type="bool">false</value>