Exemplo n.º 1
0
//-----------------------------------------------------------------------------
int ctkExpandableWidgetTest1(int argc, char * argv [] )
{
  QApplication::setStyle(new QPlastiqueStyle);
  QApplication app(argc, argv);

  QWidget topLevel;
  QHBoxLayout* topLevelLayout = new QHBoxLayout;
  topLevel.setLayout(topLevelLayout);

  QWidget frame;
  topLevelLayout->addWidget(&frame);

  ctkExpandableWidget resizableFrame1(&frame);
  QListView* listView = new QListView(&resizableFrame1);
  listView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout1 = new QVBoxLayout(&resizableFrame1);
  resizableFrameLayout1->setContentsMargins(0,0,0,0);
  resizableFrame1.setSizeGripMargins(QSize(2, 2));
  resizableFrame1.setLayout(resizableFrameLayout1);
  resizableFrameLayout1->addWidget(listView);
  resizableFrame1.setOrientations(Qt::Horizontal | Qt::Vertical);

  ctkExpandableWidget resizableFrame(&frame);
  resizableFrame.setSizeGripInside(false);
  QTreeView* treeView = new QTreeView(&resizableFrame);
  treeView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout = new QVBoxLayout(&resizableFrame);
  resizableFrameLayout->setContentsMargins(0,0,0,0);
  //resizableFrame.setSizeGripMargins(QSize(2, 2));
  resizableFrame.setLayout(resizableFrameLayout);
  resizableFrameLayout->addWidget(treeView);
  resizableFrame.setOrientations(Qt::Horizontal);

  QVBoxLayout *vbox = new QVBoxLayout;
  vbox->setContentsMargins(0, 0, 0, 0);
  vbox->addWidget(&resizableFrame1);
  vbox->addWidget(&resizableFrame);
  frame.setLayout(vbox);

  ctkExpandableWidget resizableFrame0(&topLevel);
  QTableView* tableView = new QTableView(&resizableFrame0);
  tableView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  QVBoxLayout* resizableFrameLayout0 = new QVBoxLayout(&resizableFrame0);
  resizableFrameLayout0->setContentsMargins(0,0,0,0);
  resizableFrame0.setSizeGripMargins(QSize(2, 2));
  resizableFrame0.setLayout(resizableFrameLayout0);
  resizableFrameLayout0->addWidget(tableView);
  resizableFrame0.setOrientations(Qt::Vertical);
  topLevelLayout->addWidget(&resizableFrame0);

  topLevel.show();

  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Exemplo n.º 2
0
void ComboBox::hack()
{
	QListView *v = new QListView( this );
	v->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
	v->setMinimumHeight( 50 );
	v->setModel( model() );
	setView( v );
}
Exemplo n.º 3
0
SongEditorWindow::SongEditorWindow(SlideGroup *g, QWidget *parent) : 
	AbstractSlideGroupEditor(g,parent),
	m_slideGroup(0),
	m_editWin(0),
	m_syncToDatabase(true),
	m_arrModel(0)
{
	setAttribute(Qt::WA_DeleteOnClose,true);
	
	QWidget *centerWidget = new QWidget(this);
	
	QVBoxLayout * vbox = new QVBoxLayout(centerWidget);
	
	// Title editor
	QHBoxLayout * hbox1 = new QHBoxLayout();
	QLabel *label = new QLabel("&Title: ");
	hbox1->addWidget(label);
	
	m_title = new QLineEdit();
	
	label->setBuddy(m_title);
	hbox1->addWidget(m_title);
	
	vbox->addLayout(hbox1);
	
	// Default arrangement
	QHBoxLayout *hbox2 = new QHBoxLayout();
	label = new QLabel("Default Arrangement: ");
	hbox2->addWidget(label);
	
	m_defaultArrangement = new QLineEdit();
	m_defaultArrangement->setReadOnly(true);
	
	QPalette p = m_defaultArrangement->palette();
	p.setColor(QPalette::Base, Qt::lightGray);
	m_defaultArrangement->setPalette(p);

	hbox2->addWidget(m_defaultArrangement);
	
	vbox->addLayout(hbox2);

	// My arrangement
	QHBoxLayout *hbox3 = new QHBoxLayout();
	label = new QLabel("&Arrangement:");
	hbox3->addWidget(label);
	
	//m_arrangement = new QLineEdit();
	//m_arrangement->setReadOnly(false);
	m_arrangement = new QComboBox();
	m_arrangement->setEditable(true);
	m_arrangement->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
	connect(m_arrangement, SIGNAL(editTextChanged(const QString&)), this, SLOT(arrTextChanged(const QString&)));
	connect(m_arrangement, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(arrCurrentIndexChanged(const QString&)));
	connect(m_arrangement, SIGNAL(activated(const QString &)), this, SLOT(arrActivated(const QString&)));
	label->setBuddy(m_arrangement);
	hbox3->addWidget(m_arrangement);
	
	QPushButton *btn = new QPushButton("Default");
	btn->setIcon(QIcon(":/data/stock-undo.png"));
	btn->setToolTip("Reset arrangement to default arrangement (above)");
	connect(btn, SIGNAL(clicked()), this, SLOT(resetArr()));
	hbox3->addWidget(btn);
	
	
	btn = new QPushButton("Show/Hide List");
	btn->setCheckable(true);
	btn->setIcon(QIcon(":/data/stock-find-and-replace.png"));
	btn->setToolTip("Show/hide the arrangement drag-and-drop list");
	connect(btn, SIGNAL(toggled(bool)), this, SLOT(arrListViewToggled(bool)));
	hbox3->addWidget(btn);
	
	QPushButton *listBtn = btn;
	
	vbox->addLayout(hbox3);


	setWindowIcon(QIcon(":/data/icon-d.png"));
	
	QFont font;
	font.setFamily("Courier");
	font.setFixedPitch(true);
	font.setPointSize(10);
	
	//QHBoxLayout *editorHBox = new QHBoxLayout();
	//editorHBox->setContentsMargins(0,0,0,0);
	QSplitter *editorHBox = new QSplitter();
	
	m_editor = new MyQTextEdit;
	m_editor->setFont(font);
	editorHBox->addWidget(m_editor);
	connect(m_editor, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
	//m_editor->setAcceptRichText(false);
	
	m_highlighter = new SongEditorHighlighter(m_editor->document());
	
	// Arrangement preview box
	m_arrangementPreview = new MyQTextEdit;
	m_arrangementPreview->setFont(font);
	m_arrangementPreview->setReadOnly(true);
	
	QPalette p2 = m_arrangementPreview->palette();
	p2.setColor(QPalette::Base, Qt::lightGray);
	m_arrangementPreview->setPalette(p2);

	editorHBox->addWidget(m_arrangementPreview);
	//m_editor->setAcceptRichText(false);
	
	(void*)new SongEditorHighlighter(m_arrangementPreview->document());
	
	// List view
	m_arrModel = new ArrangementListModel();
	connect(m_arrModel, SIGNAL(blockListChanged(QStringList)), this, SLOT(arrModelChange(QStringList)));
	
	QListView *arrListView = new QListView();
	
	arrListView->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding));
	arrListView->setViewMode(QListView::ListMode);
	arrListView->setWrapping(false);
	arrListView->setFlow(QListView::TopToBottom);
	
	arrListView->setMovement(QListView::Free);
	arrListView->setWordWrap(true);
	arrListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
	arrListView->setDragEnabled(true);
	arrListView->setAcceptDrops(true);
	arrListView->setDropIndicatorShown(true);
	
	arrListView->setModel(m_arrModel);
	m_arrListView = arrListView;
	
	editorHBox->addWidget(arrListView);
	
	editorHBox->setStretchFactor(0,10);
	editorHBox->setStretchFactor(1,10);
	editorHBox->setStretchFactor(2,1);
	
	//vbox->addWidget(m_editor);
	//vbox->addLayout(editorHBox);
	vbox->addWidget(editorHBox);
	
	QHBoxLayout * hboxBottom = new QHBoxLayout();
	
	m_tmplEditButton = new QPushButton("Edit &Template...");
	m_tmplEditButton->setIcon(QIcon(":data/stock-select-color.png"));
	m_tmplEditButton->setToolTip("Edit the template associated with this song arrangement");
	connect(m_tmplEditButton, SIGNAL(clicked()), this, SLOT(editSongTemplate()));
	hboxBottom->addWidget(m_tmplEditButton);
	
	QPushButton *tmplResetButton = new QPushButton("");
	tmplResetButton->setIcon(QIcon(":data/stock-undo.png"));
	tmplResetButton->setToolTip("Reset template on this song to use the current template set in the main Song Browser");
	connect(tmplResetButton, SIGNAL(clicked()), this, SLOT(resetSongTemplate()));
	hboxBottom->addWidget(tmplResetButton);
	
	hboxBottom->addStretch();
	
	m_syncBox = new QCheckBox("S&ync Changes to DB");
	m_syncBox->setToolTip("If checked, saving changes will update the master song database as well as the copy of the song in this document");
	m_syncBox->setChecked(true);
	connect(m_syncBox, SIGNAL(toggled(bool)), this, SLOT(setSyncToDatabase(bool)));
	
	hboxBottom->addWidget(m_syncBox);
	
	QCheckBox *showArrPreviewCb = new QCheckBox("Arrangement Preview");
	showArrPreviewCb->setToolTip("Show/hide arrangement preview window");
	showArrPreviewCb->setChecked(true);
	connect(showArrPreviewCb, SIGNAL(toggled(bool)), this, SLOT(showArrPreview(bool)));
	
	hboxBottom->addWidget(showArrPreviewCb);
	
	
	btn = new QPushButton("&Save Song");
	btn->setIcon(QIcon(":data/stock-save.png"));
	connect(btn, SIGNAL(clicked()), this, SLOT(accepted()));
	hboxBottom->addWidget(btn);
	
	btn = new QPushButton("&Cancel");
	connect(btn, SIGNAL(clicked()), this, SLOT(close()));
	hboxBottom->addWidget(btn);
	
	vbox->addLayout(hboxBottom);
	
	//setLayout(vbox);
	setCentralWidget(centerWidget);
	
	resize(500,600);
	
	QSettings set;
	bool flag = set.value("songdb/arrlistview",true).toBool();
	arrListViewToggled(flag);
	listBtn->setChecked(flag);
	
	flag = set.value("songdb/arrpreview",true).toBool();
	showArrPreviewCb->setChecked(flag);
	showArrPreview(flag);
	
	
	
	
		
// 	m_editWin = new SlideEditorWindow();
// 	connect(m_editWin, SIGNAL(closed()), this, SLOT(editorWindowClosed()));
//	}
	
}