Exemplo n.º 1
0
void PoitemTableView::setModel(QAbstractItemModel* model)
{
  if (DEBUG) qDebug("PoitemTableView::setModel(%p)", model);
  QTableView::setModel(model);

  setColumnWidth(ITEM_NUMBER_COL,		_itemColumn);
  setColumnWidth(WAREHOUS_CODE_COL,		100); //_whsColumn too small
  setColumnWidth(POITEM_VEND_ITEM_DESCRIP_COL, 200);
  setColumnWidth(POITEM_QTY_ORDERED_COL,	_qtyColumn);
  setColumnWidth(POITEM_UNITPRICE_COL,		_priceColumn);
  setColumnWidth(EXTPRICE_COL,			_moneyColumn);
  setColumnWidth(POITEM_FREIGHT_COL,		_priceColumn);
  setColumnWidth(POITEM_DUEDATE_COL,		_dateColumn);
#ifdef QE_NONINVENTORY
  setColumnWidth(EXPCAT_CODE_COL,		100);
#endif
  setColumnWidth(POITEM_VEND_ITEM_NUMBER_COL,	_itemColumn);

  QHeaderView *header = horizontalHeader();

  int dest = 0;
  header->moveSection(header->visualIndex(ITEM_NUMBER_COL),	 	dest++);
  header->moveSection(header->visualIndex(WAREHOUS_CODE_COL),		dest++);
  header->moveSection(header->visualIndex(POITEM_VEND_ITEM_NUMBER_COL),	dest++);
  header->moveSection(header->visualIndex(POITEM_VEND_ITEM_DESCRIP_COL),	dest++);
#ifdef QE_NONINVENTORY
  header->moveSection(header->visualIndex(EXPCAT_CODE_COL),		dest++);
#endif
  header->moveSection(header->visualIndex(POITEM_QTY_ORDERED_COL),	dest++);
  header->moveSection(header->visualIndex(POITEM_UNITPRICE_COL),	dest++);
  header->moveSection(header->visualIndex(EXTPRICE_COL),		dest++);
  header->moveSection(header->visualIndex(POITEM_FREIGHT_COL),		dest++);
  header->moveSection(header->visualIndex(POITEM_DUEDATE_COL),		dest++);

  // if we didn't explicitly place the logical section, hide it
  for (int i = dest; i < header->count(); i++)
    header->hideSection(header->logicalIndex(i));

  //header->setStretchLastSection(true);
  if (DEBUG) qDebug("PoitemTableView::setModel returning");
}
Exemplo n.º 2
0
void TreeLog::loadConfig()
{
	QList<int> colWidths = Config::treeLogColumnWidths();
	QList<int> colPositions = Config::treeLogColumnPositions();
	QList<int> colVisible = Config::treeLogColumnVisible();
	QHeaderView* header = treeLog().header();

	for (int i = 0; i < treeLog().columnCount(); i++)
	{
		if (colPositions[0] != -1 && colPositions.size() > i)
			header->moveSection(header->visualIndex(i), colPositions[i]);

		if (colVisible[0] != -1 && colVisible.size() > i)
			treeLog().setColumnHidden(i, colVisible[i] == 0);

		if (colWidths[0] != -1 && colWidths.size() > i)
			treeLog().setColumnWidth(i, colWidths[i]);
	}
}
Exemplo n.º 3
0
ProjectsTree::ProjectsTree(TTCP *ttcp, QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);
    setWindowFlags( windowFlags() & ~Qt::WindowMinimizeButtonHint );

    recentMenuClean = true;

    readSettings();

    recentMenu = new QMenu(this);
    alignmentGroup = new QActionGroup(this);

    recentMenu->setTitle(tr("projects"));
    recentMenu->setObjectName("project menu");
    recentMenu->setTearOffEnabled(true);

    TreeModel *model = new TreeModel(this);

    createActions();
    createViewActions();

    this->ttcp = ttcp;

