コード例 #1
0
void FolderItemPropertiesWidget::sl_ChooseIconButton_Clicked() {
	if (!itemToEdit) {
		WARNING("Null pointer recieved");
		reject();
	}

	if (!customIconsWidget) {
		customIconsWidget = new CustomIconsListWidget(this);
	}

	if (itemToEdit->GetItemType() == AbstractFolderItem::Type_Folder) {
		Folder* f = dynamic_cast<Folder*>(itemToEdit);
		customIconsWidget->SelectIcon(f->GetIconID());
	} else if (itemToEdit->GetItemType() == AbstractFolderItem::Type_Note) {
		Note* n = dynamic_cast<Note*>(itemToEdit);
		customIconsWidget->SelectIcon(n->GetIconID());
	}

	if (customIconsWidget->exec() != QDialog::Accepted) {return;}

	Document* doc = Application::I()->CurrentDocument();
	if (doc == 0) {
		WARNING("Current document is 0");
		return;
	}

	selectedIconKey = customIconsWidget->SelectedIconKey;
	iconLabel->setPixmap(doc->GetItemIcon(selectedIconKey));
}
コード例 #2
0
void FolderItemPropertiesWidget::SetFolderItem(AbstractFolderItem* item) {
	if (!item) {
		WARNING("Null pointer recieved");
		return;
	}

	itemToEdit = item;

	if (item->GetItemType() == AbstractFolderItem::Type_Folder) {
		Folder* f = dynamic_cast<Folder*>(item);
		creationDateLabelD->setText(f->GetCreationDate().toString(Qt::SystemLocaleShortDate));
		modificationDateLabelD->setText(f->GetModificationDate().toString(Qt::SystemLocaleShortDate));
		nameLineEdit->setText(f->GetName());
		iconLabel->setPixmap(f->GetIcon());
		selectedIconKey = f->GetIconID();
		setWindowTitle(QString("Edit properties for \"%1\"").arg(f->GetName()));

		nameLineEdit->setEnabled(!f->IsLocked());
		chooseIconButton->setEnabled(!f->IsLocked());
		resetIconToDefaultButton->setEnabled(!f->IsLocked());

	} else if (item->GetItemType() == AbstractFolderItem::Type_Note) {
		Note* n = dynamic_cast<Note*>(item);
		creationDateLabelD->setText(n->GetCreationDate().toString(Qt::SystemLocaleShortDate));
		modificationDateLabelD->setText(n->GetModificationDate().toString(Qt::SystemLocaleShortDate));
		nameLineEdit->setText(n->GetName());
		iconLabel->setPixmap(n->GetIcon());
		selectedIconKey = n->GetIconID();
		setWindowTitle(QString("Edit properties for \"%1\"").arg(n->GetName()));

		nameLineEdit->setEnabled(!n->IsLocked());
		chooseIconButton->setEnabled(!n->IsLocked());
		resetIconToDefaultButton->setEnabled(!n->IsLocked());
	}

	nameLineEdit->setFocus();
	nameLineEdit->selectAll();
}