|
|
@ -37,9 +37,9 @@
|
|
|
|
/************************************************
|
|
|
|
/************************************************
|
|
|
|
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
************************************************/
|
|
|
|
CommandItemModel::CommandItemModel(QObject *parent) :
|
|
|
|
CommandItemModel::CommandItemModel(bool useHistory, QObject *parent) :
|
|
|
|
QSortFilterProxyModel(parent),
|
|
|
|
QSortFilterProxyModel(parent),
|
|
|
|
mSourceModel(new CommandSourceItemModel(this)),
|
|
|
|
mSourceModel(new CommandSourceItemModel(useHistory, this)),
|
|
|
|
mOnlyHistory(false),
|
|
|
|
mOnlyHistory(false),
|
|
|
|
mShowHistoryFirst(true)
|
|
|
|
mShowHistoryFirst(true)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -84,11 +84,6 @@ const CommandProviderItem *CommandItemModel::command(const QModelIndex &index) c
|
|
|
|
/************************************************
|
|
|
|
/************************************************
|
|
|
|
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
************************************************/
|
|
|
|
void CommandItemModel::addHistoryCommand(const QString &command)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mSourceModel->addHistoryCommand(command);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CommandItemModel::clearHistory()
|
|
|
|
void CommandItemModel::clearHistory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mSourceModel->clearHistory();
|
|
|
|
mSourceModel->clearHistory();
|
|
|
@ -239,17 +234,21 @@ void CommandItemModel::rebuild()
|
|
|
|
/************************************************
|
|
|
|
/************************************************
|
|
|
|
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
************************************************/
|
|
|
|
CommandSourceItemModel::CommandSourceItemModel(QObject *parent) :
|
|
|
|
CommandSourceItemModel::CommandSourceItemModel(bool useHistory, QObject *parent) :
|
|
|
|
QAbstractListModel(parent)
|
|
|
|
QAbstractListModel(parent),
|
|
|
|
|
|
|
|
mHistoryProvider(nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mCustomCommandProvider = new CustomCommandProvider;
|
|
|
|
mCustomCommandProvider = new CustomCommandProvider;
|
|
|
|
mProviders.append(mCustomCommandProvider);
|
|
|
|
mProviders.append(mCustomCommandProvider);
|
|
|
|
rebuild();
|
|
|
|
rebuild();
|
|
|
|
mCustomCommandIndex = index(0, 0);
|
|
|
|
mCustomCommandIndex = index(0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
mHistoryProvider = new HistoryProvider();
|
|
|
|
if (useHistory)
|
|
|
|
mProviders.append(mHistoryProvider);
|
|
|
|
{
|
|
|
|
mCustomCommandProvider->setHistoryProvider(mHistoryProvider);
|
|
|
|
mHistoryProvider = new HistoryProvider();
|
|
|
|
|
|
|
|
mProviders.append(mHistoryProvider);
|
|
|
|
|
|
|
|
mCustomCommandProvider->setHistoryProvider(mHistoryProvider);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mProviders.append(new AppLinkProvider());
|
|
|
|
mProviders.append(new AppLinkProvider());
|
|
|
|
#ifdef MATH_ENABLED
|
|
|
|
#ifdef MATH_ENABLED
|
|
|
@ -379,9 +378,16 @@ void CommandSourceItemModel::rebuild()
|
|
|
|
************************************************/
|
|
|
|
************************************************/
|
|
|
|
void CommandSourceItemModel::clearHistory()
|
|
|
|
void CommandSourceItemModel::clearHistory()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
beginResetModel();
|
|
|
|
if (mHistoryProvider)
|
|
|
|
mHistoryProvider->clearHistory();
|
|
|
|
{
|
|
|
|
endResetModel();
|
|
|
|
beginResetModel();
|
|
|
|
|
|
|
|
mHistoryProvider->clearHistory();
|
|
|
|
|
|
|
|
endResetModel();
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QScopedPointer<HistoryProvider> history_p{new HistoryProvider};
|
|
|
|
|
|
|
|
history_p->clearHistory();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -417,23 +423,41 @@ const CommandProviderItem *CommandSourceItemModel::command(const QModelIndex &in
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
/***********************************************
|
|
|
|
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
***********************************************/
|
|
|
|
void CommandSourceItemModel::addHistoryCommand(const QString &command)
|
|
|
|
void CommandSourceItemModel::setCommand(const QString& command)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mHistoryProvider->AddCommand(command);
|
|
|
|
mCustomCommandProvider->setCommand(command);
|
|
|
|
|
|
|
|
foreach (ExternalProvider* externalProvider, mExternalProviders)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
externalProvider->setSearchTerm(command);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************
|
|
|
|
/***********************************************
|
|
|
|
|
|
|
|
|
|
|
|
***********************************************/
|
|
|
|
***********************************************/
|
|
|
|
void CommandSourceItemModel::setCommand(const QString& command)
|
|
|
|
void CommandSourceItemModel::setUseHistory(bool useHistory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mCustomCommandProvider->setCommand(command);
|
|
|
|
const bool now_using_history = mHistoryProvider != nullptr;
|
|
|
|
foreach (ExternalProvider* externalProvider, mExternalProviders)
|
|
|
|
if (now_using_history == useHistory)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
beginResetModel();
|
|
|
|
|
|
|
|
if (now_using_history)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
externalProvider->setSearchTerm(command);
|
|
|
|
mProviders.removeAll(mHistoryProvider);
|
|
|
|
|
|
|
|
mCustomCommandProvider->setHistoryProvider(nullptr);
|
|
|
|
|
|
|
|
delete mHistoryProvider;
|
|
|
|
|
|
|
|
mHistoryProvider = nullptr;
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mHistoryProvider = new HistoryProvider;
|
|
|
|
|
|
|
|
mProviders.append(mHistoryProvider);
|
|
|
|
|
|
|
|
mCustomCommandProvider->setHistoryProvider(mHistoryProvider);
|
|
|
|
|
|
|
|
connect(mHistoryProvider, SIGNAL(changed()), this, SIGNAL(layoutChanged()));
|
|
|
|
|
|
|
|
connect(mHistoryProvider, SIGNAL(aboutToBeChanged()), this, SIGNAL(layoutAboutToBeChanged()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endResetModel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|