#if defined TRAYPROJECT
    trayIcon = new QSystemTrayIcon();
    trayIconMenu = new QMenu();
    QIcon icon = QIcon(":/pics/active-icon-0.xpm");

    trayIconMenu->addAction(selectCurrentAction);
    trayIconMenu->addAction(timeEditAction);
    trayIconMenu->addAction(minimizeAction);
    trayIconMenu->addAction(maximizeAction);
    trayIconMenu->addAction(restoreAction);
    trayIconMenu->addAction(quitAction);

    trayIcon->setIcon(icon);
    trayIcon->setContextMenu(trayIconMenu);

    trayIcon->show();
#endif

    QStringList headers;
    headers << tr("Title") << tr("Description");

    view->setModel(model);
    view->resizeColumnToContents(0);
    QHeaderView *header = view->header();
    header->moveSection(0, 1);
    view->setColumnWidth(1, 100);
    view->hideColumn(2);
    header->setMovable(false);

    /*! \sa
     * MyTreeView::popMenu()
     * ProjectsTree::itemMenu()
     */
    connect(ttcp, SIGNAL(error(const QString &)), this, SLOT(p_error(const QString &)));
    connect(ttcp, SIGNAL(recentprojects(QList<int>&)), this, SLOT(updateRecentMenu(QList<int>&)));

    connect(view, SIGNAL(popMenu()), this, SLOT(itemMenu()));
    connect(view, SIGNAL(projPopMenu(int)), this, SLOT(projItemMenu(int)));

    connect(model, SIGNAL(get_time(int)), ttcp, SLOT(gettime(int)));
    connect(this, SIGNAL(changeProjectTo(int)), ttcp, SLOT(setProject(int)));

    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(view, SIGNAL(expanded(QModelIndex)),
            model, SLOT(expanded(QModelIndex)));

    connect(view, SIGNAL(collapsed(QModelIndex)),
            model, SLOT(collapsed(QModelIndex)));

    connect(ttcp, SIGNAL(disconnected()),
            view, SLOT(disable()));
    connect(ttcp, SIGNAL(connected()),
            view, SLOT(enable()));

    connect(ttcp, SIGNAL(add_entry(QString,int,int,QTime,QTime)),
            model, SLOT(add_entry(QString,int,int,QTime,QTime)));

    connect(ttcp, SIGNAL(current(int)),
            this, SLOT(setCurrent(int)));

    //! Unselect the view
    connect(ttcp, SIGNAL(current(int)),
            view, SLOT(clearSelection()));

    connect(ttcp, SIGNAL(current(int)),
            model, SLOT(set_current(int)));

    connect(ttcp, SIGNAL(settime(int, QTime, QTime)),
            model, SLOT(update_time(int, QTime, QTime)));

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

#if defined TRAYPROJECT
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
	    this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
#endif

#if defined (Q_WS_X11)
    x11();
#endif

    updateActions();

    addNoteW = new Notes(ttcp, this);
    connect(ttcp, SIGNAL(accept_note(const QString &)), addNoteW, SLOT(notesDone(const QString &)));
    addTaskW = new AddProject(ttcp, this);
    connect(ttcp, SIGNAL(accept_project(const QString &)), addTaskW, SLOT(done(const QString &)));
    addAutoSelW = new AddAuto(ttcp, this);
    connect(ttcp, SIGNAL(accept_select(const QString &)), addAutoSelW, SLOT(autoDone(const QString &)));
    errorWin = new ErrorWindow(this);
    timeEditWin = new TimeEdit(ttcp, this);
    
    connect(timeEditAction, SIGNAL(triggered()), timeEditWin, SLOT(myShow()));
//    timeEditWin->myShow();
}
Exemplo n.º 4
0
int HeaderView::moveSection(lua_State * L) // ( int from, int to )
{
    QHeaderView* obj = QtObject<QHeaderView>::check( L, 1);
	obj->moveSection( Util::toInt( L, 2), Util::toInt( L, 3) );
	return 1;
}