DlgContractors::DlgContractors(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DlgContractors)
{
    ui->setupUi(this);

    typeModel = new TypeContractorModel(this);
    organizationModel = new QSqlQueryModel(this);

    model = new QSqlQueryModel(this);
    proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel(model);
    ui->tableView->setModel(proxyModel);

    setupModels();
    setupColumns();

    setWindowTitle(tr("Контрагенты"));

    connect(ui->btnInsert,SIGNAL(clicked()),SLOT(insert()));
    connect(ui->btnEdit,SIGNAL(clicked()),SLOT(edit()));
    connect(ui->btnRemove,SIGNAL(clicked()),SLOT(remove()));

    connect(ui->tableView,SIGNAL(doubleClicked(QModelIndex)),SLOT(edit()));

    acInsert = new QAction(tr("Добавить"),this);
    connect(acInsert,SIGNAL(triggered()),SLOT(insert()));
    acInsert->setShortcut(Qt::Key_Insert);

    acEdit = new QAction(tr("Изменить"),this);
    connect(acEdit,SIGNAL(triggered()),SLOT(edit()));
    acEdit->setShortcut(Qt::Key_Return);

    acRemove = new QAction(tr("Удалить"),this);
    connect(acRemove,SIGNAL(triggered()),SLOT(remove()));
    acRemove->setShortcut(Qt::Key_Delete);

    ui->tableView->addAction(acInsert);
    ui->tableView->addAction(acEdit);
    ui->tableView->addAction(acRemove);


}
GtkTorrentSideBar::GtkTorrentSideBar(GtkTreeView *tree, const Glib::RefPtr<Gtk::Builder> rbuilder)
  : Gtk::TreeView(tree), m_builder(rbuilder)
{
	rbuilder->get_widget_derived("GtkMainWindow", m_parent);
	rbuilder->get_widget_derived("rssDialog", m_rss);
	m_rss->set_transient_for(*m_parent);

	m_liststore = Gtk::TreeStore::create(m_cols);

	set_model(m_liststore);

	set_headers_visible(false);
	set_show_expanders(true);
	set_activate_on_single_click();
	expand_all(); // Shouldn't this go after setupColumns()?

	signal_row_activated().connect([this](const Gtk::TreeModel::Path& Path, Gtk::TreeViewColumn *col){ this->onRowClicked(*m_liststore->get_iter(Path)); });

	setupColumns();
}
Beispiel #3
0
// ----------------------------------------------------------------------------
// ArchiveEntryList::ArchiveEntryList
//
// ArchiveEntryList class constructor
// ----------------------------------------------------------------------------
 ArchiveEntryList::ArchiveEntryList(wxWindow* parent) : VirtualListView(parent)
{
	// Init variables
	archive = nullptr;
	filter_category = "";
	current_dir = nullptr;
	show_dir_back = false;
	undo_manager = nullptr;
	entries_update = true;

	// Create dummy 'up folder' entry
	entry_dir_back = new ArchiveEntry();
	entry_dir_back->setType(EntryType::folderType());
	entry_dir_back->setState(0);
	entry_dir_back->setName("..");

	// Setup columns
	setupColumns();

	// Setup entry icons
	wxImageList* image_list = new wxImageList(16, 16, false, 0);

	wxArrayString et_icon_list = EntryType::getIconList();
	for (size_t a = 0; a < et_icon_list.size(); a++)
	{
		if (image_list->Add(Icons::getIcon(Icons::ENTRY, et_icon_list[a])) < 0)
			image_list->Add(Icons::getIcon(Icons::ENTRY, "default"));
	}

	SetImageList(image_list, wxIMAGE_LIST_SMALL);

	// Bind events
	Bind(wxEVT_LIST_COL_RIGHT_CLICK, &ArchiveEntryList::onColumnHeaderRightClick, this);
	Bind(wxEVT_LIST_COL_END_DRAG, &ArchiveEntryList::onColumnResize, this);
	Bind(wxEVT_LIST_ITEM_ACTIVATED, &ArchiveEntryList::onListItemActivated, this);

	// Setup flags
	SetSingleStyle(wxLC_HRULES, elist_hrules);
	SetSingleStyle(wxLC_VRULES, elist_vrules);
}
ListViewEditor::ListViewEditor( QWidget *parent, QListView *lv, FormWindow *fw )
    : ListViewEditorBase( parent, 0, true ), listview( lv ), formwindow( fw )
{
    connect( helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );
    itemText->setEnabled( false );
    itemChoosePixmap->setEnabled( false );
    itemDeletePixmap->setEnabled( false );
    itemColumn->setEnabled( false );

    setupColumns();
    PopulateListViewCommand::transferItems( listview, itemsPreview );
    setupItems();

    itemsPreview->setShowSortIndicator( listview->showSortIndicator() );
    itemsPreview->setAllColumnsShowFocus( listview->allColumnsShowFocus() );
    itemsPreview->setRootIsDecorated( listview->rootIsDecorated() );

    if ( itemsPreview->firstChild() ) {
	itemsPreview->setCurrentItem( itemsPreview->firstChild() );
	itemsPreview->setSelected( itemsPreview->firstChild(), true );
    }
}
Beispiel #5
0
// ----------------------------------------------------------------------------
// ArchiveEntryList::handleAction
//
// Handles the action [id].
// Returns true if the action was handled, false otherwise
// ----------------------------------------------------------------------------
bool ArchiveEntryList::handleAction(string id)
{
	// Don't handle action if hidden
	if (!IsShown())
		return false;

	// Only interested in actions beginning with aelt_
	if (!id.StartsWith("aelt_"))
		return false;

	if (id == "aelt_sizecol")
	{
		elist_colsize_show = !elist_colsize_show;
		setupColumns();
		updateWidth();
		updateList();
		if (GetParent())
			GetParent()->Layout();
	}
	else if (id == "aelt_typecol")
	{
		elist_coltype_show = !elist_coltype_show;
		setupColumns();
		updateWidth();
		updateList();
		if (GetParent())
			GetParent()->Layout();
	}
	else if (id == "aelt_indexcol")
	{
		elist_colindex_show = !elist_colindex_show;
		setupColumns();
		updateWidth();
		updateList();
		if (GetParent())
			GetParent()->Layout();
	}
	else if (id == "aelt_hrules")
	{
		elist_hrules = !elist_hrules;
		SetSingleStyle(wxLC_HRULES, elist_hrules);
		Refresh();
	}
	else if (id == "aelt_vrules")
	{
		elist_vrules = !elist_vrules;
		SetSingleStyle(wxLC_VRULES, elist_vrules);
		Refresh();
	}
	else if (id == "aelt_bgcolour")
	{
		elist_type_bgcol = !elist_type_bgcol;
		Refresh();
	}
	else if (id == "aelt_bgalt")
	{
		elist_alt_row_colour = !elist_alt_row_colour;
		Refresh();
	}

	// Unknown action
	else
		return false;

	// Action handled, return true
	return true;
}
ListViewEditor::ListViewEditor( QWidget *parent, QListView *lv, FormWindow *fw )
    : ListViewEditorBase( parent, 0, TRUE ), listview( lv ), formwindow( fw )
{
    connect( helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );
    itemText->setEnabled( FALSE );
    itemChoosePixmap->setEnabled( FALSE );
    itemDeletePixmap->setEnabled( FALSE );
    itemColumn->setEnabled( FALSE );

    setupColumns();
    PopulateListViewCommand::transferItems( listview, itemsPreview );
    setupItems();

    itemsPreview->setShowSortIndicator( listview->showSortIndicator() );
    itemsPreview->setAllColumnsShowFocus( listview->allColumnsShowFocus() );
    itemsPreview->setRootIsDecorated( listview->rootIsDecorated() );

    if ( itemsPreview->firstChild() ) {
	itemsPreview->setCurrentItem( itemsPreview->firstChild() );
	itemsPreview->setSelected( itemsPreview->firstChild(), TRUE );
    }

    // Clamp on drag and drop to QListView
    ListViewDnd *itemsDnd = new ListViewDnd( itemsPreview );
    itemsDnd->setDragMode( ListViewDnd::Internal | ListViewDnd::Move );
    QObject::connect( itemsDnd, SIGNAL( dropped( QListViewItem * ) ),
		      itemsDnd, SLOT( confirmDrop( QListViewItem * ) ) );

    // Enable rename for all QListViewItems
    QListViewItemIterator it = ((QListView *)itemsPreview)->firstChild();
    for ( ; *it; it++ )
	(*it)->setRenameEnabled( 0, TRUE );

    // Connect listview signal to signal-relay
    QObject::connect( itemsPreview,
		      SIGNAL( itemRenamed( QListViewItem*, int, const QString & ) ),
		      this,
		      SLOT( emitItemRenamed(QListViewItem*, int, const QString&) ) );

    // Connect signal-relay to QLineEdit "itemText"
    QObjectList *l = parent->queryList( "QLineEdit", "itemText" );
    QObject *obj;
    QObjectListIt itemsLineEditIt( *l );
    while ( (obj = itemsLineEditIt.current()) != 0 ) {
        ++itemsLineEditIt;
	QObject::connect( this,
			  SIGNAL( itemRenamed( const QString & ) ),
			  obj,
			  SLOT( setText( const QString & ) ) );
    }
    delete l;

    // Clamp on drag and drop to QListBox
    ListBoxDnd *columnsDnd = new ListBoxDnd( colPreview );
    columnsDnd->setDragMode( ListBoxDnd::Internal | ListBoxDnd::Move );
    QObject::connect( columnsDnd, SIGNAL( dropped( QListBoxItem * ) ),
		      columnsDnd, SLOT( confirmDrop( QListBoxItem * ) ) );

    // Clamp on rename to QListBox
    ListBoxRename *columnsRename = new ListBoxRename( colPreview );
    QObject::connect( columnsRename,
		      SIGNAL( itemTextChanged( const QString & ) ),
		      this,
		      SLOT( columnTextChanged( const QString & ) ) );

    // Find QLineEdit "colText" and connect
    l = parent->queryList( "QLineEdit", "colText" );
    QObjectListIt columnsLineEditIt( *l );
    while ( (obj = columnsLineEditIt.current()) != 0 ) {
        ++columnsLineEditIt;
	QObject::connect( columnsRename,
			  SIGNAL( itemTextChanged( const QString & ) ),
			  obj,
			  SLOT( setText( const QString & ) ) );
    }
    delete l;
}
GtkPeerTreeView::GtkPeerTreeView(GtkTreeView *tree, const Glib::RefPtr<Gtk::Builder> rbuilder) : Gtk::TreeView(tree)
{
	m_liststore = Gtk::ListStore::create(m_cols);
	set_model(m_liststore);
	setupColumns();
}